/// <summary> /// Detach project editor from container control. /// </summary> public void DetachEditor() { if (DataContext is IProjectEditor projectEditor) { if (!_isLoaded) { return; } if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform) { canvasPlatform.Invalidate = null; canvasPlatform.ResetZoom = null; canvasPlatform.AutoFitZoom = null; canvasPlatform.Zoom = null; } if (_zoomBorder != null) { _zoomBorder.InvalidatedChild = null; } _inputProcessor.Dispose(); _inputTarget = null; _inputProcessor = null; _inputSource = null; _isLoaded = false; } }
/// <summary> /// Detach project editor from container control. /// </summary> public void DetachEditor() { if (_projectEditor != null) { _projectEditor.CanvasPlatform.Invalidate = null; _projectEditor.CanvasPlatform.ResetZoom = null; _projectEditor.CanvasPlatform.AutoFitZoom = null; _projectEditor.LayoutPlatform.LoadLayout = null; _projectEditor.LayoutPlatform.SaveLayout = null; _projectEditor.LayoutPlatform.ResetLayout = null; zoomBorder.InvalidatedChild = null; _inputProcessor.Dispose(); _inputProcessor = null; _inputSource = null; zoomBorder.AllowDrop = false; zoomBorder.DragEnter -= ZoomBorder_DragEnter; zoomBorder.Drop -= ZoomBorder_Drop; } _projectEditor = null; }
public void Detach() { if (!(_control.DataContext is IProjectEditor projectEditor)) { return; } var zoomBorder = _control.Find <ZoomBorder>("zoomBorder"); if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform) { canvasPlatform.Invalidate = null; canvasPlatform.ResetZoom = null; canvasPlatform.AutoFitZoom = null; canvasPlatform.Zoom = null; } if (zoomBorder != null) { zoomBorder.InvalidatedChild = null; } _inputProcessor?.Dispose(); _inputProcessor = null; _inputTarget = null; _inputSource = null; }
/// <summary> /// Detach project editor from container control. /// </summary> public void DetachEditor() { if (_projectEditor != null && _containerControl != null && _zoomBorder != null) { _projectEditor.Canvas.Invalidate = null; _projectEditor.Canvas.ResetZoom = null; _projectEditor.Canvas.AutoFitZoom = null; _projectEditor.Canvas.Zoom = null; _zoomBorder.InvalidatedChild = null; _inputProcessor.Dispose(); } _projectEditor = null; _containerControl = null; _zoomBorder = null; }
public MainWindow(IServiceProvider serviceProvider) { InitializeComponent(); bool isClosing = false; _serviceProvider = serviceProvider; _projectEditor = _serviceProvider.GetService <ProjectEditor>(); _previewWindow = new SvgWindow(); _previewWindow.svgButton.Click += (sender, e) => { UpdateSvg(); }; _previewWindow.Closing += (sender, e) => { if (!isClosing) { _previewWindow.Hide(); e.Cancel = true; } }; Loaded += (seender, e) => { _projectEditor.CurrentTool = _projectEditor.Tools.FirstOrDefault(t => t.Name == "Selection"); _projectEditor.CurrentPathTool = _projectEditor.PathTools.FirstOrDefault(t => t.Name == "Line"); _projectEditor.OnNewProject(); _projectEditor.Invalidate = () => { OnRefreshRequested(null, null); if (_previewWindow.svgLive.IsChecked == true) { UpdateSvg(); } }; _renderer = _projectEditor.Renderers[0]; _container = _projectEditor.Project.CurrentContainer; _presenter = new EditorPresenter(); canvas.Focusable = true; canvas.Focus(); OnRefreshRequested(null, null); _inputProcessor = new InputProcessor( new WpfInputSource( canvas, canvas, FixPointOffset), _projectEditor); }; Closing += (sender, e) => { _inputProcessor.Dispose(); isClosing = true; _previewWindow.Close(); }; KeyDown += (sender, e) => { bool isControl = Keyboard.Modifiers == ModifierKeys.Control; if (isControl) { switch (e.Key) { case Key.P: _previewWindow.Show(); break; case Key.N: NewProject(); break; case Key.O: OpenProject(); break; case Key.S: SaveProject(); break; case Key.E: Export(_projectEditor.Project.CurrentContainer); break; case Key.Z: _projectEditor.OnUndo(); break; case Key.Y: _projectEditor.OnRedo(); break; case Key.X: _projectEditor.OnCut(); break; case Key.C: _projectEditor.OnCopy(); break; case Key.V: _projectEditor.OnPaste(); break; case Key.A: _projectEditor.OnSelectAll(); break; case Key.G: _projectEditor.OnGroupSelected(); break; case Key.U: _projectEditor.OnUngroupSelected(); break; } } else { switch (e.Key) { case Key.N: _projectEditor.OnToolNone(); break; case Key.S: _projectEditor.OnToolSelection(); break; case Key.P: _projectEditor.OnToolPoint(); break; case Key.L: _projectEditor.OnToolLine(); break; case Key.A: _projectEditor.OnToolArc(); break; case Key.B: _projectEditor.OnToolCubicBezier(); break; case Key.Q: _projectEditor.OnToolQuadraticBezier(); break; case Key.H: _projectEditor.OnToolPath(); break; case Key.M: _projectEditor.OnToolMove(); break; case Key.R: _projectEditor.OnToolRectangle(); break; case Key.E: _projectEditor.OnToolEllipse(); break; case Key.T: _projectEditor.OnToolText(); break; case Key.I: _projectEditor.OnToolImage(); break; case Key.K: _projectEditor.OnToggleDefaultIsStroked(); break; case Key.F: _projectEditor.OnToggleDefaultIsFilled(); break; case Key.D: _projectEditor.OnToggleDefaultIsClosed(); break; case Key.J: _projectEditor.OnToggleDefaultIsSmoothJoin(); break; case Key.G: _projectEditor.OnToggleSnapToGrid(); break; case Key.C: _projectEditor.OnToggleTryToConnect(); break; case Key.Y: _projectEditor.OnToggleCloneStyle(); break; case Key.Delete: _projectEditor.OnDeleteSelected(); break; case Key.Escape: _projectEditor.OnDeselectAll(); break; } } }; }