コード例 #1
0
ファイル: FrmTips.cs プロジェクト: nxzzkj/lazyiot
 /// <summary>
 /// 功能描述:清理提示框
 /// 作  者:HZH
 /// 创建日期:2019-02-28 15:11:03
 /// 任务编号:POS
 /// </summary>
 public static void ClearTips()
 {
     for (int i = m_lstTips.Count - 1; i >= 0; i--)
     {
         FrmTips current = m_lstTips[i];
         if (!current.IsDisposed)
         {
             current.Close();
             current.Dispose();
         }
     }
     m_lstTips.Clear();
 }
コード例 #2
0
ファイル: FrmTips.cs プロジェクト: nxzzkj/lazyiot
        /// <summary>
        /// 功能描述:刷新显示
        /// 作  者:HZH
        /// 创建日期:2019-02-28 15:33:06
        /// 任务编号:POS
        /// </summary>
        public static void ReshowTips()
        {
            lock (FrmTips.m_lstTips)
            {
                FrmTips.m_lstTips.RemoveAll(p => p.IsDisposed == true);
                var enumerable = from p in FrmTips.m_lstTips
                                 group p by new
                {
                    p.ShowAlign
                };
                Size size = Screen.PrimaryScreen.Bounds.Size;
                foreach (var item in enumerable)
                {
                    List <FrmTips> list = FrmTips.m_lstTips.FindAll((FrmTips p) => p.ShowAlign == item.Key.ShowAlign);
                    for (int i = 0; i < list.Count; i++)
                    {
                        FrmTips frmTips = list[i];
                        if (frmTips.InvokeRequired)
                        {
                            frmTips.BeginInvoke(new MethodInvoker(delegate()
                            {
                                switch (item.Key.ShowAlign)
                                {
                                case ContentAlignment.BottomCenter:
                                    frmTips.Location = new Point((size.Width - frmTips.Width) / 2, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.BottomLeft:
                                    frmTips.Location = new Point(10, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.BottomRight:
                                    frmTips.Location = new Point(size.Width - frmTips.Width - 10, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.MiddleCenter:
                                    frmTips.Location = new Point((size.Width - frmTips.Width) / 2, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.MiddleLeft:
                                    frmTips.Location = new Point(10, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.MiddleRight:
                                    frmTips.Location = new Point(size.Width - frmTips.Width - 10, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.TopCenter:
                                    frmTips.Location = new Point((size.Width - frmTips.Width) / 2, 10 + (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.TopLeft:
                                    frmTips.Location = new Point(10, 10 + (i + 1) * (frmTips.Height + 10));
                                    break;

                                case ContentAlignment.TopRight:
                                    frmTips.Location = new Point(size.Width - frmTips.Width - 10, 10 + (i + 1) * (frmTips.Height + 10));
                                    break;

                                default:
                                    break;
                                }
                            }));
                        }
                        else
                        {
                            switch (item.Key.ShowAlign)
                            {
                            case ContentAlignment.BottomCenter:
                                frmTips.Location = new Point((size.Width - frmTips.Width) / 2, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.BottomLeft:
                                frmTips.Location = new Point(10, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.BottomRight:
                                frmTips.Location = new Point(size.Width - frmTips.Width - 10, size.Height - 100 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.MiddleCenter:
                                frmTips.Location = new Point((size.Width - frmTips.Width) / 2, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.MiddleLeft:
                                frmTips.Location = new Point(10, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.MiddleRight:
                                frmTips.Location = new Point(size.Width - frmTips.Width - 10, size.Height - (size.Height - list.Count * (frmTips.Height + 10)) / 2 - (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.TopCenter:
                                frmTips.Location = new Point((size.Width - frmTips.Width) / 2, 10 + (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.TopLeft:
                                frmTips.Location = new Point(10, 10 + (i + 1) * (frmTips.Height + 10));
                                break;

                            case ContentAlignment.TopRight:
                                frmTips.Location = new Point(size.Width - frmTips.Width - 10, 10 + (i + 1) * (frmTips.Height + 10));
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: FrmTips.cs プロジェクト: nxzzkj/lazyiot
 /// <summary>
 /// Shows the tips warning.
 /// </summary>
 /// <param name="frm">The FRM.</param>
 /// <param name="strMsg">The string MSG.</param>
 /// <returns>FrmTips.</returns>
 public static FrmTips ShowTipsWarning(Form frm, string strMsg)
 {
     return(FrmTips.ShowTips(frm, strMsg, 3000, false, ContentAlignment.BottomCenter, null, TipsSizeMode.Large, null, TipsState.Warning));
 }
コード例 #4
0
ファイル: FrmTips.cs プロジェクト: nxzzkj/lazyiot
        /// <summary>
        /// Shows the tips.
        /// </summary>
        /// <param name="frm">The FRM.</param>
        /// <param name="strMsg">The string MSG.</param>
        /// <param name="intAutoColseTime">The int automatic colse time.</param>
        /// <param name="blnShowCoseBtn">if set to <c>true</c> [BLN show cose BTN].</param>
        /// <param name="align">The align.</param>
        /// <param name="point">The point.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="size">The size.</param>
        /// <param name="state">The state.</param>
        /// <param name="color">The color.</param>
        /// <returns>FrmTips.</returns>
        public static FrmTips ShowTips(
            Form frm,
            string strMsg,
            int intAutoColseTime   = 0,
            bool blnShowCoseBtn    = true,
            ContentAlignment align = ContentAlignment.BottomLeft,
            Point?point            = null,
            TipsSizeMode mode      = TipsSizeMode.Small,
            Size?size       = null,
            TipsState state = TipsState.Default)
        {
            if (m_lastTips.Key == strMsg + state && !m_lastTips.Value.IsDisposed && m_lastTips.Value.Visible)
            {
                m_lastTips.Value.ResetTimer();
                return(m_lastTips.Value);
            }
            else
            {
                FrmTips frmTips = new FrmTips();
                switch (mode)
                {
                case TipsSizeMode.Small:
                    frmTips.Size = new Size(350, 35);
                    break;

                case TipsSizeMode.Medium:
                    frmTips.Size = new Size(350, 50);
                    break;

                case TipsSizeMode.Large:
                    frmTips.Size = new Size(350, 65);
                    break;

                case TipsSizeMode.None:
                    if (!size.HasValue)
                    {
                        frmTips.Size = new Size(350, 35);
                    }
                    else
                    {
                        frmTips.Size = size.Value;
                    }
                    break;
                }

                frmTips.BackColor = Color.FromArgb((int)state);

                if (state == TipsState.Default)
                {
                    frmTips.lblMsg.ForeColor = SystemColors.ControlText;
                }
                else
                {
                    frmTips.lblMsg.ForeColor = Color.White;
                }
                switch (state)
                {
                case TipsState.Default:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.alarm;
                    break;

                case TipsState.Success:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.success;
                    break;

                case TipsState.Info:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.alarm;
                    break;

                case TipsState.Warning:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.warning;
                    break;

                case TipsState.Error:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.error;
                    break;

                default:
                    frmTips.pctStat.Image = Scada.Controls.Properties.Resources.alarm;
                    break;
                }

                frmTips.lblMsg.Text      = strMsg;
                frmTips.CloseTime        = intAutoColseTime;
                frmTips.btnClose.Visible = blnShowCoseBtn;


                frmTips.ShowAlign = align;
                frmTips.Owner     = frm;
                FrmTips.m_lstTips.Add(frmTips);
                FrmTips.ReshowTips();
                frmTips.Show(frm);
                if (frm != null && !frm.IsDisposed)
                {
                    ControlHelper.SetForegroundWindow(frm.Handle);
                }
                //frmTips.BringToFront();
                m_lastTips = new KeyValuePair <string, FrmTips>(strMsg + state, frmTips);
                return(frmTips);
            }
        }