spc-kiosk-pb/Kiosk/Common/SPC.Kiosk.Common/Functions/KioskMessageBox.cs
2019-06-16 14:12:09 +09:00

426 lines
24 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Globalization;
using SPC.Kiosk.Base;
namespace SPC.Kiosk.Common
{
public static class KioskMessageBox
{
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(0, new Size(0, 0), null, null, _message, MessageBoxButton.OK, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(List<M_Language> _message,
MessageBoxButton _boxButton,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(0, new Size(0, 0), null, null, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_title"></param>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(List<M_Language> _title,
List<M_Language> _message,
MessageBoxButton _boxButton = MessageBoxButton.OK,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(0, new Size(0, 0), _title, null, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
MessageBoxButton _boxButton = MessageBoxButton.OK,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(0, new Size(0, 0), _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_screenNo"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(int _screenNo,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
MessageBoxButton _boxButton = MessageBoxButton.OK,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(_screenNo, new Size(0, 0), _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_size"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(Size _size,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
MessageBoxButton _boxButton,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
return ShowMessageBox(0, _size, _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// ShowMessageBox
/// </summary>
/// <param name="_screenNo"></param>
/// <param name="_size"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_boxButton"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
/// <returns></returns>
public static MessageBoxResult ShowMessageBox(int _screenNo,
Size _size,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
MessageBoxButton _boxButton,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 0)
{
var result = MessageBoxResult.None;
try
{
var frmMessageBox = new MessageBoxForm(_screenNo, _size, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
if (_title == null)
{
frmMessageBox.MessageHeader.Visibility = Visibility.Collapsed;
}
else
{
frmMessageBox.MessageHeader.MultiLanguage = _title;
}
if (_subtitle == null)
{
frmMessageBox.MessageSubHeader.Visibility = Visibility.Collapsed;
}
else
{
frmMessageBox.MessageSubHeader.MultiLanguage = _subtitle;
}
frmMessageBox.Message.MultiLanguage = _message;
switch (_boxButton)
{
case MessageBoxButton.OK:
frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width;
frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039");
frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Center;
frmMessageBox.No_Button.Visibility = Visibility.Collapsed;
frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed;
break;
case MessageBoxButton.OKCancel:
frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 2;
frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039");
frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left;
frmMessageBox.No_Button.Visibility = Visibility.Collapsed;
frmMessageBox.Cancel_Button.Width = frmMessageBox.BoxBase.Width / 2;
frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033");
frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right;
break;
case MessageBoxButton.YesNo:
frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 2;
frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005");
frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left;
frmMessageBox.No_Button.Width = frmMessageBox.BoxBase.Width / 2;
frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021");
frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Right;
frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed;
break;
case MessageBoxButton.YesNoCancel:
frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 3;
frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005");
frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left;
frmMessageBox.No_Button.Width = frmMessageBox.BoxBase.Width / 3;
frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021");
frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Center;
frmMessageBox.Cancel_Button.Width = frmMessageBox.BoxBase.Width / 3;
frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033");
frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right;
break;
}
frmMessageBox.ShowDialog();
result = frmMessageBox.BoxResult;
frmMessageBox = null;
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "KioskMessageBox", "ShowMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
result = MessageBoxResult.None;
}
return result;
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
TimeMessageBox(0, new Size(0, 0), null, null, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_title"></param>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(List<M_Language> _title,
List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
TimeMessageBox(0, new Size(0, 0), _title, null, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
TimeMessageBox(0, new Size(0, 0), _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_screenNo"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(int _screenNo,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
TimeMessageBox(_screenNo, new Size(0, 0), _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_size"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(
Size _size,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
TimeMessageBox(0, _size, _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
}
/// <summary>
/// Show Time Message Box
/// </summary>
/// <param name="_screenNo"></param>
/// <param name="_size"></param>
/// <param name="_title"></param>
/// <param name="_subtitle"></param>
/// <param name="_message"></param>
/// <param name="_openAnimationType"></param>
/// <param name="_closeAnimationType"></param>
/// <param name="_startEndOpacity"></param>
/// <param name="_animationSeconds"></param>
/// <param name="_waitTime"></param>
public static void TimeMessageBox(int _screenNo,
Size _size,
List<M_Language> _title,
List<M_Language> _subtitle,
List<M_Language> _message,
OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None,
OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None,
double _startEndOpacity = 0.5,
double _animationSeconds = 0.2,
double _waitTime = 5)
{
try
{
if (_message is List<M_Language> && !string.IsNullOrEmpty(_message.GetLanguageData(SupportLanguageType.ko)))
{
var frmMessageBox = new MessageBoxForm(_screenNo, _size, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime);
if (_title == null)
{
frmMessageBox.MessageHeader.Visibility = Visibility.Collapsed;
}
else
{
frmMessageBox.MessageHeader.MultiLanguage = _title;
}
if (_subtitle == null)
{
frmMessageBox.MessageSubHeader.Visibility = Visibility.Collapsed;
}
else
{
frmMessageBox.MessageHeader.MultiLanguage = _title;
}
frmMessageBox.Message.MultiLanguage = _message;
frmMessageBox.ShowDialog();
frmMessageBox = null;
}
}
catch (Exception ex)
{
CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "KioskMessageBox", "TimeMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
}
}
}
}