commit 7255962f43e01bd5b5c022ad71d1061475c5a446 Author: dunestorm Date: Tue Mar 5 22:15:27 2019 +0000 Imported final version of OpenPackager diff --git a/.vs/OpenPackager/v14/.suo b/.vs/OpenPackager/v14/.suo new file mode 100644 index 0000000..85bca06 Binary files /dev/null and b/.vs/OpenPackager/v14/.suo differ diff --git a/ClearCache.bat b/ClearCache.bat new file mode 100644 index 0000000..e4c68d8 --- /dev/null +++ b/ClearCache.bat @@ -0,0 +1,7 @@ +@echo off +echo Clearing cache... +cd OpenPackager +rmdir /S /Q obj +rmdir /S /Q bin\Debug +echo Existing cache has been cleared! +pause \ No newline at end of file diff --git a/OpenPackager.sln b/OpenPackager.sln new file mode 100644 index 0000000..8b327b5 --- /dev/null +++ b/OpenPackager.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPackager", "OpenPackager\OpenPackager.csproj", "{656D7B60-8CBF-4139-A28B-443FEBA70D4E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {656D7B60-8CBF-4139-A28B-443FEBA70D4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {656D7B60-8CBF-4139-A28B-443FEBA70D4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {656D7B60-8CBF-4139-A28B-443FEBA70D4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {656D7B60-8CBF-4139-A28B-443FEBA70D4E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/OpenPackager.v12.suo b/OpenPackager.v12.suo new file mode 100644 index 0000000..ffff6f9 Binary files /dev/null and b/OpenPackager.v12.suo differ diff --git a/OpenPackager.v12.suo.doc b/OpenPackager.v12.suo.doc new file mode 100644 index 0000000..305265e Binary files /dev/null and b/OpenPackager.v12.suo.doc differ diff --git a/OpenPackager/App.config b/OpenPackager/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/OpenPackager/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OpenPackager/App.xaml b/OpenPackager/App.xaml new file mode 100644 index 0000000..7feaa21 --- /dev/null +++ b/OpenPackager/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/OpenPackager/App.xaml.cs b/OpenPackager/App.xaml.cs new file mode 100644 index 0000000..ada54d4 --- /dev/null +++ b/OpenPackager/App.xaml.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace OpenPackager +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + + } +} diff --git a/OpenPackager/Components/CommonIO.cs b/OpenPackager/Components/CommonIO.cs new file mode 100644 index 0000000..85277c6 --- /dev/null +++ b/OpenPackager/Components/CommonIO.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenPackager +{ + /// + /// Provides common IO functionality via Windows Forms. + /// + public class CommonIO + { + /// + /// Browse to existing folder on the system. + /// + /// + /// + public string BrowseFolder(string originalPath) + { + // The result of the Windows Forms dialog is passed as a + // string to the method caller. + var folder = new System.Windows.Forms.FolderBrowserDialog(); + System.Windows.Forms.DialogResult result = folder.ShowDialog(); + + // Only change the value if a valid path is entered. + string newPath; + if (folder.SelectedPath != "") + { + newPath = folder.SelectedPath.ToString(); + } + else + { + newPath = originalPath; + } + + return newPath; + } + + /// + /// Browse to an existing file on the system. + /// + /// + /// + public string BrowseFile(string fileType) + { + var file = new System.Windows.Forms.OpenFileDialog(); + file.Filter = null; + + switch (fileType) + { + case "image": + file.Filter = "PNG Image|*.png|JPG Image|*.jpg"; + break; + case "bat": + file.Filter = "Batch File|*.bat"; + break; + case "txt": + file.Filter = "Text File|*.txt"; + break; + case "ico": + file.Filter = "Icon File|*.ico"; + break; + } + + System.Windows.Forms.DialogResult result = file.ShowDialog(); + + return file.FileName.ToString(); + } + + + } +} diff --git a/OpenPackager/Components/LMZAParser.cs b/OpenPackager/Components/LMZAParser.cs new file mode 100644 index 0000000..bec4a90 --- /dev/null +++ b/OpenPackager/Components/LMZAParser.cs @@ -0,0 +1,159 @@ +using OpenPackager; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; + +namespace LMZAParser +{ + public class Parser + { + public Process proc = new Process(); + bool abortProcess = false; + + public int MakePackage(string fileName, string sourceDir, string destDir, int compressLvl, string password, bool sfx) + { + string argMethod = " a "; + Func argSourceDir = SourceDir; + Func argDestDir = DestDir; + Func argCompressLvl = CompressLvl; + Func argPassword = Password; + Func argSfx = Sfx; + + return RunProcess(argMethod + + argSfx(sfx) + + argDestDir(destDir, fileName) + + argPassword(password) + + argSourceDir(sourceDir) + + argCompressLvl(compressLvl)); + } + #region MakePackage + + private string Sfx(bool arg) + { + // Appends SFX parameter to archive. + string result = null; + if (arg) + { + result = "-sfx"; + } + + return result; + } + + private string CompressLvl(int arg) + { + return String.Format("-mx={0}", arg.ToString()); + } + + private string DestDir(string path, string file) + { + // Combines the path and filename into one. + return String.Format("\"{0}\\{1}\" ", path, file); + } + + private string SourceDir(string arg) + { + return String.Format("\"{0}\\*\" ", arg); + } + + private string Password(string pass) + { + string result = null; + if (pass != "") { result += String.Format("-p{0} -mhe ", pass); } + + return result; + } + + #endregion + + public int ExtractPackage(string fileName, string inDir, string outDir, string password) + { + int exitCode = 0; + + // Test archive before attempting to extract it + exitCode += TestArchive(fileName, inDir, password); + if (exitCode == 0) + { + string argMethod = " x "; + //Func argSourceDir = SourceDir; + //Func argDestDir = DestDir; + Func argInDir = InDir; + Func argOutDir = OutDir; + Func argOutPassword = OutPassword; + + RunProcess(argMethod + + argInDir(inDir, fileName) + + argOutPassword(password) + + argOutDir(outDir)); + } + + return exitCode; + } + #region ExtractPackage + + private string OutDir(string path) + { + return String.Format("-o\"{0}\" ", path); + } + + private string InDir(string path, string file) + { + return String.Format("\"{0}\\{1}\" -aoa ", path, file); + } + + private string OutPassword(string pass) + { + return String.Format("-p{0} ", pass); + } + + #endregion + + private int TestArchive(string fileName, string inDir, string password) + { + string argMethod = " t "; + Func argInDir = InDir; + Func argOutPassword = OutPassword; + + return RunProcess(argMethod + + argInDir(inDir, fileName) + + argOutPassword(password)); + } + + private int RunProcess(string args) + { + int exitCode = 0; + + try + { + proc.StartInfo.FileName = SysEnvironment.szExe; + proc.StartInfo.WorkingDirectory = SysEnvironment.szWorkDir; + proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + /// + proc.StartInfo.Arguments = args; + + proc.Start(); + while (!proc.HasExited) + { + Thread.Sleep(1000); + Console.WriteLine("Process is alive..."); + if (abortProcess) { proc.Kill(); } + } + + exitCode = proc.ExitCode; + } + catch (Exception) + { + exitCode = 1; + proc.Dispose(); + } + + return exitCode; + } + + public void Abort() { abortProcess = true; } + } +} diff --git a/OpenPackager/Components/LogWriter.cs b/OpenPackager/Components/LogWriter.cs new file mode 100644 index 0000000..80ad438 --- /dev/null +++ b/OpenPackager/Components/LogWriter.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Threading; + +namespace OpenPackager.LogWriter +{ + public class Writer + { + public enum logEntries + { + StartPkgCreation, + GenPkgStructure, + ImportResources, + PackageCancelled, + XmlGeneration, + CreateOPF, + CreatedOPF, + SevenZPkgError, + FinalOperations, + FinishedNoErrors, + FinishedWithErrors, + FinishReadXml, + ErrorReadXml, + InstallAborted, + ErrorWriteToDisk, + ExtractError, + ExtractSizeMismatch, + InstallFailure, + ExternalScriptError, + InstallSuccess + } + + public string Records(logEntries le, string str, int i) + { + string currentDateTime = Convert.ToString(DateTime.Now.ToShortDateString() + " " + + DateTime.Now.ToLongTimeString()); + string currentRecord = currentDateTime + " - "; + + switch (le) + { + case logEntries.StartPkgCreation: + currentRecord += "Started creation of package: " + str; + break; + case logEntries.GenPkgStructure: + currentRecord += "Finished generating internal structure of package"; + break; + case logEntries.ImportResources: + currentRecord += "Resource import complete, total resources: " + i.ToString(); + break; + case logEntries.PackageCancelled: + currentRecord += "ERROR: Package creation was cancelled by the user!"; + break; + case logEntries.XmlGeneration: + currentRecord += "Setup XML file has been created successfully"; + break; + case logEntries.CreateOPF: + currentRecord += "Compressing package..."; + break; + case logEntries.CreatedOPF: + currentRecord += "Finished compressing package"; + break; + case logEntries.SevenZPkgError: + currentRecord += "ERROR: There was a problem trying to compress the package"; + break; + case logEntries.FinalOperations: + currentRecord += "Performing post operation: " + i.ToString(); + break; + case logEntries.FinishedNoErrors: + currentRecord += "Finished creating OPF without any errors"; + break; + case logEntries.FinishedWithErrors: + currentRecord += "ERROR: An unknown problem occurred whilst finalising the package"; + break; + case logEntries.FinishReadXml: + currentRecord += "Successfully imported XML file without any errors."; + break; + case logEntries.ErrorReadXml: + currentRecord += "ERROR: Could not parse XML: " + str; + break; + case logEntries.InstallAborted: + currentRecord += "ERROR: Installation was cancelled by the user."; + break; + case logEntries.ErrorWriteToDisk: + currentRecord += "ERROR: Unable to write to disk, no permission to write to specified directory/drive: " + str; + break; + case logEntries.ExtractError: + currentRecord += "ERROR: The archive cannot be extracted. Verify the password is correct and 7-zip is installed."; + break; + case logEntries.ExtractSizeMismatch: + currentRecord += "ERROR: There is a mismatch between the original package size and the output."; + break; + case logEntries.InstallFailure: + currentRecord += "ERROR: The installation has failed with one or more errors."; + break; + case logEntries.ExternalScriptError: + currentRecord += "ERROR: An external script has returned with error code: " + str; + break; + case logEntries.InstallSuccess: + currentRecord += String.Format("Installation for {0} has completed successfully!", str); + break; + + } + + return currentRecord; + } + + /// + /// Write out current entry to specified log file. Recommended to run + /// from outside main thread for performance reasons. + /// + /// Text to write + /// Location to write log + public void WriteOutLog(string currentEntry, string logLocation) + { + if (!Directory.Exists(SysEnvironment.workingDir)) + { Directory.CreateDirectory(SysEnvironment.workingDir); } + + // Streamwriter must append all entries or it will overwrite entries with + // the latest only. + using (StreamWriter writer = File.AppendText(logLocation)) + { + writer.WriteLine(currentEntry); + writer.Close(); + } + } + } +} diff --git a/OpenPackager/Components/MessageHandler.cs b/OpenPackager/Components/MessageHandler.cs new file mode 100644 index 0000000..f854eda --- /dev/null +++ b/OpenPackager/Components/MessageHandler.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace OpenPackager +{ + public class MessageHandler + { + + // Call error messages by specifying an enum code + public enum msgCodes + { + ERR_Test, + ERR_PackageCreationFail, + ERR_PackageValidation, + INF_CreationWiz2_PkgValidated, + INF_NotYetImplemented, + INF_CreationWiz2_FinishedNoErr, + ERR_ShutdownCleanupFailed, + ERR_XMLError, + ERR_InstallerWiz1_BadDir, + ERR_InstallerWiz1__LicAgreementNotAccepted, + Err_InstallerWiz2_InstallAborted, + Err_InstallerWiz2_ExtractError, + Err_InstallerWiz2_BadPackage, + Err_InstallerWiz2_FSAccessError + } + + /// + /// Create an error message dialogue box. + /// + /// + /// + internal void errorMessage(msgCodes mc, string info) + { + switch (mc) + { + case msgCodes.ERR_Test: + MessageBox.Show("This is a sample error message", "Sample Error Message", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.ERR_PackageCreationFail: + MessageBox.Show("Package creation failed with one or more errors.", + "Package Failed", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.ERR_PackageValidation: + MessageBox.Show("One or more entries are invalid; please check the parameters specified for this package and try again. Errors detected have been highlighted to your left in yellow.", + "Invalid Parameters", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.ERR_ShutdownCleanupFailed: + MessageBox.Show("There was a problem shutting down Open Packager, please ensure you have administrative privileges.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.ERR_XMLError: + MessageBox.Show("Unable to read configuration file for package. This archive may be corrupt or invalid.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Exclamation); + break; + case msgCodes.ERR_InstallerWiz1_BadDir: + MessageBox.Show("The path you've specified is invalid.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.ERR_InstallerWiz1__LicAgreementNotAccepted: + MessageBox.Show("You must accept the licence agreement to continue.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Exclamation); + break; + case msgCodes.Err_InstallerWiz2_InstallAborted: + MessageBox.Show("The installation has been aborted.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Exclamation); + break; + case msgCodes.Err_InstallerWiz2_ExtractError: + MessageBox.Show("There was a problem extracting the package. If password protected, ensure the password is correct and that 7-Zip is installed.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Exclamation); + break; + case msgCodes.Err_InstallerWiz2_BadPackage: + MessageBox.Show(String.Format("There is a problem with the consistency of {0}. Please obtain a new copy.", info), + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Error); + break; + case msgCodes.Err_InstallerWiz2_FSAccessError: + MessageBox.Show("Unable to write to disk, ensure you are running as an Administrator.", + "Open Packager", MessageBoxButton.OK, MessageBoxImage.Error); + break; + } + + } + + /// + /// Create an informational message dialogue box. + /// + /// + /// + /// + internal int stdMessage(msgCodes mc, string info) + { + switch(mc) + { + case msgCodes.INF_CreationWiz2_PkgValidated: + MessageBoxResult msb = MessageBox.Show("Your package is now ready to be created! Click the Create Package button to proceed.", "Package Ready", + MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (msb == MessageBoxResult.OK) + { + return 1; // Return non-default response + } + break; + case msgCodes.INF_NotYetImplemented: + MessageBox.Show("This feature has not yet been implemented.", "Information", MessageBoxButton.OK, MessageBoxImage.Stop); + break; + case msgCodes.INF_CreationWiz2_FinishedNoErr: + MessageBox.Show("Your package was created successfully!", + "Package Created", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + return 0; // Return default response + } + } +} diff --git a/OpenPackager/Components/WinIntegration.cs b/OpenPackager/Components/WinIntegration.cs new file mode 100644 index 0000000..1385faf --- /dev/null +++ b/OpenPackager/Components/WinIntegration.cs @@ -0,0 +1,21 @@ +using System.IO; +using IWshRuntimeLibrary; + +namespace OpenPackager.Components +{ + public partial class WinIntegration + { + public void CreateShortcut(string shortcutName, string shortcutFile, string shortcutDir, string targetDir, string icon) + { + string targetLocation = Path.Combine(shortcutDir, shortcutFile); + string shortcutLocation = Path.Combine(targetDir, shortcutName + ".lnk"); + WshShell shell = new WshShell(); + IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation); + + shortcut.WorkingDirectory = shortcutDir; + if (icon != null) shortcut.IconLocation = icon; + shortcut.TargetPath = targetLocation; + shortcut.Save(); + } + } +} diff --git a/OpenPackager/Dialogs/AboutBox.Designer.cs b/OpenPackager/Dialogs/AboutBox.Designer.cs new file mode 100644 index 0000000..1ae56fc --- /dev/null +++ b/OpenPackager/Dialogs/AboutBox.Designer.cs @@ -0,0 +1,170 @@ +namespace OpenPackager.Dialogs +{ + partial class AboutBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.logoPictureBox = new System.Windows.Forms.PictureBox(); + this.labelProductName = new System.Windows.Forms.Label(); + this.labelVersion = new System.Windows.Forms.Label(); + this.labelCopyright = new System.Windows.Forms.Label(); + this.labelCompanyName = new System.Windows.Forms.Label(); + this.textBoxDescription = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit(); + this.SuspendLayout(); + // + // tableLayoutPanel + // + this.tableLayoutPanel.ColumnCount = 2; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67F)); + this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); + this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); + this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); + this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2); + this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3); + this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 5; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(417, 265); + this.tableLayoutPanel.TabIndex = 0; + // + // logoPictureBox + // + this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.logoPictureBox.Image = global::OpenPackager.Properties.Resources.LogoV21; + this.logoPictureBox.Location = new System.Drawing.Point(3, 3); + this.logoPictureBox.Name = "logoPictureBox"; + this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 5); + this.logoPictureBox.Size = new System.Drawing.Size(131, 259); + this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.logoPictureBox.TabIndex = 12; + this.logoPictureBox.TabStop = false; + // + // labelProductName + // + this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelProductName.Location = new System.Drawing.Point(143, 0); + this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17); + this.labelProductName.Name = "labelProductName"; + this.labelProductName.Size = new System.Drawing.Size(271, 17); + this.labelProductName.TabIndex = 19; + this.labelProductName.Text = "Product Name"; + this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // labelVersion + // + this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelVersion.Location = new System.Drawing.Point(143, 29); + this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17); + this.labelVersion.Name = "labelVersion"; + this.labelVersion.Size = new System.Drawing.Size(271, 17); + this.labelVersion.TabIndex = 0; + this.labelVersion.Text = "Version"; + this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // labelCopyright + // + this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCopyright.Location = new System.Drawing.Point(143, 58); + this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17); + this.labelCopyright.Name = "labelCopyright"; + this.labelCopyright.Size = new System.Drawing.Size(271, 17); + this.labelCopyright.TabIndex = 21; + this.labelCopyright.Text = "Copyright"; + this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // labelCompanyName + // + this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCompanyName.Location = new System.Drawing.Point(143, 87); + this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); + this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17); + this.labelCompanyName.Name = "labelCompanyName"; + this.labelCompanyName.Size = new System.Drawing.Size(271, 17); + this.labelCompanyName.TabIndex = 22; + this.labelCompanyName.Text = "Company Name"; + this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBoxDescription + // + this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBoxDescription.Location = new System.Drawing.Point(143, 119); + this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); + this.textBoxDescription.Multiline = true; + this.textBoxDescription.Name = "textBoxDescription"; + this.textBoxDescription.ReadOnly = true; + this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxDescription.Size = new System.Drawing.Size(271, 143); + this.textBoxDescription.TabIndex = 23; + this.textBoxDescription.TabStop = false; + this.textBoxDescription.Text = "Description"; + // + // AboutBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(435, 283); + this.Controls.Add(this.tableLayoutPanel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AboutBox"; + this.Padding = new System.Windows.Forms.Padding(9); + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "About"; + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + private System.Windows.Forms.PictureBox logoPictureBox; + private System.Windows.Forms.Label labelProductName; + private System.Windows.Forms.Label labelVersion; + private System.Windows.Forms.Label labelCopyright; + private System.Windows.Forms.Label labelCompanyName; + private System.Windows.Forms.TextBox textBoxDescription; + } +} diff --git a/OpenPackager/Dialogs/AboutBox.cs b/OpenPackager/Dialogs/AboutBox.cs new file mode 100644 index 0000000..8224114 --- /dev/null +++ b/OpenPackager/Dialogs/AboutBox.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OpenPackager.Dialogs +{ + partial class AboutBox : Form + { + public AboutBox() + { + InitializeComponent(); + this.Text = String.Format("About {0}", AssemblyTitle); + this.labelProductName.Text = AssemblyProduct; + this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); + this.labelCopyright.Text = "Free Software - GPL V3"; + this.labelCompanyName.Text = AssemblyCompany; + this.textBoxDescription.Text = AssemblyDescription; + } + + #region Assembly Attribute Accessors + + public string AssemblyTitle + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + if (attributes.Length > 0) + { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; + if (titleAttribute.Title != "") + { + return titleAttribute.Title; + } + } + return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); + } + } + + public string AssemblyVersion + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + + public string AssemblyDescription + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyDescriptionAttribute)attributes[0]).Description; + } + } + + public string AssemblyProduct + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyProductAttribute)attributes[0]).Product; + } + } + + public string AssemblyCopyright + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + } + + public string AssemblyCompany + { + get + { + object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); + if (attributes.Length == 0) + { + return ""; + } + return ((AssemblyCompanyAttribute)attributes[0]).Company; + } + } + #endregion + } +} diff --git a/OpenPackager/Dialogs/AboutBox.resx b/OpenPackager/Dialogs/AboutBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OpenPackager/Dialogs/AboutBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpenPackager/Dialogs/PasswordEntry.xaml b/OpenPackager/Dialogs/PasswordEntry.xaml new file mode 100644 index 0000000..bb19bad --- /dev/null +++ b/OpenPackager/Dialogs/PasswordEntry.xaml @@ -0,0 +1,19 @@ + + + +