Exemple #1
0
        private void saveData()
        {
            String stBuffer = "";

            stBuffer = stBuffer + Des.DESEncrypt(password);
            foreach (KeyValuePair <string, ObservableCollection <BookMarkBean> > dicTemp in dic)
            {
                int numCnt = 1;
                if (dicTemp.Value.Count > 0)
                {
                    foreach (BookMarkBean bookMarkBeanTemp in dicTemp.Value)
                    {
                        stBuffer = stBuffer + "\n" + Des.DESEncrypt(dicTemp.Key) + "\n";
                        stBuffer = stBuffer + numCnt + "\n";
                        stBuffer = stBuffer + Des.DESEncrypt(bookMarkBeanTemp.ShuoMing) + "\n";
                        stBuffer = stBuffer + Des.DESEncrypt(bookMarkBeanTemp.Url) + "\n";
                        stBuffer = stBuffer + Des.DESEncrypt(bookMarkBeanTemp.User) + "\n";
                        stBuffer = stBuffer + Des.DESEncrypt(bookMarkBeanTemp.Psw);
                        numCnt++;
                    }
                }
                else
                {
                    stBuffer = stBuffer + "\n" + Des.DESEncrypt(dicTemp.Key) + "\n";
                    stBuffer = stBuffer + "" + "\n";
                    stBuffer = stBuffer + "" + "\n";
                    stBuffer = stBuffer + "" + "\n";
                    stBuffer = stBuffer + "" + "\n";
                    stBuffer = stBuffer + "";
                }
            }
            System.IO.StreamWriter sw = (new System.IO.StreamWriter(@"const.ini", false));
            sw.WriteLine(stBuffer);
            sw.Close();
        }
Exemple #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            string pwd1 = passwordBox1.Password;
            string pwd2 = passwordBox2.Password;

            if (pwd1 == pwd2 && pwd1.Length != 0)
            {
                String stBuffer = "";
                stBuffer = Des.DESEncrypt(pwd1);

                System.IO.StreamWriter sw = (new System.IO.StreamWriter(@"const.ini", false));
                sw.WriteLine(stBuffer);
                sw.Close();

                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
        }
Exemple #3
0
        private void InitData()
        {
            //int status = 0;//0:密码  1:类别  2:书签详细
            int lineNum = 1;                                                                                  //按顺序排列,通过求余知道是什么内容

            string classNameNow = "";                                                                         //当前循环的书签类名
            string classNameNew = "";                                                                         //新循环的书签类名
            ObservableCollection <BookMarkBean> bookMarkListTemp = new ObservableCollection <BookMarkBean>(); //当前循环的书签List
            BookMarkBean bookMarkTemp = new BookMarkBean();                                                   //当前循环的书签

            StreamReader sr      = (new System.IO.StreamReader(@"const.ini"));
            String       lineStr = sr.ReadLine();

            while (lineStr != null)
            {
                if (lineNum == 1)
                {   //第一行密码
                    password = Des.DESDecrypt(lineStr);
                }
                else
                {
                    switch ((lineNum - 1) % 6)
                    {
                    case 1:
                        classNameNew = Des.DESDecrypt(lineStr);

                        if (classNameNew != classNameNow && lineNum != 2)
                        {
                            //新书签List时,把上一个保存到字典中
                            dic.Add(classNameNow, bookMarkListTemp);
                            bookMarkListTemp = new ObservableCollection <BookMarkBean>();
                            classList.Add(classNameNow);
                        }
                        classNameNow = classNameNew;

                        bookMarkTemp = new BookMarkBean();
                        //bookMarkTemp.ClassName = lineStr;

                        break;

                    case 2:
                        bookMarkTemp.No = lineStr;
                        break;

                    case 3:
                        bookMarkTemp.ShuoMing = Des.DESDecrypt(lineStr);
                        break;

                    case 4:
                        bookMarkTemp.Url = Des.DESDecrypt(lineStr);
                        break;

                    case 5:
                        bookMarkTemp.User = Des.DESDecrypt(lineStr);
                        break;

                    case 0:
                        //书签区块的最后一行时,保存在同类书签List中
                        bookMarkTemp.Psw = Des.DESDecrypt(lineStr);
                        if (bookMarkTemp.No != "")     //No==""无效的空白书签
                        {
                            bookMarkListTemp.Add(bookMarkTemp);
                        }
                        break;
                    }
                }

                lineNum++;
                lineStr = sr.ReadLine();
                continue;
            }
            //读到最后,将没保存的最后一个保存
            dic.Add(classNameNow, bookMarkListTemp);
            classList.Add(classNameNow);
            sr.Close();

            this.comboBox.ItemsSource = classList;
            //初期选择第一个
            classSelectChange(classList.IndexOf(ConfigurationManager.AppSettings["defaultClass"]));

            //浏览器区块设置
            this.comboBox_browser.ItemsSource       = browser_list;
            this.comboBox_browser.SelectedValuePath = "Key";
            this.comboBox_browser.DisplayMemberPath = "Value";
            this.comboBox_browser.SelectedValue     = ConfigurationManager.AppSettings["defaultBrowser"];

            //3个参数设置
            this.textBox_parm1.Text = ConfigurationManager.AppSettings["defaultParm1"];
            this.textBox_parm2.Text = ConfigurationManager.AppSettings["defaultParm2"];
            this.textBox_parm3.Text = ConfigurationManager.AppSettings["defaultParm3"];


            listView_View.AddHandler(Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(listView_View_MouseLeftButtonDown), true);
        }