chr
2025-01-03 31a636e735a0addc56e4f4527f500b7aa0874eb5
PdmSwPlugin.PropertySetting/CommonSettingControl.xaml.cs
@@ -234,26 +234,33 @@
        public void InitPropertyData()
        {
            if (Client == null)
            try
            {
                Client = clientCreator.GetClient();
                if (Client == null)
                {
                    Client = clientCreator.GetClient();
                }
                DefaultPanel defaultPanel = new DefaultPanel();
                controlCache.Add("default", defaultPanel);
                JgjPartPanel jgjPart = new JgjPartPanel();
                controlCache.Add("jgjPart", jgjPart);
                JgjModulePanel jgjModule = new JgjModulePanel();
                controlCache.Add("jgjModule", jgjModule);
                var stPart = new StandardPartPanel();
                controlCache.Add("standardPart", stPart);
                var stModule = new StandardModulePanel();
                controlCache.Add("standardModule", stModule);
                LoadComboxItemSource();
                Refresh_Click(null, null);
            }
            DefaultPanel defaultPanel = new DefaultPanel();
            controlCache.Add("default", defaultPanel);
            JgjPartPanel jgjPart = new JgjPartPanel();
            controlCache.Add("jgjPart", jgjPart);
            JgjModulePanel jgjModule = new JgjModulePanel();
            controlCache.Add("jgjModule", jgjModule);
            var stPart = new StandardPartPanel();
            controlCache.Add("standardPart", stPart);
            var stModule = new StandardModulePanel();
            controlCache.Add("standardModule", stModule);
            LoadComboxItemSource();
            Refresh_Click(null, null);
            catch (Exception ex)
            {
                Logger.Error($"PropertySetting Init Error!", ex);
            }
        }
        private void Jgj_SinglePropertyChanged(object sender, string name, object value)
@@ -285,6 +292,8 @@
        private void UpdateActiveDoc()
        {
            long start = DateTime.Now.Millisecond;
            Logger.Debug("UpdateActiveDoc Start...");
            if (activeDoc != null)
            {
                DetachDocNotify(activeDoc);
@@ -300,7 +309,11 @@
                    activeDoc.ClearSelection2(true);
                }
            }
            Logger.Debug($"UpdateActiveDoc End {activeDoc?.GetPathName()} {DateTime.Now.Millisecond - start}ms.");
            start = DateTime.Now.Millisecond;
            Logger.Debug("UpdateUI Start...");
            UpdateUI(activeDoc);
            Logger.Debug($"UpdateUI End {activeDoc?.GetPathName()} {DateTime.Now.Millisecond - start}ms.");
        }
        /// <summary>
@@ -382,9 +395,10 @@
            ReadDoc = doc;
            Dispatcher.Invoke(() =>
            {
                SwitchVisiable();
                // LoadDocProperties();
            });
            SwitchVisiable();
        }
        private int Ass_UserSelectionPostNotify()
@@ -419,6 +433,9 @@
        /// </summary>
        private void SwitchVisiable()
        {
            var start = DateTime.Now.Millisecond;
            Logger.Debug("SwitchVisiable Start...");
            HashSet<string> skipName = new HashSet<string> {
                NameConstant.materialCode
            };
@@ -522,9 +539,15 @@
                last = null;
            }
            ActiveOpter = control;
            contentPanel.Children.Clear();
            newOne.UpdateProperty += Jgj_SinglePropertyChanged;
            contentPanel.Children.Add(control);
            Dispatcher.Invoke(() =>
            {
                contentPanel.Children.Clear();
                contentPanel.Children.Add(control);
            });
            Logger.Debug($"SwitchVisiable End {activeDoc?.GetPathName()} {DateTime.Now.Millisecond - start}ms.");
        }
        /// <summary>
@@ -694,11 +717,19 @@
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (ReadDoc == null)
            try
            {
                return;
                if (ReadDoc == null)
                {
                    return;
                }
                SaveDoc(false);
            }
            SaveDoc(false);
            catch (Exception ex)
            {
                Logger.Error($"Property Setting Save Doc Error!", ex);
                this.Error($"保存失败!{ex.Message}");
            }
        }
        public void RefreshData()
@@ -773,12 +804,20 @@
        public void OnCustomPropertyChange(string propName, string Configuration, string oldValue, string NewValue, int valueType)
        {
            if (oldValue == NewValue)
            try
            {
                return;
                if (oldValue == NewValue)
                {
                    return;
                }
                IPropertyOpt opt = ActiveOpter as IPropertyOpt;
                opt.UpdateSingleProperty(propName, NewValue);
            }
            IPropertyOpt opt = ActiveOpter as IPropertyOpt;
            opt.UpdateSingleProperty(propName, NewValue);
            catch (Exception ex)
            {
                Logger.Error("Property Setting OnCustomPropertyChange Error!", ex);
                this.Error($"属性变更异常!{ex.Message}");
            }
        }
        public void OnDocDestroy(ModelDoc2 doc)
@@ -796,6 +835,8 @@
        /// </summary>
        public void AlertSaveWindow()
        {
            var start = DateTime.Now.Millisecond;
            Logger.Debug("AlertSaveWindow Start...");
            IPropertyOpt opt = ActiveOpter as IPropertyOpt;
            if (opt != null && opt.GetDocChanged())
            {
@@ -818,29 +859,38 @@
                    opt.ResetProperty(out string errMsg);
                }
            }
            Logger.Debug($"AlertSaveWindow End {activeDoc?.GetPathName()} {DateTime.Now.Millisecond - start}ms.");
        }
        public void OnTabControlSelectionChange(object sender, SelectionChangedEventArgs e)
        {
            if (e.RemovedItems == null)
            try
            {
                return;
            }
            foreach (object obj in e.RemovedItems)
            {
                if (obj is TabItem item)
                {
                    if (item.Content == this)
                    {
                        AlertSaveWindow();
                        break;
                    }
                }
                else
                if (e.RemovedItems == null)
                {
                    return;
                }
                foreach (object obj in e.RemovedItems)
                {
                    if (obj is TabItem item)
                    {
                        if (item.Content == this)
                        {
                            AlertSaveWindow();
                            break;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error($"Property Setting OnTabControlSelectionChange Error!", ex);
                this.Error($"{ex.Message}");
            }
        }
    }