/// <summary> /// Adds the document as a tab to the NestedDocking view. /// </summary> /// <param name="documentView">The document view.</param> /// <param name="dockingSettings">The docking settings.</param> public void AddDockedWindow(LayoutAnchorable documentView, DockingSettings dockingSettings) { Argument.IsNotNull(() => documentView); Argument.IsNotNull(() => dockingSettings); switch (dockingSettings.DockLocation) { case DockLocation.Right: rightPropertiesPane.Children.Add(documentView); SetDockWidthForPane(rightPropertiesPane, dockingSettings); break; case DockLocation.Left: leftPropertiesPane.Children.Add(documentView); SetDockWidthForPane(leftPropertiesPane, dockingSettings); break; case DockLocation.Bottom: bottomPropertiesPane.Children.Add(documentView); break; case DockLocation.Top: topPropertiesPane.Children.Add(documentView); break; //case DockLocation.Floating: // rightPropertiesPane.Children.Add(documentView); // _floatingWindowsCollection.Add(documentView, dockingSettings); // break; } }
/// <summary> /// Dock a view to the specified <see cref="DockLocation" /> /// </summary> /// <param name="document">The document.</param> /// <param name="dockingSettings">The docking settings.</param> public static void DockView(LayoutAnchorable document, DockingSettings dockingSettings) { Argument.IsNotNull(() => document); Debug.WriteLine("DockView"); switch (dockingSettings.DockLocation) { case DockLocation.Bottom: BottomPropertiesPane.Children.Add(document); break; case DockLocation.Left: LeftLayoutAnchorablePane.Children.Add(document); SetDockWidthForPane(RightLayoutAnchorablePane, dockingSettings); break; case DockLocation.Right: RightLayoutAnchorablePane.Children.Add(document); document.CanFloat = true; SetDockWidthForPane(RightLayoutAnchorablePane, dockingSettings); break; case DockLocation.Top: TopPropertiesPane.Children.Add(document); break; } }
/// <summary> /// Adds the new document to docking manager. /// </summary> /// <param name="dockingSettings">The docking settings.</param> /// <param name="layoutDocument">The layout document.</param> public static void AddNewDocumentToDockingManager(DockingSettings dockingSettings, LayoutAnchorable layoutDocument) { if (dockingSettings == null) { LayoutDocumentPane.Children.Add(layoutDocument); } else { DockView(layoutDocument, dockingSettings); } }
private void SetDockWidthForPane(LayoutAnchorablePane propertiesPane, DockingSettings dockingSettings) { Argument.IsNotNull(() => propertiesPane); Argument.IsNotNull(() => dockingSettings); var paneGroup = propertiesPane.Parent as LayoutAnchorablePaneGroup; if (paneGroup != null && paneGroup.DockWidth.Value < dockingSettings.Width) { paneGroup.DockWidth = new GridLength(dockingSettings.Width); } }
/// <summary> /// Adds the context ensitive views to nested dock view. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="nestedDockingManager">The nested docking manager.</param> public void AddContextSensitiveViewsToNestedDockView(IViewModel viewModel, NestedDockingManager nestedDockingManager) { // viewModel is the viewmodel related to the nestedDockingManager var viewModeltype = viewModel.GetType(); // Open all, context sensitive vies related to the documentView if (_contextualViewModelCollection.ContainsKey(viewModeltype)) { foreach (var type in (_contextualViewModelCollection[viewModeltype]).ContextDependentViewModels) { IViewModel contextDependenViewModel; if (_openContextSensitiveViews.All(v => v.GetType() != type)) { try { var typeFactory = TypeFactory.Default; contextDependenViewModel = (IViewModel)typeFactory.CreateInstanceWithParametersAndAutoCompletion(type, _contextualViewModelCollection[viewModeltype].Title); } catch (Exception ex) { Log.ErrorWithData(ex, "Error creating contextualViewModel."); continue; } if (contextDependenViewModel != null) { DockingSettings dockingSettings = _contextualViewModelCollection[viewModeltype].DockingSettings; _orchestraService.ShowDocumentInNestedDockView(contextDependenViewModel, nestedDockingManager, dockingSettings, null); if (_openContextSensitiveViews.All(v => v.GetType() != contextDependenViewModel.GetType())) { _openContextSensitiveViews.Add(contextDependenViewModel); } Log.Debug("ShowDocumentInNestedDockView: {0}, docklocation: {1}", contextDependenViewModel, dockingSettings.DockLocation); } } else { contextDependenViewModel = _openContextSensitiveViews.FirstOrDefault(v => v.GetType() == type); if (contextDependenViewModel != null) { DockingSettings dockingSettings = _contextualViewModelCollection[viewModeltype].DockingSettings; _orchestraService.ShowDocumentInNestedDockView(contextDependenViewModel, nestedDockingManager, dockingSettings, null); } } } } }
/// <summary> /// Initializes the ribbon. /// <para /> /// Use this method to hook up views to ribbon items. /// </summary> /// <param name="ribbonService">The ribbon service.</param> protected override void InitializeRibbon(IRibbonService ribbonService) { LoadResourceDictionary(); var orchestraService = GetService <IOrchestraService>(); // Module specific var typeFactory = TypeFactory.Default; ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.HomeRibbonTabName, ModuleName, BrowserModuleResources.OpenNewBrowserModuleMenuItem, new Command(() => { var browserViewModel = typeFactory.CreateInstance <BrowserViewModel>(); orchestraService.ShowDocument(browserViewModel); })) { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_browse.png" }); // View specific var backButton = new RibbonButton(Name, Name, BrowserModuleResources.GoBackMenuItem, "GoBack") { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_left.png" }; var forwardButton = new RibbonButton(Name, Name, BrowserModuleResources.GoForwardMenuItem, "GoForward") { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_right.png" }; ribbonService.RegisterContextualRibbonItem <BrowserView>(backButton, ModuleName); ribbonService.RegisterContextualRibbonItem <BrowserView>(forwardButton, ModuleName); ribbonService.RegisterContextualRibbonItem <BrowserView>(new RibbonButton(Name, Name, BrowserModuleResources.BrowseMenuItem, "Browse") { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_browse.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <BrowserView>(new RibbonSplitButton(Name, Name, BrowserModuleResources.CloseMenuItem, "CloseBrowser") { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_close.png", ToolTip = new RibbonToolTip { Title = BrowserModuleResources.CloseRibbonToolTipTitle, Text = BrowserModuleResources.CloseRibbonToolTipText }, Items = new List <IRibbonItem> { new RibbonGallery { Items = new List <IRibbonItem> { backButton, forwardButton }, Orientation = Orientation.Horizontal, ItemWidth = 56, ItemHeight = 64 } } }, ModuleName); ribbonService.RegisterContextualRibbonItem <BrowserView>(new RibbonComboBox(Name, BrowserModuleResources.RecentSitesMenuItem) { ItemsSource = "RecentSites", SelectedItem = "SelectedSite", Layout = new RibbonItemLayout { Width = 150 }, Style = Application.Current.Resources["SelectedSitesComboBoxStyle"] as Style }, ModuleName); // Find the template to show as dynamic content. TODO: Refactor, make more elegant. var template = Application.Current.Resources["TestTemplate"] as DataTemplate; //ribbonService.RegisterContextualRibbonItem<BrowserView>(new RibbonContentControl(Name, "Dynamic content") { ContentTemplate = template, Layout = new RibbonItemLayout {Width = 120}}, ModuleName); ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.ViewRibbonTabName, ModuleName, BrowserModuleResources.BrowserPropertiesViewHeader, new Command(() => { orchestraService.ShowDocumentIfHidden <PropertiesViewModel>(); })) { ItemImage = "/Orchestra.Modules.Browser;component/Resources/Images/action_browse.png" }); var dockingSettings = new DockingSettings(); dockingSettings.DockLocation = DockLocation.Right; dockingSettings.Width = 225; // Demo: register contextual view related to browserview var contextualViewModelManager = GetService <IContextualViewModelManager>(); contextualViewModelManager.RegisterContextualView <BrowserViewModel, PropertiesViewModel>(BrowserModuleResources.BrowserPropertiesViewHeader, dockingSettings); // Demo: show two pages with different tags var orchestraViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <BrowserViewModel>("Orchestra"); orchestraViewModel.Url = "http://www.github.com/Orcomp/Orchestra"; orchestraService.ShowDocument(orchestraViewModel, "orchestra"); var catelViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <BrowserViewModel>("Catel"); catelViewModel.Url = "http://www.catelproject.com"; orchestraService.ShowDocument(catelViewModel, "catel"); }
/// <summary> /// Shows the document in nested dock view. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="dockingManager">The docking manager.</param> /// <param name="dockingSettings">The docking settings.</param> /// <param name="tag">The tag.</param> public void ShowDocumentInNestedDockView(IViewModel viewModel, NestedDockingManager dockingManager, DockingSettings dockingSettings, object tag = null) { var document = CreateDocument(viewModel, tag); dockingManager.AddDockedWindow(document, dockingSettings); }
/// <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); }
/// <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> /// Registers 'contextual' view type, with the type of views that are context sensitive to this view. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <typeparam name="TContextSensitiveViewModel">The type of the context sensitive view model.</typeparam> /// <param name="title">The title.</param> /// <param name="dockingSettings">The docking settings.</param> public void RegisterContextualView <TViewModel, TContextSensitiveViewModel>(string title, DockingSettings dockingSettings) { Type viewModelType = typeof(TViewModel); Type contextSensitiveViewModelType = typeof(TContextSensitiveViewModel); if (!_contextualViewModelCollection.ContainsKey(viewModelType)) { _contextualViewModelCollection.Add(viewModelType, new ContextSensitviveViewModelData(title, dockingSettings)); } if (!_contextualViewModelCollection[viewModelType].ContextDependentViewModels.Contains(contextSensitiveViewModelType)) { _contextualViewModelCollection[viewModelType].ContextDependentViewModels.Add(contextSensitiveViewModelType); } }
/// <summary> /// Initializes the ribbon. /// <para /> /// Use this method to hook up views to ribbon items. /// </summary> /// <param name="ribbonService">The ribbon service.</param> protected override void InitializeRibbon(IRibbonService ribbonService) { var orchestraService = GetService <IOrchestraService>(); var typeFactory = TypeFactory.Default; // Module specific ribbonService.RegisterRibbonItem( new RibbonButton(OrchestraResources.HomeRibbonTabName, ModuleName, "Open", new Command(() => _orchestraService.ShowDocument <DataGridViewModel>())) { ItemImage = "/Orchestra.Modules.DataGrid;component/Resources/Images/Table.png" }); // View specific ribbonService.RegisterContextualRibbonItem <DataGridView>( new RibbonButton(Name, "File", "Open", "OpenFileCommand") { ItemImage = "/Orchestra.Library;component/Resources/Images/FileOpen.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <DataGridView>( new RibbonButton(Name, "File", "Save", "SaveToFileCommand") { ItemImage = "/Orchestra.Library;component/Resources/Images/FileSave.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <DataGridView>( new RibbonButton(Name, "Rows", "Add", "AddRowCommand") { ItemImage = "/Orchestra.Library;component/Resources/Images/ActionAdd.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <DataGridView>( new RibbonButton(Name, "Rows", "Remove", "RemoveRowCommand") { ItemImage = "/Orchestra.Library;component/Resources/Images/ActionRemove.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <DataGridView>( new RibbonButton(Name, "Tools", "Plot", "Plot") { ItemImage = "/Orchestra.Modules.DataGrid;component/Resources/Images/ActionPlot.png" }, ModuleName); var contextualViewModelManager = GetService <IContextualViewModelManager>(); // Demo: Register the view as a Nested dockingmanager contextualViewModelManager.RegisterNestedDockView <DataGridViewModel>(); DockingSettings dockingSettings = new DockingSettings(); dockingSettings.DockLocation = DockLocation.Right; dockingSettings.Top = 100; dockingSettings.Left = 450; dockingSettings.Width = 200; dockingSettings.Height = 200; // Demo: Register context sensitive view, within the Nested dockingmanager contextualViewModelManager.RegisterContextualView <DataGridViewModel, DataGridPropertiesViewModel>("Datagrid properties", dockingSettings); // Add the contextual view in the "View" menu ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.ViewRibbonTabName, ModuleName, "Browser properties", new Command(() => orchestraService.ShowDocumentIfHidden <DataGridPropertiesViewModel>())) { ItemImage = "/Orchestra.Modules.DataGrid;component/Resources/Images/Table.png" }); // Test showing a datagrid view at startup var dataGridViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <DataGridViewModel>("Datagrid"); orchestraService.ShowDocument(dataGridViewModel, "Datagrid"); }
/// <summary> /// Initializes the ribbon. /// <para /> /// Use this method to hook up views to ribbon items. /// </summary> /// <param name="ribbonService">The ribbon service.</param> protected override void InitializeRibbon(IRibbonService ribbonService) { LoadResourceDictionary(); orchestraService = GetService <IOrchestraService>(); // Module specific var typeFactory = TypeFactory.Default; //ribbonService.RegisterRibbonItem(new RibbonButton(HomeRibbonTabName, ModuleName, "Open", new Command(() => NewDocumentCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png" }); ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.HomeRibbonTabName, ModuleName, "Open", new Command(() => { var textEditorViewModel = typeFactory.CreateInstance <TextEditorViewModel>(); orchestraService.ShowDocument(textEditorViewModel); })) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png" }); // View specific #region File Buttons // View specific ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "File", "New", new Command(() => NewDocumentCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_New32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "File", "Open", new Command(() => OpenDocumentCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Open32.png" }, ModuleName); //ribbonService.RegisterContextualRibbonItem<TextEditorView>( // new RibbonButton(Name, "File", "Open", "OpenDocumentCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Open32.png" }, // ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "File", "Save", "SaveCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Save32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "File", "SaveAs", "SaveAsCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_SaveAs32.png" }, ModuleName); //ribbonService.RegisterContextualRibbonItem<TextEditorView>( // new RibbonButton(Name, "File", "CloseMe", new Command(() => CloseDocumentCommand.Execute(null))) // { // ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/action_close.png", // ToolTip = new RibbonToolTip { Title = "Close (Ctrl+X)", Text = "Closes the file." } // }, //ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "File", "CloseMe", "CloseDocument") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/action_close.png", ToolTip = new RibbonToolTip { Title = "Close (Ctrl+X)", Text = "Closes the file." } }, ModuleName); #endregion #region Edit Buttons ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Edit", "Copy", ApplicationCommands.Copy) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Copy32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Edit", "Cut", ApplicationCommands.Cut) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Cut32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Edit", "Paste", ApplicationCommands.Paste) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Paste32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Edit", "Delete", ApplicationCommands.Delete) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Delete32.png" }, ModuleName); #endregion #region Undo / Redo Buttons ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Undo", "Undo", ApplicationCommands.Undo) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Undo32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Undo", "Redo", ApplicationCommands.Redo) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Redo32.png" }, ModuleName); #endregion #region Text Editor Buttons ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Text Editor", "WordWrap", "WordWrapCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png" }, ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Text Editor", "LineNumbers", "ShowLineNumbersCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Numbers32.png" }, ModuleName); #endregion #region ScriptCS Buttons ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Run ScriptCS", "ScriptCS", "ScriptCSCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/cs_32.png" }, ModuleName); #endregion //ribbonService.RegisterContextualRibbonItem<TextEditorView>( // new RibbonButton(Name, "Document", "Map", new Command(() => ShowDocumentMapCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/ShowWordWrap32.png" }, // ModuleName); ribbonService.RegisterContextualRibbonItem <TextEditorView>( new RibbonButton(Name, "Document", "Map", "DocumentMapOpenCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/ShowWordWrap32.png" }, ModuleName); #region TextEditor Module // Language selection combobox //ribbonService.RegisterContextualRibbonItem<TextEditorView>(new RibbonComboBox(Name, "Languages") //{ // ItemsSource = "SyntaxHighlighting", // SelectedItem = "SelectedLanguage", // Layout = new RibbonItemLayout { Width = 100 }, // Style = Application.Current.Resources["SelectedSitesComboBoxStyle"] as Style //}, ModuleName); // Find the template to show as dynamic content. TODO: Refactor, make more elegant. var template = Application.Current.Resources["TestTemplate"] as DataTemplate; ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.ViewRibbonTabName, ModuleName, "TextEditor properties", new Command(() => { orchestraService.ShowDocumentIfHidden <PropertiesViewModel>(); })) { ItemImage = "/rchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png" }); #endregion var dockingSettings = new DockingSettings(); dockingSettings.DockLocation = DockLocation.Right; dockingSettings.Width = 225; // Demo: register contextual view related to browserview var contextualViewModelManager = GetService <IContextualViewModelManager>(); contextualViewModelManager.RegisterContextualView <TextEditorViewModel, PropertiesViewModel>("Document Map", DockLocation.Right); // Open blank document during application start var currenttextEditorViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <TextEditorViewModel>("Orchestra", this); //orchestraViewModel.Url = "http://www.github.com/Orcomp/Orchestra"; orchestraService.ShowDocument(currenttextEditorViewModel, "New Document"); }