Exemple #1
0
        public void Show(Lib header)
        {
            _LibHeader = header;

            TbText.Text = _LibHeader.Text;
            TbScript.Text = _LibHeader.Script;
            TbMemo.Text = _LibHeader.Memo;
        }
Exemple #2
0
        public void Init(DataModel dataModel, ViewModel viewModel)
        {
            _DataModel = dataModel;

            TbName.GotFocus += new EventHandler(TbName_GotFocus);
            TbMeta.GotFocus += new EventHandler(TbMeta_GotFocus);
            TbAuto.GotFocus += new EventHandler(TbMemo_GotFocus);

            _DefLib = new Lib { Id = "", Text = "请选择", Target = "", Script = "" };
        }
Exemple #3
0
        /// <summary>
        /// 口令数据
        /// </summary>
        /// <param name="index"></param>
        public bool InitData(Lib header)
        {
            for (int i = _AttList.Count - 1; i >= Att.HEAD_SIZE; i -= 1)
            {
                _AttList.RemoveAt(i);
            }

            Att att = _AttList[Att.PWDS_HEAD_AUTO];
            att.Text = header.Target ?? "";
            att.Data = header.Script ?? "";

            int order = 1;
            foreach (LibDetail detail in header.Details)
            {
                att = Att.GetInstance(detail.Type, detail.Text, detail.Data);
                att.Id = (_Key.AttIndex++).ToString();
                att.Order = (order++).ToString();
                _AttList.Add(att);
            }
            return true;
        }
Exemple #4
0
 public void InitOnce(DataModel dataModel, ViewModel viewModel)
 {
     _DataModel = dataModel;
     _DefLib = new Lib { Id = "", Text = "请选择", Target = "", Script = "" };
 }
Exemple #5
0
        private void ImportWPwdLib(AUserModel userModel, XmlReaderSettings setting)
        {
            string file = Path.Combine(userModel.DatHome, "WPwd-Lib.xml");
            if (File.Exists(file))
            {
                return;
            }

            StreamReader 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.DeleteVcs(header);
                    _DataModel.SaveVcs(header);
                }
            }
            stream.Close();
        }
Exemple #6
0
        private void InitLib_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;
                }

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

            WebClient client = new WebClient();
            client.Headers["Content-type"] = "application/x-www-form-urlencoded";
            client.Encoding = Encoding.UTF8;
            client.UploadStringCompleted += new UploadStringCompletedEventHandler(InitUdc_UploadStringCompleted);
            client.UploadStringAsync(new Uri(CApp.SERVER_PATH), "POST", "&o=udc&c=" + _UserModel.Code);
        }
Exemple #7
0
        private void ShowHeader(Lib header)
        {
            if (_UcEditer.Name != "LibHeader")
            {
                GbGroup.Controls.Clear();

                _UcHeader.Location = new System.Drawing.Point(6, 20);
                _UcHeader.Size = new System.Drawing.Size(231, 183);
                _UcHeader.TabIndex = 0;
                GbGroup.Controls.Add(_UcHeader);
                GbGroup.Text = "模板";

                _UcEditer = _UcHeader;
            }
            _UcHeader.Show(header);
        }
Exemple #8
0
        public void SaveHeader(Lib header)
        {
            if (CharUtil.IsValidateHash(header.Id))
            {
                _Selected.Text = header.Text;
                _Selected.ToolTipText = header.Memo;
            }
            else
            {
                _DataModel.LibList.Add(header);

                TreeNode node = new TreeNode();
                node.Name = header.Id;
                node.Tag = header;
                node.Text = header.Text;
                node.ToolTipText = header.Memo;
                TvLibView.Nodes.Add(node);

                TvLibView.SelectedNode = null;
            }

            _DataModel.SaveVcs(header);
            _DataModel.LibModified = -1;
        }
Exemple #9
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);
        }