private void CopyCodeCommandHandler(TargetBitmapInfo targetBitmapInfo)
        {
            var str =
                $"await WindowsApi.ScreenApi.WaitScanBitmapLocation(new Bitmap(\"Pictures\\\\{Path.GetFileName(targetBitmapInfo.FilePath)}\"), WindowsApi.ScreenApi.AllScreens[{SelectedScreenInfo.Index}]);";

            Clipboard.SetDataObject(str);
            PromptHelper.Instance.Prompt = str;
        }
 private void CopyTargetBitmapCommandHandler(TargetBitmapInfo targetBitmapInfo)
 {
     Clipboard.SetFileDropList(new StringCollection
     {
         targetBitmapInfo.FilePath
     });
     PromptHelper.Instance.Prompt = targetBitmapInfo.FilePath;
 }
        private void DeleteTargetBitmapCommandHandler(TargetBitmapInfo targetBitmapInfo)
        {
            BitmapInfos.Remove(targetBitmapInfo);
            targetBitmapInfo.Dispose();

            if (targetBitmapInfo.FilePath.StartsWith(AppDomain.CurrentDomain.BaseDirectory) &&
                File.Exists(targetBitmapInfo.FilePath))
            {
                File.Delete(targetBitmapInfo.FilePath);
            }
        }
        private void AddPictureFileHandler()
        {
            var dialog = new OpenFileDialog
            {
                Filter      = "Bitmap (*.bmp)|*.bmp",
                Multiselect = false
            };

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (dialog.FileNames.Any())
                {
                    var targetBitmap = new TargetBitmapInfo(dialog.FileName);
                    targetBitmap.Init();

                    BitmapInfos.Add(targetBitmap);
                }
            }
        }
        private void Sketchpad_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (_viewModel.StartPaint)
            {
                var point = Mouse.GetPosition(Sketchpad);

                if (_startPaintPoint == null)
                {
                    if (point.X >= 0 && point.Y >= 0 && point.X <= Sketchpad.ActualWidth &&
                        point.Y <= Sketchpad.ActualHeight)
                    {
                        _startPaintPoint = point;
                    }
                }
                else
                {
                    var locationPoint = _startPaintPoint.Value;

                    var width  = point.X - _startPaintPoint.Value.X;
                    var height = point.Y - _startPaintPoint.Value.Y;

                    if (width < 0)
                    {
                        locationPoint.X = _startPaintPoint.Value.X + width;
                    }
                    else
                    {
                        locationPoint.X = _startPaintPoint.Value.X;
                    }

                    if (height < 0)
                    {
                        locationPoint.Y = _startPaintPoint.Value.Y + height;
                    }
                    else
                    {
                        locationPoint.Y = _startPaintPoint.Value.Y;
                    }

                    var rectangle = new Rectangle((int)(locationPoint.X / _canvasScreenWidthRatio),
                                                  (int)(locationPoint.Y / _canvasScreenHeightRatio),
                                                  (int)Math.Abs(width / _canvasScreenWidthRatio),
                                                  (int)Math.Abs(height / _canvasScreenHeightRatio));

                    //保存图片
                    using (var bitmap = _viewModel.SelectedScreenInfo.CopyBitmap())
                        using (var subBitmap = bitmap.Clone(rectangle, bitmap.PixelFormat))
                        {
                            var path = BitmapHelper.SaveFile(subBitmap);

                            var targetBitmapInfo = new TargetBitmapInfo(path);
                            targetBitmapInfo.Init();
                            _viewModel.BitmapInfos.Add(targetBitmapInfo);
                            _viewModel.SelectedBitmapInfo = targetBitmapInfo;
                        }

                    //结束画图
                    _viewModel.StartPaint = false;
                }
            }
        }