/// <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> /// 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); }