//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// UserWin satellite library | Author: Sergei Y.Kitáev
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Threading.Tasks;

using System.Windows;

using CommonHelpers;

namespace UserWin {

//**************************************************************************************************
partial class UXMessageBox {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   string text )
{
   return await YesNoCancelDialog( extraInfo, (Window)null, text );
}

//--------------------------------------------------------------------------------------------------

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   [HOptional] Window owner, string text )
{
   return await YesNoCancelDialog( extraInfo, owner, text, null );
}

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

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   string text, [HOptional] string caption )
{
   return await YesNoCancelDialog( extraInfo, (Window)null, text, caption);
}

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   string text, [HOptional] string caption,
   MessageBoxResult defaultResult )
{
   return await YesNoCancelDialog( extraInfo, (Window)null, text, caption, MessageBoxResult.Yes );
}

//--------------------------------------------------------------------------------------------------

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   [HOptional] Window owner, string text,
   [HOptional] string caption )
{
   return await YesNoCancelDialog( extraInfo, owner, text, caption, YesNoCancelDialogDefaultIcon );
}

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   [HOptional] Window owner, string text,
   [HOptional] string caption, MessageBoxResult defaultResult )
{
   return await YesNoCancelDialog( extraInfo, owner, text, caption,
      YesNoCancelDialogDefaultIcon, MessageBoxResult.Yes );
}

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

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   string text, [HOptional] string caption,
   MessageBoxImage icon )
{
   return await YesNoCancelDialog( extraInfo, null, text, caption, icon );
}

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   string text, [HOptional] string caption,
   MessageBoxImage icon, MessageBoxResult defaultResult )
{
   return await YesNoCancelDialog( extraInfo, null, text, caption, icon, MessageBoxResult.Yes );
}

//--------------------------------------------------------------------------------------------------

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   [HOptional] Window owner, string text,
   [HOptional] string caption, MessageBoxImage icon )
{
   return await YesNoCancelDialog( extraInfo, owner, text, caption, icon, MessageBoxResult.Yes );
}

public static async Task<bool?> YesNoCancelDialog(
   [HOptional] UXShowMessageExtraInfo extraInfo,
   [HOptional] Window owner, string text,
   [HOptional] string caption, MessageBoxImage icon,
   MessageBoxResult defaultResult )
{
   if (!HOps.IsOneOf( defaultResult,
      MessageBoxResult.Yes, MessageBoxResult.No, MessageBoxResult.Cancel ))
      throw new ArgumentException( "Incorrect value for default result." );
   switch ( await ShowMessage( extraInfo, owner, text, caption, MessageBoxButton.YesNoCancel,
                               icon, defaultResult ) )
   {
   case MessageBoxResult.Yes: return true;
   case MessageBoxResult.No : return false;
   default: return null;
   }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UXMessageBox
//**************************************************************************************************

} // UserWin
