/// <inheritdoc /> public IPerspective OpenPerspective(string perspectiveId) { if (string.IsNullOrEmpty(perspectiveId)) { return(null); } IPerspective newPerspective = PerspectiveFactory.Instance.GetPerspective(perspectiveId); IWidgetCompound widgetCompound = newPerspective.GetPanel(); MainWindow.SetContent(widgetCompound); IPerspective oldPerspective = ActivePerspective; if (oldPerspective != null) { // Currently nothing to do } ActivePerspective = newPerspective; _workbenchEventManager.Dispatch(lstnr => lstnr.OnPerspectiveChanged(oldPerspective, newPerspective), OnPerspectiveChangedException); if (newPerspective != null) { // Currently nothing to do } return(newPerspective); }
/// <inheritdoc /> void IShell.SetContent(IWidgetCompound widgetCompound) { using (this.DeferLayout()) { // Remove the old content if (WindowContent != null) { Control oldContentControl = CastUtil.Cast <Control>(WindowContent); Controls.Remove(oldContentControl); } // Store current window content WindowContent = widgetCompound; if (widgetCompound == null) { return; } Control newContentControl = CastUtil.Cast <Control>(widgetCompound); newContentControl.Dock = DockStyle.Fill; // Add the new content Controls.Add(newContentControl); // Due to a bug of WeifenLou DockPanel the content panel should be at first position Controls.SetChildIndex(newContentControl, 0); } }
/// <summary> /// Convenience method to create a type-safe widget of the given type. /// </summary> /// <typeparam name="TWidget">Type of the widget</typeparam> /// <returns>Instance or null</returns> public static TWidget NewWidget <TWidget>(IWidgetCompound composite) where TWidget : class, IWidget { if (composite == null) { throw new ArgumentNullException(nameof(composite)); } return(FactoryProvider.Instance.GetWidgetFactory().CreateInstance <TWidget>(composite)); }
/// <summary> /// Return a new instance of the given type. /// </summary> /// <typeparam name="TWidget">Type of the widget to create</typeparam> /// <param name="widgetCompound">Parent element that contains this widget</param> /// <returns>Newly created instance of the given widget type</returns> public TWidget CreateInstance <TWidget>(IWidgetCompound widgetCompound) where TWidget : class, IWidget { Type type = typeof(TWidget); if (type.IsAssignableFrom(typeof(IGridPanel))) { return(new GridPanel() as TWidget); } if (type.IsAssignableFrom(typeof(ITreeViewer))) { return(new TreeViewer() as TWidget); } if (type.IsAssignableFrom(typeof(IListViewer))) { return(new ListViewer() as TWidget); } if (type.IsAssignableFrom(typeof(ITextBox))) { return(new TextBox() as TWidget); } if (type.IsAssignableFrom(typeof(IRichTextBox))) { return(new RichTextBox() as TWidget); } if (type.IsAssignableFrom(typeof(IContentAssistTextBox))) { return(new ContentAssistTextBox() as TWidget); } if (type.IsAssignableFrom(typeof(IComboBox))) { return(new ComboBox() as TWidget); } if (type.IsAssignableFrom(typeof(ICheckBox))) { return(new CheckBox() as TWidget); } if (type.IsAssignableFrom(typeof(ITextBlock))) { return(new TextBlock() as TWidget); } return(null); }
/// <inheritdoc /> void IShell.SetContent(IWidgetCompound widgetCompound) { using (this.DeferLayout()) { // Remove old content iContentControl.Controls.Clear(); // Save new content WindowContent = widgetCompound; if (widgetCompound == null) { return; } // Add new content Control dialogContent = CastUtil.Cast <Control>(widgetCompound); dialogContent.Dock = DockStyle.Fill; // XXX iContentControl.Controls.Add(dialogContent); } }