Ejemplo n.º 1
0
        private void Window_Closed(object sender, EventArgs e)
        {
            SqliteClient dbClient = new SqliteClient(CommonData.DbSource);

            dbClient.Open();
            dbClient.ClearTask();
            foreach (var task in CommonData.Tasks)
            {
                dbClient.InsertTask(task);
            }
            dbClient.Close();
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            totalCounts = new long[4];
            freqs       = new Dictionary <string, long> [4];
            for (int i = 0; i < 4; i++)
            {
                freqs[i] = new Dictionary <string, long>();
            }

            SqliteClient freqDB = new SqliteClient(CommonData.DbSource);

            freqDB.Open();

            (var wordList, var frequencyList) = freqDB.QueryAllWordFreq();
            for (int i = 0; i < wordList.Count; i++)
            {
                (var word, var freq) = (wordList[i], frequencyList[i]);
                if (word.Length >= 4)
                {
                    for (int j = 0; j < word.Length - 4; j++)
                    {
                        string sub = word.Substring(j, 4);
                        if (freqs[0].ContainsKey(sub))
                        {
                            freqs[0][sub] += freq;
                        }
                        else
                        {
                            freqs[0][sub] = freq;
                        }
                        totalCounts[0] += freq;
                    }
                }
                else
                {
                    freqs[word.Length][word]  = freq;
                    totalCounts[word.Length] += freq;
                }
            }

            freqDB.Close();
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            /*
             * 右键快捷加密解密部分
             */
            var args = Environment.GetCommandLineArgs();

            if (args.Length > 2)
            {
                string originPath = args[2];                    //获取加密文件路径

                FileScheme fileScheme = new FileScheme();

                if (args[1] == "encrypt")                       //加密文件
                {
                    fileScheme.File2Bytes(originPath, originPath += ".cb");
                }
                else if (args[1] == "decrypt" && originPath.Contains(".cb"))                     //解密文件,且检查是否为加密过的文件
                {
                    int index = originPath.IndexOf(".cb");
                    fileScheme.Bytes2File(originPath, originPath.Remove(index, 3));
                }
            }

            /*创建或读入设置文件部分*/
            string xmlPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

            xmlPath += "settings.xml";
            if (!File.Exists(xmlPath))
            {
                XMLSaveAndRead xmlHandle = new XMLSaveAndRead();

                //存储信息
                List <Settings> info     = new List <Settings>();
                Settings        settings = new Settings(false, true, ("crtl", "E"), "3", SchemeType.Caesar, SchemeType.RailFence, SchemeType.Substitution);          //默认配置
                info.Add(settings);
                //将info的类型List<Test>和自身info传入
                string xmlInfo = xmlHandle.SerializeObject <List <Settings> >(info);
                xmlHandle.CreateXML(xmlPath, xmlInfo);
                CommonData.settings = settings;
            }
            else
            {
                XMLSaveAndRead  xmlHandle = new XMLSaveAndRead();
                string          doc       = xmlHandle.LoadXML(xmlPath);
                List <Settings> info1     = (List <Settings>)xmlHandle.DeserializeObject <List <Settings> >(doc);
                for (int i = 0; i < info1.Count; i++)
                {
                    CommonData.settings.isAutoStart    = info1[i].isAutoStart;
                    CommonData.settings.isUsingServer  = info1[i].isUsingServer;
                    CommonData.settings.shortCutKey    = info1[i].shortCutKey;
                    CommonData.settings.clipDefaultKey = info1[i].clipDefaultKey;
                    CommonData.settings.encryptType    = info1[i].encryptType;
                    CommonData.settings.decryptType    = info1[i].decryptType;
                    CommonData.settings.breakType      = info1[i].breakType;
                }
            }

            this.TaskListBox.ItemsSource = CommonData.Tasks;

            SqliteClient dbClient = new SqliteClient(CommonData.DbSource);

            dbClient.Open();
            var taskList = dbClient.QueryAllTask();

            foreach (var task in taskList)
            {
                CommonData.Tasks.Add(task);
            }
            dbClient.Close();

            //DebugWindow debugWindow = new DebugWindow();
            //debugWindow.Show();
        }