diff --git a/CBTool/CBTool.csproj b/CBTool/CBTool.csproj
index 0de9407..19bbaf4 100644
--- a/CBTool/CBTool.csproj
+++ b/CBTool/CBTool.csproj
@@ -8,8 +8,8 @@
enable
True
7.0
- 1.2.1
- 1.2.1
+ 1.2.2
+ 1.2.2
@@ -21,6 +21,7 @@
+
@@ -45,6 +46,9 @@
+
+ Always
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/CBTool/CBToolCS.Designer.cs b/CBTool/CBToolCS.Designer.cs
index 87762ef..6a28f60 100644
--- a/CBTool/CBToolCS.Designer.cs
+++ b/CBTool/CBToolCS.Designer.cs
@@ -62,6 +62,7 @@ private void InitializeComponent()
// rainbowLabel1
//
resources.ApplyResources(rainbowLabel1, "rainbowLabel1");
+ rainbowLabel1.BackColor = SystemColors.Control;
rainbowLabel1.Float = true;
rainbowLabel1.Name = "rainbowLabel1";
//
diff --git a/CBTool/CBToolCS.resx b/CBTool/CBToolCS.resx
index 99536fa..884c8a1 100644
--- a/CBTool/CBToolCS.resx
+++ b/CBTool/CBToolCS.resx
@@ -198,10 +198,10 @@
True
- 76, 4
+ 66, 4
- 65, 22
+ 77, 22
4
diff --git a/CBTool/DataInfo.cs b/CBTool/DataInfo.cs
index df9fcde..82126ee 100644
--- a/CBTool/DataInfo.cs
+++ b/CBTool/DataInfo.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -80,5 +81,30 @@ internal class DataInfo
{"A0044", "邹荣"},
{"A0045", "张智睿" }
};
+
+ public static void LoadFile()
+ {
+ string jsonString = File.ReadAllText("data/scene_numbering.json");
+ Dictionary scene_numbering = JsonConvert.DeserializeObject>(jsonString);
+ string jsonString2 = File.ReadAllText("data/category_numbering.json");
+ Dictionary category_numbering = JsonConvert.DeserializeObject>(jsonString2);
+ string jsonString3 = File.ReadAllText("data/member_numbering.json");
+ Dictionary member_numbering = JsonConvert.DeserializeObject>(jsonString3);
+ DataInfo.scene_numbering = scene_numbering;
+ DataInfo.category_numbering = category_numbering;
+ DataInfo.member_numbering = member_numbering;
+ }
+
+ public static void GenData()
+ {
+ if(!Directory.Exists("data"))
+ Directory.CreateDirectory("data");
+ string updatedJson = Newtonsoft.Json.JsonConvert.SerializeObject(scene_numbering, Formatting.Indented);
+ File.WriteAllText("data/scene_numbering.json", updatedJson);
+ string updatedJson2 = Newtonsoft.Json.JsonConvert.SerializeObject(category_numbering, Formatting.Indented);
+ File.WriteAllText("data/category_numbering.json", updatedJson2);
+ string updatedJson3 = Newtonsoft.Json.JsonConvert.SerializeObject(member_numbering, Formatting.Indented);
+ File.WriteAllText("data/member_numbering.json", updatedJson3);
+ }
}
}
diff --git a/CBTool/PicNumbering.Designer.cs b/CBTool/PicNumbering.Designer.cs
index f8be4b1..0eb0b46 100644
--- a/CBTool/PicNumbering.Designer.cs
+++ b/CBTool/PicNumbering.Designer.cs
@@ -52,6 +52,8 @@ private void InitializeComponent()
panel1 = new Panel();
groupBox4 = new GroupBox();
toolTip1 = new ToolTip(components);
+ label7 = new Label();
+ checkBox1 = new CheckBox();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
contextMenuStrip1.SuspendLayout();
@@ -211,6 +213,7 @@ private void InitializeComponent()
listBox1.Size = new Size(417, 224);
listBox1.TabIndex = 7;
listBox1.SelectedIndexChanged += listBox1_SelectedIndexChanged;
+ listBox1.DoubleClick += listBox1_DoubleClick;
//
// button1
//
@@ -286,12 +289,38 @@ private void InitializeComponent()
groupBox4.TabStop = false;
groupBox4.Text = "文件列表";
//
+ // toolTip1
+ //
+ toolTip1.ToolTipIcon = ToolTipIcon.Info;
+ //
+ // label7
+ //
+ label7.AutoSize = true;
+ label7.Location = new Point(444, 22);
+ label7.Name = "label7";
+ label7.Size = new Size(140, 17);
+ label7.TabIndex = 14;
+ label7.Text = "双击人物列表来添加人物";
+ //
+ // checkBox1
+ //
+ checkBox1.AutoSize = true;
+ checkBox1.Location = new Point(447, 44);
+ checkBox1.Name = "checkBox1";
+ checkBox1.Size = new Size(327, 21);
+ checkBox1.TabIndex = 15;
+ checkBox1.Text = "不预览图片(防止潜在的异常发生,例如文件无法打开)";
+ checkBox1.UseVisualStyleBackColor = true;
+ checkBox1.CheckedChanged += checkBox1_CheckedChanged;
+ //
// PicNumbering
//
AllowDrop = true;
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(981, 544);
+ Controls.Add(checkBox1);
+ Controls.Add(label7);
Controls.Add(groupBox4);
Controls.Add(groupBox3);
Controls.Add(button4);
@@ -318,6 +347,7 @@ private void InitializeComponent()
panel1.PerformLayout();
groupBox4.ResumeLayout(false);
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -344,5 +374,7 @@ private void InitializeComponent()
private Panel panel1;
private GroupBox groupBox4;
private ToolTip toolTip1;
+ private Label label7;
+ private CheckBox checkBox1;
}
}
\ No newline at end of file
diff --git a/CBTool/PicNumbering.cs b/CBTool/PicNumbering.cs
index 9f35c35..e1a2a8a 100644
--- a/CBTool/PicNumbering.cs
+++ b/CBTool/PicNumbering.cs
@@ -12,6 +12,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
+using System.Diagnostics;
namespace CBTool
{
@@ -28,7 +29,7 @@ public PicNumbering()
private void PicNumbering_DragEnter(object sender, DragEventArgs e)
{
-
+
}
public static bool canPares(string s)
@@ -74,6 +75,7 @@ private void PicNumbering_DragDrop(object sender, DragEventArgs e)
private void PicNumbering_Load(object sender, EventArgs e)
{
+ DataInfo.LoadFile();
comboBox3.Items.Clear();
foreach (var item in DataInfo.scene_numbering.Keys)
{
@@ -144,7 +146,7 @@ private void button1_Click(object sender, EventArgs e)
private void LoadFile()
{
listBox1.Items.Clear();
- if (!Directory.Exists("images"))
+ if (!Directory.Exists("images"))
{
Directory.CreateDirectory("images");
}
@@ -188,14 +190,14 @@ private void button2_Click(object sender, EventArgs e)
foreach (var filePath in Directory.EnumerateFiles("images", "*", SearchOption.TopDirectoryOnly))
{
string name = Path.GetFileNameWithoutExtension(filePath);
- if (canPares(name))
+ if (canPares(name))
{
int i = int.Parse(name);
nums.Add(i);
}
}
nums.Sort((a, b) => b.CompareTo(a));
- if(nums.Count > 0 )
+ if (nums.Count > 0)
{
num = nums[0] + 1;
}
@@ -289,7 +291,6 @@ private void button3_Click(object sender, EventArgs e)
indexAndTag.elements.Add(element);
string updatedJson = Newtonsoft.Json.JsonConvert.SerializeObject(indexAndTag, Formatting.Indented);
File.WriteAllText(filePath, updatedJson);
- MessageBox.Show(updatedJson);
}
//IndexAndTag indexAndTag = new IndexAndTag();
//List strings = new List();
@@ -387,7 +388,8 @@ private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
label1.Text = "图片格式:" + fileInfo.Extension;
label5.Text = "图片大小:" + FileSizeConverter.ConvertFileSize(fileInfo.Length);
label6.Text = "图片ID:" + Path.GetFileNameWithoutExtension(listItem.Path);
- pictureBox1.ImageLocation = listItem.Path;
+ if (!checkBox1.Checked)
+ pictureBox1.ImageLocation = listItem.Path;
}
else
{
@@ -421,10 +423,41 @@ private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
FileInfo fileInfo = new FileInfo(listItem.Path);
if (fileInfo.Exists)
{
- PicPreview picPreview = new PicPreview();
+ PicPreview picPreview = new PicPreview(Image.FromFile(listItem.Path));
picPreview.pictureBox1.ImageLocation = listItem.Path;
picPreview.ShowDialog();
- }
+ }
+ }
+
+ private void listBox1_DoubleClick(object sender, EventArgs e)
+ {
+ if (listBox1.SelectedItem == null) return;
+ ListItem listItem = (ListItem)listBox1.SelectedItem;
+ if (listItem == null) return;
+ Console.WriteLine(listItem.Path);
+ try
+ {
+ ProcessStartInfo startInfo = new ProcessStartInfo(Path.GetFullPath(listItem.Path));
+
+ // 可选:隐藏启动程序的窗口(如果需要静默打开)
+ // startInfo.WindowStyle = ProcessWindowStyle.Hidden;
+
+ // 启动新进程打开图片
+ Process process = Process.Start(startInfo);
+ }
+ catch (Exception ex)
+ {
+ // 处理可能出现的异常,如文件不存在、没有关联程序等
+ Debug.WriteLine($"无法打开文件:{ex.Message}");
+ }
+ }
+
+ private void checkBox1_CheckedChanged(object sender, EventArgs e)
+ {
+ if(checkBox1.Checked)
+ {
+ pictureBox1.Image = null;
+ }
}
}
}
diff --git a/CBTool/PicNumbering.resx b/CBTool/PicNumbering.resx
index 6a8d7f3..bf96dec 100644
--- a/CBTool/PicNumbering.resx
+++ b/CBTool/PicNumbering.resx
@@ -123,7 +123,4 @@
17, 17
-
- 181, 17
-
\ No newline at end of file
diff --git a/CBTool/PicPreview.Designer.cs b/CBTool/PicPreview.Designer.cs
index 33e4aa1..f42b795 100644
--- a/CBTool/PicPreview.Designer.cs
+++ b/CBTool/PicPreview.Designer.cs
@@ -30,39 +30,54 @@ private void InitializeComponent()
{
panel1 = new Panel();
pictureBox1 = new PictureBox();
+ panel2 = new Panel();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// panel1
//
+ panel1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
panel1.AutoScroll = true;
panel1.Controls.Add(pictureBox1);
- panel1.Dock = DockStyle.Fill;
- panel1.Location = new Point(0, 0);
+ panel1.Location = new Point(132, 0);
panel1.Name = "panel1";
- panel1.Size = new Size(800, 450);
+ panel1.Size = new Size(704, 480);
panel1.TabIndex = 0;
//
// pictureBox1
//
+ pictureBox1.Dock = DockStyle.Fill;
pictureBox1.Location = new Point(0, 0);
pictureBox1.Name = "pictureBox1";
- pictureBox1.Size = new Size(100, 50);
- pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
+ pictureBox1.Size = new Size(704, 480);
+ pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
+ pictureBox1.Click += pictureBox1_Click;
+ pictureBox1.Resize += pictureBox1_Resize;
+ //
+ // panel2
+ //
+ panel2.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
+ panel2.BackColor = Color.White;
+ panel2.Location = new Point(0, 0);
+ panel2.Name = "panel2";
+ panel2.Size = new Size(126, 480);
+ panel2.TabIndex = 1;
//
// PicPreview
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(836, 480);
+ Controls.Add(panel2);
Controls.Add(panel1);
Name = "PicPreview";
Text = "PicPreview";
+ FormClosed += PicPreview_FormClosed;
+ Load += PicPreview_Load;
panel1.ResumeLayout(false);
- panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
}
@@ -71,5 +86,6 @@ private void InitializeComponent()
private Panel panel1;
public PictureBox pictureBox1;
+ private Panel panel2;
}
}
\ No newline at end of file
diff --git a/CBTool/PicPreview.cs b/CBTool/PicPreview.cs
index 020a363..0038d48 100644
--- a/CBTool/PicPreview.cs
+++ b/CBTool/PicPreview.cs
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -12,9 +13,84 @@ namespace CBTool
{
public partial class PicPreview : Form
{
- public PicPreview()
+ public Image Image { get; set; }
+ public int Width { get; set; }
+ public int Height { get; set; }
+ private int _width = 0;
+ private int _height = 0;
+ private List bitmaps = new List();
+
+ public PicPreview(Image image)
{
InitializeComponent();
+ Image = image;
+ Width = Image.Width;
+ Height = Image.Height;
+ _width = Width;
+ _height = Height;
+ panel1.MouseWheel += PictureBox1_MouseWheel;
+ pictureBox1.MouseWheel += PictureBox1_MouseWheel;
+ }
+
+ private void PictureBox1_MouseWheel(object? sender, MouseEventArgs e)
+ {
+ const double ZoomStep = 0.1; // 缩放步长,可根据需要调整
+ var pictureBox = pictureBox1;
+
+ // 判断滚轮方向(正数表示向前滚动,负数表示向后滚动)
+ double scaleFactor = e.Delta > 0 ? 1 + ZoomStep : 1 / (1 + ZoomStep);
+
+ // 获取当前图片的原始尺寸
+ Image originalImage = Image;
+ if (originalImage == null) return;
+
+ // 计算新的尺寸
+ int newWidth = (int)(Width * scaleFactor);
+ int newHeight = (int)(Height * scaleFactor);
+
+ // 避免缩放后尺寸过小或超出控件边界
+ newWidth = Math.Max(newWidth, _width / 10);
+ newHeight = Math.Max(newHeight, _height / 10);
+ newWidth = Math.Min(newWidth, _width * 10);
+ newHeight = Math.Min(newHeight, _height * 10);
+
+ if (newHeight == Height && newWidth == Width)
+ {
+ return;
+ }
+
+ // 使用Graphics对象进行缩放操作
+ var tempBitmap = new Bitmap(newWidth, newHeight);
+ using var g = Graphics.FromImage(tempBitmap);
+ g.InterpolationMode = InterpolationMode.High;
+ g.DrawImage(originalImage, new Rectangle(0, 0, newWidth, newHeight));
+ Width = newWidth;
+ Height = newHeight;
+ pictureBox.Image = tempBitmap;
+ bitmaps.Add(tempBitmap);
+ }
+
+ private void pictureBox1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void pictureBox1_Resize(object sender, EventArgs e)
+ {
+
+ }
+
+ private void PicPreview_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void PicPreview_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ foreach (var item in bitmaps)
+ {
+ item.Dispose();
+ }
}
}
}
diff --git a/CBTool/Program.cs b/CBTool/Program.cs
index 76c9bb9..e11177d 100644
--- a/CBTool/Program.cs
+++ b/CBTool/Program.cs
@@ -1,16 +1,24 @@
+using log4net;
+using log4net.Config;
+using log4net.Repository.Hierarchy;
+
namespace CBTool
{
internal static class Program
{
+ public static ILog LOGGER = LogManager.GetLogger(typeof(CBToolCS));
+
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
+ XmlConfigurator.ConfigureAndWatch(new FileInfo("Log4Net.config"));
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
+ LOGGER.Info("Start");
Application.Run(new CBToolCS());
}
}
diff --git a/CBTool/Properties/PublishProfiles/FolderProfile.pubxml.user b/CBTool/Properties/PublishProfiles/FolderProfile.pubxml.user
index 9a080a8..c927506 100644
--- a/CBTool/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/CBTool/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
- True|2024-04-02T13:09:06.2134141Z;True|2024-04-02T20:35:47.2538037+08:00;True|2024-04-02T20:32:43.1723438+08:00;False|2024-04-02T20:31:42.2534478+08:00;
+ True|2024-04-04T03:04:10.1864294Z;True|2024-04-04T11:03:46.1612541+08:00;True|2024-04-02T21:09:06.2134141+08:00;True|2024-04-02T20:35:47.2538037+08:00;True|2024-04-02T20:32:43.1723438+08:00;False|2024-04-02T20:31:42.2534478+08:00;
\ No newline at end of file
diff --git a/CBTool/RainbowLabel.cs b/CBTool/RainbowLabel.cs
index 615ba0a..448c588 100644
--- a/CBTool/RainbowLabel.cs
+++ b/CBTool/RainbowLabel.cs
@@ -165,6 +165,7 @@ public override Size GetPreferredSize(Size proposedSize)
{
Size size = base.GetPreferredSize(proposedSize);
size.Height = size.Height + 5;
+ size.Width = size.Width + TextRenderer.MeasureText(" ",Font,new Size(int.MaxValue,int.MaxValue),TextFormatFlags.SingleLine).Width;
return size;
}
}
diff --git a/CBTool/obj/Debug/net8.0-windows/CBTool.AssemblyInfo.cs b/CBTool/obj/Debug/net8.0-windows/CBTool.AssemblyInfo.cs
index 3f7e6db..b8a3df4 100644
--- a/CBTool/obj/Debug/net8.0-windows/CBTool.AssemblyInfo.cs
+++ b/CBTool/obj/Debug/net8.0-windows/CBTool.AssemblyInfo.cs
@@ -13,11 +13,11 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("CBTool")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
-[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.1")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3a0d295981461ceea63049137adca51f94dabcc1")]
+[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.2")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6dbc49852ca0c5b792399f798c3935bbc4d0cad0")]
[assembly: System.Reflection.AssemblyProductAttribute("CBTool")]
[assembly: System.Reflection.AssemblyTitleAttribute("CBTool")]
-[assembly: System.Reflection.AssemblyVersionAttribute("1.2.1")]
+[assembly: System.Reflection.AssemblyVersionAttribute("1.2.2")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]