Skip to content

Commit

Permalink
show file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Exsper committed Feb 3, 2024
1 parent 2fb8ed9 commit ad544a0
Show file tree
Hide file tree
Showing 3 changed files with 2,669 additions and 2,594 deletions.
32 changes: 28 additions & 4 deletions LazerFilesViewer/MainForm.Designer.cs

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

97 changes: 74 additions & 23 deletions LazerFilesViewer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public partial class MainForm : Form

string DeleteWarning = "1";
string CleanTemp = "1";
string HideDeleted = "-1";

private RealmConfiguration GetConfiguration()
{
Expand Down Expand Up @@ -147,16 +148,22 @@ private void ShowCurrentDirectory(FakeDirectory d, bool isHistory = false)
ListViewItem item = FileListView.Items.Add(subDirectory.Name, (int)FileListIcons.Folder);
item.Tag = subDirectory;
item.SubItems.Add("文件夹");
item.SubItems.Add("");
item.SubItems.Add(subDirectory.FullName);
item.SubItems.Add("");
}
foreach (FakeFile f in d.ChildFiles)
{
ListViewItem item = FileListView.Items.Add(f.Name, (int)GetIconIndex(f.GetFileType()));
item.Tag = f;
item.SubItems.Add(f.GetFileType());
item.SubItems.Add(f.FullName);
item.SubItems.Add(f.GetFilePath());
bool isExists = File.Exists(LazerFilePath + f.GetFilePath());
if (HideDeleted != "1" || isExists)
{
ListViewItem item = FileListView.Items.Add(f.Name, (int)GetIconIndex(f.GetFileType()));
item.Tag = f;
item.SubItems.Add(f.GetFileType());
item.SubItems.Add(isExists ? "是" : "否");
item.SubItems.Add(f.FullName);
item.SubItems.Add(f.GetFilePath());
}
}
AddressToolStripComboBox.Text = d.FullName;
if (!isHistory) historyControl.AddHistory(CurrentPage.Directory, d.FullName);
Expand All @@ -171,12 +178,14 @@ private void ShowRootDirectory(bool isHistory = false)
item.SubItems.Add("文件夹");
item.SubItems.Add("");
item.SubItems.Add("");
item.SubItems.Add("");

item = FileListView.Items.Add("Skins", (int)FileListIcons.Folder);
item.Tag = Skins;
item.SubItems.Add("文件夹");
item.SubItems.Add("");
item.SubItems.Add("");
item.SubItems.Add("");
AddressToolStripComboBox.Text = "\\";
if (!isHistory) historyControl.AddHistory(CurrentPage.Directory, "\\");
CheckButtonEnable();
Expand Down Expand Up @@ -256,6 +265,8 @@ private void MainForm_Load(object sender, EventArgs e)
DeleteWarningStripMenuItem.Checked = (DeleteWarning == "1") ? true : false;
CleanTemp = ConfigurationManager.AppSettings["CleanTemp"] ?? CleanTemp;
CleanTempStripMenuItem.Checked = (CleanTemp == "1") ? true : false;
HideDeleted = ConfigurationManager.AppSettings["HideDeleted"] ?? HideDeleted;
HideDeletedStripMenuItem.Checked = (HideDeleted == "1") ? true : false;
if (CleanTemp == "1")
{
try
Expand Down Expand Up @@ -549,22 +560,32 @@ private void ViewerContextMenuStrip_Opening(object sender, System.ComponentModel
}


private void Reload()
private void Reload(bool reloadDataBase = true)
{
string nowpath = AddressToolStripComboBox.Text;
try
HistoryPoint hp = historyControl.GetCurrentHistoryPoint();
if (reloadDataBase)
{
BuildDirectories();
}
catch (Exception ex)
{
DialogResult result = MessageBox.Show("读取数据库错误!\r\n" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (result == DialogResult.OK)
try
{
Close();
BuildDirectories();
}
catch (Exception ex)
{
DialogResult result = MessageBox.Show("读取数据库错误!\r\n" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (result == DialogResult.OK)
{
Close();
}
}
}
OpenPath(nowpath);
if (hp.CurrentPage == CurrentPage.Search)
{
Search(hp.Content, true);
}
else if (hp.CurrentPage == CurrentPage.Directory)
{
OpenPath(hp.Content, true);
}
}

private void TSMI_File_Temp_Open_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -705,7 +726,7 @@ private void DeleteSelected()
string sourcePath = LazerFilePath + ff.GetFilePath();
FileSystem.DeleteFile(sourcePath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
}
Reload();
Reload(false);
Process p = new Process();
p.StartInfo.FileName = "explorer.exe";
p.StartInfo.Arguments = "shell:RecycleBinFolder";
Expand Down Expand Up @@ -783,7 +804,7 @@ private void TSMI_Folder_EnableMulti_Copy_Click(object sender, EventArgs e)

private void ReloadToolStripButton_Click(object sender, EventArgs e)
{
Reload();
Reload(true);
}

private void TSMI_Mix_EnableMulti_Copy_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -884,16 +905,22 @@ private void Search(string searchText, bool isHistory = false)
ListViewItem item = FileListView.Items.Add(dir.Name, (int)FileListIcons.Folder);
item.Tag = dir;
item.SubItems.Add("文件夹");
item.SubItems.Add("");
item.SubItems.Add(dir.FullName);
item.SubItems.Add("");
}
foreach (FakeFile f in files)
{
ListViewItem item = FileListView.Items.Add(f.Name, (int)GetIconIndex(f.GetFileType()));
item.Tag = f;
item.SubItems.Add(f.GetFileType());
item.SubItems.Add(f.FullName);
item.SubItems.Add(f.GetFilePath());
bool isExists = File.Exists(LazerFilePath + f.GetFilePath());
if (HideDeleted != "1" || isExists)
{
ListViewItem item = FileListView.Items.Add(f.Name, (int)GetIconIndex(f.GetFileType()));
item.Tag = f;
item.SubItems.Add(f.GetFileType());
item.SubItems.Add(isExists ? "是" : "否");
item.SubItems.Add(f.FullName);
item.SubItems.Add(f.GetFilePath());
}
}
AddressToolStripComboBox.Text = "搜索结果";
if (!isHistory) historyControl.AddHistory(CurrentPage.Search, searchText);
Expand Down Expand Up @@ -979,6 +1006,11 @@ private void SetDatabasePathToolStripMenuItem_Click(object sender, EventArgs e)
OpenPath("");
}

private void TSMI_Empty_Reload_Click(object sender, EventArgs e)
{
Reload(true);
}

private void DeleteWarningStripMenuItem_Click(object sender, EventArgs e)
{
if (DeleteWarning == "1") DeleteWarning = "-1";
Expand All @@ -992,6 +1024,14 @@ private void CleanTempStripMenuItem_Click(object sender, EventArgs e)
else CleanTemp = "1";
AddUpdateAppSettings("CleanTemp", CleanTemp);
}

private void HideDeletedStripMenuItem_Click(object sender, EventArgs e)
{
if (HideDeleted == "1") HideDeleted = "-1";
else HideDeleted = "1";
AddUpdateAppSettings("HideDeleted", HideDeleted);
Reload(false);
}
}

public class SelectedItemsList
Expand Down Expand Up @@ -1083,6 +1123,17 @@ private void RemoveAfter()
return null;
}
}
public HistoryPoint? GetCurrentHistoryPoint()
{
if (CurrentIndex >= 0)
{
return HistoryPoints[CurrentIndex];
}
else
{
return null;
}
}
public void AddHistory(CurrentPage currentPage, string content)
{
if (CurrentIndex >= 0)
Expand Down
Loading

0 comments on commit ad544a0

Please sign in to comment.