public FrmFrequencies(xTextFile xFile) { InitializeComponent(); _xFile = xFile; lblCategory.Text += xFile.getCategoryName(); lblCharactersCount.Text += xFile.charactersCount.ToString(); Text += " | " + xFile.fileName; lblUniqueWords.Text += xFile.uniqueWordsCount.ToString(); lblWordCount.Text += xFile.wordsCount.ToString(); olvFrequencies.SetObjects(xFile.frequencies); }
public static List <xTextFile> GetHistory(string dtFrom, string dtTo) { if (dtFrom != "") { CACHE_DT_FROM = dtFrom; CACHE_DT_TO = dtTo; } else { dtFrom = CACHE_DT_FROM; dtTo = CACHE_DT_TO; } WORDS_COUNT = 0; CHARACTERS_COUNT = 0; FILES_COUNT = 0; ResetSQLiteConnection(); Utils.frequencies = new List <xWordFrequencies>(); string query = string.Format("SELECT * FROM `wf_files` WHERE strftime('%Y-%m-%d %H:%M:%S',created_at) BETWEEN ('{0}') AND ('{1}')", dtFrom, dtTo); List <xTextFile> list = new List <xTextFile>(); sql_cmd.CommandText = query; SQLiteDataReader Reader = sql_cmd.ExecuteReader(); if (!Reader.HasRows) { return(null); } while (Reader.Read()) { xTextFile tFile = new xTextFile() { fileId = Convert.ToInt64(GetDBInt64("id", Reader)), fileName = GetDBString("file_name", Reader), wordsCount = GetDBInt("words_count", Reader), uniqueWordsCount = GetDBInt("unique_words_count", Reader), charactersCount = GetDBInt("characters_count", Reader), categoryIndex = GetDBInt("category", Reader), created_at = GetDBString("created_at", Reader), frequencies = GetFrequencies(Convert.ToInt64(GetDBInt64("id", Reader))) }; WORDS_COUNT += tFile.wordsCount; CHARACTERS_COUNT += tFile.charactersCount; FILES_COUNT++; list.Add(tFile); } Reader.Close(); return(list); }
public FrmFrequencies(xTextFile xFile, string word) { InitializeComponent(); _xFile = xFile; lblCategory.Text += xFile.getCategoryName(); lblCharactersCount.Text += xFile.charactersCount.ToString(); Text += " | " + xFile.fileName; lblUniqueWords.Text += xFile.uniqueWordsCount.ToString(); lblWordCount.Text += xFile.wordsCount.ToString(); olvFrequencies.SetObjects(xFile.frequencies); // Select the element olvFrequencies.SelectedObject = (xFile.frequencies.First(xObj => xObj.word == word)); // Scroll to the selected element olvFrequencies.EnsureModelVisible((xFile.frequencies.First(xObj => xObj.word == word))); }
private void bgwCounter_ProgressChanged(object sender, ProgressChangedEventArgs e) { xTextFile xFile = (xTextFile)e.UserState; if (e.ProgressPercentage == -1) { // Is cancelled lblStatus.Text = "Отменено пользователем"; } else if (e.ProgressPercentage == -2) { // Still reading if (!lblStatus.Text.Equals("Читаю: " + xFile.fileName)) { lblStatus.Text = "Читаю: " + xFile.fileName; Update(); } } else if (e.ProgressPercentage == -3) { // Has finished onFinishCounting(); } else { // Counting prbStatus.Maximum = xFile.wordsCount; prbStatus.Value = e.ProgressPercentage; if ((prbStatus.Maximum != prbStatus.Value) || prbStatus.Maximum == 0) { if (prbStatus.Visible == false) { prbStatus.Visible = true; } if (!lblStatus.Text.Equals("Обрабатываю: " + xFile.fileName)) { lblStatus.Text = "Обрабатываю: " + xFile.fileName; Update(); } } else { // Current file has been finished, let's move to the next prbStatus.Value = 0; prbStatus.Visible = false; } } }
private void CtrlHistory_Load(object sender, EventArgs e) { olvHistory.SubItemChecking += delegate(object olvCheckSender, SubItemCheckingEventArgs olvCheckArgs) { // Set false all the other categories xTextFile rowObject = ((xTextFile)olvCheckArgs.RowObject); rowObject.isSelected = !rowObject.isSelected; // After completion it will set the new value }; isReady = true; DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(6, 23, 59, 59); dtpFrom.Value = dt.Subtract(ts); dtpTo.Value = dt; }
private void search() { if (txtWord.Text.Length < 1) { return; } string word = txtWord.Text.Substring(0, 1).ToUpper() + txtWord.Text.Substring(1); List <xWordFrequencies> searchResults = DbHelper.FindInFrequencies(word); if (searchResults == null) { olvSearchResults.ClearObjects(); ((FrmMain)this.Parent.Parent.Parent).lblStatus.Text = string.Format("Ничего не найдено"); return; } List <xDetails> rowObjects = new List <xDetails>(); foreach (xWordFrequencies xwf in searchResults) { xTextFile fileInfo = Utils.GetTextFile(xwf.fileId); xDetails rowObject = new xDetails(); rowObject.fileId = fileInfo.fileId; rowObject.fileName = fileInfo.fileName; rowObject.categoryIndex = fileInfo.categoryIndex; rowObject.wordsCount = fileInfo.wordsCount; rowObject.uniqueWordsCount = fileInfo.uniqueWordsCount; rowObject.created_at = fileInfo.created_at; rowObject.word = xwf.word; rowObject.frequency = xwf.frequency; rowObject.percentage = xwf.percentage; rowObjects.Add(rowObject); } olvSearchResults.SetObjects(rowObjects); ((FrmMain)this.Parent.Parent.Parent).lblStatus.Text = string.Format("Найдено в {0} файлах(е)", rowObjects.GroupBy(xFile => xFile.fileId).Select(grp => grp.First()).ToList().Count.ToString()); olvSearchResults.PrimarySortColumn = olvSearchResults.GetColumn(0); olvSearchResults.PrimarySortOrder = SortOrder.Descending; olvSearchResults.Sort(); }
// public static void setStatusMessage(string msg) // private void Form1_Load(object sender, EventArgs e) { this.Text = "Strange Words ver." + AssemblyVersion; myCtrlHistory = new CtrlHistory(); myCtrlHistory.Dock = DockStyle.Fill; tbpHistory.Controls.Add(myCtrlHistory); myCtrlWordAnalyzer = new CtrlWordAnalyzer(); myCtrlWordAnalyzer.Dock = DockStyle.Fill; tbpSearch.Controls.Add(myCtrlWordAnalyzer); DirectoryInfo dInfo = new DirectoryInfo(Utils.WorkDirPath); if (!dInfo.Exists) { dInfo.Create(); } txtWorkingDir.Text = Utils.WorkDirPath; DbHelper.SetConnection(); DbHelper.createTables(); olvFiles.SubItemChecking += delegate(object olvCheckSender, SubItemCheckingEventArgs olvCheckArgs) { // Set false all the other categories xTextFile rowObject = ((xTextFile)olvCheckArgs.RowObject); rowObject.isFiction = false; rowObject.isPoetry = false; rowObject.isScientific = false; rowObject.isSocPol = false; rowObject.isReligious = false; // After completion it will set the new value }; loadFiles(); // Refresh history list myCtrlHistory.loadHistory(); olvFiles.PrimarySortColumn = olvFiles.GetColumn(0); olvFiles.PrimarySortOrder = SortOrder.Descending; }