/// <summary> /// Shows the document in the main shell. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="viewModel">The view model to show which will automatically be resolved to a view.</param> /// <param name="tag">The tag.</param> /// <param name="dockingSettings">The docking settings.</param> /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception> public void ShowContextSensitiveDocument <TViewModel>(TViewModel viewModel, object tag = null, DockingSettings dockingSettings = null) where TViewModel : IViewModel { Argument.IsNotNull("viewModel", viewModel); Log.Debug("Showing document for view model '{0}'", viewModel.UniqueIdentifier); var viewType = GetViewType(viewModel); var document = AvalonDockHelper.FindDocument(viewType, tag); if (document == null) { var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel); document = AvalonDockHelper.CreateDocument(view, tag); if (dockingSettings != null) { AvalonDockHelper.AddNewDocumentToDockingManager(dockingSettings, document); } } AvalonDockHelper.ActivateDocument(document); Log.Debug("Showed document for view model '{0}'", viewModel.UniqueIdentifier); }
private LayoutAnchorable CreateDocument <TViewModel>(TViewModel viewModel, object tag) where TViewModel : IViewModel { var viewLocator = GetService <IViewLocator>(); var viewType = viewLocator.ResolveView(viewModel.GetType()); var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel); var document = AvalonDockHelper.CreateDocument(view, tag); return(document); }
public MainViewModel(ICommandManager commandManager, GlobalFrontendService globalFrontendService) { _layoutDocumentPane = ServiceLocator.Default.ResolveType <LayoutDocumentPane>(); _layoutDocumentPane.PropertyChanged += LayoutDocumentPaneOnPropertyChanged; _commandManager = commandManager; _globalFrontendService = globalFrontendService; AvalonDockHelper.CreateDocument <VstPluginsViewModel>(activateDocument: true); AvalonDockHelper.CreateDocument <PresetExportListViewModel>(); }
/// <summary> /// Opens a new document. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="viewModel">The view model.</param> /// <param name="tag">The tag.</param> /// <param name="dockingSettings">The docking settings.</param> public void ShowDocument <TViewModel>(TViewModel viewModel, object tag = null, DockingSettings dockingSettings = null) where TViewModel : IViewModel { Argument.IsNotNull("viewModel", viewModel); Log.Debug("Opening document for view model '{0}'", viewModel.UniqueIdentifier); var document = CreateDocument(viewModel, tag); AvalonDockHelper.AddNewDocumentToDockingManager(dockingSettings, document); AvalonDockHelper.ActivateDocument(document); }
/// <summary> /// Shows the helper window. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="tag">The tag.</param> public void ShowDocumentIfHidden <TViewModel>(object tag = null) where TViewModel : IViewModel { var viewLocator = GetService <IViewLocator>(); var viewType = viewLocator.ResolveView(typeof(TViewModel)); var document = AvalonDockHelper.FindDocument(viewType, tag); if (document != null) { document.Show(); Log.Debug("Show hidden document '{0}'", document.Title); } Log.Debug("Can not show hidden view because it can not be found for viewmodel type {0}", typeof(TViewModel)); }
/// <summary> /// Closes the document in the main shell with the specified view model. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="tag">The tag.</param> public void CloseDocument(IViewModel viewModel, object tag = null) { Argument.IsNotNull(() => viewModel); Log.Debug("Closing document for view model '{0}'", viewModel.UniqueIdentifier); var viewType = GetViewType(viewModel); var document = AvalonDockHelper.FindDocument(viewType, tag); if (document == null) { Log.Warning("Cannot find document belonging to view model '{0}' with id '{1}' thus cannot close the document", ObjectToStringHelper.ToTypeString(viewModel), viewModel.UniqueIdentifier); } else { AvalonDockHelper.CloseDocument(document); } Log.Debug("Closed document for view model '{0}'", viewModel.UniqueIdentifier); }
/// <summary> /// Shows the document in the main shell. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="viewModel">The view model to show which will automatically be resolved to a view.</param> /// <param name="tag">The tag.</param> /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception> public void ShowDocument <TViewModel>(TViewModel viewModel, object tag = null) where TViewModel : IViewModel { Argument.IsNotNull("viewModel", viewModel); Log.Debug("Showing document for view model '{0}'", viewModel.UniqueIdentifier); var viewLocator = GetService <IViewLocator>(); var viewType = viewLocator.ResolveView(viewModel.GetType()); var document = AvalonDockHelper.FindDocument(viewType, tag); if (document == null) { var view = ViewHelper.ConstructViewWithViewModel(viewType, viewModel); document = AvalonDockHelper.CreateDocument(view, tag); } AvalonDockHelper.ActivateDocument(document); Log.Debug("Showed document for view model '{0}'", viewModel.UniqueIdentifier); }
protected override void Execute(object parameter) { AvalonDockHelper.ActivateDocument <PresetExportListViewModel>(); base.Execute(parameter); }