Ejemplo n.º 1
0
        /// <summary>
        /// Show this PMPage
        /// </summary>
        public void ShowPage()
        {
            //使用单线程单元,防止SolidWorks闪退
            Thread.CurrentThread.TrySetApartmentState(System.Threading.ApartmentState.STA);

            _doc = App.IActiveDoc2;

            if (_doc == null)
            {
                throw new InvalidOperationException($"No active doc,can not show the pmpage");
            }

            if (Page == null)
            {
                CreatePage();

                AddSldControls();
                AddUserControl();
                AddSldBackControls();

                _host = new ElementHost();
            }

            //数据绑定在此处执行
            _host.Child = this;
            PMPageWinformHandle.SetWindowHandlex64(_host.Handle.ToInt64());

            OnShowPagePreview();

            swPropertyManagerPageStatus_e result_e = swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay;

            try
            {
                Debug.Print("PMPage.Show");
                result_e = (swPropertyManagerPageStatus_e)Page.Show();// 2((int)swPropertyManagerPageShowOptions_e.swPropertyManagerShowOptions_StackPage);
                Debug.Print("PMPage.Showed");
            }
            catch (Exception)
            {
                throw;
            }

            if (result_e != swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay)
            {
                throw new CreatePMPageErrorException($"{nameof(ShowPage)} Error: {result_e}");
            }

            //处理预先选择
            ProcessPreSelect();

            //设置控件可见
            SldControls.ForEach(p => p.SldControlVisibility = true);

            //AttachDocEvent();
        }
Ejemplo n.º 2
0
        protected override void Command()
        {
            if (!IsInit)
            {
                return;
            }

            try
            {
                _Calque = new Calque(_PmPage, NomModule);
                _Calque.Entete("Info", DescriptionModule);

                if (OnCalque.IsRef())
                {
                    OnCalque();
                }

                if (OnPreSelection.IsRef())
                {
                    OnPreSelection();
                }

                swPropertyManagerPageStatus_e r = (swPropertyManagerPageStatus_e)_PmPage.Show2(0);
                _IsShow = true;

                if (r == swPropertyManagerPageStatus_e.swPropertyManagerPage_CreationFailure)
                {
                    this.LogMethode(new Object[] { "Erreur de création" });
                    _IsShow = false;
                }
                else
                {
                }
            }
            catch (Exception e)
            { this.LogMethode(new Object[] { e }); }
        }