Пример #1
0
        /// <summary>
        /// Show this PMPage
        /// </summary>
        public void ShowPage()
        {
            _doc = App.IActiveDoc2;

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

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

                _host = new ElementHost();
            }

            _host.Child = this;
            PMPageWinformHandle.SetWindowHandlex64(_host.Handle.ToInt64());

            var result_e = (swPropertyManagerPageStatus_e)Page.Show();

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

            AttachDocEvent();
        }
Пример #2
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();
        }