/// <inheritdoc /> public IDialog CreateDialog(string title, IEditorViewModel editor, DialogOptions options) { var dialog = CreateDialog(title, (UIElement)editor.GetView(), options, new CloseActionCommand(_localization.GetValue("Cancel")), new AsyncActionCommand(_localization.GetValue("Save"), async() => { try { await editor.Save(); return(true); } catch (ValidationException) { return(false); } }) { Tag = ActionCommandTags.SaveCommand }); return(dialog); }
/// <summary> /// Create a new dialog instance and then calls the show method of the instance. /// </summary> /// <param name="dialogs">The dialog service</param> /// <param name="title">The title of the dialog.</param> /// <param name="editor">The content of the dialog.</param> /// <param name="options">Dialog options.</param> public static IDialog ShowDialog(this IDialogService dialogs, string title, IEditorViewModel editor, DialogOptions options) { var dialog = dialogs.CreateDialog(title, editor, options); dialog.Show(); return(dialog); }
/// <summary> /// Create a new dialog instance and then calls the show method of the instance. /// </summary> /// <param name="dialogs">The dialog service</param> /// <param name="editor">The content of the dialog.</param> public static IDialog ShowDialog(this IDialogService dialogs, IEditorViewModel editor) { var dialog = dialogs.CreateDialog(editor); dialog.Show(); return(dialog); }
public MainViewModel(IIoC ioc, ISelectRootDirectoryViewModel selectRootDirectoryViewModel, IListNotebooksViewModel listNotebooksViewModel, IListSectionsViewModel listSectionsViewModel, IListPagesViewModel listPagesViewModel, IEditorViewModel editorViewModel, IAddNotebookViewModel addNotebookViewModel, IAddSectionViewModel addSectionViewModel, IAddPageViewModel addPageViewModel, IRootDirectoryFacade rootDirectory, IImageCarouselViewModel imageCarousel ) : base(ioc) { if (selectRootDirectoryViewModel == null) throw new ArgumentNullException(nameof(selectRootDirectoryViewModel)); if (listNotebooksViewModel == null) throw new ArgumentNullException(nameof(listNotebooksViewModel)); if (listSectionsViewModel == null) throw new ArgumentNullException(nameof(listSectionsViewModel)); if (listPagesViewModel == null) throw new ArgumentNullException(nameof(listPagesViewModel)); if (editorViewModel == null) throw new ArgumentNullException(nameof(editorViewModel)); if (addNotebookViewModel == null) throw new ArgumentNullException(nameof(addNotebookViewModel)); if (addSectionViewModel == null) throw new ArgumentNullException(nameof(addSectionViewModel)); if (addPageViewModel == null) throw new ArgumentNullException(nameof(addPageViewModel)); if (rootDirectory == null) throw new ArgumentNullException(nameof(rootDirectory)); if (imageCarousel == null) throw new ArgumentNullException(nameof(imageCarousel)); _rootDirectory = rootDirectory; SelectRootDirectory = selectRootDirectoryViewModel; ListNotebooks = listNotebooksViewModel; ListSections = listSectionsViewModel; ListPages = listPagesViewModel; Editor = editorViewModel; AddNotebook = addNotebookViewModel; AddSection = addSectionViewModel; AddPage = addPageViewModel; ImageCarousel = imageCarousel; MessageBus.Subscribe<RootDirectoryChanged>(OnNewRootDirectory); MessageBus.Subscribe<NotebookSelected>(OnNotebookSelected); MessageBus.Subscribe<SectionSelected>(OnSectionSelected); }
public EditorView(IEditorViewModel viewModel) { GridControl.AllowInfiniteGridSize = true; InitializeComponent(); viewModel.SetParentView(this); DataContext = viewModel; }
public Window CreateToolAsWindow(IEditorViewModel viewModel) { var toolView = _viewModelToViewMap[viewModel.GetType()]; var instance = (Control)Activator.CreateInstance(toolView); Window newWindow = new Window(); newWindow.Content = instance; newWindow.DataContext = viewModel; return(newWindow); }
private void CreateTextViewHost(string text, string filePath) { ITextDataModel textDataModel; text = text ?? string.Empty; var diskBuffer = _textBufferFactoryService.CreateTextBuffer(text, ContentType); var cs = _services.GetService <ICompositionService>(); _editorViewModel = EditorViewModelFactory.CreateEditorViewModel(diskBuffer, _services); if (_editorViewModel != null) { textDataModel = new TextDataModel(diskBuffer, _editorViewModel.ViewBuffer.As <ITextBuffer>()); } else { textDataModel = new TextDataModel(diskBuffer, diskBuffer); } var textBuffer = textDataModel.DocumentBuffer; TextDocument = _textDocumentFactoryService.CreateTextDocument(textBuffer, filePath); SetGlobalEditorOptions(); var textView = _textEditorFactoryService.CreateTextView(textDataModel, new DefaultTextViewRoleSet(), GlobalOptions); _wpftextViewHost = _textEditorFactoryService.CreateTextViewHost(textView, true); ApplyDefaultSettings(); Control.Content = _wpftextViewHost.HostControl; var baseController = new BaseController(); BaseController = baseController; if (_editorViewModel != null) { CommandTarget = _editorViewModel.GetCommandTarget(textView.ToEditorView()); var controller = CommandTarget as Common.Core.UI.Commands.Controller; Debug.Assert(controller != null); controller.ChainedController = baseController; } else { CommandTarget = baseController; } baseController.Initialize(textView, EditorOperations, UndoManager, _services); }
public void Close() { if (_wpftextViewHost != null) { _wpftextViewHost.Close(); _wpftextViewHost = null; } if (_editorViewModel != null) { _editorViewModel.Dispose(); _editorViewModel = null; } }
public async Task <T> RunAsync(IEditorViewModel <T> p) { if (p == null) { throw new ArgumentNullException(nameof(p), "must not be null"); } await _Navigator.TryShowModalAsync(p); var result = await p.GetResultAsync(); await _Navigator.TryPopModalAsync(); return(result); }
public Window CreateToolAsWindow <ViewModel>(out IEditorViewModel viewModelInstance) where ViewModel : IEditorViewModel { var viewType = _viewModelToViewMap[typeof(ViewModel)]; var viewModelType = typeof(ViewModel); var view = _serviceProvider.GetService(viewType); viewModelInstance = _serviceProvider.GetService(viewModelType) as IEditorViewModel; Window newWindow = new Window(); newWindow.Content = view; newWindow.DataContext = viewModelInstance; return(newWindow); }
public NpcTypeEditTab(NpcTypeEditViewModel viewModel) { DataContext = _viewModel = viewModel; InitializeComponent(); DataGrid.AutoGeneratingColumn += new EventHandler<DataGridAutoGeneratingColumnEventArgs>(DataGrid_AutoGeneratingColumn); var categories = viewModel.NpcTemplates.Templates.GroupBy(x => x.Category); foreach (var cat in categories) { var itemCategory = new TreeViewItem(); itemCategory.Header = cat.Key; foreach (var i in cat) { var item = new TreeViewItem(); item.Header = i.Name; itemCategory.Items.Add(item); } TreeView.Items.Add(itemCategory); } TreeView.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(TreeView_SelectedItemChanged); viewModel.PropertyChanged += new PropertyChangedEventHandler(viewModel_PropertyChanged); viewModel.TemplateAppliedToNpc += new TemplateApplied(viewModel_TemplateAppliedToNpc); DataGrid.SelectedCellsChanged += new SelectedCellsChangedEventHandler(DataGrid_SelectedCellsChanged); View3D.PanGesture = new MouseGesture() { MouseAction = MouseAction.MiddleClick }; View3D.CameraInertiaFactor = 0.2; View3D.Camera = new PerspectiveCamera() { Position = new Point3D(0, 0, 0), FieldOfView = 45, UpDirection = new Vector3D(0, 0, 1), LookDirection = new Vector3D(0, 0, 0) }; this.Loaded += new RoutedEventHandler(NpcTypeEditTab_Loaded); }
public Editor(IEditorViewModel owner) { editorViewModel_ = owner; State.Value = new EmptyState(this); var project = Project.Where(x => x != null); var dependencyChanged = project.SelectMany(x => Observable.Merge(x.DependenciesPathes.ToArray())); OnSettingChanged = project.SelectMany(x => x.SavePath) .Merge(project.SelectMany(x => x.AssemblyPath)) .Merge(project.SelectMany(x => x.ProjectTypeName)) .Merge(dependencyChanged) .Select(x => Unit.Default); Title = State.Select(x => "PropertyWriter" + VersionInfo.GetAppVersionString() + x.Title) .ToReactiveProperty(); CanSave = State.Select(x => x.CanSave).ToReactiveProperty(); CanClose = State.SelectMany(x => x.CanClose).ToReactiveProperty(); }
/// <inheritdoc /> public IDialog CreateDialog(IEditorViewModel editor) { return(CreateDialog(editor.FullTitle, editor)); }
public NpcTypeRibbonTab(NpcTypeEditViewModel vm) { InitializeComponent(); DataContext = _viewModel = vm; }
public EditorView(IEditorViewModel editorViewModel) : this() { this.DataContext = editorViewModel; }
/// <inheritdoc /> public IDialog CreateDialog(IEditorViewModel editor, DialogOptions options) { return(CreateDialog(editor.FullTitle, editor, options)); }
/// <inheritdoc /> public IDialog CreateDialog(string title, IEditorViewModel editor) { return(CreateDialog(title, editor, DialogOptions.Default)); }