Пример #1
0
        public void Bind(ConfMgmt conf)
        {
            var list = conf.Root.Keys.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();

            list.Insert(0, "");
            DataSource = list;
        }
Пример #2
0
        private void Remove()
        {
            Utils.UI.Help.ConfirmAction($"是否确定删除产品档({SelectedName})?", () => {
                File.Delete($@"{RootPath}\{SelectedName}.xml");

                ConfMgmt.Inst(InstName).Generate(RootPath, true);
                var names = ReOrder(ConfMgmt.Inst(InstName).Root.Keys.Select(x => Path.GetFileNameWithoutExtension(x)).ToList());

                CMB_ProductFileList.DataSource = IsShow == null ? names : IsShow;
                OnChange?.Invoke(SelectedConf);

                return(ErrInfo.Ok);
            });
        }
Пример #3
0
        public void Bind(string title, string confType, string path, Action <ConfTree> onChange, Func <string, bool> onSave = null)
        {
            Name     = $"{title}Controller";
            IsBinded = true;

            OnChange       = onChange;
            SaveEvtHandler = onSave;

            if (path == null)
            {
                return;
            }

            LBL_Title.Text = title;
            InstName       = confType;
            RootPath       = path.Last() == '\\' ? path.Substring(0, path.Length - 1) : path;

            ConfMgmt.Inst(InstName).Generate(path, true);
            var names = ReOrder(ConfMgmt.Inst(InstName).Root.Keys.Select(x => Path.GetFileNameWithoutExtension(x)).ToList());

            CMB_ProductFileList.DataSource = IsShow == null ? names : IsShow;
            OnChange?.Invoke(SelectedConf);
        }
Пример #4
0
        private void BTN_SaveAs_Click(object sender, EventArgs e)
        {
            var name = Interaction.InputBox("", "配置名称", "", 100, 200);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            OrigConf = ConfTrees[SelectedFile].Clone() as ConfTree;
            var path = SelectedFile.Replace($"{SelectedName}.xml", $"{name}.xml");

            if (SaveEvtHandler == null || SaveEvtHandler(null))
            {
                Save(path);

                ConfMgmt.Inst(InstName).Generate(Path.GetDirectoryName(path), true);
                CMB_ProductFileList.DataSource = ConfTrees.Keys.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
                CMB_ProductFileList.Text       = name;

                OnChange?.Invoke(SelectedConf);
            }
        }
Пример #5
0
 public static void Initialize(ConfMgmt conf)
 {
     conf.Clear();
 }