示例#1
0
        /// <summary>
        /// 保存tabPage的名字
        /// </summary>
        public bool WriteJsonTabPageNames(string tabPageName, TabPageAll tabPageAll)
        {
            Logger.Debug("[保存tabPage的名字] 执行开始");
            // 读取json数据存入tpnList里
            try
            {
                TabPageAll obj = JsonAccess.ReadJson_TabNames(path);
                if (obj != null)
                {
                    foreach (TabPageNames item in obj.TabPageNames)
                    {
                        TabPageNames tpn1 = new TabPageNames();
                        tpn1.Name = item.Name;
                        tabPageAll.TabPageNames.Add(tpn1);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
                return(false);
            }

            int cnt = 0;

            if (tabPageAll != null && tabPageAll.TabPageNames.Count > 0)
            {
                cnt = (from tpn in tabPageAll.TabPageNames
                       where tpn.Name == tabPageName
                       select tpn).Count();
            }

            if (cnt > 0)
            {
                MessageBox.Show("类别名称已存在!");
                return(false);
            }
            // 声明TabPageNames
            TabPageNames tpn2 = new TabPageNames();

            tpn2.Name = tabPageName;       // 画面传来在name
                                           // 添加到tpnList里
            tabPageAll.TabPageNames.Add(tpn2);

            // 写入json
            JsonAccess.WriteJson(path, tabPageAll);

            // 如果添加在名字存在

            Logger.Debug("[保存tabPage的名字] 执行终了");
            return(true);
        }
示例#2
0
        private void StorageBox_Load(object sender, EventArgs e)
        {
            Logger.Debug("[收纳箱界面加载]执行开始");
            GetJsonPath(JsonFileName);

            // 读取json数据存入tpnList里
            TabPageAll tabPageAll = new TabPageAll();

            try
            {
                TabPageAll obj = JsonAccess.ReadJson_TabNames(JsonPath);

                if (obj != null)
                {
                    foreach (TabPageNames item in obj.TabPageNames)
                    {
                        TabPageNames tpn1 = new TabPageNames();
                        tpn1.Name = item.Name;
                        tabPageAll.TabPageNames.Add(tpn1);
                    }
                }
            }
            catch (Exception e1)
            {
                Logger.Error(e1.ToString());
            }

            if (tabPageAll == null || tabPageAll.TabPageNames.Count == 0)
            {
                return;
            }

            foreach (TabPageNames item in tabPageAll.TabPageNames)
            {
                Logger.Debug("开始添加Tab:" + item.Name.Remove(0, 3));
                tabC_ctx.TabPages.Add(item.Name.Remove(0, 3));
            }
            Logger.Debug("[收纳箱界面加载]执行结束");
        }