public SaveDocumentCommand(InkWriterDocument document) { Safeguard.EnsureNotNull("document", document); this.document = document; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public MainWindowViewModel() { this.settings = InkWriterSettings.Load(); this.InkCanvas = new InkCanvas(); this.InkCanvas.PreviewStylusDown += this.OnInkCanvasPreviewStylusDown; this.InkCanvas.StylusUp += this.OnInkCanvasStylusUp; this.InkCanvas.Background = Brushes.Black; this.InkCanvas.DefaultDrawingAttributes.Color = Colors.LightGray; this.InkCanvas.DefaultDrawingAttributes.Width = 1; this.InkCanvas.DefaultDrawingAttributes.FitToCurve = true; this.InkCanvas.PreviewMouseDown += this.OnInkCanvasPreviewMouseDown; this.InkCanvas.MouseMove += this.OnInkCanvasMouseMove; this.InkCanvas.MouseUp += this.OnInkCanvasMouseUp; this.InkCanvas.PreviewMouseUp += this.OnInkCanvasPreviewMouseUp; this.InkCanvas.AllowDrop = true; this.InkCanvas.Gesture += this.HandleInkCanvasGesture; this.InkCanvas.EditingMode = InkCanvasEditingMode.None; this.GridType = GridType.None; string[] commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.Length == 2) { string filePath = commandLineArgs[1]; if (File.Exists(filePath)) { this.document = InkWriterDocument.Load(filePath); } } this.document = new InkWriterDocument(); this.document.Pages.Add(new Data.Page(this.document)); this.document.PageChanged += this.OnDocumentPageChanged; this.document.ActivePageIndex = this.document.Pages.Count - 1; this.NewPageCommand = new NewPageCommand(this, this.document); this.FirstPageCommand = new PageNavigationCommand(this, this.document, NavigationRequestType.First); this.NextPageCommand = new PageNavigationCommand(this, this.document, NavigationRequestType.Next); this.PreviousPageCommand = new PageNavigationCommand(this, this.document, NavigationRequestType.Previous); this.LastPageCommand = new PageNavigationCommand(this, this.document, NavigationRequestType.Last); this.DeletePageCommand = new DeletePageCommand(this, this.document); this.SaveDocumentCommand = new SaveDocumentCommand(this.document); this.LoadDocumentCommand = new LoadDocumentCommand(this); this.SelectColorCommand = new SelectColorCommand(this); this.SelectWidthCommand = new SelectWidthCommand(this); this.CapturePictureCommand = new CapturePictureCommand(this); this.ToggleGridCommand = new ToggleGridCommand(this); this.CopyToClipboardCommand = new CopyToClipboardCommand(() => { return(this.document?.ActivePage?.GetBitmap(null)); }); this.CloseApplicationCommand = new CloseApplicationCommand(this, this.document, this.settings); this.MinimizeWindowCommand = new MinimizeWindowCommand(Application.Current.MainWindow); this.PrintCommand = new PrintCommand(this.document); }
public void ResetDocument(InkWriterDocument newDocument) { Safeguard.EnsureNotNull("newDocument", newDocument); this.document.PageChanged -= this.OnDocumentPageChanged; this.document = newDocument; this.document.PageChanged += this.OnDocumentPageChanged; }
public DeletePageCommand(MainWindowViewModel mainWindow, InkWriterDocument document) { Safeguard.EnsureNotNull("mainWindow", mainWindow); Safeguard.EnsureNotNull("document", document); this.mainWindow = mainWindow; this.document = document; this.document.PageChanged += this.OnDocumentPageChanged; }
public NewPageCommand(MainWindowViewModel mainWindow, InkWriterDocument document) { Safeguard.EnsureNotNull("mainWindow", mainWindow); Safeguard.EnsureNotNull("document", document); this.mainWindow = mainWindow; this.document = document; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public PageNavigationCommand(MainWindowViewModel mainWindow, InkWriterDocument document, NavigationRequestType navigationRequestType) { Safeguard.EnsureNotNull("mainWindow", mainWindow); Safeguard.EnsureNotNull("document", document); this.document = document; this.mainWindow = mainWindow; this.document.PageChanged += this.OnDocumentPageChanged; this.navigationRequestType = navigationRequestType; }
public CloseApplicationCommand(MainWindowViewModel mainWindow, InkWriterDocument document, InkWriterSettings settings) { Safeguard.EnsureNotNull("mainWindow", mainWindow); Safeguard.EnsureNotNull("document", document); Safeguard.EnsureNotNull("settings", settings); this.document = document; this.settings = settings; this.mainWindow = mainWindow; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public void Execute(object parameter) { SearchPattern[] searchPatterns = new SearchPattern[] { new SearchPattern("InkWriter-Dateien (*.iwd)", "*.iwd"), new SearchPattern("Alle Dateien (*.*)", "*.*") }; FileDialogResult result = FileDialog.Show("Open File...", searchPatterns, searchPatterns[0]); if (result.Result == FileDialogResultEnum.OK) { this.mainWindow.SetActiveDocument(InkWriterDocument.Load(result.SelectedFile)); } }
public void SetActiveDocument(InkWriterDocument documentToSet) { if (this.document != null) { this.document.PageChanged -= this.OnDocumentPageChanged; } this.DefaultDrawingColor = Colors.LightGray; this.document = documentToSet; this.NewPageCommand.ResetDocument(this.document); this.FirstPageCommand.ResetDocument(this.document); this.NextPageCommand.ResetDocument(this.document); this.PreviousPageCommand.ResetDocument(this.document); this.LastPageCommand.ResetDocument(this.document); this.DeletePageCommand.ResetDocument(this.document); this.SaveDocumentCommand.ResetDocument(this.document); this.CloseApplicationCommand.ResetDocument(this.document); this.PrintCommand.ResetDocument(this.document); this.document.PageChanged += this.OnDocumentPageChanged; this.document.ActivePageIndex = 0; }
public void ResetDocument(InkWriterDocument newDocument) { Safeguard.EnsureNotNull("newDocument", newDocument); this.document = newDocument; }
public PrintCommand(InkWriterDocument document) { ResetDocument(document); this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public void ResetDocument(InkWriterDocument documentToSet) { Safeguard.EnsureNotNull("document", documentToSet); this.document = documentToSet; }