internal static int GetSimpleWordCount(string orgText) { (int L5_Chinese, int L7_Japanese, int L8_Korea) = StatisticsWindow.GetChracterLength(orgText); int L6_EngWord = StatisticsWindow.GetEnglishLength(orgText); return(L5_Chinese + L6_EngWord); }
public static int GetStatistics(string orgText, int orgWordCount, int parags) { int L2_WordCount = orgWordCount; int L3_AllCount = orgText.Count(t => t != '\r' && t != '\n' && t != '\t'); int L4_Paragraph = parags; (int L5_Chinese, int L7_Japanese, int L8_Korea) = StatisticsWindow.GetChracterLength(orgText); int L6_EngWord = StatisticsWindow.GetEnglishLength(orgText); int L9_Symbols = orgText.Count(Char.IsPunctuation); int L1_All = L5_Chinese + L6_EngWord; StatisticsWindow.statisticsStr = String.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}", Environment.NewLine, L1_All, L2_WordCount, L3_AllCount, L4_Paragraph, L5_Chinese, L6_EngWord, L7_Japanese, L8_Korea, L9_Symbols); return(L1_All); }
/// <summary> /// 事件:更改新建里程碑的文章绑定 /// </summary> private void ComboBox_Chapters_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.ComboBox_Chapters.SelectedIndex == -1) { return; } WorldWindow.core.RetrieveOffspringArticle(this.BookRef.HomePage.Id, true, out var chapterVec); var ao = chapterVec[this.ComboBox_Chapters.SelectedIndex]; this.wordCountCache = StatisticsWindow.GetSimpleWordCountByMetadata(ao); this.Label_WordNow.Content = this.wordCountCache.ToString(); this.ProgessBar_Process.Value = this.wordCountCache / (double)this.Numberic_WordThreshold.Value * 100.0; if (this.wordCountCache >= (double)this.Numberic_WordThreshold.Value) { this.MetroProgressBar_Working.Visibility = Visibility.Hidden; } }
/// <summary> /// 事件:里程碑选择改变 /// </summary> private void Listbox_Milestone_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.Listbox_Milestone.SelectedIndex == -1) { return; } if (e.AddedItems[0] == this.Listbox_Milestone.Items[0]) { this.ComboBox_Chapters.SelectedIndex = -1; this.TextBox_MilestoneName.Text = String.Empty; this.DateTimePicker_endTime.SelectedDate = null; this.DateTimePicker_endTime.SelectedTime = null; this.Numberic_WordThreshold.Value = 1000; this.Button_Milestone_Delete.Visibility = Visibility.Hidden; this.ComboBox_Chapters.IsEnabled = true; this.ProgessBar_Process.Value = 0; this.MetroProgressBar_Working.Visibility = Visibility.Hidden; } else { this.Button_Milestone_Delete.Visibility = Visibility.Visible; var msObj = this.MsList[this.Listbox_Milestone.SelectedIndex - 1]; var articleObj = WorldWindow.core.ArticleDict[msObj.ArticleId]; for (int i = 0; i < this.ComboBox_Chapters.Items.Count; i++) { if (this.ComboBox_Chapters.Items[i].ToString() == articleObj.Name) { this.ComboBox_Chapters.SelectedIndex = i; break; } } this.ComboBox_Chapters.IsEnabled = false; this.TextBox_MilestoneName.Text = msObj.Detail; this.Numberic_WordThreshold.Value = msObj.Destination; this.wordCountCache = StatisticsWindow.GetSimpleWordCountByMetadata(articleObj); this.DateTimePicker_endTime.SelectedDate = msObj.EndTimeStamp; this.Label_WordNow.Content = this.wordCountCache.ToString(); this.ProgessBar_Process.Value = this.wordCountCache / (double)this.Numberic_WordThreshold.Value * 100.0; this.MetroProgressBar_Working.Visibility = this.wordCountCache >= (double)this.Numberic_WordThreshold.Value ? Visibility.Hidden : Visibility.Visible; } }
internal static int GetSimpleWordCountByMetadata(HArticle ao) { var dict = StatisticsWindow.core.mainWndRef.RTBPageCacheDict; if (dict.ContainsKey(ao.Id)) { return(StatisticsWindow.GetSimpleWordCount(dict[ao.Id].GetText())); } else { RTBPage np = new RTBPage() { ArticalRef = ao }; TextRange t = new TextRange(np.RichTextBox_TextArea.Document.ContentStart, np.RichTextBox_TextArea.Document.ContentEnd); t.Load(ao.DocumentMetadata, DataFormats.XamlPackage); np.UpdateRTBStyle(); dict[ao.Id] = np; return(StatisticsWindow.GetSimpleWordCount(np.GetText())); } }