using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; namespace Project { public partial class MessageWindow { public enum eWindowPosition { center = 0, top = 1, bottom = 2 } public enum eWindowType { information, error, attention, } public bool needClose = false; public Boolean needShow = false; private CMessageData msgBuffer = new CMessageData(); public void setMessage(CMessageData msgData) { //마지막데잍와 동일하고 버퍼에 데이터가 있다면 처리하지 않는다. if (msgBuffer == msgData) return; //신규 메세지를 추가 msgBuffer = msgData; //화면이 표시되어야하므로 플래그 설정 needShow = true; } public void setMessage(string msg, eWindowType winType = eWindowType.error, int width = 900, int height = 500, Boolean enbClose = true, Font fontTitle = null, Font fontBody = null) { setMessage(new CMessageData() { EnableClose = enbClose, FontContent = fontBody, FontTitle = fontTitle, Message = msg, WindowSize = new Size(width, height), WindowType = winType }); } fMessageWindow msgwin;// = new fMsgWindow(""); /// /// 메세지 버퍼의 내용을 폼으로 표시합니다. /// UI 쓰레드를 사용하므로 invoke 를 이용해 호출 하거나 /// UI 쓰레드내에서 실행 하시기 바랍니다. /// public void showMessage() { //등록된 메세지 버퍼의 내용을 화면에 표시한다. if (msgwin == null) msgwin = new fMessageWindow(""); msgwin.TopMost = true; // msgwin.Disposed += (s1, e1) => { CloseMsg(item.Key); }; //msgwin.Width = this.msgBuffer.WindowSize.Width; //msgwin.Height = msgBuffer.WindowSize.Height; //msgwin.BackColor = Color.FromArgb(200, 200, 200); msgwin.StartPosition = FormStartPosition.CenterScreen; msgwin.btNo.Visible = false; msgwin.btYes.Visible = false; msgwin.Height = 474; msgwin.setMessage(msgBuffer.Message); //set font if (msgBuffer.FontTitle != null) msgwin.lbTitle.Font = msgBuffer.FontTitle; if (msgBuffer.FontContent != null) { msgwin.lb1.Font = msgBuffer.FontContent; msgwin.lb2.Font = msgBuffer.FontContent; msgwin.lb3.Font = msgBuffer.FontContent; msgwin.lb4.Font = msgBuffer.FontContent; msgwin.lb5.Font = msgBuffer.FontContent; msgwin.lb6.Font = msgBuffer.FontContent; msgwin.lb7.Font = msgBuffer.FontContent; } switch (msgBuffer.WindowType) { case eWindowType.attention: msgwin.SetWindowColor(fMessageWindow.EWinColor.Attention); break; case eWindowType.error: msgwin.SetWindowColor(fMessageWindow.EWinColor.Error); break; default: msgwin.SetWindowColor(fMessageWindow.EWinColor.Information); break; } if (!msgBuffer.EnableClose) msgwin.EnableUserClose = false; if (msgwin.Visible == false) msgwin.Show(); else { msgwin.Visible = true; msgwin.Activate(); } needShow = false; } public Boolean Visible { get { if (msgwin == null) return false; return msgwin.Visible; } set { if(value == true) { if (msgwin.Visible == false) { msgwin.Show(); msgwin.Activate(); } else { msgwin.Activate(); } needShow = false; } else { if (msgwin != null) msgwin.Visible = false; needClose = false; } } } } }