/// <summary> /// Advices the perspective to make the given <paramref name="dataView"/> visible at the <paramref name="viewPosition"/>. /// </summary> /// <param name="dataView">Data view to show</param> /// <param name="viewPosition">Target view position</param> public virtual void ShowView(IDataView dataView, EViewPosition viewPosition) { if (dataView == null) { return; } try { // Notify data view to init dataView.Init(); // Set up new view IWidgetFactory widgetFactory = FactoryProvider.Instance.GetWidgetFactory(); dataView.WidgetFactory = widgetFactory; // Make view visible OnShowDataView(dataView, viewPosition); // Update internal state and dispatch events ActiveDataViews.Add(dataView); PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartOpened(dataView), OnDispatchWorkbenchEventException); } catch (Exception ex) { _log.Error($"Error on showing data view '{dataView}' by perspective '{this}'.", ex); } }
/// <inheritdoc /> protected override void OnShowDataView(IDataView dataView, EViewPosition viewPosition) { // Visual root element DockContent dataViewDockContent = new DockContent(); // Let the view create its content GridPanel gridPanel = new GridPanel { Dock = DockStyle.Fill }; dataView.CreateContents(gridPanel); // Place into a dock content dataViewDockContent.Controls.Add(gridPanel); // Provide a tool bar ToolBar dataViewToolBar = new ToolBar(); dataView.ConfigureToolBar(dataViewToolBar); // Only add the tool bar if any item has been added if (dataViewToolBar.Items.Count != 0) { // Add ToolStripContainer to the top of the perspective ToolStripContainer toolStripContainer = new ToolStripContainer { Dock = DockStyle.Top }; toolStripContainer.TopToolStripPanel.Controls.Add(dataViewToolBar); // Add the tool bar to the controls dataViewDockContent.Controls.Add(dataViewToolBar); } // Set up properties dataViewDockContent.TabText = dataView.Name; ImageDescriptor imageDescriptor = dataView.Image; if (imageDescriptor != null) { using (Bitmap tmpBitmap = new Bitmap(imageDescriptor.ImageStream)) { IntPtr intPtr = tmpBitmap.GetHicon(); using (Icon tmpIcon = Icon.FromHandle(intPtr)) { dataViewDockContent.Icon = tmpIcon; dataViewDockContent.ShowIcon = true; } } } // Make it visible DockState dockState = ConvertToDockState(viewPosition); dataViewDockContent.Show(iDockPanel, dockState); }
/// <inheritdoc /> protected override DockState ConvertToDockState(EViewPosition viewPosition) { if (viewPosition == EViewPosition.Left) { return(DockState.DockLeft); } if (viewPosition == EViewPosition.Top) { return(DockState.DockTop); } if (viewPosition == EViewPosition.Right) { return(DockState.DockRight); } if (viewPosition == EViewPosition.Bottom) { return(DockState.DockBottom); } if (viewPosition == EViewPosition.LeftCollapsed) { return(DockState.DockLeftAutoHide); } if (viewPosition == EViewPosition.RightCollapsed) { return(DockState.DockRightAutoHide); } if (viewPosition == EViewPosition.BottomCollapsed) { return(DockState.DockBottomAutoHide); } if (viewPosition == EViewPosition.TopCollapsed) { return(DockState.DockTopAutoHide); } return(DockState.DockLeftAutoHide); }
/// <summary> /// Converts the given <paramref name="viewPosition"/> into the corresponding <see cref="DockState"/>. /// If there is no corresponding element, <see cref="DockState.DockLeftAutoHide"/> is returned. /// </summary> /// <param name="viewPosition">View position to convert</param> /// <returns>Corresponding <see cref="DockState"/></returns> protected virtual DockState ConvertToDockState(EViewPosition viewPosition) { return(DockState.Document); }
/// <summary> /// Tells the instance to make the given <paramref name="dataView"/> visible to the user at the given /// <paramref name="viewPosition"/>. /// </summary> /// <param name="dataView">Data view to show</param> /// <param name="viewPosition">Target view position</param> protected abstract void OnShowDataView(IDataView dataView, EViewPosition viewPosition);
/// <inheritdoc /> public virtual void OpenView <TDataView>(EViewPosition viewPosition) where TDataView : class, IDataView { TDataView dataView = DataViewRegistry.Instance.GetDataView <TDataView>(); ShowView(dataView, viewPosition); }
/// <inheritdoc /> public virtual void OpenView(string dataViewId, EViewPosition viewPosition) { IDataView dataView = DataViewRegistry.Instance.GetDataView(dataViewId); ShowView(dataView, viewPosition); }