示例#1
0
        public CenterControl()
        {
            messageScheduler   = new MessageScheduler();
            serialPortDetector = new SerialPortDetector();
            profileContainer   = new ProfileContainer();

            if (!profileContainer.Load())
            {
                System.Windows.Forms.MessageBox.Show("錯誤"
                                                     , "無法開啟或重建" + GlobalSetting.ProfileLocation
                                                     , System.Windows.Forms.MessageBoxButtons.OK
                                                     , System.Windows.Forms.MessageBoxIcon.Error);
                throw new CannotUnloadAppDomainException();
            }

            serialPortDetector.PortsChanged += PortsChanged;
            form.VisibleChanged             += Form_VisibleChanged;
            messageScheduler.ProfileChanged += ProfileChanged;

            messageScheduler.handlers
                = MakeHandlers(profileContainer.jSONProfiles[profileContainer.ProfileIndex]);

            ScanPorts();

            notifyIcon.Visible = true;
            notifyIcon.Text    = "TinyKeyboard";
            notifyIcon.Click  += notifyIconClick;
            var cms = new System.Windows.Forms.MenuItem[1];

            cms[1] = new System.Windows.Forms.MenuItem("Exit", (sender, e) =>
            {
                System.Windows.Forms.Application.Exit();
            });
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(cms);
        }