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 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());
        }