Example #1
0
        public override void Execute(object parameter)
        {
            IFileVM file = (IFileVM)_vm.ActiveDocument.GetVM();

            if (file.ExistsOnFileSystem)
            {
                file.SaveFile();
            }
            else
            {
                this._vm.SaveAsCommand.Execute(null);
            }
        }
Example #2
0
 public override void Execute(object parameter)
 {
     foreach (IDocumentView current in _vm.ActiveDocuments)
     {
         if ((current.GetVM() as IFileVM) != null)
         {
             IFileVM currentFile = current.GetVM() as IFileVM;
             if (currentFile.ExistsOnFileSystem)
             {
                 currentFile.SaveFile();
             }
             else
             {
                 this._vm.SaveAsCommand.Execute(currentFile);
             }
         }
     }
 }
Example #3
0
        public override void Execute(object parameter)
        {
            if (parameter == null)
            {
                // Use currently active document
                if (_vm.ActiveDocument != null && (_vm.ActiveDocument.GetVM() as IFileVM) != null)
                {
                    // Explicitly cast the active document to a file view model.
                    IFileVM file = _vm.ActiveDocument.GetVM() as IFileVM;

                    // Create save file dialog.
                    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.FileName        = file.TitleName;        // Default file name
                    dlg.DefaultExt      = file.FileExt;          // Default file extension
                    dlg.Filter          = "All Files (*.*)|*.*"; // Filter files by extension
                    dlg.CheckPathExists = true;
                    dlg.AddExtension    = true;

                    // Show save file dialog box
                    Nullable <bool> result = dlg.ShowDialog();

                    // Process save file dialog box results
                    if (result == true)
                    {
                        // Save document
                        file.SaveFile(dlg.FileName);
                    }
                }
            }
            else
            {
                // Use document specified in parameter.
                if ((parameter as IFileVM) == null)
                {
                    throw new ArgumentException("Save-as param not a file!!!");
                }
                else
                {
                    // Explicitly cast the document vm from the parameter to a file view model.
                    IFileVM file = parameter as IFileVM;

                    // Create save file dialog.
                    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.FileName        = file.TitleName;        // Default file name
                    dlg.DefaultExt      = file.FileExt;          // Default file extension
                    dlg.Filter          = "All Files (*.*)|*.*"; // Filter files by extension
                    dlg.CheckPathExists = true;
                    dlg.AddExtension    = true;

                    // Show save file dialog box
                    Nullable <bool> result = dlg.ShowDialog();

                    // Process save file dialog box results
                    if (result == true)
                    {
                        // Save document
                        file.SaveFile(dlg.FileName);
                    }
                }
            }
        }