Skip to content

Commit

Permalink
select file if folder of library file is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Dec 23, 2021
1 parent 111a33f commit 1479b57
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,16 +1327,7 @@ private void SetMessageLabelText(string text = null, MessageBoxIcon icon = Messa

private void lbLibrarySelectionInfo_Click(object sender, EventArgs e)
{
bool isFile = false;
if (string.IsNullOrEmpty(_librarySelectionInfoClickPath)) return;

if (File.Exists(_librarySelectionInfoClickPath))
isFile = true;
else if (!Directory.Exists(_librarySelectionInfoClickPath))
return;

Process.Start("explorer.exe",
$"{(isFile ? "/select, " : string.Empty)}\"{_librarySelectionInfoClickPath}\"");
OpenFolderInExplorer(_librarySelectionInfoClickPath);
}

private void listBoxSpeciesLib_SelectedIndexChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -3116,10 +3107,24 @@ private void StatsMultiplierTesting1_OnApplyMultipliers()

private void openFolderOfCurrentFileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_currentFileName)) return;
string path = Path.GetDirectoryName(_currentFileName);
OpenFolderInExplorer(_currentFileName);
}

/// <summary>
/// Opens the folder in the explorer. If it's a file, it will be selected.
/// </summary>
private static void OpenFolderInExplorer(string path)
{
if (string.IsNullOrEmpty(path)) return;
Process.Start(path);
bool isFile = false;

if (File.Exists(path))
isFile = true;
else if (!Directory.Exists(path))
return;

Process.Start("explorer.exe",
$"{(isFile ? "/select, " : string.Empty)}\"{path}\"");
}

private void customStatOverridesToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 1479b57

Please sign in to comment.