using System;

using CommonHelpers;

namespace ConfirmationPause {

//**************************************************************************************************
static partial class Program {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public const int
   ConfirmationCode = 0,
   CancellationCode = 2,
   ErrorCode        = 1,
   FatalErrorCode   =-1;

//==================================================================================================

const string DialogPromptFormatString =
   "\u25BA {0} . . . ";

static string DialogPromptMessage =>
   string.Format( HLocal.TEXT(
   "Press either <{0}> to continue or <{1}> to cancel",
   "Нажмите <{0}> для продолжения, либо <{1}> для отмены" ),
   ConsoleKey.Enter, ConsoleKey.Escape );

//==================================================================================================

static bool PerformDialog()
{
   var color = (int)Console.BackgroundColor < 7 ? ConsoleColor.White : ConsoleColor.Black;
   HConsole.Output( color, DialogPromptFormatString, DialogPromptMessage );
   for (;;)
   {
      WaitInput( true );
      var keyInfo = Console.ReadKey( true );
      var key = keyInfo.Key;
      var modifiers = keyInfo.Modifiers;
      if ( HOps.IsOneOf( key, ConsoleKey.Enter, ConsoleKey.Escape ) && modifiers==0 )
      {
         HConsole.Print();
         return key == ConsoleKey.Enter;
      }
      if ( !HOps.IsOneOf( key, ConsoleKey.LeftWindows, ConsoleKey.RightWindows,
                               ConsoleKey.Applications ) )
         BeepHigh();
   }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // Program
//**************************************************************************************************

} // ConfirmationPause
