Esempio n. 1
0
        ///<summary>
        ///MouseHookedイベントを発生させる。
        ///</summary>
        ///<param name="e">イベントのデータ。</param>
        protected virtual void OnMouseHooked(MouseHookedEventArgs e)
        {
            MouseHookedEventHandler handler = base.Events[EventMouseHooked] as MouseHookedEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 2
0
 private int CallNextHook(int code, MouseMessage message, ref MouseState state)
 {
     if (code >= 0)
     {
         MouseHookedEventArgs e = new MouseHookedEventArgs(message, ref state);
         this.OnMouseHooked(e);
         if (e.Cancel)
         {
             return(-1);
         }
     }
     return(CallNextHookEx(hook, code, message, ref state));
 }
Esempio n. 3
0
        /// <summary>
        /// マウス押下時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mouseHook_MouseHooked(object sender, HongliangSoft.Utilities.Gui.MouseHookedEventArgs e)
        {
            //ドラッグ時
            if (_state == state.keyPress && e.Message == MouseMessage.LDown)
            {
                _imageCapture.StartPoint = e.Point;
                _state = state.mouseDrag;
            }

            //ドロップ時
            if (_state == state.mouseDrag && e.Message == MouseMessage.LUp)
            {
                _state = state.none;                      //状態ステート更新
                CloseVirtualScreen();                     //仮想スクリーンをすべて削除
                _imageCapture.EndPoint = e.Point;         //キャプチャの終点を指定
                _image = _imageCapture.GetCaptureImage(); //キャプチャイメージ取得
                _imageCapture.ClearCapture();             //保持しているキャプチャイメージを破棄
                if (_mode == mode.clip)
                {
                    Clipboard.SetDataObject(_image, true); //クリップボードにキャプチャをコピー
                }
                else if (_mode == mode.save)
                {
                    string path = Properties.Settings.Default.save_path;
                    if (path.Length <= 0)
                    {
                        MessageBox.Show("設定から保存先を指定してください。",
                                        "エラー",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        return;
                    }
                    string date = path + "\\" + System.DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg";

                    _image.Save(date);
                }
                new SoundPlayer().playShutter();
            }
        }