コード例 #1
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     //Ctrl + Shift + Esc,显示正在进行等待提示的Controls
     if (e.Control & e.Shift & e.KeyCode == Keys.D)
     {
         var list = GetUncloseControl?.Invoke();
         if (list != null && list.Count > 0)
         {
             MessageBox.Show(string.Join(Environment.NewLine, list.Keys));
         }
     }
 }
コード例 #2
0
        private void WaitForm_Shown(object sender, EventArgs e)
        {
            SetForegroundWindow(this.Handle);

            DateTime start        = DateTime.Now;
            bool     closeVisible = false;
            //延迟显示关闭按钮
            Task tsk = new Task(() =>
            {
                while (true)
                {
                    if (Disposing || IsDisposed)
                    {
                        return;
                    }
                    if (!closeVisible)
                    {
                        TimeSpan ts = DateTime.Now - start;
                        if (ts.TotalMilliseconds >= ShowCloseButtonDelay)
                        {
                            this.Invoke((MethodInvoker)(() =>
                            {
                                picClose.Visible = true;
                                closeVisible = true;
                            }));
                        }
                    }

                    var dic = GetUncloseControl?.Invoke();
                    if (dic == null || dic.Count == 0)
                    {
                        UIContext?.Post((o) =>
                        {
                            if (!Disposing && !IsDisposed)
                            {
                                this.Close();
                            }
                        }, null);
                        break;
                    }
                    Thread.Sleep(100);
                }
            });

            tsk.Start();
        }