From 9bcc9461485bf046ce74a700fb4c4f141899ac12 Mon Sep 17 00:00:00 2001 From: Fengshaoyuan <1914442689@qq.com> Date: Tue, 11 Jun 2024 17:12:26 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=94=AF=E6=8C=81=E7=AB=A0=E8=8A=82=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 001.HtmlToTxtWFA/001.HtmlToTxtWFA.csproj | 15 +++ 001.HtmlToTxtWFA/MainForm.Designer.cs | 114 +++++++++++++++++++- 001.HtmlToTxtWFA/MainForm.cs | 91 +++++++++++++++- 001.HtmlToTxtWFA/MainForm.resx | 30 ++++++ 001.HtmlToTxtWFA/Resource.Designer.cs | 83 +++++++++++++++ 001.HtmlToTxtWFA/Resource.resx | 127 +++++++++++++++++++++++ 001.HtmlToTxtWFA/Resources/end.png | Bin 0 -> 303 bytes 001.HtmlToTxtWFA/Resources/start.png | Bin 0 -> 302 bytes 8 files changed, 455 insertions(+), 5 deletions(-) create mode 100644 001.HtmlToTxtWFA/Resource.Designer.cs create mode 100644 001.HtmlToTxtWFA/Resource.resx create mode 100644 001.HtmlToTxtWFA/Resources/end.png create mode 100644 001.HtmlToTxtWFA/Resources/start.png diff --git a/001.HtmlToTxtWFA/001.HtmlToTxtWFA.csproj b/001.HtmlToTxtWFA/001.HtmlToTxtWFA.csproj index 56c4353..38b47f3 100644 --- a/001.HtmlToTxtWFA/001.HtmlToTxtWFA.csproj +++ b/001.HtmlToTxtWFA/001.HtmlToTxtWFA.csproj @@ -25,4 +25,19 @@ + + + True + True + Resource.resx + + + + + + ResXFileCodeGenerator + Resource.Designer.cs + + + \ No newline at end of file diff --git a/001.HtmlToTxtWFA/MainForm.Designer.cs b/001.HtmlToTxtWFA/MainForm.Designer.cs index 5472e8e..9c4abd6 100644 --- a/001.HtmlToTxtWFA/MainForm.Designer.cs +++ b/001.HtmlToTxtWFA/MainForm.Designer.cs @@ -31,10 +31,14 @@ namespace HtmlToTxtWFA /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.loadingPanel = new CustomizedLoading.LoadingPanel(); this.queryListButton = new System.Windows.Forms.Button(); this.exportButton = new System.Windows.Forms.Button(); this.chapterListBox = new System.Windows.Forms.ListBox(); + this.rightContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.setChapterStartToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setChapterEndToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.progressBar = new System.Windows.Forms.ProgressBar(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); @@ -44,6 +48,14 @@ namespace HtmlToTxtWFA this.label3 = new System.Windows.Forms.Label(); this.platformComboBox = new System.Windows.Forms.ComboBox(); this.HOST = new System.Windows.Forms.LinkLabel(); + this.label4 = new System.Windows.Forms.Label(); + this.startChapterNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.label5 = new System.Windows.Forms.Label(); + this.endChapterNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.setAllButton = new System.Windows.Forms.Button(); + this.rightContextMenuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.startChapterNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.endChapterNumericUpDown)).BeginInit(); this.SuspendLayout(); // // loadingPanel @@ -85,12 +97,38 @@ namespace HtmlToTxtWFA // // chapterListBox // + this.chapterListBox.ContextMenuStrip = this.rightContextMenuStrip; this.chapterListBox.FormattingEnabled = true; this.chapterListBox.ItemHeight = 15; - this.chapterListBox.Location = new System.Drawing.Point(10, 84); + this.chapterListBox.Location = new System.Drawing.Point(10, 114); this.chapterListBox.Name = "chapterListBox"; - this.chapterListBox.Size = new System.Drawing.Size(367, 349); + this.chapterListBox.Size = new System.Drawing.Size(367, 319); this.chapterListBox.TabIndex = 13; + this.chapterListBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ChapterListBox_MouseDown); + // + // rightContextMenuStrip + // + this.rightContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.setChapterStartToolStripMenuItem, + this.setChapterEndToolStripMenuItem}); + this.rightContextMenuStrip.Name = "rightContextMenuStrip"; + this.rightContextMenuStrip.Size = new System.Drawing.Size(207, 70); + // + // setChapterStartToolStripMenuItem + // + this.setChapterStartToolStripMenuItem.Image = global::HtmlToTxtWFA.Resource.start; + this.setChapterStartToolStripMenuItem.Name = "setChapterStartToolStripMenuItem"; + this.setChapterStartToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.setChapterStartToolStripMenuItem.Text = "设置选中章节为开始章节"; + this.setChapterStartToolStripMenuItem.Click += new System.EventHandler(this.SetChapterStartToolStripMenuItem_Click); + // + // setChapterEndToolStripMenuItem + // + this.setChapterEndToolStripMenuItem.Image = global::HtmlToTxtWFA.Resource.end; + this.setChapterEndToolStripMenuItem.Name = "setChapterEndToolStripMenuItem"; + this.setChapterEndToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.setChapterEndToolStripMenuItem.Text = "设置选中章节为结束章节"; + this.setChapterEndToolStripMenuItem.Click += new System.EventHandler(this.SetChapterEndToolStripMenuItem_Click); // // progressBar // @@ -171,11 +209,72 @@ namespace HtmlToTxtWFA this.HOST.TabIndex = 22; this.HOST.Click += new System.EventHandler(this.HOST_Click); // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(12, 89); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(67, 15); + this.label4.TabIndex = 23; + this.label4.Tag = "章节序号从0开始!"; + this.label4.Text = "导出章节:"; + // + // startChapterNumericUpDown + // + this.startChapterNumericUpDown.InterceptArrowKeys = false; + this.startChapterNumericUpDown.Location = new System.Drawing.Point(84, 85); + this.startChapterNumericUpDown.Maximum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.startChapterNumericUpDown.Name = "startChapterNumericUpDown"; + this.startChapterNumericUpDown.Size = new System.Drawing.Size(89, 23); + this.startChapterNumericUpDown.TabIndex = 24; + this.startChapterNumericUpDown.ValueChanged += new System.EventHandler(this.StartChapterNumericUpDown_ValueChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(179, 89); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(17, 15); + this.label5.TabIndex = 25; + this.label5.Text = "--"; + // + // endChapterNumericUpDown + // + this.endChapterNumericUpDown.Location = new System.Drawing.Point(202, 85); + this.endChapterNumericUpDown.Maximum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.endChapterNumericUpDown.Name = "endChapterNumericUpDown"; + this.endChapterNumericUpDown.Size = new System.Drawing.Size(89, 23); + this.endChapterNumericUpDown.TabIndex = 26; + this.endChapterNumericUpDown.ValueChanged += new System.EventHandler(this.EndChapterNumericUpDown_ValueChanged); + // + // setAllButton + // + this.setAllButton.Location = new System.Drawing.Point(302, 85); + this.setAllButton.Name = "setAllButton"; + this.setAllButton.Size = new System.Drawing.Size(75, 23); + this.setAllButton.TabIndex = 27; + this.setAllButton.Text = "全部"; + this.setAllButton.UseVisualStyleBackColor = true; + this.setAllButton.Click += new System.EventHandler(this.SetAllButton_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(390, 497); + this.Controls.Add(this.setAllButton); + this.Controls.Add(this.endChapterNumericUpDown); + this.Controls.Add(this.label5); + this.Controls.Add(this.startChapterNumericUpDown); + this.Controls.Add(this.label4); this.Controls.Add(this.HOST); this.Controls.Add(this.platformComboBox); this.Controls.Add(this.label3); @@ -194,6 +293,9 @@ namespace HtmlToTxtWFA this.MinimumSize = new System.Drawing.Size(406, 535); this.Name = "MainForm"; this.Text = "查询章节"; + this.rightContextMenuStrip.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.startChapterNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.endChapterNumericUpDown)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -213,6 +315,14 @@ namespace HtmlToTxtWFA private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox platformComboBox; private System.Windows.Forms.LinkLabel HOST; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.NumericUpDown startChapterNumericUpDown; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.NumericUpDown endChapterNumericUpDown; + private System.Windows.Forms.Button setAllButton; + private System.Windows.Forms.ContextMenuStrip rightContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem setChapterStartToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem setChapterEndToolStripMenuItem; } } diff --git a/001.HtmlToTxtWFA/MainForm.cs b/001.HtmlToTxtWFA/MainForm.cs index 1959f7a..f7f0ebe 100644 --- a/001.HtmlToTxtWFA/MainForm.cs +++ b/001.HtmlToTxtWFA/MainForm.cs @@ -164,6 +164,90 @@ namespace HtmlToTxtWFA } } + private void StartChapterNumericUpDown_ValueChanged(object sender, EventArgs e) + { + // 确保起始值不超过结束值 + if (startChapterNumericUpDown.Value > endChapterNumericUpDown.Value) + { + MessageBox.Show("起始值不能大于结束值,已自动调整为结束值。"); + startChapterNumericUpDown.Value = endChapterNumericUpDown.Value; + } + } + + private void EndChapterNumericUpDown_ValueChanged(object sender, EventArgs e) + { + // 确保结束值不小于起始值 + if (endChapterNumericUpDown.Value < startChapterNumericUpDown.Value) + { + MessageBox.Show("结束值不能小于起始值,已自动调整为起始值。"); + endChapterNumericUpDown.Value = startChapterNumericUpDown.Value; + } + } + + private void SetAllButton_Click(object sender, EventArgs e) + { + int Maximum = ChapterList.Count - 1 < 0 ? 0 : ChapterList.Count - 1; + startChapterNumericUpDown.Maximum = Maximum; + startChapterNumericUpDown.Value = 0; + endChapterNumericUpDown.Maximum = Maximum; + endChapterNumericUpDown.Value = Maximum; + } + + private void ChapterListBox_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + // 获取鼠标点击位置的索引 + int index = chapterListBox.IndexFromPoint(e.Location); + + // 检查索引是否有效,即确保有项目被点击 + if (index >= 0 && index < chapterListBox.Items.Count) + { + // 选中该行 + chapterListBox.SelectedIndex = index; + + // 如果需要显示上下文菜单,则在这里显示 + rightContextMenuStrip.Show(chapterListBox, e.Location); + } + } + } + + private void SetChapterStartToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = chapterListBox.SelectedIndex; + if (index < 0) + { + MessageBox.Show("请先选中要设置的章节"); + return; + } + + if (index > endChapterNumericUpDown.Value) + { + MessageBox.Show("开始章节不能大于结束章节"); + return; + } + + startChapterNumericUpDown.Value = index; + } + + private void SetChapterEndToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = chapterListBox.SelectedIndex; + if (index < 0) + { + MessageBox.Show("请先选中要设置的章节"); + return; + } + + if (index < startChapterNumericUpDown.Value) + { + MessageBox.Show("结束章节不能小于开始章节"); + return; + } + + endChapterNumericUpDown.Value = index; + } + private async void QueryListButton_Click(object sender, EventArgs e) { string serialNumber = memuSerialNumberTextBox.Text; @@ -176,6 +260,7 @@ namespace HtmlToTxtWFA queryListButton.Enabled = false; exportButton.Enabled = false; await AnalysisChapterList(); + SetAllButton_Click(null, null); queryListButton.Enabled = true; exportButton.Enabled = true; } @@ -255,18 +340,18 @@ namespace HtmlToTxtWFA { loadingPanel.Visible = true; loadingPanel.Start(); - progressBar.Maximum = ChapterList.Count; + progressBar.Maximum = (int)(endChapterNumericUpDown.Value - startChapterNumericUpDown.Value + 1); progressBar.Minimum = 0; progressBar.Value = 0; progressBar.Visible = true; })); try { - for (int i = 0; i < ChapterList.Count; i++) + for (int i = (int)startChapterNumericUpDown.Value; i <= (int)endChapterNumericUpDown.Value; i++) { this.Invoke((MethodInvoker)(() => { - progressBar.Value = i + 1; + progressBar.Value = i - (int)startChapterNumericUpDown.Value + 1; chapterListBox.SelectedIndex = i; })); ChapterClass chapter = ChapterList[i]; diff --git a/001.HtmlToTxtWFA/MainForm.resx b/001.HtmlToTxtWFA/MainForm.resx index b25187e..9c61dd9 100644 --- a/001.HtmlToTxtWFA/MainForm.resx +++ b/001.HtmlToTxtWFA/MainForm.resx @@ -66,15 +66,30 @@ True + + True + + + 17, 17 + True True + + True + + + True + True + + True + True @@ -84,6 +99,21 @@ True + + True + + + True + + + True + + + True + + + True + True diff --git a/001.HtmlToTxtWFA/Resource.Designer.cs b/001.HtmlToTxtWFA/Resource.Designer.cs new file mode 100644 index 0000000..ae59e8c --- /dev/null +++ b/001.HtmlToTxtWFA/Resource.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace HtmlToTxtWFA { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HtmlToTxtWFA.Resource", typeof(Resource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap end { + get { + object obj = ResourceManager.GetObject("end", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap start { + get { + object obj = ResourceManager.GetObject("start", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/001.HtmlToTxtWFA/Resource.resx b/001.HtmlToTxtWFA/Resource.resx new file mode 100644 index 0000000..0f0318e --- /dev/null +++ b/001.HtmlToTxtWFA/Resource.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Resources\end.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\start.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/001.HtmlToTxtWFA/Resources/end.png b/001.HtmlToTxtWFA/Resources/end.png new file mode 100644 index 0000000000000000000000000000000000000000..615bc5faf06ee386317df1a0f0b6bf5800dcdfce GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWNq$1fP z$d`ekN|k}3p_zf<=YJsml7XSrfPvvv0t1893 zQA#Hxk3m#Jhl>9B=4Zhj(}R*;y*WL{pTX`0;{v_ZR0d{=0}TIJPc&IIu$l2Yh+Wyb z_K6>3-SY52Em1KJ!J~}p;!eNG*1w?Pe&BBOM%_KrB`cgJaJ|pvxWDo~^AFpd2R3zo u;LJJCT4>PV6e>RFO>hK=Lcgdq$_|PVDNPHb6Mw<&;$UqR&GrI literal 0 HcmV?d00001 diff --git a/001.HtmlToTxtWFA/Resources/start.png b/001.HtmlToTxtWFA/Resources/start.png new file mode 100644 index 0000000000000000000000000000000000000000..2305a6fb3da8c41734e121870e9f9592b42ae056 GIT binary patch literal 302 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWNq$1fP z$d`ekN|k}3p_zf<=YJsml7XSrfPvvv0t1893