/// <summary> /// Saves the changes made to this view. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="ViewModeEventArgs"/> that contains the event data.</param> private void GroupEditorViewSave(object sender, ViewModeEventArgs e) { if (e != null && e.SourceView.Equals(ViewMode.Editor)) { this.ViewModel.SaveToDisk(e.TargetPath); } }
/// <summary> /// Copy the current application state to the user's clipboard. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="ViewModeEventArgs"/> that contains the event data.</param> private void TextEditorViewCopyToClipboard(object sender, ViewModeEventArgs e) { if (e != null && e.SourceView.Equals(ViewMode.TextEditor)) { Clipboard.SetData(DataFormats.Text, this.txtHostsFileContent.Text); } }
/// <summary> /// Saves the changes made to this view. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="ViewModeEventArgs"/> that contains the event data.</param> private void TextEditorViewSave(object sender, ViewModeEventArgs e) { if (e != null && e.SourceView.Equals(ViewMode.TextEditor)) { this.SaveChanges(e.TargetPath); } }
/// <summary> /// Discard all changes and reload the current hosts file from disk. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="ViewModeEventArgs"/> that contains the event data.</param> private void GroupEditorViewReloadFromDisk(object sender, ViewModeEventArgs e) { if (e == null || e.SourceView.Equals(ViewMode.Editor) == false || this.ViewModel == null) { return; } this.ViewModel.ReloadFromDisk(); }
/// <summary> /// Copy the current application state to the user's clipboard. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="ViewModeEventArgs"/> that contains the event data.</param> private void GroupEditorViewCopyToClipboard(object sender, ViewModeEventArgs e) { if (e == null || e.SourceView.Equals(ViewMode.Editor) == false) { return; } string text = this.ViewModel.GetText(); Clipboard.SetData(DataFormats.Text, text); }
/// <summary>Discard all changes and reload the the current hosts file.</summary> /// <param name="currentView">The current view.</param> public void ReloadFromDisk(ViewMode currentView) { if (this.Reload == null) { return; } ViewModeEventArgs e = new ViewModeEventArgs(currentView, null); this.Reload(this, e); }
/// <summary> /// Copy the current application state to the user's clipboard. /// </summary> /// <param name="currentView">The current <see cref="ViewMode"/>.</param> public void CopyToClipboard(ViewMode currentView) { if (this.Copy == null) { return; } ViewModeEventArgs e = new ViewModeEventArgs(currentView, null); this.Copy(this, e); }
/// <summary>Save the changes to the view-model back to the disk.</summary> /// <param name="currentView">The current <see cref="ViewMode"/>.</param> /// <param name="targetPath">The target Path.</param> public void SaveChanges(ViewMode currentView, string targetPath) { if (this.Save == null) { return; } ViewModeEventArgs e = new ViewModeEventArgs(currentView, targetPath); this.Save(this, e); }