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
        public void AfterClose()
        {
            int IndentSize;

            IndentSize = System.Diagnostics.Debug.IndentSize;
            System.Diagnostics.Debug.WriteLine(IndentSize);

            if (CloseReason == swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay)
            {
                OkClicked?.Invoke();
                CloseCommand?.Execute(null);
            }
            else
            {
                CloseCommand?.Execute(-1);
            }
            Closed?.Invoke(CloseReason);

            SldControls.ForEach(p => p.SldControlVisibility = false);

            this.Dispose();
        }