Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-techkid committed Sep 10, 2022
1 parent 4aa6a68 commit cfe0e4e
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 73 deletions.
2 changes: 1 addition & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<configuration>
<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
</configuration>
2 changes: 1 addition & 1 deletion CabMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CabMaker</RootNamespace>
<AssemblyName>CabMaker</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down
12 changes: 8 additions & 4 deletions Form1.Designer.cs

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

147 changes: 84 additions & 63 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public Form1()
}

int jobFiles = 0;
int successFiles = 0;
string txtTargetDir = "";
bool proceed = true;

private bool IncludeCompressionWindowSize =>
!Constants.DefaultCompressionType.ToString().Equals(DropdownCompressType.Items[DropdownCompressType.SelectedIndex]) &&
Expand All @@ -32,7 +34,8 @@ private void ClearFiles_Click(object sender, EventArgs e)
{
FilesListBox.Items.Clear();
jobFiles = 0;
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported";
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported!";
GroupBoxFiles.Text = "Files";
}

private void SelectAllFiles_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -70,8 +73,8 @@ private void AddFolder_Click(object sender, EventArgs e)
FilesListBox.Items.Add(fileName, true);
jobFiles += 1;
}
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported";
LabelOutputStatus.ForeColor = Color.OrangeRed;
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported!";
GroupBoxFiles.Text = "Files" + " [" + jobFiles + " Imported]";
}
catch { }
}
Expand All @@ -92,8 +95,8 @@ private void AddFile_Click(object sender, EventArgs e)
FilesListBox.Items.Add(fileName, true);
jobFiles += 1;
}
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported";
LabelOutputStatus.ForeColor = Color.Green;
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported!";
GroupBoxFiles.Text = "Files [" + jobFiles + " Files Imported]";
}
}

Expand Down Expand Up @@ -125,7 +128,7 @@ private void ButtonClear_Click(object sender, EventArgs e)
txtTargetDir = "";
TextOutputFile.Text = "";
TextRootDirectory.Text = "";
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported";
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported!";
}

private void ButtonExport_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -156,25 +159,22 @@ private List<DdfFileRow> GetFiles(string RootDir)

private void ButtonRun_Click(object sender, EventArgs e)
{
// Disables form UI elements
// Disable form UI elements
DisableForm(true);

jobFiles = FilesListBox.CheckedItems.Count; // Sets count of checked file list to jobFiles
LabelOutputStatus.Text = "[JOB] Compressing " + jobFiles + " Files to CAB"; // Sends jobFiles to statusBar
LabelOutputStatus.ForeColor = Color.OrangeRed;
LabelOutputStatus.Text = "[JOB] Compressing " + jobFiles + " File(s) to CAB..."; // Sends jobFiles to statusBar
TextOutput.ForeColor = SystemColors.WindowText;

if (String.IsNullOrWhiteSpace(TextOutputFile.Text))
{
// If TextOutputFile is empty
LabelOutputStatus.Text = "[ERROR] Please Specify a Target File";
LabelOutputStatus.ForeColor = Color.Red;
LabelOutputStatus.Text = "[ERR] Please Specify a Target File!";
}
else if (String.IsNullOrWhiteSpace(DropdownCompressType.Text))
{
// If DropdownCompressType is empty
LabelOutputStatus.Text = "[ERROR] Please Specify a Compression Type";
LabelOutputStatus.ForeColor = Color.Red;
LabelOutputStatus.Text = "[ERR] Please Specify a Compression Type!";
}
else
// If TextOutputFile and DropdownCompressType are selected
Expand Down Expand Up @@ -213,8 +213,9 @@ .OPTION EXPLICIT
if (String.IsNullOrWhiteSpace(TextRootDirectory.Text))
{
// If there is nothing in TextRootDirectory
foreach (string fileName in FilesListBox.Items)
foreach (string fileName in FilesListBox.SelectedItems)
{
proceed = true;
ddf.AppendFormat($"{fileName.EnsureQuoted()}{Environment.NewLine}");
}
}
Expand All @@ -225,59 +226,76 @@ .OPTION EXPLICIT
List<DdfFileRow> ddfFiles = GetFiles(TextRootDirectory.Text);
foreach (var ddfFile in ddfFiles.Take(maxFiles))
{
ddf.AppendFormat("\"{0}\" \"{1}\"{2}", ddfFile.FullName, ddfFile.Path, Environment.NewLine);
if (ddfFile.FullName.Contains(TextRootDirectory.Text))
{
proceed = true;
successFiles += 1;
ddf.AppendFormat("\"{0}\" \"{1}\"{2}", ddfFile.FullName, ddfFile.Path, Environment.NewLine);
}
else
{
// janky, perhaps attach a false bool to if statement below
proceed = false;
successFiles = 0;
}
}
}

File.WriteAllText(ddfPath, ddf.ToString(), Encoding.Default);
if (proceed == true)
{
File.WriteAllText(ddfPath, ddf.ToString(), Encoding.Default);

string cmd = String.Format("/f {0}", ddfPath.EnsureQuoted());
string cmd = String.Format("/f {0}", ddfPath.EnsureQuoted());

// Run "makecab.exe"
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
CreateNoWindow = true,
FileName = "makecab.exe",
Arguments = cmd,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
process.StartInfo = startInfo;

process.ErrorDataReceived += Process_ErrorDataReceived;
process.OutputDataReceived += Process_OutputDataReceived;

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();

TextOutput.AppendText("Exit code: " + process.ExitCode);

if (process.ExitCode == EXIT_CODE_SUCCESS)
{
File.SetLastWriteTime((TextOutputFile.Text), DateTime.Now);
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Added to CAB Successfully";
LabelOutputStatus.ForeColor = Color.Green;
// Run "makecab.exe"
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
CreateNoWindow = true,
FileName = "makecab.exe",
Arguments = cmd,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
process.StartInfo = startInfo;

process.ErrorDataReceived += Process_ErrorDataReceived;
process.OutputDataReceived += Process_OutputDataReceived;

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();

TextOutput.AppendText("Exit code: " + process.ExitCode);

if (process.ExitCode == EXIT_CODE_SUCCESS)
{
File.SetLastWriteTime((TextOutputFile.Text), DateTime.Now);
LabelOutputStatus.Text = "[JOB] " + successFiles + " of " + jobFiles + " File(s) Successfully Sent to CAB!";
}
else
{
LabelOutputStatus.Text = "[ERR] Error Creating CAB File. Check the Log for Details!";
}
}
else
{
LabelOutputStatus.Text = "[JOB] CAB File could not be created. Check the Log for Details";
LabelOutputStatus.ForeColor = Color.Red;
LabelOutputStatus.Text = "[ERR] CAB Root DIR is Out of Range!";
}

}
catch (Exception ex)
{
LabelOutputStatus.Text = "[JOB] CAB File could not be created. Check the Log for Details";
LabelOutputStatus.ForeColor = Color.Red;
TextOutput.AppendText("[Error] " + ex.ToString());
LabelOutputStatus.Text = "[ERR] Error Creating CAB File. Check the Log for Details!";
TextOutput.AppendText("Exit code: " + ex.ToString());
TextOutput.ForeColor = Color.Red;
}
}
// Enabled form UI elements
// Enable form UI elements
DisableForm(false);
successFiles = 0;
}

private void DisableForm(bool disable)
Expand Down Expand Up @@ -361,7 +379,8 @@ private void Form1_Load(object sender, EventArgs e)
DropdownCompressType.SelectedItem = Constants.DefaultCompressionType;
DropdownCompressMemory.SelectedValue = Constants.DefaultCompressionWindowSize.Exponent;
}
LabelVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(2);
LabelVersion.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString(2);
LabelOutputStatus.Text = "[JOB] " + jobFiles + " Files Imported!";
}

private void DropdownCompressType_SelectedIndexChanged(object sender, EventArgs e)
Expand All @@ -371,16 +390,6 @@ private void DropdownCompressType_SelectedIndexChanged(object sender, EventArgs
LabelCompressionMemory.Visible = IncludeCompressionWindowSize;
}











private void Exit_Click(object sender, EventArgs e)
{
this.Close();
Expand All @@ -389,7 +398,7 @@ private void Exit_Click(object sender, EventArgs e)
private void MenuSave_Click(object sender, EventArgs e)
{
SaveSettings(true);
LabelOutputStatus.Text = "[CabMaker] Compressor Settings Saved";
LabelOutputStatus.Text = "[CabMaker] Compressor Settings Saved!";
}

private void MenuAbout_Click(object sender, EventArgs e)
Expand All @@ -401,5 +410,17 @@ private void MenuHelp_Click(object sender, EventArgs e)
{
MessageBox.Show("Help with CabMaker 1.3" + Environment.NewLine + Environment.NewLine + "Use the 'Add Folder' and 'Add File' buttons in the 'Files' area to add files for your Cabinet into the list box below. When you have added all your input files, go down to the 'Compressor' group, and browse for the location of the 'Output File', where your CAB will be saved. Additionally, If your CAB will contain subfolders, browse for the path of the first folder with 'CAB Root Dir'. When you are ready, select the type of compression the CAB will have (None, MSZIP, or LZX), and click 'Make CAB'. If you wish to save the settings used with the Compressor group, you can check the 'Save on Exit' box, or save the settings manually in the Menu.", "Help", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}

private void CheckSaveSettings_CheckedChanged(object sender, EventArgs e)
{
if (CheckSaveSettings.Checked == true)
{
LabelOutputStatus.Text = "[CabMaker] Compressor Settings Will Save on Exit";
}
else if (CheckSaveSettings.Checked == false)
{
LabelOutputStatus.Text = "[CabMaker] Compressor Settings Won't Save on Exit";
}
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
2 changes: 1 addition & 1 deletion Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion Properties/Settings.Designer.cs

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

0 comments on commit cfe0e4e

Please sign in to comment.