Ejemplo n.º 1
0
        private void BtOk_Click(object sender, EventArgs e)
        {
            string name = TbName.Text.Trim();
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请输入类别名称!");
                TbName.Focus();
                return;
            }
            if (!CharUtil.IsValidate(name, 1, DBConst.ACAT0104_SIZE))
            {
                MessageBox.Show("类别名称不能多于" + DBConst.ACAT0104_SIZE + "个字符!");
                TbName.Focus();
                return;
            }

            if (_Cat == null)
            {
                _Cat = new Cat();
            }

            _Cat.Text = name;
            _Cat.Tips = TbTips.Text;
            _Cat.Meta = TbMeta.Text;
            _Cat.Memo = TbMemo.Text;

            if (CallBackHandler != null)
            {
                CallBackHandler(_Cat);
            }
            Close();
        }
Ejemplo n.º 2
0
        public void Init(ImageList imgList)
        {
            TvCatTree.ImageList = imgList;

            Cat cat = new Cat { Id = CPwd.DEF_CAT_ID, Text = "阿木密码箱", Tips = "阿木密码箱", Icon = "Amon" };
            _RootNode = new TreeNode { Name = cat.Id, Text = cat.Text, ToolTipText = cat.Tips, ImageKey = cat.Icon, SelectedImageKey = cat.Icon };
            _RootNode.Tag = cat;
            TvCatTree.Nodes.Add(_RootNode);
            InitCat(_RootNode);
            _RootNode.Expand();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 类别
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="setting"></param>
        private void ImportWPwdCat(AUserModel userModel, XmlReaderSettings setting)
        {
            string file = Path.Combine(userModel.DatHome, "WPwd-Cat.xml");
            if (!File.Exists(file))
            {
                return;
            }

            StreamReader stream = new StreamReader(file);
            using (XmlReader reader = XmlReader.Create(stream, setting))
            {
                Cat cat;
                while (reader.Name == "Cat" || reader.ReadToFollowing("Cat"))
                {
                    cat = new Cat();
                    if (!cat.FromXml(reader))
                    {
                        continue;
                    }
                    _DataModel.DeleteVcs(cat);
                    _DataModel.SaveVcs(cat);
                }
            }
            stream.Close();
        }
Ejemplo n.º 4
0
        private void InitCat_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                _SignAc.HideWaiting();
                Main.ShowAlert(e.Error.Message);
                return;
            }

            string xml = e.Result;
            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                if (xml.IndexOf("<Error>") > 0)
                {
                    _SignAc.HideWaiting();
                    reader.ReadToFollowing("Error");
                    Main.ShowAlert(reader.ReadElementContentAsString());
                    return;
                }

                Cat cat;
                while (reader.Name == "Cat" || reader.ReadToFollowing("Cat"))
                {
                    cat = new Cat();
                    if (!cat.FromXml(reader))
                    {
                        continue;
                    }
                    _DataModel.SaveVcs(cat);
                }
            }

            WebClient client = new WebClient();
            client.Headers["Content-type"] = "application/x-www-form-urlencoded";
            client.Encoding = Encoding.UTF8;
            client.UploadStringCompleted += new UploadStringCompletedEventHandler(InitLib_UploadStringCompleted);
            client.UploadStringAsync(new Uri(CApp.SERVER_PATH), "POST", "&o=lib&c=" + _UserModel.Code);
        }
Ejemplo n.º 5
0
        public void AppendCat(Cat cat)
        {
            if (cat == null || _LastNode == null)
            {
                return;
            }
            Cat parent = SelectedCat;
            if (parent == null)
            {
                return;
            }

            cat.Parent = parent.Id;
            cat.Order = _LastNode.Nodes.Count;
            cat.AppId = CApp.IAPP_WPWD;
            _DataModel.SaveVcs(cat);
            if (parent.IsLeaf)
            {
                parent.IsLeaf = false;
                _DataModel.SaveVcs(parent);
            }

            TreeNode node = new TreeNode();
            node.Name = cat.Id;
            node.Text = cat.Text;
            node.ToolTipText = cat.Tips;
            node.Tag = cat;
            if (CharUtil.IsValidateHash(cat.Icon))
            {
                node.ImageKey = cat.Icon;
            }
            node.SelectedImageKey = node.ImageKey;
            _LastNode.Nodes.Add(node);
            //_LastNode.Expand();
            TvCat.SelectedNode = node;
        }
Ejemplo n.º 6
0
        private void TvCat_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (KeyList == null)
            {
                return;
            }

            Main.LogInfo("TvCatTree_AfterSelect");
            TreeNode node = e.Node;
            if (node == null || node == _LastNode)
            {
                return;
            }
            _LastNode = node;

            SelectedCat = node.Tag as Cat;
            if (SelectedCat != null && !string.IsNullOrWhiteSpace(SelectedCat.Meta))
            {
                string meta = SelectedCat.Meta.ToLower();
                // 待提示
                if (meta == CPwd.TAG_TASK)
                {
                    KeyList.ListKeysByGtd();
                    return;
                }
                // 已过期
                if (meta == CPwd.TAG_TASK_VAL_EXPIRED)
                {
                    KeyList.ListKeysByGtd(Gtd.CGtd.STATUS_EXPIRED);
                    return;
                }
                // 未过期
                if (meta.StartsWith(CPwd.TAG_TASK_VAR))
                {
                    ProcessGtdMeta(meta.Substring(5));
                    return;
                }
            }

            KeyList.ListKeys(node.Name);
        }
Ejemplo n.º 7
0
        public void UpdateCat(Cat cat)
        {
            if (cat == null)
            {
                return;
            }

            Cat cur = SelectedCat;
            if (cur == null)
            {
                Main.ShowAlert("请选择您要更新的类别!");
                //TvCatTree.Focus();
                return;
            }

            if (cur.Id == CPwd.DEF_CAT_ID)
            {
                return;
            }

            cur.Text = cat.Text;
            cur.Tips = cat.Tips;
            cur.Memo = cat.Memo;
            _DataModel.SaveVcs(cur);

            _LastNode.Text = cat.Text;
            _LastNode.ToolTipText = cat.Tips;
        }
Ejemplo n.º 8
0
        public void Init(ImageList images)
        {
            ImageList = images;
            if (ImageList == null)
            {
                ImageList = new ImageList();
                ImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
                ImageList.ImageSize = new System.Drawing.Size(16, 16);
                ImageList.TransparentColor = System.Drawing.Color.Transparent;
            }
            this.TvCat.ImageList = ImageList;
            ImageList.Images.Add(CPwd.DEF_CAT_IMG, BeanUtil.NaN16);

            Cat cat = new Cat { Id = CPwd.DEF_CAT_ID, Text = "默认类别", Tips = "默认类别", Icon = "Amon" };
            ImageList.Images.Add(cat.Icon, Resources.Logo);
            _RootNode = new TreeNode { Name = cat.Id, Text = cat.Text, ToolTipText = cat.Tips, ImageKey = cat.Icon, SelectedImageKey = cat.Icon };
            _RootNode.Tag = cat;
            TvCat.Nodes.Add(_RootNode);
            DoInitCat(_RootNode);
            _RootNode.Expand();
        }
Ejemplo n.º 9
0
 private void ShowData(Cat cat)
 {
     _Cat = cat;
     TbName.Text = _Cat.Text;
     TbTips.Text = _Cat.Tips;
     TbMeta.Text = _Cat.Meta;
     TbMemo.Text = _Cat.Memo;
 }
Ejemplo n.º 10
0
 public void Show(IWin32Window owner, Cat cat)
 {
     base.Show(owner);
     ShowData(cat);
 }
Ejemplo n.º 11
0
        private void InitDat()
        {
            _UserModel.Load();
            BeanUtil.UnZip(CApp.FILE_DAT, _UserModel.DatHome);
            _DataModel = new ADataModel(_UserModel);
            _DataModel.Init();

            string file;
            StreamReader stream;
            XmlReaderSettings setting = new XmlReaderSettings { IgnoreWhitespace = true };

            #region 字符
            file = Path.Combine(_UserModel.DatHome, "App-Udc.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Udc udc;
                    while (reader.Name == "Udc" || reader.ReadToFollowing("Udc"))
                    {
                        udc = new Udc();
                        if (!udc.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(udc);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 类别
            file = Path.Combine(_UserModel.DatHome, "App-Cat.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Cat cat;
                    while (reader.Name == "Cat" || reader.ReadToFollowing("Cat"))
                    {
                        cat = new Cat();
                        if (!cat.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(cat);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 模板
            file = Path.Combine(_UserModel.DatHome, "WPwd-Lib.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Lib header;
                    while (reader.Name == "Lib" || reader.ReadToFollowing("Lib"))
                    {
                        header = new Lib();
                        if (!header.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(header);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 目录
            file = Path.Combine(_UserModel.DatHome, "WPwd-Dir.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Dir dir;
                    while (reader.Name == "Dir" || reader.ReadToFollowing("Dir"))
                    {
                        dir = new Dir();
                        if (!dir.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(dir);
                    }
                }
                stream.Close();
            }
            #endregion

            _DataModel.Dispose();
            _SignAc.CallBack(CApp.IAPP_WPWD);
        }
Ejemplo n.º 12
0
Archivo: WPwd.cs Proyecto: burstas/rmps
 /// <summary>
 /// 添加类别
 /// </summary>
 /// <param name="cat"></param>
 public void AppendCat(Cat cat)
 {
     _CatTree.AppendCat(cat);
 }
Ejemplo n.º 13
0
Archivo: WPwd.cs Proyecto: burstas/rmps
 /// <summary>
 /// 更新类别
 /// </summary>
 /// <param name="cat"></param>
 public void UpdateCat(Cat cat)
 {
     _CatTree.UpdateCat(cat);
 }