Пример #1
0
        public void Paste(InkCanvas inkCanvas, InkCanvas clipboardCanvas)
        {
            if (!ContainsImage())
            {
                EventBroker.Instance.ActionResult(Resources.Title_Paste, Resources.Message_Clipboard_does_not_contain_any_image_as_expected);
                return;
            }

            if (ClipboardWasChangedOutside())
            {
                var image = ImageHelper.AddImageTo(inkCanvas, new Bitmap(GetImage()));
                ActivateSelectionMode(inkCanvas);
                inkCanvas.Select(new List <UIElement> {
                    image
                });
                return;
            }
            _currentPasteOffset += PasteOffset;
            ClearSelection(inkCanvas);
            var elements = new List <UIElement>();
            var strokes  = new StrokeCollection();

            WPFHelper.CloneElementsTo(elements, clipboardCanvas.Children.GetEnumerator(), inkCanvas, _currentPasteOffset);
            WPFHelper.CloneStrokesTo(strokes, clipboardCanvas.Strokes, _currentPasteOffset);
            elements.ForEach(element => inkCanvas.Children.Add(element));
            inkCanvas.Strokes.Add(strokes);
            ActivateSelectionMode(inkCanvas);
            inkCanvas.Select(strokes, elements);
        }
 public void ImportAndClose()
 {
     if (CanBeImported)
     {
         ImageHelper.AddImageTo(ModelStorage.WorkAreaModel.CurrentInkCanvas, new Bitmap(_captureArea.Image));
     }
     CloseView();
 }
Пример #3
0
        public override void Execute(object parameter)
        {
            var openFileDialog = new OpenFileDialog {
                Filter = Filter
            };

            if (openFileDialog.ShowDialog() == DialogResult.Cancel || string.IsNullOrEmpty(openFileDialog.FileName))
            {
                return;
            }
            using (Stream stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read))
            {
                ImageHelper.AddImageTo(ModelStorage.WorkAreaModel.CurrentInkCanvas, stream);
            }
        }