private bool CallOnCreateTaskPaneInfo(TaskPaneInfo paneInfo) { try { return(OnCreateTaskPaneInfo(paneInfo)); } catch (Exception exception) { Factory.Console.WriteException(exception); OnError(ErrorMethodKind.CTPFactoryAvailable, exception); return(false); } }
private void ProceedCustomPaneAttributes() { CustomPaneAttribute[] paneAttributes = AttributeHelper.GetCustomPaneAttributes(Type); foreach (CustomPaneAttribute itemPane in paneAttributes) { if (null != itemPane) { TaskPaneInfo item = TaskPanes.Add(itemPane.PaneType, itemPane.PaneType.Name); if (!CallOnCreateTaskPaneInfo(item)) { item.Title = itemPane.Title; item.Visible = itemPane.Visible; item.DockPosition = (Office.Enums.MsoCTPDockPosition)Enum.Parse(typeof(Office.Enums.MsoCTPDockPosition), itemPane.DockPosition.ToString()); item.DockPositionRestrict = (Office.Enums.MsoCTPDockPositionRestrict)Enum.Parse(typeof(Office.Enums.MsoCTPDockPositionRestrict), itemPane.DockPositionRestrict.ToString()); item.Width = itemPane.Width; item.Height = itemPane.Height; item.Arguments = new object[] { this }; } item.VisibleStateChange += new NetOffice.OfficeApi.CustomTaskPane_VisibleStateChangeEventHandler(AttributePane_VisibleStateChange); item.DockPositionStateChange += new Office.CustomTaskPane_DockPositionStateChangeEventHandler(AttributePane_DockPositionStateChange); } } }
/// <summary> /// The method is called while the CustomPane attribute is processed /// </summary> /// <param name="paneInfo">pane definition</param> /// <returns>true if paneInfo is modified, otherwise false to set the default or attribute values</returns> protected internal virtual bool OnCreateTaskPaneInfo(TaskPaneInfo paneInfo) { return(false); }
private bool CallOnCreateTaskPaneInfo(TaskPaneInfo paneInfo) { try { return OnCreateTaskPaneInfo(paneInfo); } catch(Exception exception) { Factory.Console.WriteException(exception); OnError(ErrorMethodKind.CTPFactoryAvailable, exception); return false; } }
/// <summary> /// The method is called while the CustomPane attribute is processed /// </summary> /// <param name="paneInfo">pane definition</param> /// <returns>true if paneInfo is modified, otherwise false to set the default or attribute values</returns> protected internal virtual bool OnCreateTaskPaneInfo(TaskPaneInfo paneInfo) { return false; }
/// <summary> /// ICustomTaskPaneConsumer implementation /// </summary> /// <param name="CTPFactoryInst">factory proxy from host application</param> public virtual void CTPFactoryAvailable(object CTPFactoryInst) { try { if (null == CTPFactoryInst) { Factory.Console.WriteLine("Warning: null argument recieved in CTPFactoryAvailable. argument name: CTPFactoryInst"); return; } CustomPaneAttribute paneAttribute = AttributeHelper.GetCustomPaneAttribute(Type); if (null != paneAttribute) { TaskPaneInfo item = TaskPanes.Add(paneAttribute.PaneType, paneAttribute.PaneType.Name); if (!CallOnCreateTaskPaneInfo(item)) { item.Title = paneAttribute.Title; item.Visible = paneAttribute.Visible; item.DockPosition = (Office.Enums.MsoCTPDockPosition)Enum.Parse(typeof(Office.Enums.MsoCTPDockPosition), paneAttribute.DockPosition.ToString()); item.DockPositionRestrict = (Office.Enums.MsoCTPDockPositionRestrict)Enum.Parse(typeof(Office.Enums.MsoCTPDockPositionRestrict), paneAttribute.DockPositionRestrict.ToString()); item.Width = paneAttribute.Width; item.Height = paneAttribute.Height; item.Arguments = new object[] { this }; } item.VisibleStateChange += new NetOffice.OfficeApi.CustomTaskPane_VisibleStateChangeEventHandler(AttributePane_VisibleStateChange); item.DockPositionStateChange += new Office.CustomTaskPane_DockPositionStateChangeEventHandler(AttributePane_DockPositionStateChange); } TaskPaneFactory = new NetOffice.OfficeApi.ICTPFactory(Factory, null, CTPFactoryInst); foreach (TaskPaneInfo item in TaskPanes) { string title = item.Title; Office.CustomTaskPane taskPane = TaskPaneFactory.CreateCTP(item.Type.FullName, title) as Office.CustomTaskPane; item.Pane = taskPane; item.AssignEvents(); item.IsLoaded = true; switch (taskPane.DockPosition) { case NetOffice.OfficeApi.Enums.MsoCTPDockPosition.msoCTPDockPositionLeft: case NetOffice.OfficeApi.Enums.MsoCTPDockPosition.msoCTPDockPositionRight: taskPane.Width = item.Width; break; case NetOffice.OfficeApi.Enums.MsoCTPDockPosition.msoCTPDockPositionTop: case NetOffice.OfficeApi.Enums.MsoCTPDockPosition.msoCTPDockPositionBottom: taskPane.Height = item.Height; break; case NetOffice.OfficeApi.Enums.MsoCTPDockPosition.msoCTPDockPositionFloating: item.Width = paneAttribute.Width; taskPane.Height = item.Height; break; default: break; } ITaskPane pane = taskPane.ContentControl as ITaskPane; if (null != pane) { TaskPaneInstances.Add(pane); object[] argumentArray = new object[0]; if (item.Arguments != null) { argumentArray = item.Arguments; } pane.OnConnection(Application, taskPane, argumentArray); } foreach (KeyValuePair <string, object> property in item.ChangedProperties) { if (property.Key == "Title") { continue; } try { if (property.Key == "Width") // avoid to set width in top and bottom align { object outValue = null; item.ChangedProperties.TryGetValue("DockPosition", out outValue); if (null != outValue) { Office.Enums.MsoCTPDockPosition position = (Office.Enums.MsoCTPDockPosition)Enum.Parse(typeof(Office.Enums.MsoCTPDockPosition), outValue.ToString()); if (position == Office.Enums.MsoCTPDockPosition.msoCTPDockPositionTop || position == Office.Enums.MsoCTPDockPosition.msoCTPDockPositionBottom) { continue; } } } if (property.Key == "Height") // avoid to set height in left and right align { object outValue = null; item.ChangedProperties.TryGetValue("DockPosition", out outValue); if (null == outValue) { outValue = Office.Enums.MsoCTPDockPosition.msoCTPDockPositionRight; // NetOffice default position if unset } Office.Enums.MsoCTPDockPosition position = (Office.Enums.MsoCTPDockPosition)Enum.Parse(typeof(Office.Enums.MsoCTPDockPosition), outValue.ToString()); if (position == Office.Enums.MsoCTPDockPosition.msoCTPDockPositionLeft || position == Office.Enums.MsoCTPDockPosition.msoCTPDockPositionRight) { continue; } } taskPane.GetType().InvokeMember(property.Key, BindingFlags.SetProperty, null, taskPane, new object[] { property.Value }); } catch { ; } } } } catch (NetRuntimeSystem.Exception exception) { Factory.Console.WriteException(exception); OnError(ErrorMethodKind.CTPFactoryAvailable, exception); } }
/// <summary> /// Initializes a new instance of the TaskPane class with default settings /// </summary> public TaskPane() { // This call is required by the Windows.Forms Form Designer. components = new System.ComponentModel.Container(); // set control styles this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.expandoCollection = new TaskPane.ExpandoCollection(this); // get the system theme settings this.systemSettings = ThemeManager.GetSystemExplorerBarSettings(); this.customSettings = new TaskPaneInfo(); this.customSettings.TaskPane = this; this.customSettings.SetDefaultEmptyValues(); this.BackColor = this.systemSettings.TaskPane.GradientStartColor; this.BackgroundImage = this.BackImage; this.classicTheme = false; this.customTheme = false; // size int width = (this.systemSettings.TaskPane.Padding.Left + this.systemSettings.TaskPane.Padding.Right + this.systemSettings.Header.BackImageWidth); int height = width; this.Size = new Size(width, height); // setup sutoscrolling this.AutoScroll = false; this.AutoScrollMargin = new Size(this.systemSettings.TaskPane.Padding.Right, this.systemSettings.TaskPane.Padding.Bottom); // Listen for changes to the parent this.ParentChanged += new EventHandler(this.OnParentChanged); this.allowExpandoDragging = false; this.dropPoint = Point.Empty; this.dropIndicatorColor = Color.Red; this.beginUpdateCount = 0; this.initialising = false; this.layout = false; }