Skip to content

Commit

Permalink
Modify UI & SettingForm
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Jun 25, 2019
1 parent 13084a2 commit 75a5bc2
Show file tree
Hide file tree
Showing 14 changed files with 636 additions and 114 deletions.
23 changes: 8 additions & 15 deletions SubtitleRenamer/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public partial class MainForm

private void ReloadFiles()
{
MatchEpisodeBtn.Enabled = false;
if (OpenPath == null || OpenPath.Trim() == "") return;

var folder = new DirectoryInfo(OpenPath);
Expand All @@ -46,8 +45,6 @@ private void ReloadFiles()
SubtitleFileList.Add(file);

// 清空历史数据
MatchEpisodeBtn.Enabled = true;
StartBtn.Enabled = false;
SubtitleRenameDict.Clear();
VideoEpisDict.Clear();
SubtitleEpisDict.Clear();
Expand All @@ -58,31 +55,30 @@ private void ReloadFiles()

private void RefreshFileListBox()
{
FileListBox.Items.Clear();
FileListBox.Items.Add(">> 字幕");
// 字幕 listBox
SubtitleFileListBox.Items.Clear();
foreach (var file in SubtitleFileList)
{
var str = "";
str += " ";
if (SubtitleEpisDict.ContainsKey(file.Name))
str += $"[集数:{SubtitleEpisDict[file.Name]}] ";
str += file.Name;
FileListBox.Items.Add(str);
SubtitleFileListBox.Items.Add(str);
if (SubtitleRenameDict.ContainsKey(file.Name))
{
FileListBox.Items.Add(String.Format("{0,12}", " => ") + SubtitleRenameDict[file.Name]);
SubtitleFileListBox.Items.Add(String.Format("{0,12}", " => ") + SubtitleRenameDict[file.Name]);
}
}
FileListBox.Items.Add("");
FileListBox.Items.Add(">> 视频");

// 视频 listBox
VideoFileListBox.Items.Clear();
foreach (var file in VideoFileList)
{
var str = "";
str += " ";
if (VideoEpisDict.ContainsKey(file.Name))
str += $"[集数:{VideoEpisDict[file.Name]}] ";
str += file.Name;
FileListBox.Items.Add(str);
VideoFileListBox.Items.Add(str);
}
}

Expand Down Expand Up @@ -126,9 +122,6 @@ private void MatchEpisode()

// 刷新文件列表
RefreshFileListBox();

// 设置改名按钮可用
StartBtn.Enabled = true;
}

// 通过比对两个文件名中 数字 不同的部分来得到 集数 的位置
Expand Down
129 changes: 84 additions & 45 deletions SubtitleRenamer/MainForm.Designer.cs

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

48 changes: 47 additions & 1 deletion SubtitleRenamer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ namespace SubtitleRenamer
{
public partial class MainForm : Form
{
private static SettingForm settingForm;

public MainForm()
{
InitializeComponent();
settingForm = new SettingForm();
LoadFilesByPath(Application.StartupPath);
}

private void PathSelBtn_Click(object sender, EventArgs e)
Expand All @@ -28,8 +32,13 @@ private void PathSelBtn_Click(object sender, EventArgs e)
PathSelDialog.SelectedPath = OpenPath;
}
PathSelDialog.ShowDialog();
PathTextBox.Text = OpenPath = PathSelDialog.SelectedPath;
LoadFilesByPath(PathSelDialog.SelectedPath);
}

private void LoadFilesByPath(string path)
{
OpenPath = path;
PathTextBox.Text = OpenPath;
// 刷新文件列表
ReloadFiles();
}
Expand Down Expand Up @@ -72,5 +81,42 @@ public static string InputDialog(string text, string caption)

return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "";
}

private void FileListBox_MouseMove(object sender, MouseEventArgs e)
{
ListBox listBox = (ListBox)sender;
int index = listBox.IndexFromPoint(e.Location);
// Check if the index is valid.
if (index != -1 && index < listBox.Items.Count)
{
MainToolTip.Active = true;
// Check if the ToolTip's text isn't already the one
// we are now processing.
if (MainToolTip.GetToolTip(listBox) != listBox.Items[index].ToString())
{
// If it isn't, then a new item needs to be
// displayed on the toolTip. Update it.
MainToolTip.SetToolTip(listBox, listBox.Items[index].ToString());
}
} else
{
MainToolTip.Active = false;
}
}

private void CopyrightText_Click(object sender, EventArgs e)
{
Process.Start("https://qwqaq.com/?from=SubtitleRenamer");
}

private void StartEasyBtn_Click(object sender, EventArgs e)
{

}

private void SettingBtn_Click(object sender, EventArgs e)
{
settingForm.ShowDialog();
}
}
}
6 changes: 6 additions & 0 deletions SubtitleRenamer/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="MainToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>42</value>
</metadata>
</root>
62 changes: 62 additions & 0 deletions SubtitleRenamer/MainSettings.Designer.cs

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

15 changes: 15 additions & 0 deletions SubtitleRenamer/MainSettings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SubtitleRenamer" GeneratedClassName="MainSettings">
<Profiles />
<Settings>
<Setting Name="RawSubtitleBuckup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="OpenFolderFinished" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="RenameConfirmDialog" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit 75a5bc2

Please sign in to comment.