Example #1
0
 private void UnlockDialog_Load(object sender, EventArgs e)
 {
     panel4.Visible         = false;
     UnlockDialogLabel.Text = "Unlock " + EntType.ToString();
     EntityLabel.Text       = EntType.ToString();
     EntityNameLabel.Text   = EntityName;
     Quit = new ExitForm(CloseForm);
 }
Example #2
0
        /// <summary>
        /// 检测USB串口的拔插
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_DEVICE_CHANGE)                    // 捕获USB设备的拔出消息WM_DEVICECHANGE
            {
                switch (m.WParam.ToInt32())
                {
                case DBT_DEVICE_REMOVE_COMPLETE:                            // USB拔出
                    DEV_BROADCAST_HDR dbhdr0 = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(m.LParam, typeof(DEV_BROADCAST_HDR));
                    if (dbhdr0.dbch_devicetype == DBT_DEVTYP_PORT)
                    {
                        string portName = Marshal.PtrToStringUni((IntPtr)(m.LParam.ToInt32() + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT_Fixed))));
                        LogHelper.LibraryLogger.Instance.WriteLog(LogHelper.LibraryLogger.libLogLevel.Error, "串口掉线,串口号:" + portName);
                    }
                    break;

                case DBT_DEVICEARRIVAL:                                     // USB插入获取对应串口名称
                    DEV_BROADCAST_HDR dbhdr = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(m.LParam, typeof(DEV_BROADCAST_HDR));
                    if (dbhdr.dbch_devicetype == DBT_DEVTYP_PORT)
                    {
                        string portName = Marshal.PtrToStringUni((IntPtr)(m.LParam.ToInt32() + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT_Fixed))));
                        LogHelper.LibraryLogger.Instance.WriteLog(LogHelper.LibraryLogger.libLogLevel.Error, "串口接入,串口号:" + portName);
                    }
                    break;
                }
            }
            if (m.Msg == WM_SYSCOMMAND && ((int)m.WParam == SC_CLOSE))
            {
                // 点击winform右上关闭按钮 f
                // 加入想要的逻辑处理
                ExitForm     exit = new ExitForm();
                DialogResult dr   = exit.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    isStop = true;
                    closeCom();
                    timer1.Stop();
                    Application.Exit();
                }
                else if (dr == DialogResult.Yes)
                {
                    // 改关闭效果为最小化
                    this.WindowState = FormWindowState.Minimized;
                    this.Hide();
                    return;
                }
                else if (dr == DialogResult.Cancel)
                {
                    return;
                }
            }
            base.WndProc(ref m);
        }
Example #3
0
        private void AddEntityDialog_Load(object sender, EventArgs e)
        {
            panel2.Visible = false;
            Quit           = new ExitForm(CloseForm);

            if (Entity == EntityType.Folder)
            {
                label1.Text            = "Secure folder";
                TargetEntitylabel.Text = "Target folder";
                this.Text          = "Add folder dialog";
                ContextImage.Image = Secure_Bin.Properties.Resources.encrypt;
            }
            else
            {
                label1.Text            = "Secure file";
                TargetEntitylabel.Text = "Target file";
                this.Text          = "Add file dialog";
                ContextImage.Image = Secure_Bin.Properties.Resources.protect_document;
            }
        }
Example #4
0
        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ExitForm exitForm = new ExitForm(this);

            exitForm.Show();
        }