chr
2024-08-21 9ee7d3bd9c58a204b1efe38e6be61155bbb15c16
PdmSwPlugin.PropertySetting/CommonSettingControl.xaml.cs
@@ -82,9 +82,14 @@
                    if (string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(attr.defaultValue))
                    {
                        value = attr.defaultValue;
                        // 默认值不写入initData
                    }
                    else
                    {
                        // 其他写入initData
                        if (initData != null) initData[name] = value;
                    }
                    prop.SetValue(container, value);
                    if (initData != null) initData[name] = value;
                }
            });
            return true;
@@ -105,7 +110,14 @@
                string name = attr.Name;
                string value = initData.Get(name, string.Empty);
                string newValue = prop.GetValue(container) as string;
                if (value != newValue)
                if (name == NameConstant.weight)
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        return true;
                    }
                }
                else if (value != newValue)
                {
                    return true;
                }
@@ -365,20 +377,7 @@
        public void UpdateUI(ModelDoc2 doc)
        {
            IPropertyOpt opt = ActiveOpter as IPropertyOpt;
            if (opt != null && opt.GetDocChanged())
            {
                string Message = $"{Path.GetFileName(ReadDocPath)}属性发生变更,是否保存?";
                if (SwApp.SendMsgToUser2(Message, (int)swMessageBoxIcon_e.swMbWarning
                   , (int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes)
                {
                    SaveDoc(true);
                }
                else
                {
                    opt.ResetProperty(out string errMsg);
                }
            }
            AlertSaveWindow();
            LastReadDoc = ReadDoc;
            ReadDoc = doc;
            Dispatcher.Invoke(() =>
@@ -775,6 +774,35 @@
        }
        /// <summary>
        /// 判断是否需要弹窗提示保存
        /// </summary>
        public void AlertSaveWindow()
        {
            IPropertyOpt opt = ActiveOpter as IPropertyOpt;
            if (opt != null && opt.GetDocChanged())
            {
                // 历史文档直接重置
                string fullName = Path.GetFileName(ReadDocPath);
                if (NameUtil.IsHistoryDoc(fullName))
                {
                    opt.ResetProperty(out string errMsg);
                    return;
                }
                string Message = $"{fullName}属性发生变更,是否保存?";
                if (SwApp.SendMsgToUser2(Message, (int)swMessageBoxIcon_e.swMbWarning
                   , (int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes)
                {
                    SaveDoc(true);
                }
                else
                {
                    opt.ResetProperty(out string errMsg);
                }
            }
        }
        public void OnTabControlSelectionChange(object sender, SelectionChangedEventArgs e)
        {
            if (e.RemovedItems == null)
@@ -788,20 +816,7 @@
                {
                    if (item.Content == this)
                    {
                        IPropertyOpt opt = ActiveOpter as IPropertyOpt;
                        if (opt != null && opt.GetDocChanged())
                        {
                            string Message = $"{Path.GetFileName(ReadDocPath)}属性发生变更,是否保存?";
                            if (SwApp.SendMsgToUser2(Message, (int)swMessageBoxIcon_e.swMbWarning
                               , (int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes)
                            {
                                SaveDoc(true);
                            }
                            else
                            {
                                opt.ResetProperty(out string errMsg);
                            }
                        }
                        AlertSaveWindow();
                        break;
                    }
                }