/// <summary> /// Analyze COMAddin custom taskpane attributes /// </summary> /// <param name="taskPanes">taskpanes you want to create</param> /// <param name="addinType">addin class type informations</param> /// <param name="addin">addin instance</param> /// <param name="callOnCreateTaskPaneInfo">callback to manipulate the process dynamicly</param> /// <param name="visibleStateChange">visible changed event handler</param> /// <param name="dockPositionStateChange">dock state changed event handler</param> public void ProceedCustomPaneAttributes(OfficeApi.Tools.CustomTaskPaneCollection taskPanes, Type addinType, COMAddinBase addin, CallOnCreateTaskPaneInfoHandler callOnCreateTaskPaneInfo, CustomTaskPane_VisibleStateChangeEventHandler visibleStateChange, CustomTaskPane_DockPositionStateChangeEventHandler dockPositionStateChange) { CustomPaneAttribute[] paneAttributes = AttributeReflector.GetCustomPaneAttributes(addinType); foreach (CustomPaneAttribute itemPane in paneAttributes) { if (null != itemPane) { TaskPaneInfo item = taskPanes.Add(itemPane.PaneType, itemPane.PaneType.Name); item.Title = itemPane.Title; item.Visible = itemPane.Visible; item.DockPosition = (OfficeApi.Enums.MsoCTPDockPosition)Enum.Parse(typeof(OfficeApi.Enums.MsoCTPDockPosition), itemPane.DockPosition.ToString()); item.DockPositionRestrict = (OfficeApi.Enums.MsoCTPDockPositionRestrict)Enum.Parse(typeof(OfficeApi.Enums.MsoCTPDockPositionRestrict), itemPane.DockPositionRestrict.ToString()); item.Width = itemPane.Width; item.Height = itemPane.Height; item.Arguments = new object[] { addin, this }; if (callOnCreateTaskPaneInfo(item)) { item.VisibleStateChange += visibleStateChange; item.DockPositionStateChange += dockPositionStateChange; } else { taskPanes.Remove(item); } } } }
private void ProceedCustomPaneAttributes() { CustomPaneAttribute[] paneAttributes = AttributeReflector.GetCustomPaneAttributes(Type); foreach (CustomPaneAttribute itemPane in paneAttributes) { if (null != itemPane) { TaskPaneInfo item = TaskPanes.Add(itemPane.PaneType, itemPane.PaneType.Name); 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 }; if (CallOnCreateTaskPaneInfo(item)) { item.VisibleStateChange += new NetOffice.OfficeApi.CustomTaskPane_VisibleStateChangeEventHandler(AttributePane_VisibleStateChange); item.DockPositionStateChange += new Office.CustomTaskPane_DockPositionStateChangeEventHandler(AttributePane_DockPositionStateChange); } else { TaskPanes.Remove(item); } } } }