spc-kiosk-pb/Window/WinBasic/frmCountdownMessageBox.cs
2019-06-16 14:12:09 +09:00

176 lines
6.9 KiB
C#

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.Common;
using System.Drawing;
namespace Cosmos.CommonManager
{
public partial class frmCountdownMessageBox : Form
{
private int m_iCountdown = 20;
private string m_sMessageType;
/// <summary>
/// 메시지 형태(MSG_BOX_TYPE)
/// </summary>
public string PosMessageType { get { return this.m_sMessageType; } set { this.m_sMessageType = value; } }
string m_sMessageStr;
/// <summary>
/// 메시지
/// </summary>
public string PosMessageStr { get { return this.m_sMessageStr; } set { this.m_sMessageStr = value; } }
string m_sMessageTitle;
/// <summary>
/// 메시지 타이틀
/// </summary>
public string PosMessageTitle { get { return this.m_sMessageTitle; } set { this.m_sMessageTitle = value; } }
public frmCountdownMessageBox()
{
InitializeComponent();
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
//this.UpdateStyles();
}
private void frmCountdownMessageBox_Load(object sender, EventArgs e)
{
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "");
this.BackgroundImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
InitControl();
}
private void frmCountdownMessageBox_FormClosing(object sender, FormClosingEventArgs e)
{
m_iCountdown = 20;
tmrCountdown.Enabled = false;
UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
}
/// <summary>
/// 폼 컨트롤 초기화
/// </summary>
private void InitControl()
{
try
{
CmMessage m_PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig);
string sFont = m_PosConfig.GetMessage("GLOBAL").GetMessageValue("Font");
FormManager.SetFormAllControlFont(this, sFont);
picTabImg1.Image = CmUtil.LoadImage(BaseCom.NxImgPath + "TagImg_00207_03.png");
lblTitle.BackColor = Color.FromArgb(70, 86, 98);
lblTitle.ForeColor = Color.White; // Color.FromArgb(35, 31, 32);
lblTitle.Text = m_sMessageTitle;
switch (m_sMessageType)
{
case PosConst.MSG_BOX_TYPE.CONFIRM: // 확인메시지
btnYes.Visible = false;
btnNo.Visible = false;
btnEsc.Visible = true;
lblMessage.Text = m_sMessageStr;
btnEsc.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0009); //확인
break;
case PosConst.MSG_BOX_TYPE.QUESTION: // 질문메시지(예,아니오)
btnEsc.Visible = false;
btnYes.Visible = true;
btnNo.Visible = true;
btnYes.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0025);
btnNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0026);
lblMessage.Text = string.Format("{0}\n{1} {2}", m_sMessageStr, m_iCountdown, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0367));
tmrCountdown.Enabled = true;
m_iCountdown = 20;
break;
}
this.TopMost = true;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "Process Exception !!! " + ex.Message);
}
}
/// <summary>
/// 버튼 입력 처리
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnProc_Click(object sender, EventArgs e)
{
try
{
if (((Cosmos.UI.CsmButton)sender) == btnEsc)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
if (((Cosmos.UI.CsmButton)sender) == btnYes)
{
this.DialogResult = DialogResult.Yes;
this.Close();
}
if (((Cosmos.UI.CsmButton)sender) == btnNo)
{
this.DialogResult = DialogResult.No;
this.Close();
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "Process Exception !!! " + ex.Message);
}
}
/// <summary>
/// 카운다운 타이머
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tmrCountdown_Tick(object sender, EventArgs e)
{
try
{
tmrCountdown.Enabled = false;
if (m_iCountdown == 0)
{
btnProc_Click(btnYes, null);
}
else
{
m_iCountdown--;
lblMessage.Text = string.Format("{0}\n{1} {2}", m_sMessageStr, m_iCountdown, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0367));
tmrCountdown.Enabled = true;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "Process Exception !!! " + ex.Message);
}
}
}
}