private void HideTipsMessage() { switch (TipsStateNow) { case TipsState.Showing: { ShowTipsThread.Abort(); ShowTipsThread = null; break; } case TipsState.Shown: { break; } case TipsState.Hiding: case TipsState.Hidden: { return; } } TipsStateNow = TipsState.Hiding; try { TipsBox.Left = TipsBox.Parent.Width - TipsBox.Width; } catch { } HideTipsThread = new Thread(HideTipsSub); HideTipsThread.Start(); HideTipsThread.Join(); try{ TipsBox.Hide(); }catch { } TipsStateNow = TipsState.Hidden; HideTipsThread = null; if (SleepThread != null) { SleepThread.Abort(); SleepThread = null; } }
/// <summary> /// 在窗体内部显示一个轻巧的信息提示框 /// </summary> /// <param name="Title">提示框标题</param> /// <param name="Message">信息内容</param> /// <param name="iconType">提示框图标</param> private void ShowTipsMessage(string Title, string Message, MyMessageBox.IconType iconType) { switch (TipsStateNow) { case TipsState.Showing: case TipsState.Shown: { HideTipsMessage(); break; } case TipsState.Hiding: { break; } case TipsState.Hidden: { break; } } TipsStateNow = TipsState.Showing; try{ TipsBox.BringToFront(); TipsBox.Left = TipsBox.Parent.Width; TipsTitleLabel.Text = Title; TipsMessageLabel.Text = Message; TipsIconLabel.Image = UnityResource.ResourceManager.GetObject(iconType.ToString()) as System.Drawing.Image; TipsBox.Show(); }catch { } ShowTipsThread = new Thread(ShowTipsSub); ShowTipsThread.Start(); ShowTipsThread.Join(); TipsStateNow = TipsState.Shown; ShowTipsThread = null; SleepThread = new Thread(delegate(){ Thread.Sleep(5000); HideTipsMessage(); }); SleepThread.Start(); }
/// <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 = HZH_Controls.Properties.Resources.alarm; break; case TipsState.Success: frmTips.pctStat.Image = HZH_Controls.Properties.Resources.success; break; case TipsState.Info: frmTips.pctStat.Image = HZH_Controls.Properties.Resources.alarm; break; case TipsState.Warning: frmTips.pctStat.Image = HZH_Controls.Properties.Resources.warning; break; case TipsState.Error: frmTips.pctStat.Image = HZH_Controls.Properties.Resources.error; break; default: frmTips.pctStat.Image = HZH_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); } }
public ShortTips() { State = TipsState.NeedToShow; }
public ShortTips() { State = TipsState.NeedToShow; }