public ISwModelViewTab <TControl> CreateDocumentTab <TControl>(ISwDocument doc) { var mdlViewMgr = doc.Model.ModelViewManager; return(CustomControlHelper.HostControl <TControl, SwModelViewTab <TControl> >( (c, h, t, _) => { if (mdlViewMgr.DisplayWindowFromHandlex64(t, h.Handle.ToInt64(), true)) { return new SwModelViewTab <TControl>(c, t, mdlViewMgr, (SwDocument)doc, Logger); } else { throw new NetControlHostException(h.Handle); } }, (p, t, _) => { var ctrl = (TControl)mdlViewMgr.AddControl3(t, p, "", true); if (ctrl == null) { throw new ComControlHostException(p); } return new SwModelViewTab <TControl>(ctrl, t, mdlViewMgr, (SwDocument)doc, Logger); })); }
public ISwFeatureMgrTab <TControl> CreateFeatureManagerTab <TControl>(ISwDocument doc) { var mdlViewMgr = doc.Model.ModelViewManager; using (var iconsConv = m_SvcProvider.GetService <IIconsCreator>()) { return(CustomControlHelper.HostControl <TControl, SwFeatureMgrTab <TControl> >( (c, h, t, i) => { var imgPath = iconsConv.ConvertIcon(new FeatMgrViewIcon(i)).First(); var featMgr = mdlViewMgr.CreateFeatureMgrWindowFromHandlex64( imgPath, h.Handle.ToInt64(), t, (int)swFeatMgrPane_e.swFeatMgrPaneBottom) as IFeatMgrView; if (featMgr != null) { return new SwFeatureMgrTab <TControl>(c, featMgr, (SwDocument)doc, Logger); } else { throw new NetControlHostException(h.Handle); } }, (p, t, i) => { var imgPath = iconsConv.ConvertIcon(new FeatMgrViewIcon(i)).First(); var featMgr = mdlViewMgr.CreateFeatureMgrControl3(imgPath, p, "", t, (int)swFeatMgrPane_e.swFeatMgrPaneBottom) as IFeatMgrView; TControl ctrl = default; if (featMgr != null) { ctrl = (TControl)featMgr.GetControl(); } if (ctrl == null) { throw new ComControlHostException(p); } return new SwFeatureMgrTab <TControl>(ctrl, featMgr, (SwDocument)doc, Logger); })); } }
protected override PropertyManagerPageCustomControl CreateControl( IPropertyManagerPageWindowFromHandle swCtrl, IAttributeSet atts, SwPropertyManagerPageHandler handler, short height) { if (height <= 0) { height = 50; } swCtrl.Height = height; var ctrlType = atts.Get <CustomControlAttribute>().ControlType; var ctrlFact = new Func <IXCustomControl>(() => CustomControlHelper.HostControl(ctrlType, (c, h, t, _) => { if (swCtrl.SetWindowHandlex64(h.Handle.ToInt64())) { if (c is IXCustomControl) { return((IXCustomControl)c); } else { if (c is System.Windows.FrameworkElement) { return(new WpfCustomControl((System.Windows.FrameworkElement)c, h)); } throw new NotSupportedException($"'{c.GetType()}' must implement '{typeof(IXCustomControl).FullName}' or inherit '{typeof(System.Windows.FrameworkElement).FullName}'"); } } else { throw new NetControlHostException(h.Handle); } }, (p, t, _) => { throw new NotImplementedException("ActiveX controls are not implemented yet"); })); return(new PropertyManagerPageCustomControl(atts.Id, atts.Tag, swCtrl, handler, ctrlFact)); }
public ISwTaskPane <TControl> CreateTaskPane <TControl>(TaskPaneSpec spec) { if (spec == null) { spec = new TaskPaneSpec(); } ITaskpaneView CreateTaskPaneView(IIconsCreator iconConv, IXImage icon, string title) { if (icon == null) { if (spec.Icon != null) { icon = spec.Icon; } } if (string.IsNullOrEmpty(title)) { if (spec != null) { title = spec.Title; } } if (Application.Sw.SupportsHighResIcons(CompatibilityUtils.HighResIconsScope_e.TaskPane)) { string[] taskPaneIconImages = null; if (icon != null) { taskPaneIconImages = iconConv.ConvertIcon(new TaskPaneHighResIcon(icon)); } return(Application.Sw.CreateTaskpaneView3(taskPaneIconImages, title)); } else { var taskPaneIconImage = ""; if (icon != null) { taskPaneIconImage = iconConv.ConvertIcon(new TaskPaneIcon(icon)).First(); } return(Application.Sw.CreateTaskpaneView2(taskPaneIconImage, title)); } } using (var iconConv = m_SvcProvider.GetService <IIconsCreator>()) { var taskPane = CustomControlHelper.HostControl <TControl, SwTaskPane <TControl> >( (c, h, t, i) => { var v = CreateTaskPaneView(iconConv, i, t); if (!v.DisplayWindowFromHandle(h.Handle.ToInt32())) { throw new NetControlHostException(h.Handle); } return(new SwTaskPane <TControl>(Application.Sw, v, c, spec, m_SvcProvider)); }, (p, t, i) => { var v = CreateTaskPaneView(iconConv, i, t); var ctrl = (TControl)v.AddControl(p, ""); if (ctrl == null) { throw new ComControlHostException(p); } return(new SwTaskPane <TControl>(Application.Sw, v, ctrl, spec, m_SvcProvider)); }); m_Disposables.Add(taskPane); return(taskPane); } }