Exemple #1
0
 public override ManagerStateEnum Start()
 {
     if (this.ManagerState != ManagerStateEnum.Started)
     {
         OnStart(ManagerEventStateEnum.Before);
         try
         {
             if (ApplicationHelper.IsUIThread())
             {
                 mViewer           = new ClipboardViewer(this);
                 this.ManagerState = ManagerStateEnum.Started;
             }
             else
             {
                 throw new InvalidOperationException("Manager must be started on the STA thread.");
             }
         }
         catch (Exception)
         {
             this.ManagerState = ManagerStateEnum.Fault;
             throw;
         }
         finally
         {
             OnStart(ManagerEventStateEnum.After);
         }
     }
     return(this.ManagerState);
 }
Exemple #2
0
        /// <summary>
        /// インスタンスが破棄された際の処理。
        /// </summary>
        public void Destroy()
        {
            if (clipboardViewer != null)
            {
                clipboardViewer.Dispose();
                clipboardViewer = null; // Destroyが二回以上呼び出されても良いようにnullクリアする
            }

            // 時折、常駐アイコンが残ったままになるのでDisposeメソッドを明示的に呼び出す
            notifyIcon.Dispose();
        }
Exemple #3
0
        /// <summary>
        /// フォームのロード処理。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FMain_Load(object sender, EventArgs e)
        {
            appConfig = new AppConfig();
            appConfig.Read();

            LoadConvertScriptList(menuGroupAutoConvert, menuItemAutoConvertScripts_Click);
            LoadConvertScriptList(menuGroupConvert, menuItemConvertScripts_Click);

            SelectConvertScriptMenuItem(menuGroupAutoConvert, appConfig.ConvertScriptMenuItemLastSelected);

            clipboardViewer = new Clipboard.ClipboardViewer(this.Handle);
            clipboardViewer.DrawClipBoardEventHandler += OnDrawClipboard;
        }
Exemple #4
0
 public override ManagerStateEnum Stop()
 {
     if (this.ManagerState == ManagerStateEnum.Started)
     {
         OnStop(ManagerEventStateEnum.Before);
         try
         {
             mViewer.Dispose();
             mViewer           = null;
             this.ManagerState = ManagerStateEnum.Stopped;
         }
         catch (Exception)
         {
             this.ManagerState = ManagerStateEnum.Fault;
             throw;
         }
         finally
         {
             OnStop(ManagerEventStateEnum.After);
         }
     }
     return(this.ManagerState);
 }
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == Messages.WM_CREATE)
            {
                this._clipboardViewer = new ClipboardViewer(this.Handle);
                this._clipboardViewer.ClipboardUpdated += (object sender, EventArgs e) =>
                {
                    this.ClipbordUpdated?.Invoke(this, EventArgs.Empty);
                };
                WindowsFunctions.RegisterHotKey(this.Handle, 0, 1, (int)Keys.C);

                this._StartTrickTimer(23);
            }
            else if (this._clipboardViewer != null)
            {
                this._clipboardViewer.HandleWindowsMessage(m.Msg, m.WParam, m.LParam);
            }

            if (m.Msg == Messages.WM_HOTKEY)
            {
                Keys key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                var  modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);

                if (key == Keys.C && modifier == System.Windows.Input.ModifierKeys.Alt)
                {
                    this.Activate();
                }
            }

            if (m.Msg == Messages.WM_QUERYENDSESSION)
            {
                this.Exit();
            }

            base.WndProc(ref m);
        }