Exemplo n.º 1
0
        public DialogResult ShowSaveFileDialog(object ownerViewModel, ISaveFileDialog saveFileDialog)
        {
            Contract.Requires(ownerViewModel != null);
            Contract.Requires(saveFileDialog != null);

            return(default(DialogResult));
        }
        public CodeExplorer_RemoveCommand(ISaveFileDialog saveFileDialog, IMessageBox messageBox)
        {
            _saveFileDialog = saveFileDialog;
            _saveFileDialog.OverwritePrompt = true;

            _messageBox = messageBox;
        }
Exemplo n.º 3
0
 public TxtExporter(
     ISaveFileDialog sfd,
     IDataObjectsConverter dataObjectsConverter)
 {
     _newSFD = sfd;
     _dataObjectsConverter = dataObjectsConverter;
 }
Exemplo n.º 4
0
        public RemoveCommand(ISaveFileDialog saveFileDialog, IMessageBox messageBox) : base(LogManager.GetCurrentClassLogger())
        {
            _saveFileDialog = saveFileDialog;
            _saveFileDialog.OverwritePrompt = true;

            _messageBox = messageBox;
        }
        public MainWindowViewModel(WindowSettingsViewModel windowSettingsViewModel, InputTextBoxViewModel inputTextBoxViewModel, StatusBarViewModel statusBarViewModel, IFontDialog fontDialog,
                                   IFindDialog findDialog, IColorDialog colorDialog, IAboutDialog aboutDialog, IMessageDialog messageDialog, IReplaceDialog replaceDialog, IOpenFileDialog openFileDialog,
                                   ISaveFileDialog saveFileDialog, IGoToLineDialog goToLineDialog, ITextFileWriter textFileWriter, ITextFileReader textFileReader, IDocInfoService docInfoService,
                                   IFindNextAndReplaceConditionsService findNextSearchConditionsService)
        {
            _fontDialog     = fontDialog;
            _findDialog     = findDialog;
            _colorDialog    = colorDialog;
            _aboutDialog    = aboutDialog;
            _messageDialog  = messageDialog;
            _replaceDialog  = replaceDialog;
            _openFileDialog = openFileDialog;
            _saveFileDialog = saveFileDialog;
            _goToLineDialog = goToLineDialog;
            _textFileWriter = textFileWriter;
            _textFileReader = textFileReader;
            _docInfoService = docInfoService;
            _findNextSearchConditionsService = findNextSearchConditionsService;

            StatusBarViewModel      = statusBarViewModel;
            InputTextBoxViewModel   = inputTextBoxViewModel;
            WindowSettingsViewModel = windowSettingsViewModel;

            InitMessengerRegistrations();
        }
Exemplo n.º 6
0
 public SaveFileAsCommand(MainWindowViewModel callerViewModel, ISaveFileDialog saveFileDialog, IDocInfoService docInfoService,
                          ITextFileWriter textFileWriter) : base(callerViewModel)
 {
     _saveFileDialog = saveFileDialog;
     _docInfoService = docInfoService;
     _textFileWriter = textFileWriter;
 }
        /// <summary>
        /// Runs a common dialog box with the specified owner.
        /// </summary>
        /// <param name="owner">
        /// Any object that implements System.Windows.Forms.IWin32Window that represents the top-level
        /// window that will own the modal dialog box.
        /// </param>
        /// <returns>
        /// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box; otherwise,
        /// System.Windows.Forms.DialogResult.Cancel.
        /// </returns>
        public DialogResult ShowDialog(ISaveFileDialog saveFile)
        {
            this.saveFileDialog = saveFile;

            var saveFileDlg = new WinFormsSaveFileDialog();

            // Create concrete OpenFileDialog
            concreteOpenFileDialog = new WinFormsSaveFileDialog
            {
                AddExtension = saveFileDialog.AddExtension,
                CheckFileExists = saveFileDialog.CheckFileExists,
                CheckPathExists = saveFileDialog.CheckPathExists,
                DefaultExt = saveFileDialog.DefaultExt,
                FileName = saveFileDialog.FileName,
                Filter = saveFileDialog.Filter,
                InitialDirectory = saveFileDialog.InitialDirectory,
                Title = saveFileDialog.Title,
                CreatePrompt = saveFileDialog.CreatePrompt,
                OverwritePrompt = saveFileDialog.OverwritePrompt

            };

            DialogResult result = concreteOpenFileDialog.ShowDialog();

            // Update ViewModel
            saveFileDialog.FileName = concreteOpenFileDialog.FileName;
            saveFileDialog.FileNames = concreteOpenFileDialog.FileNames;

            return result;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Runs a common dialog box with the specified owner.
        /// </summary>
        /// <param name="owner">
        /// Any object that implements System.Windows.Forms.IWin32Window that represents the top-level
        /// window that will own the modal dialog box.
        /// </param>
        /// <returns>
        /// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box; otherwise,
        /// System.Windows.Forms.DialogResult.Cancel.
        /// </returns>
        public DialogResult ShowDialog(ISaveFileDialog saveFile)
        {
            this.saveFileDialog = saveFile;

            var saveFileDlg = new WinFormsSaveFileDialog();

            // Create concrete OpenFileDialog
            concreteOpenFileDialog = new WinFormsSaveFileDialog
            {
                AddExtension     = saveFileDialog.AddExtension,
                CheckFileExists  = saveFileDialog.CheckFileExists,
                CheckPathExists  = saveFileDialog.CheckPathExists,
                DefaultExt       = saveFileDialog.DefaultExt,
                FileName         = saveFileDialog.FileName,
                Filter           = saveFileDialog.Filter,
                InitialDirectory = saveFileDialog.InitialDirectory,
                Title            = saveFileDialog.Title,
                CreatePrompt     = saveFileDialog.CreatePrompt,
                OverwritePrompt  = saveFileDialog.OverwritePrompt
            };

            DialogResult result = concreteOpenFileDialog.ShowDialog();

            // Update ViewModel
            saveFileDialog.FileName  = concreteOpenFileDialog.FileName;
            saveFileDialog.FileNames = concreteOpenFileDialog.FileNames;

            return(result);
        }
Exemplo n.º 9
0
 private void InitAlsoSaveDialog(ISaveFileDialog dlg)
 {
     dlg.InitialDirectory = Path.GetDirectoryName(dlg.FileName);
     dlg.Filter           = ResourceHelper.FileFilter(FileFilterType.XML);
     dlg.Title            = m_sAlsoSaveDialogTitle;
     dlg.FileName         = Path.GetFileNameWithoutExtension(dlg.FileName);
 }
Exemplo n.º 10
0
        public RemoveCommand(ISaveFileDialog saveFileDialog, IMessageBox messageBox, IProjectsProvider projectsProvider) : base(LogManager.GetCurrentClassLogger())
        {
            _saveFileDialog = saveFileDialog;
            _saveFileDialog.OverwritePrompt = true;

            _messageBox       = messageBox;
            _projectsProvider = projectsProvider;
        }
Exemplo n.º 11
0
        public ExportCommand(ISaveFileDialog saveFileDialog, IProjectsProvider projectsProvider)
            : base(LogManager.GetCurrentClassLogger())
        {
            _saveFileDialog = saveFileDialog;
            _saveFileDialog.OverwritePrompt = true;

            _projectsProvider = projectsProvider;
        }
Exemplo n.º 12
0
 private void InitSaveAsWebpageDialog(ISaveFileDialog dlg)
 {
     dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
     dlg.FileName         = m_mediator.StringTbl.GetString(m_sFileNameKey, m_sStringsPath);
     dlg.AddExtension     = true;
     dlg.Filter           = ResourceHelper.FileFilter(FileFilterType.HTM);
     dlg.Title            = m_sSaveAsWebpageDialogTitle;
 }
Exemplo n.º 13
0
        /// <summary>
        /// Shows the SaveFileDialog.
        /// </summary>
        /// <param name="ownerViewModel">
        /// A ViewModel that represents the owner window of the dialog.
        /// </param>
        /// <param name="saveFileDialog">The interface of a save file dialog.</param>
        /// <returns>DialogResult.OK if successful; otherwise DialogResult.Cancel.</returns>
        public DialogResult ShowSaveFileDialog(object ownerViewModel, ISaveFileDialog saveFileDialog)
        {
            // Create SaveFileDialog with specified ViewModel
            var dialog = new SaveFileDialog(saveFileDialog);

            // Show dialog
            return(dialog.ShowDialog(new WindowWrapper(FindOwnerWindow(ownerViewModel))));
        }
 public ApplicationCloseCommand(MainWindowViewModel callerViewModel, IMessageDialog messageDialog, ISaveFileDialog saveFileDialog, IDocInfoService docInfoService,
                                ITextFileWriter textFileWriter) : base(callerViewModel)
 {
     _messageDialog  = messageDialog;
     _saveFileDialog = saveFileDialog;
     _docInfoService = docInfoService;
     _textFileWriter = textFileWriter;
 }
 public OpenFileCommand(MainWindowViewModel callerViewModel, IMessageDialog messageDialog, ISaveFileDialog saveFileDialog, IOpenFileDialog openFileDialog,
                        IDocInfoService docInfoService, ITextFileWriter textFileWriter, ITextFileReader textFileReader) : base(callerViewModel)
 {
     _messageDialog  = messageDialog;
     _saveFileDialog = saveFileDialog;
     _openFileDialog = openFileDialog;
     _docInfoService = docInfoService;
     _textFileWriter = textFileWriter;
     _textFileReader = textFileReader;
 }
Exemplo n.º 16
0
 public ExcelWriter(
     IPredictionMatrixWriter predictionMatrixWriter,
     IAttributeWriter attributeWriter,
     ISaveFileDialog sfd,
     IDataObjectsConverter dataObjectsConverter)
 {
     _predictionMatrixWriter = predictionMatrixWriter;
     _attributeWriter        = attributeWriter;
     _newSFD = sfd;
     _dataObjectsConverter = dataObjectsConverter;
 }
        private SaveFileWizard Setup(ISaveFileDialog saveFileDialog = null)
        {
            var saveFileDialogCreator = new StubISaveFileDialogCreator
            {
                CreateIFile = file => saveFileDialog
            };

            var fileFactory = new StubIFileFactory();

            return new SaveFileWizard(saveFileDialogCreator, fileFactory);
        }
        protected virtual void OnSaveAsButton()
        {
            ISaveFileDialog fileDialog = CommonDialogsInternal.CommonDialogProvider.Instance.CreateDefaultSaveFileDialog() ?? CommonDialogsInternal.CommonDialogProvider.Instance.CreateStandardSaveFileDialog();

            fileDialog.Filter      = "iCalendar files (*.ics)|*.ics";
            fileDialog.FilterIndex = 1;
            if (fileDialog.ShowDialog() != CommonDialogsInternal.DialogResult.OK)
            {
                return;
            }
            try {
                using (Stream stream = new FileInfo(fileDialog.FileName).OpenWrite())
                    ExportAppointment(stream);
            }
            catch {
                ShowMessageBox("Error: could not export appointments", String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenFileDialog"/> class.
        /// </summary>
        /// <param name="openFileDialog">The interface of a open file dialog.</param>
        public SaveFileDialog(ISaveFileDialog saveFileDialog)
        {
            Contract.Requires(saveFileDialog != null);

            this.saveFileDialog = saveFileDialog;

            // Create concrete OpenFileDialog
            concreteSaveFileDialog = new WinFormsSaveFileDialog
            {
                AddExtension     = saveFileDialog.AddExtension,
                CheckFileExists  = saveFileDialog.CheckFileExists,
                CheckPathExists  = saveFileDialog.CheckPathExists,
                DefaultExt       = saveFileDialog.DefaultExt,
                FileName         = saveFileDialog.FileName,
                Filter           = saveFileDialog.Filter,
                InitialDirectory = saveFileDialog.InitialDirectory,
                Title            = saveFileDialog.Title,
            };
        }
Exemplo n.º 20
0
        public DialogResult ShowDialog <T>(ISaveFileDialog saveFile, T userForm) where T : FileDialogControlBase
        {
            userForm.FileDlgAddExtension    = saveFile.AddExtension;
            userForm.FileDlgCheckFileExists = saveFile.CheckFileExists;
            //userForm.MSDialog.CheckPathExists = saveFile.CheckPathExists;
            userForm.FileDlgDefaultExt       = saveFile.DefaultExt;
            userForm.FileDlgFileName         = saveFile.FileName;
            userForm.FileDlgFilter           = saveFile.Filter;
            userForm.FileDlgInitialDirectory = saveFile.InitialDirectory;
            //userForm.MSDialog.Title = saveFile.Title;
            userForm.FileDlgType = Win32Types.FileDialogType.SaveFileDlg;
            //userForm.MSDialog.CreatePrompt = saveFile.CreatePrompt;
            //userForm.MSDialog.OverwritePrompt = saveFile.OverwritePrompt;
            DialogResult result = userForm.ShowDialog();

            saveFile.FileName  = userForm.FileDlgFileName;
            saveFile.FileNames = userForm.FileDlgFileNames;
            return(result);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenFileDialog"/> class.
        /// </summary>
        /// <param name="openFileDialog">The interface of a open file dialog.</param>
        public SaveFileDialog(ISaveFileDialog saveFileDialog)
        {
            Contract.Requires(saveFileDialog != null);

            this.saveFileDialog = saveFileDialog;

            // Create concrete OpenFileDialog
            concreteSaveFileDialog = new WinFormsSaveFileDialog
            {
                AddExtension = saveFileDialog.AddExtension,
                CheckFileExists = saveFileDialog.CheckFileExists,
                CheckPathExists = saveFileDialog.CheckPathExists,
                DefaultExt = saveFileDialog.DefaultExt,
                FileName = saveFileDialog.FileName,
                Filter = saveFileDialog.Filter,
                InitialDirectory = saveFileDialog.InitialDirectory,
                Title = saveFileDialog.Title,
            };
        }
Exemplo n.º 22
0
        internal void SaveWorkspaceAs()
        {
            ViewModelBase vm = this.WorkspaceManager.GetCurrentWorkspace() as ViewModelBase;

            if (vm == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(vm.Filename))
            {
                vm.Filename = CreateNumberedFileName(vm.DisplayName);
            }
            ISaveFileDialog dialog   = this.ServiceContainer.Create <ISaveFileDialog>();
            string          filename = dialog.Show(vm.Filename, vm.Filter);

            if (!String.IsNullOrEmpty(filename))
            {
                vm.Filename = filename;
                SaveWorkspace(vm);
            }
        }
Exemplo n.º 23
0
        private void DoAlsoSaveAs(ISaveFileDialog dlg)
        {
            string sAlsoSaveFile = Path.ChangeExtension(dlg.FileName, "xml");

            RemoveWriteProtection(sAlsoSaveFile);
            if (m_sReplaceDoctype == "")
            {
                File.Copy(m_sAlsoSaveFileName, sAlsoSaveFile, true);
            }
            else
            {
                string sContents;
                using (var sr = new StreamReader(m_sAlsoSaveFileName, System.Text.Encoding.UTF8))
                {
                    sContents = sr.ReadToEnd();
                    sr.Close();
                }
                int i = sContents.IndexOf("<!DOCTYPE ");
                if (i > -1)
                {
                    var sb = new StringBuilder();
                    sb.Append(sContents.Substring(0, i + 10));
                    sb.Append(m_sReplaceDoctype);
                    i = sContents.IndexOf(">", i);
                    sb.Append(sContents.Substring(i));
                    using (var sw = new StreamWriter(sAlsoSaveFile, false))
                    {
                        sw.Write(sb.ToString());
                        sw.Close();
                    }
                }
                else
                {                 // could not find DOCTYPE; nothing to replace
                    File.Copy(m_sAlsoSaveFileName, sAlsoSaveFile, true);
                }
            }
        }
Exemplo n.º 24
0
 private void InitSaveAsWebpageDialog(ISaveFileDialog dlg)
 {
     dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
     dlg.FileName =  m_mediator.StringTbl.GetString(m_sFileNameKey, m_sStringsPath);
     dlg.AddExtension = true;
     dlg.Filter = ResourceHelper.FileFilter(FileFilterType.HTM);
     dlg.Title = m_sSaveAsWebpageDialogTitle;
 }
Exemplo n.º 25
0
 private void InitAlsoSaveDialog(ISaveFileDialog dlg)
 {
     dlg.InitialDirectory = Path.GetDirectoryName(dlg.FileName);
     dlg.Filter = ResourceHelper.FileFilter(FileFilterType.XML);
     dlg.Title = m_sAlsoSaveDialogTitle;
     dlg.FileName = Path.GetFileNameWithoutExtension(dlg.FileName);
 }
Exemplo n.º 26
0
 private void DoAlsoSaveAs(ISaveFileDialog dlg)
 {
     string sAlsoSaveFile = Path.ChangeExtension(dlg.FileName, "xml");
     RemoveWriteProtection(sAlsoSaveFile);
     if (m_sReplaceDoctype == "")
     {
         File.Copy(m_sAlsoSaveFileName, sAlsoSaveFile, true);
     }
     else
     {
         string sContents;
         using (var sr = new StreamReader(m_sAlsoSaveFileName, System.Text.Encoding.UTF8))
         {
             sContents = sr.ReadToEnd();
             sr.Close();
         }
         int i = sContents.IndexOf("<!DOCTYPE ");
         if (i > -1)
         {
             var sb = new StringBuilder();
             sb.Append(sContents.Substring(0, i + 10));
             sb.Append(m_sReplaceDoctype);
             i = sContents.IndexOf(">", i);
             sb.Append(sContents.Substring(i));
             using (var sw = new StreamWriter(sAlsoSaveFile, false))
             {
                 sw.Write(sb.ToString());
                 sw.Close();
             }
         }
         else
         { // could not find DOCTYPE; nothing to replace
             File.Copy(m_sAlsoSaveFileName, sAlsoSaveFile, true);
         }
     }
 }
Exemplo n.º 27
0
 public ClassUnderTest(ISaveFileDialog dialog)
 {
     dialog.FileOk += OnFileOk;
 }
 public CodeExplorer_ExportCommand(ISaveFileDialog saveFileDialog)
 {
     _saveFileDialog = saveFileDialog;
     _saveFileDialog.OverwritePrompt = true;
 }
Exemplo n.º 29
0
 public DialogResult ShowSaveFileDialog(ISaveFileDialog saveFileDialog)
 {
     //SaveFileDialogMvvm saveDlg = new SaveFileDialogMvvm(saveFileDialog);
     return(_saveFileDialog.ShowDialog(saveFileDialog));
 }
Exemplo n.º 30
0
 public ExportCommand(ISaveFileDialog saveFileDialog) : base(LogManager.GetCurrentClassLogger())
 {
     _saveFileDialog = saveFileDialog;
     _saveFileDialog.OverwritePrompt = true;
 }
Exemplo n.º 31
0
 public DialogResult ShowSaveFileDialog <T>(ISaveFileDialog saveFileDialog, T UserForm) where T : FileDialogControlBase
 {
     return(_saveFileDialog.ShowDialog <T>(saveFileDialog, UserForm));
 }
Exemplo n.º 32
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public SaveDocumentDialog(ISaveFileDialog saveFileDialog)
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            _saveFileDialog = saveFileDialog;
        }
Exemplo n.º 33
0
 public SaveDocumentDialog(ISaveFileDialog saveFileDialog)
 {
     _saveFileDialog = saveFileDialog;
 }