Example #1
0
 // ドラッグ終了
 private void pictureBoxCaptureSheet_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (_isDraging == false)
     {
         return;
     }
     this.Visible = false;
     _isDraging   = false;
     // カーソル位置を取得し、計算用に変換
     System.Drawing.Point ep = System.Windows.Forms.Cursor.Position;
     dragEndPoint = this.PointToClient(ep);
     if (dragStartPoint.X - dragEndPoint.X != 0 && dragStartPoint.Y - dragEndPoint.Y != 0)
     {
         Bitmap bmp = ClsCapture.CaptureTrim(FullScreenImg, dragStartPoint, dragEndPoint);
         // キャプチャ後の処理実行
         Common.ImageCaptured(bmp);
         // メモ画面が開いているとき
         if (Common.fPreview.Visible == true)
         {
             // キャプチャ終了後メモ画面に貼り付け
             Common.fPreview.RichTextBox1.Paste();
         }
         // 開放
         bmp.Dispose();
     }
     // フォームを閉じる
     this.Close();
 }
Example #2
0
        // ロード時の処理
        private void FormCaputureSheet_Load(System.Object sender, System.EventArgs e)
        {
            // PictureBox1の解放
            if (!(this.pictureBoxCaptureSheet.Image == null))
            {
                this.pictureBoxCaptureSheet.Image.Dispose();
            }

            // FullScreenImgの解放
            if (!(FullScreenImg == null))
            {
                FullScreenImg.Dispose();
            }

            // DispScreenImgの解放
            if (!(DispScreenImg == null))
            {
                DispScreenImg.Dispose();
            }

            // フルスクリーンのキャプチャを取得
            FullScreenImg = new Bitmap(ClsCapture.FullScreenCapture());
            // カーソルを追加する場合実行
            if (Settings.Instance.CaptureCursorMode == true)
            {
                FullScreenImg = ClsCapture.AddCursor((Image)FullScreenImg.Clone());
            }
            DispScreenImg = new Bitmap(FullScreenImg);
            // スタートメニューを閉じる
            this.Cursor = Cursors.Cross;
            this.pictureBoxCaptureSheet.Left   = 0;
            this.pictureBoxCaptureSheet.Top    = 0;
            this.pictureBoxCaptureSheet.Width  = this.Width;
            this.pictureBoxCaptureSheet.Height = this.Height;
            // 白塗り画像の格納先
            Bitmap bmp_white = new Bitmap(pictureBoxCaptureSheet.Width, pictureBoxCaptureSheet.Height);
            // ImageオブジェクトのGraphicsオブジェクトを作成する
            Graphics  g    = Graphics.FromImage(bmp_white);
            Rectangle rect = new Rectangle(0, 0, FullScreenImg.Width, FullScreenImg.Height);

            // 白塗り画像を生成
            g.FillRectangle(Brushes.White, rect);
            // 白塗り画像を重ねて擬似的に透過
            Add_currentImage(bmp_white);
            // PictureBox1に反映
            this.pictureBoxCaptureSheet.Image = DispScreenImg;
            this.Opacity = 1.0;
            // リソースの解放
            g.Dispose();
            bmp_white.Dispose();
            // フォームを最前面に設定し表示
            this.TopMost = true;
            this.Visible = true;
        }
Example #3
0
        // ホットキーによる動作
        protected override void WndProc(ref Message m)
        {
            const int WM_SYSCOMMAND = 0x0112;
            const int SC_CLOSE      = 0xF060;
            const int WM_HOTKEY     = 0x312;

            if (m.Msg == WM_HOTKEY && m.LParam == hotkeyPrtSc.LParam)
            {
                // カーソルを追加する場合
                if (Settings.Instance.CaptureCursorMode == true)
                {
                    // カーソルの情報を取得
                    CURSORINFO ci = new CURSORINFO();
                    ci.cbSize = (uint)Marshal.SizeOf(typeof(CURSORINFO));
                    GetCursorInfo(ref ci);
                    // カーソルの形状を取得
                    ClsCapture.shotCursor = new Cursor(ci.hCursor);
                    // カーソルのホットスポットを取得
                    ClsCapture.shotCursorHotspot = System.Windows.Forms.Cursor.Current.HotSpot;
                    // カーソルの位置を取得
                    ClsCapture.shotPoint = System.Windows.Forms.Cursor.Position;
                }
                // ホットキーの登録を解除(念のため)
                hotkeyPrtSc.Unregister();
                hotkeyAltPrtSc.Unregister();
                // トリミングモードを実行
                SetForm_Capture();
                try
                {
                    // PrtSrcをID 0のホットキーとして登録
                    hotkeyPrtSc = new ClsHotkeys(this.Handle, 0, Keys.PrintScreen);
                    // Alt+PrtSrcをID 1のホットキーとして登録
                    hotkeyAltPrtSc = new ClsHotkeys(this.Handle, 1, Keys.Alt | Keys.PrintScreen);
                }
                catch (Exception ex)
                {
                    // エラーメッセージ表示
                    MessageBox.Show("キャプチャソフトの併用はできません。"
                                    + "\n" + "他のキャプチャソフトを終了してからお試しください。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // 終了(フォーム表示していないとうまく終了しない)
                    this.Show();
                    Application.Exit();
                }
            }
            else if (m.Msg == WM_HOTKEY && m.LParam == hotkeyAltPrtSc.LParam)
            {
                // キャプチャを取得
                Bitmap bmp = ClsCapture.ActiveWindowsCapture();
                // キャプチャ後の処理実行
                Common.ImageCaptured(bmp);
                // メモ画面が開いているとき
                if (Common.fPreview.Visible == true)
                {
                    // キャプチャ終了後メモ画面に貼り付け
                    Common.fPreview.RichTextBox1.Paste();
                }
                bmp.Dispose();
            }
            else if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE)
            {
                Hide();
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Example #4
0
 public static void CaptureMe(Control pnl)
 {
     ClsCapture cc = new ClsCapture(pnl);
 }