mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Code refactoring
This commit is contained in:
parent
cc63d784a6
commit
cd22e384e2
4 changed files with 12 additions and 17 deletions
|
@ -39,9 +39,9 @@ public CLICommand(string command = null, string parameter = null)
|
||||||
Parameter = parameter;
|
Parameter = parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckCommand(string command)
|
public bool CheckCommand(string command, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
return !string.IsNullOrEmpty(Command) && Command.Equals(command, StringComparison.InvariantCultureIgnoreCase);
|
return !string.IsNullOrEmpty(Command) && Command.Equals(command, comparisonType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -285,7 +285,7 @@ public static bool OpenFile(string filePath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OpenFolder(string folderPath)
|
public static bool OpenFolder(string folderPath, bool allowMessageBox = true)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
|
if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
|
||||||
{
|
{
|
||||||
|
@ -316,7 +316,7 @@ public static bool OpenFolder(string folderPath)
|
||||||
DebugHelper.WriteException(e, $"OpenFolder({folderPath}) failed.");
|
DebugHelper.WriteException(e, $"OpenFolder({folderPath}) failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (allowMessageBox)
|
||||||
{
|
{
|
||||||
MessageBox.Show(Resources.Helpers_OpenFolder_Folder_not_exist_ + Environment.NewLine + folderPath, "ShareX",
|
MessageBox.Show(Resources.Helpers_OpenFolder_Folder_not_exist_ + Environment.NewLine + folderPath, "ShareX",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
|
|
@ -198,7 +198,7 @@ private static void Main(string[] args)
|
||||||
|
|
||||||
if (Job.HasFlag(SetupJobs.OpenOutputDirectory))
|
if (Job.HasFlag(SetupJobs.OpenOutputDirectory))
|
||||||
{
|
{
|
||||||
OpenOutputDirectory();
|
FileHelpers.OpenFolder(OutputDir, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("ShareX setup successfully completed.");
|
Console.WriteLine("ShareX setup successfully completed.");
|
||||||
|
@ -238,6 +238,12 @@ private static void CheckArgs(string[] args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetAppVersion()
|
||||||
|
{
|
||||||
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ExecutablePath);
|
||||||
|
return $"{versionInfo.ProductMajorPart}.{versionInfo.ProductMinorPart}.{versionInfo.ProductBuildPart}";
|
||||||
|
}
|
||||||
|
|
||||||
private static void CompileSetup()
|
private static void CompileSetup()
|
||||||
{
|
{
|
||||||
CompileISSFile("Recorder-devices-setup.iss");
|
CompileISSFile("Recorder-devices-setup.iss");
|
||||||
|
@ -366,16 +372,5 @@ private static void DownloadFFmpeg()
|
||||||
ZipManager.Extract(filePath, OutputDir, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase), 200_000_000);
|
ZipManager.Extract(filePath, OutputDir, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase), 200_000_000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OpenOutputDirectory()
|
|
||||||
{
|
|
||||||
Process.Start(OutputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetAppVersion()
|
|
||||||
{
|
|
||||||
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(ExecutablePath);
|
|
||||||
return $"{versionInfo.ProductMajorPart}.{versionInfo.ProductMinorPart}.{versionInfo.ProductBuildPart}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -77,7 +77,7 @@ public static void CopyFiles(string directory, string searchPattern, string toFo
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileName(file);
|
string fileName = Path.GetFileName(file);
|
||||||
|
|
||||||
if (ignoreFiles.All(x => !fileName.Equals(x, StringComparison.InvariantCultureIgnoreCase)))
|
if (ignoreFiles.All(x => !fileName.Equals(x, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
newFiles.Add(file);
|
newFiles.Add(file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue