Beispiel #1
0
        private bool FindHotKey(Message m)
        {
            if (m.Msg != WindowNative.WM_HOTKEY)
            {
                return(false);
            }
            if (_captureThread != null)
            {
                return(false);
            }

            var modifier = (WindowNative.KeyModifiers)((int)m.LParam & 0xFFFF);
            var key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);

            CaptureMode mode = CaptureSetting.GetCaptureMode(modifier, key);

            if (mode == CaptureMode.None)
            {
                return(false);
            }

            DoCapture(mode);

            return(true);
        }
Beispiel #2
0
        private void ImageEditForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_canvas.CanUndo)
            {
                var result = MessageBoxUtil.ConfirmYesNoCancel(Resource.GetString(Key.CloseOrSaveConfirmMsg));
                if (result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        byte[] data = _canvas.GetImageData();
                        if (data == null)
                        {
                            return;
                        }

                        File.WriteAllBytes(_filePath, data);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }

            CaptureSetting.Save();
        }
Beispiel #3
0
        public void Update(WindowNative.KeyModifiers modifiers, Keys key)
        {
            CaptureSetting.UnregisterHotKey(CaptureMode);

            if (modifiers == WindowNative.KeyModifiers.None && key == Keys.Escape)
            {
                key = Keys.None;
            }

            Modifiers = modifiers;
            Key       = key;
            CaptureSetting.RegisterHotKey(CaptureMode);
        }
Beispiel #4
0
        private void SaveImage(Image img)
        {
            if (img == null)
            {
                return;
            }
            try
            {
                string savePath = GetCaptureSaveFilePath(CaptureSetting.SaveImageFormat);
                img.Save(savePath, CaptureSetting.GetImageFormat());

                Clipboard.SetImage(img);
                ToastMessageForm.ShowMessage(savePath);
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }