/// <summary> /// Creates a new SolidWorks property manager page, adds controls, and shows the page. /// </summary> public virtual void Show() { var options = _OptionsE.Aggregate(0, (acc, v) => (int)v | acc); var errors = 0; _PropertyManagerPage2Handler9Wrapper = new PropertyManagerPage2Handler9Wrapper(this); var propertyManagerPage = SwApp.CreatePropertyManagerPage(_Name, options, _PropertyManagerPage2Handler9Wrapper, ref errors); if (errors != (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay) { throw new Exception("Unable to Create PMP"); } Page = (IPropertyManagerPage2)propertyManagerPage; var selectionMgr = (ISelectionMgr)ModelDoc.SelectionManager; _Deselect = selectionMgr.DeselectAllUndoable(); AddControls(); Page.Show(); // Force validation of the page ValidationSubject.OnNext(Unit.Default); var d = this.WhenAnyValue(p => p.IsValid) .Subscribe(isValid => Page.EnableButton((int)swPropertyManagerPageButtons_e.swPropertyManagerPageButton_Ok, isValid)); DisposeOnClose(d); AddSelections(); _ShowSubject.OnNext(Unit.Default); }
/// <summary> /// Creates a new SolidWorks property manager page, adds controls, and shows the page. /// </summary> public virtual void Show() { using (Disposable.Create(() => _ShowSubject.OnNext(Unit.Default))) { if (Page != null) { Page.Show(); return; } var options = _OptionsE.Aggregate(0, (acc, v) => (int)v | acc); var errors = 0; _PropertyManagerPage2Handler9Wrapper = new PropertyManagerPage2Handler9Wrapper(this); var propertyManagerPage = SwApp.CreatePropertyManagerPage(_Name, options, _PropertyManagerPage2Handler9Wrapper, ref errors); Page = (IPropertyManagerPage2)propertyManagerPage; if (errors != (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay) { throw new Exception("Unable to Create PMP"); } var selectionMgr = (ISelectionMgr)ModelDoc.SelectionManager; _Deselect = selectionMgr.DeselectAllUndoable(); AddControls(); Page.Show(); AddSelections(); } }
protected void CreatePropertyManagerPage() { int errors = -1; int options = (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton | (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton; handler = new PMPHandler(userAddin); swPropertyPage = (IPropertyManagerPage2)iSwApp.CreatePropertyManagerPage("Estrusion PMP", options, handler, ref errors); if (swPropertyPage != null && errors == (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay) { try { AddControls(); } catch (Exception e) { iSwApp.SendMsgToUser2(e.Message, 0, 0); } } }
protected void CreatePropertyManagerPage() { int errors = -1; const int Options = (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton | (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton; this.handler = new PropManPageHandler(this.userAddin); this.swPropertyPage = (IPropertyManagerPage2)iSwApp.CreatePropertyManagerPage("Save PDF", Options, this.handler, ref errors); if (this.swPropertyPage != null && errors == (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay) { try { this.AddControls(); } catch (Exception e) { this.iSwApp.SendMsgToUser2(e.Message, 0, 0); } } }
protected override PropertyManagerPagePage Create(IAttributeSet atts) { int err = -1; swPropertyManagerPageOptions_e opts; TitleIcon titleIcon = null; IconAttribute commIconAtt; if (atts.ContextType.TryGetAttribute(out commIconAtt)) { if (commIconAtt.Icon != null) { titleIcon = new TitleIcon(commIconAtt.Icon); } } if (atts.Has <PageOptionsAttribute>()) { var optsAtt = atts.Get <PageOptionsAttribute>(); //TODO: implement conversion opts = (swPropertyManagerPageOptions_e)optsAtt.Options; } else { //TODO: implement conversion opts = (swPropertyManagerPageOptions_e)(PageOptions_e.OkayButton | PageOptions_e.CancelButton); } var helpLink = ""; var whatsNewLink = ""; if (atts.Has <HelpAttribute>()) { var helpAtt = atts.Get <HelpAttribute>(); if (!string.IsNullOrEmpty(helpAtt.WhatsNewLink)) { if (!opts.HasFlag(swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew)) { opts |= swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew; } } helpLink = helpAtt.HelpLink; whatsNewLink = helpAtt.WhatsNewLink; } var page = m_App.CreatePropertyManagerPage(atts.Name, (int)opts, m_Handler, ref err) as IPropertyManagerPage2; if (titleIcon != null) { var iconPath = m_IconsConv.ConvertIcon(titleIcon).First(); page.SetTitleBitmap2(iconPath); } if (atts.Has <MessageAttribute>()) { var msgAtt = atts.Get <MessageAttribute>(); page.SetMessage3(msgAtt.Text, (int)msgAtt.Visibility, (int)msgAtt.Expanded, msgAtt.Caption); } else if (!string.IsNullOrEmpty(atts.Description)) { page.SetMessage3(atts.Description, (int)swPropertyManagerPageMessageVisibility.swMessageBoxVisible, (int)swPropertyManagerPageMessageExpanded.swMessageBoxExpand, ""); } return(new PropertyManagerPagePage(page, m_Handler, m_App, helpLink, whatsNewLink)); }