Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lxxgd committed Apr 4, 2024
1 parent 6dbc498 commit 382e279
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 28 deletions.
8 changes: 6 additions & 2 deletions CBTool/CBTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<AssemblyVersion>1.2.1</AssemblyVersion>
<FileVersion>1.2.1</FileVersion>
<AssemblyVersion>1.2.2</AssemblyVersion>
<FileVersion>1.2.2</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -21,6 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.17" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand All @@ -45,6 +46,9 @@
</ItemGroup>

<ItemGroup>
<None Update="Log4Net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
1 change: 1 addition & 0 deletions CBTool/CBToolCS.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions CBTool/CBToolCS.resx
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@
<value>True</value>
</data>
<data name="rainbowLabel1.Location" type="System.Drawing.Point, System.Drawing">
<value>76, 4</value>
<value>66, 4</value>
</data>
<data name="rainbowLabel1.Size" type="System.Drawing.Size, System.Drawing">
<value>65, 22</value>
<value>77, 22</value>
</data>
<data name="rainbowLabel1.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
Expand Down
28 changes: 27 additions & 1 deletion CBTool/DataInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -80,5 +81,30 @@ internal class DataInfo
{"A0044", "邹荣"},
{"A0045", "张智睿" }
};

public static void LoadFile()
{
string jsonString = File.ReadAllText("data/scene_numbering.json");
Dictionary<string, string> scene_numbering = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonString);
string jsonString2 = File.ReadAllText("data/category_numbering.json");
Dictionary<string, string> category_numbering = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonString2);
string jsonString3 = File.ReadAllText("data/member_numbering.json");
Dictionary<string, string> member_numbering = JsonConvert.DeserializeObject<Dictionary<string, string>>(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);
}
}
}
32 changes: 32 additions & 0 deletions CBTool/PicNumbering.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 41 additions & 8 deletions CBTool/PicNumbering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace CBTool
{
Expand All @@ -28,7 +29,7 @@ public PicNumbering()

private void PicNumbering_DragEnter(object sender, DragEventArgs e)
{

}

public static bool canPares(string s)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<string> strings = new List<string>();
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
}
}
}
3 changes: 0 additions & 3 deletions CBTool/PicNumbering.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,4 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>181, 17</value>
</metadata>
</root>
30 changes: 23 additions & 7 deletions CBTool/PicPreview.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 382e279

Please sign in to comment.