diff --git a/MicronSync/Components/Forms/ChangeLog.Designer.cs b/MicronSync/Components/Forms/ChangeLog.Designer.cs index 5b7f845..cb138c9 100644 --- a/MicronSync/Components/Forms/ChangeLog.Designer.cs +++ b/MicronSync/Components/Forms/ChangeLog.Designer.cs @@ -42,7 +42,7 @@ this.richTextBox.Location = new System.Drawing.Point(13, 38); this.richTextBox.Name = "richTextBox"; this.richTextBox.ReadOnly = true; - this.richTextBox.Size = new System.Drawing.Size(359, 361); + this.richTextBox.Size = new System.Drawing.Size(679, 360); this.richTextBox.TabIndex = 0; this.richTextBox.Text = ""; // @@ -60,7 +60,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(384, 412); + this.ClientSize = new System.Drawing.Size(704, 411); this.Controls.Add(this.labelVersionInfo); this.Controls.Add(this.richTextBox); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/MicronSync/Components/Forms/ChangeLog.txt b/MicronSync/Components/Forms/ChangeLog.txt index 47ba559..c74c2a5 100644 --- a/MicronSync/Components/Forms/ChangeLog.txt +++ b/MicronSync/Components/Forms/ChangeLog.txt @@ -1,4 +1,18 @@ [New Features] +- Browse directly to any of the backup and restore paths with a conveniently placed shortcut. +- Restore backups can now be triggered every time a restore operation is run. +- Choose between dark and light themes which are persistent on the system.. + +[Enhancements] +- Ability to resize main window horizontally for easier legibility of long paths. Horizontal window size is +also stored in a per config basis to accommodate different jobs. + +[MicronSync 1.2.5.1]------------------------------------------------------------------------------- +[Enhancements] +- MicronSync now notifies you when importing an invalid or bad configuration file. + +[MicronSync 1.2.5.0]------------------------------------------------------------------------------- +[New Features] - The size of the source backup directory can now be calculated within MicronSync. - Backups created can have their size shown once calculated from the restore tab. diff --git a/MicronSync/Components/Forms/WorkerUI.cs b/MicronSync/Components/Forms/WorkerUI.cs index 0b7e7c3..d14d68e 100644 --- a/MicronSync/Components/Forms/WorkerUI.cs +++ b/MicronSync/Components/Forms/WorkerUI.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Diagnostics; using System.IO; +using System.Threading; using System.Windows.Forms; namespace MicronSync.Components @@ -16,7 +17,7 @@ namespace MicronSync.Components } public LMZAParser.endResult _endResultLMZA = LMZAParser.endResult.Default; public CommonIO.endResult _endResultCIO = CommonIO.endResult.Default; - private readonly MSConfig _ManageConfig_RO = MainWindow._MSConfig; + private readonly MSConfig _MSConfig = MainWindow._MSConfig; private Stopwatch stopWatch = new Stopwatch(); public TimeSpan compTime; @@ -40,10 +41,10 @@ namespace MicronSync.Components private void LmzaBackup_DoWork(object sender, DoWorkEventArgs e) { _endResultLMZA = lmzaParser.MakePackage( - Path.GetFileName(_ManageConfig_RO.BackupDestination), - _ManageConfig_RO.BackupSource, - Path.GetDirectoryName(_ManageConfig_RO.BackupDestination), - _ManageConfig_RO.CompressionLevel, + Path.GetFileName(_MSConfig.BackupDestination), + _MSConfig.BackupSource, + Path.GetDirectoryName(_MSConfig.BackupDestination), + _MSConfig.CompressionLevel, "", false); } @@ -59,26 +60,39 @@ namespace MicronSync.Components // Process params. using (CommonIO cio = new CommonIO()) { - // Move source directory if also purging, otherwise perform standard copy. - if (_ManageConfig_RO.EnableBackup && !_ManageConfig_RO.EnablePurge) - _endResultCIO = cio.CopyEntireDirectory(_ManageConfig_RO.RestoreDestination, - _ManageConfig_RO.RestoreDestination + ".Backup"); - else if (_ManageConfig_RO.EnableBackup && _ManageConfig_RO.EnablePurge) + var restoreBackupDir = _MSConfig.RestoreDestination + ".Backup"; + + // Clear out old backup directory if it exists. + if (_MSConfig.OverwriteBackup && Directory.Exists(restoreBackupDir)) { - _endResultCIO = cio.RenameEntireDirectory(_ManageConfig_RO.RestoreDestination, - _ManageConfig_RO.RestoreDestination + ".Backup"); - Directory.CreateDirectory(_ManageConfig_RO.RestoreDestination); + Directory.Delete(restoreBackupDir, true); + Thread.Sleep(500); // Delay needed for reliability! } - if (_ManageConfig_RO.EnablePurge) - _endResultCIO = cio.ClearEntireDirectory(_ManageConfig_RO.RestoreDestination); + // Move source directory if also purging, otherwise perform standard copy. + if (_MSConfig.EnableBackup && !_MSConfig.EnablePurge) + { + _endResultCIO = cio.CopyEntireDirectory( + _MSConfig.RestoreDestination, + restoreBackupDir); + } + else if (_MSConfig.EnableBackup && _MSConfig.EnablePurge) + { + _endResultCIO = cio.RenameEntireDirectory( + _MSConfig.RestoreDestination, + restoreBackupDir); + Directory.CreateDirectory(_MSConfig.RestoreDestination); + } + + if (_MSConfig.EnablePurge) + _endResultCIO = cio.ClearEntireDirectory(_MSConfig.RestoreDestination); } if (_endResultCIO == CommonIO.endResult.Default) _endResultLMZA = lmzaParser.ExtractPackage( - Path.GetFileName(_ManageConfig_RO.RestoreSource), - Path.GetDirectoryName(_ManageConfig_RO.RestoreSource), - _ManageConfig_RO.RestoreDestination, + Path.GetFileName(_MSConfig.RestoreSource), + Path.GetDirectoryName(_MSConfig.RestoreSource), + _MSConfig.RestoreDestination, ""); } diff --git a/MicronSync/Components/Licencer.cs b/MicronSync/Components/Licencer.cs index 7af0d94..962ee32 100644 --- a/MicronSync/Components/Licencer.cs +++ b/MicronSync/Components/Licencer.cs @@ -1,44 +1,35 @@ using Microsoft.Win32; using System; +using System.Net.NetworkInformation; +using System.Text; namespace MicronSync.Components { public class Licencer { private readonly string privateKey = "TRZzjAutdtA542aeQj"; - private readonly string msRegPath = @"SOFTWARE\MicronSync\"; - private readonly string msRegKey = "Key"; + private static SimplerAES aes = new SimplerAES(Encoding.ASCII.GetBytes(GetMachineGUID())); public static bool isRegistered { get; set; } = false; public bool CheckForExistingLicence() { - bool licenceExists = false; + bool isValidKey = false; try { - var regPath = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); - var regKey = regPath?.OpenSubKey(msRegPath); - var value = regKey?.GetValue(msRegKey); - - bool isValidKey = ValidateKey((string)value); - - if (isValidKey) - { - licenceExists = true; - } - else if (regKey != null && !isValidKey) - { - MessageHandler.errorMessage(MessageHandler.errCodes.NewRegKeyUI_PirateKey, null); - Environment.Exit(2); - } - + isValidKey = ValidateKey( + aes.Decrypt(Settings.Default.UserLicenseKey)); } - catch (Exception) + catch (Exception) { isValidKey = false; } + + if (isValidKey == false && Settings.Default.UserLicenseKey != string.Empty) { - licenceExists = false; + MessageHandler.errorMessage(MessageHandler.errCodes.NewRegKeyUI_PirateKey, null); + Settings.Default.UserLicenseKey = string.Empty; + Settings.Default.Save(); } - return licenceExists; + return isValidKey; } public void ShowDonationPrompt() @@ -47,6 +38,18 @@ namespace MicronSync.Components dui.ShowDialog(); } + /// + /// Get Windows GUID. + /// + /// + private static string GetMachineGUID() + { + var regPath = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default); + var regKey = regPath?.OpenSubKey(@"SOFTWARE\Microsoft\Cryptography"); + + return regKey.GetValue("MachineGuid").ToString().Replace("-", string.Empty); + } + /// /// Returns legitimacy of key. /// @@ -62,21 +65,13 @@ namespace MicronSync.Components } /// - /// Stores key into user level registry. + /// Stores key into user level AppData. /// /// public void SetKey(string key) { - try - { - var regPath = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); - var regKey = regPath.CreateSubKey(msRegPath); - regKey.SetValue(msRegKey, key.ToUpper(), RegistryValueKind.String); - } - catch (Exception) - { - throw; - } + Settings.Default.UserLicenseKey = aes.Encrypt(key); + Settings.Default.Save(); } /// @@ -91,4 +86,4 @@ namespace MicronSync.Components return skgl.doKey(0, DateTime.Now); } } -} +} \ No newline at end of file diff --git a/MicronSync/Components/MessageHandler.cs b/MicronSync/Components/MessageHandler.cs index be61632..124eb16 100644 --- a/MicronSync/Components/MessageHandler.cs +++ b/MicronSync/Components/MessageHandler.cs @@ -35,6 +35,9 @@ namespace MicronSync MainWindow_BadConfigFile, MainWindow_BadConfigFile_FromEXE, MainWindow_DirectoryNotFound, + Config_BadFile, + MainWindow_BadExplorePath, + MainWindow_EmptyExplorePath, } /// @@ -99,7 +102,7 @@ namespace MicronSync MessageBoxButtons.OK, MessageBoxIcon.Error); break; case errCodes.NewRegKeyUI_PirateKey: - MessageBox.Show($"You have imported a bad key onto your system. Please delete it to continue using this software.", "MicronSync", + MessageBox.Show($"You have imported a bad key onto your system. It will now be deleted for the continued use of this software.", "MicronSync", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case errCodes.MainWindow_BadConfigFile: @@ -110,6 +113,18 @@ namespace MicronSync MessageBox.Show($"Unsupported data.\nOnly config files are supported when loaded directly from application!", "MicronSync", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; + case errCodes.Config_BadFile: + MessageBox.Show($"The following configuration file is corrupt or invalid:\n\n{info}", "MicronSync", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + break; + case errCodes.MainWindow_BadExplorePath: + MessageBox.Show($"The following path could not be found:\n\n{info}", "MicronSync", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + break; + case errCodes.MainWindow_EmptyExplorePath: + MessageBox.Show($"Cannot browse to an empty path.", "MicronSync", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + break; } } @@ -147,7 +162,7 @@ namespace MicronSync MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); break; case msgCodes.MainWindow_LoadIncompatible: - _dialogResult = MessageBox.Show($"You are trying load a legacy config file (v{info}) which is incompatible with this version of MicronSync. Please create a new config file, sorry for any inconvenience caused!", "MicronSync - Incompatible config", + _dialogResult = MessageBox.Show($"You are trying load a legacy config file (v{info}) which is incompatible with this version of MicronSync.\nPlease load a config file which is at least of version 1.2.0.0 or create a new one, sorry for any inconvenience caused!", "MicronSync - Incompatible config", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case msgCodes.MainWindow_SZNotInstalled: diff --git a/MicronSync/Components/SimplerAES.cs b/MicronSync/Components/SimplerAES.cs new file mode 100644 index 0000000..bbc6f69 --- /dev/null +++ b/MicronSync/Components/SimplerAES.cs @@ -0,0 +1,53 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace MicronSync.Components +{ + public class SimplerAES + { + //private static byte[] key = { 123, 217, 19, 11, 24, 26, 85, 45, 114, 184, 27, 162, 37, 112, 222, 209, 241, 24, 175, 144, 173, 53, 196, 29, 24, 26, 17, 218, 131, 236, 53, 209 }; + private static byte[] vector = { 124, 134, 176, 172, 17, 45, 121, 41, 250, 61, 14, 213, 50, 136, 255, 236 }; + private ICryptoTransform encryptor, decryptor; + private UTF8Encoding encoder; + + public SimplerAES(byte[] key) + { + RijndaelManaged rm = new RijndaelManaged(); + encryptor = rm.CreateEncryptor(key, vector); + decryptor = rm.CreateDecryptor(key, vector); + encoder = new UTF8Encoding(); + } + + public string Encrypt(string unencrypted) + { + return Convert.ToBase64String(Encrypt(encoder.GetBytes(unencrypted))); + } + + public string Decrypt(string encrypted) + { + return encoder.GetString(Decrypt(Convert.FromBase64String(encrypted))); + } + + public byte[] Encrypt(byte[] buffer) + { + return Transform(buffer, encryptor); + } + + public byte[] Decrypt(byte[] buffer) + { + return Transform(buffer, decryptor); + } + + protected byte[] Transform(byte[] buffer, ICryptoTransform transform) + { + MemoryStream stream = new MemoryStream(); + using (CryptoStream cs = new CryptoStream(stream, transform, CryptoStreamMode.Write)) + { + cs.Write(buffer, 0, buffer.Length); + } + return stream.ToArray(); + } + } +} diff --git a/MicronSync/Confused/bin/Release/MicronSync.exe b/MicronSync/Confused/bin/Release/MicronSync.exe index 5604335..d1a01d1 100644 Binary files a/MicronSync/Confused/bin/Release/MicronSync.exe and b/MicronSync/Confused/bin/Release/MicronSync.exe differ diff --git a/MicronSync/MainWindow.Designer.cs b/MicronSync/MainWindow.Designer.cs index b5eb5a4..98c552d 100644 --- a/MicronSync/MainWindow.Designer.cs +++ b/MicronSync/MainWindow.Designer.cs @@ -31,6 +31,7 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow)); this.groupRestoreOptions = new System.Windows.Forms.GroupBox(); + this.chkOverwriteBackup = new System.Windows.Forms.CheckBox(); this.chkBackup = new System.Windows.Forms.CheckBox(); this.chkPurge = new System.Windows.Forms.CheckBox(); this.trackBar = new System.Windows.Forms.TrackBar(); @@ -51,6 +52,7 @@ this.labelSourceSize = new System.Windows.Forms.Label(); this.labelLastChange = new System.Windows.Forms.Label(); this.panelBHighlight = new System.Windows.Forms.Panel(); + this.btnExploreBSource = new System.Windows.Forms.Button(); this.cmbRootBSrc = new System.Windows.Forms.ComboBox(); this.btnRepBackupSource = new System.Windows.Forms.Button(); this.labelBackupSource = new System.Windows.Forms.Label(); @@ -69,6 +71,7 @@ this.labelBackupDest = new System.Windows.Forms.Label(); this.textBackupDest = new System.Windows.Forms.TextBox(); this.tabRestore = new System.Windows.Forms.TabPage(); + this.btnExploreRDestination = new System.Windows.Forms.Button(); this.cmbRootRDst = new System.Windows.Forms.ComboBox(); this.panel2 = new System.Windows.Forms.Panel(); this.btnCalcBackupSize = new System.Windows.Forms.Button(); @@ -98,8 +101,11 @@ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.refreshDrivesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.websiteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.enableDarkThemeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.changelogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.registerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.enterDonationKeyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.donateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -120,6 +126,7 @@ // // groupRestoreOptions // + this.groupRestoreOptions.Controls.Add(this.chkOverwriteBackup); this.groupRestoreOptions.Controls.Add(this.chkBackup); this.groupRestoreOptions.Controls.Add(this.chkPurge); this.groupRestoreOptions.Location = new System.Drawing.Point(10, 85); @@ -129,6 +136,18 @@ this.groupRestoreOptions.TabStop = false; this.groupRestoreOptions.Text = "Restore Options"; // + // chkOverwriteBackup + // + this.chkOverwriteBackup.AutoSize = true; + this.chkOverwriteBackup.Enabled = false; + this.chkOverwriteBackup.Location = new System.Drawing.Point(9, 66); + this.chkOverwriteBackup.Name = "chkOverwriteBackup"; + this.chkOverwriteBackup.Size = new System.Drawing.Size(159, 17); + this.chkOverwriteBackup.TabIndex = 23; + this.chkOverwriteBackup.Text = "Overwrite backup each time"; + this.chkOverwriteBackup.UseVisualStyleBackColor = true; + this.chkOverwriteBackup.CheckedChanged += new System.EventHandler(this.chkOverwriteBackup_CheckedChanged); + // // chkBackup // this.chkBackup.AutoSize = true; @@ -241,13 +260,16 @@ // // tabControl // + this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tabControl.Controls.Add(this.tabBackup); this.tabControl.Controls.Add(this.tabRestore); - this.tabControl.Location = new System.Drawing.Point(12, 38); + this.tabControl.Location = new System.Drawing.Point(-4, 38); this.tabControl.Multiline = true; this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(672, 214); + this.tabControl.Size = new System.Drawing.Size(692, 225); this.tabControl.TabIndex = 1; this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged); // @@ -264,7 +286,7 @@ this.tabBackup.Location = new System.Drawing.Point(4, 22); this.tabBackup.Name = "tabBackup"; this.tabBackup.Padding = new System.Windows.Forms.Padding(3); - this.tabBackup.Size = new System.Drawing.Size(664, 188); + this.tabBackup.Size = new System.Drawing.Size(684, 199); this.tabBackup.TabIndex = 0; this.tabBackup.Text = "Backup"; this.tabBackup.UseVisualStyleBackColor = true; @@ -283,6 +305,7 @@ // // panel1 // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.panel1.BackColor = System.Drawing.Color.MediumSeaGreen; this.panel1.Controls.Add(this.btnSourceSize); this.panel1.Controls.Add(this.labelSourceSizeValue); @@ -290,9 +313,9 @@ this.panel1.Controls.Add(this.labelLastChange); this.panel1.Controls.Add(this.labelSyncDate); this.panel1.Controls.Add(this.btnBackup); - this.panel1.Location = new System.Drawing.Point(528, 0); + this.panel1.Location = new System.Drawing.Point(548, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(136, 188); + this.panel1.Size = new System.Drawing.Size(136, 203); this.panel1.TabIndex = 33; // // btnSourceSize @@ -341,7 +364,10 @@ // // panelBHighlight // + this.panelBHighlight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panelBHighlight.BackColor = System.Drawing.Color.SeaGreen; + this.panelBHighlight.Controls.Add(this.btnExploreBSource); this.panelBHighlight.Controls.Add(this.cmbRootBSrc); this.panelBHighlight.Controls.Add(this.btnRepBackupSource); this.panelBHighlight.Controls.Add(this.labelBackupSource); @@ -349,9 +375,20 @@ this.panelBHighlight.Controls.Add(this.textBackupSource); this.panelBHighlight.Location = new System.Drawing.Point(0, 0); this.panelBHighlight.Name = "panelBHighlight"; - this.panelBHighlight.Size = new System.Drawing.Size(533, 41); + this.panelBHighlight.Size = new System.Drawing.Size(553, 41); this.panelBHighlight.TabIndex = 32; // + // btnExploreBSource + // + this.btnExploreBSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnExploreBSource.Location = new System.Drawing.Point(451, 10); + this.btnExploreBSource.Name = "btnExploreBSource"; + this.btnExploreBSource.Size = new System.Drawing.Size(29, 20); + this.btnExploreBSource.TabIndex = 34; + this.btnExploreBSource.Text = "↑"; + this.btnExploreBSource.UseVisualStyleBackColor = true; + this.btnExploreBSource.Click += new System.EventHandler(this.btnExploreBSource_Click); + // // cmbRootBSrc // this.cmbRootBSrc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -366,7 +403,8 @@ // // btnRepBackupSource // - this.btnRepBackupSource.Location = new System.Drawing.Point(498, 10); + this.btnRepBackupSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRepBackupSource.Location = new System.Drawing.Point(518, 10); this.btnRepBackupSource.Name = "btnRepBackupSource"; this.btnRepBackupSource.Size = new System.Drawing.Size(24, 20); this.btnRepBackupSource.TabIndex = 5; @@ -388,7 +426,8 @@ // // btnBackupBrowseSource // - this.btnBackupBrowseSource.Location = new System.Drawing.Point(459, 10); + this.btnBackupBrowseSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBackupBrowseSource.Location = new System.Drawing.Point(479, 10); this.btnBackupBrowseSource.Name = "btnBackupBrowseSource"; this.btnBackupBrowseSource.Size = new System.Drawing.Size(40, 20); this.btnBackupBrowseSource.TabIndex = 4; @@ -398,15 +437,18 @@ // // textBackupSource // + this.textBackupSource.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textBackupSource.Location = new System.Drawing.Point(218, 10); this.textBackupSource.Name = "textBackupSource"; - this.textBackupSource.Size = new System.Drawing.Size(240, 20); + this.textBackupSource.Size = new System.Drawing.Size(232, 20); this.textBackupSource.TabIndex = 3; this.textBackupSource.TextChanged += new System.EventHandler(this.textBackupSource_TextChanged); // // btnRepBackupDest // - this.btnRepBackupDest.Location = new System.Drawing.Point(498, 51); + this.btnRepBackupDest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRepBackupDest.Location = new System.Drawing.Point(518, 51); this.btnRepBackupDest.Name = "btnRepBackupDest"; this.btnRepBackupDest.Size = new System.Drawing.Size(24, 20); this.btnRepBackupDest.TabIndex = 9; @@ -519,7 +561,8 @@ // // btnBackupBrowseDest // - this.btnBackupBrowseDest.Location = new System.Drawing.Point(459, 51); + this.btnBackupBrowseDest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBackupBrowseDest.Location = new System.Drawing.Point(479, 51); this.btnBackupBrowseDest.Name = "btnBackupBrowseDest"; this.btnBackupBrowseDest.Size = new System.Drawing.Size(40, 20); this.btnBackupBrowseDest.TabIndex = 8; @@ -539,15 +582,18 @@ // // textBackupDest // + this.textBackupDest.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textBackupDest.Location = new System.Drawing.Point(218, 51); this.textBackupDest.Name = "textBackupDest"; - this.textBackupDest.Size = new System.Drawing.Size(240, 20); + this.textBackupDest.Size = new System.Drawing.Size(260, 20); this.textBackupDest.TabIndex = 7; this.textBackupDest.TextChanged += new System.EventHandler(this.textBackupDest_TextChanged); this.textBackupDest.Validating += new System.ComponentModel.CancelEventHandler(this.textBackupDest_Validating); // // tabRestore // + this.tabRestore.Controls.Add(this.btnExploreRDestination); this.tabRestore.Controls.Add(this.cmbRootRDst); this.tabRestore.Controls.Add(this.panel2); this.tabRestore.Controls.Add(this.btnRepRestoreDest); @@ -560,11 +606,22 @@ this.tabRestore.Location = new System.Drawing.Point(4, 22); this.tabRestore.Name = "tabRestore"; this.tabRestore.Padding = new System.Windows.Forms.Padding(3); - this.tabRestore.Size = new System.Drawing.Size(664, 188); + this.tabRestore.Size = new System.Drawing.Size(684, 199); this.tabRestore.TabIndex = 1; this.tabRestore.Text = "Restore"; this.tabRestore.UseVisualStyleBackColor = true; // + // btnExploreRDestination + // + this.btnExploreRDestination.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnExploreRDestination.Location = new System.Drawing.Point(451, 51); + this.btnExploreRDestination.Name = "btnExploreRDestination"; + this.btnExploreRDestination.Size = new System.Drawing.Size(29, 20); + this.btnExploreRDestination.TabIndex = 37; + this.btnExploreRDestination.Text = "↑"; + this.btnExploreRDestination.UseVisualStyleBackColor = true; + this.btnExploreRDestination.Click += new System.EventHandler(this.btnExploreRDestination_Click); + // // cmbRootRDst // this.cmbRootRDst.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -579,6 +636,7 @@ // // panel2 // + this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.panel2.BackColor = System.Drawing.Color.GreenYellow; this.panel2.Controls.Add(this.btnCalcBackupSize); this.panel2.Controls.Add(this.labelBackupSizeValue); @@ -586,9 +644,9 @@ this.panel2.Controls.Add(this.labelLastBackup); this.panel2.Controls.Add(this.labelBackupDate); this.panel2.Controls.Add(this.btnRestore); - this.panel2.Location = new System.Drawing.Point(528, 0); + this.panel2.Location = new System.Drawing.Point(548, 0); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(136, 188); + this.panel2.Size = new System.Drawing.Size(136, 203); this.panel2.TabIndex = 35; // // btnCalcBackupSize @@ -634,7 +692,8 @@ // // btnRepRestoreDest // - this.btnRepRestoreDest.Location = new System.Drawing.Point(498, 51); + this.btnRepRestoreDest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRepRestoreDest.Location = new System.Drawing.Point(518, 51); this.btnRepRestoreDest.Name = "btnRepRestoreDest"; this.btnRepRestoreDest.Size = new System.Drawing.Size(24, 20); this.btnRepRestoreDest.TabIndex = 19; @@ -655,7 +714,8 @@ // // btnRestoreBrowseDest // - this.btnRestoreBrowseDest.Location = new System.Drawing.Point(459, 51); + this.btnRestoreBrowseDest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRestoreBrowseDest.Location = new System.Drawing.Point(479, 51); this.btnRestoreBrowseDest.Name = "btnRestoreBrowseDest"; this.btnRestoreBrowseDest.Size = new System.Drawing.Size(40, 20); this.btnRestoreBrowseDest.TabIndex = 18; @@ -675,15 +735,19 @@ // // textRestoreDest // + this.textRestoreDest.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textRestoreDest.Location = new System.Drawing.Point(218, 51); this.textRestoreDest.Name = "textRestoreDest"; - this.textRestoreDest.Size = new System.Drawing.Size(240, 20); + this.textRestoreDest.Size = new System.Drawing.Size(232, 20); this.textRestoreDest.TabIndex = 17; this.textRestoreDest.TextChanged += new System.EventHandler(this.textRestoreDest_TextChanged); this.textRestoreDest.Validating += new System.ComponentModel.CancelEventHandler(this.textRestoreDest_Validating); // // panel3 // + this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panel3.BackColor = System.Drawing.Color.YellowGreen; this.panel3.Controls.Add(this.btnRepRestoreSource); this.panel3.Controls.Add(this.cmbRootRSrc); @@ -691,12 +755,13 @@ this.panel3.Controls.Add(this.textRestoreSource); this.panel3.Location = new System.Drawing.Point(0, 0); this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(533, 41); + this.panel3.Size = new System.Drawing.Size(553, 41); this.panel3.TabIndex = 34; // // btnRepRestoreSource // - this.btnRepRestoreSource.Location = new System.Drawing.Point(498, 10); + this.btnRepRestoreSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRepRestoreSource.Location = new System.Drawing.Point(518, 10); this.btnRepRestoreSource.Name = "btnRepRestoreSource"; this.btnRepRestoreSource.Size = new System.Drawing.Size(24, 20); this.btnRepRestoreSource.TabIndex = 15; @@ -718,8 +783,9 @@ // // btnRestoreBrowseSource // + this.btnRestoreBrowseSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnRestoreBrowseSource.BackColor = System.Drawing.Color.Transparent; - this.btnRestoreBrowseSource.Location = new System.Drawing.Point(459, 10); + this.btnRestoreBrowseSource.Location = new System.Drawing.Point(479, 10); this.btnRestoreBrowseSource.Name = "btnRestoreBrowseSource"; this.btnRestoreBrowseSource.Size = new System.Drawing.Size(40, 20); this.btnRestoreBrowseSource.TabIndex = 14; @@ -729,9 +795,11 @@ // // textRestoreSource // + this.textRestoreSource.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textRestoreSource.Location = new System.Drawing.Point(218, 10); this.textRestoreSource.Name = "textRestoreSource"; - this.textRestoreSource.Size = new System.Drawing.Size(240, 20); + this.textRestoreSource.Size = new System.Drawing.Size(260, 20); this.textRestoreSource.TabIndex = 13; this.textRestoreSource.TextChanged += new System.EventHandler(this.textRestoreSource_TextChanged); this.textRestoreSource.Validating += new System.ComponentModel.CancelEventHandler(this.textRestoreSource_Validating); @@ -758,8 +826,8 @@ // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, + this.optionsToolStripMenuItem, this.changelogToolStripMenuItem, - this.aboutToolStripMenuItem, this.registerToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; @@ -840,6 +908,36 @@ this.websiteToolStripMenuItem.Text = "Website..."; this.websiteToolStripMenuItem.Click += new System.EventHandler(this.websiteToolStripMenuItem_Click); // + // optionsToolStripMenuItem + // + this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.enableDarkThemeToolStripMenuItem, + this.toolStripSeparator3, + this.aboutToolStripMenuItem1}); + this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); + this.optionsToolStripMenuItem.Text = "Options"; + // + // enableDarkThemeToolStripMenuItem + // + this.enableDarkThemeToolStripMenuItem.CheckOnClick = true; + this.enableDarkThemeToolStripMenuItem.Name = "enableDarkThemeToolStripMenuItem"; + this.enableDarkThemeToolStripMenuItem.Size = new System.Drawing.Size(176, 22); + this.enableDarkThemeToolStripMenuItem.Text = "Enable Dark Theme"; + this.enableDarkThemeToolStripMenuItem.Click += new System.EventHandler(this.enableDarkThemeToolStripMenuItem_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(173, 6); + // + // aboutToolStripMenuItem1 + // + this.aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1"; + this.aboutToolStripMenuItem1.Size = new System.Drawing.Size(176, 22); + this.aboutToolStripMenuItem1.Text = "About"; + this.aboutToolStripMenuItem1.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); + // // changelogToolStripMenuItem // this.changelogToolStripMenuItem.Name = "changelogToolStripMenuItem"; @@ -847,13 +945,6 @@ this.changelogToolStripMenuItem.Text = "Change Log"; this.changelogToolStripMenuItem.Click += new System.EventHandler(this.changelogToolStripMenuItem_Click); // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20); - this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); - // // registerToolStripMenuItem // this.registerToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -879,13 +970,14 @@ // // labelDevBuild // + this.labelDevBuild.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.labelDevBuild.AutoSize = true; this.labelDevBuild.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelDevBuild.Location = new System.Drawing.Point(614, 6); + this.labelDevBuild.Location = new System.Drawing.Point(609, 6); this.labelDevBuild.Name = "labelDevBuild"; - this.labelDevBuild.Size = new System.Drawing.Size(64, 13); + this.labelDevBuild.Size = new System.Drawing.Size(69, 13); this.labelDevBuild.TabIndex = 23; - this.labelDevBuild.Text = "Beta Build 2"; + this.labelDevBuild.Text = "Alpha Build 2"; // // MainWindow // @@ -900,14 +992,16 @@ this.Controls.Add(this.tabControl); this.Controls.Add(this.statusStrip); this.Controls.Add(this.menuStrip1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(5000, 325); + this.MinimumSize = new System.Drawing.Size(700, 325); this.Name = "MainWindow"; this.Text = "MicronSync"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWindow_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); + this.SizeChanged += new System.EventHandler(this.MainWindow_SizeChanged); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainWindow_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainWindow_DragEnter); this.groupRestoreOptions.ResumeLayout(false); @@ -972,7 +1066,6 @@ private System.Windows.Forms.Label labelNoCompression; private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; @@ -1012,6 +1105,13 @@ private System.Windows.Forms.Button btnSourceSize; private System.Windows.Forms.Label labelSourceSizeValue; private System.Windows.Forms.Label labelSourceSize; + private System.Windows.Forms.Button btnExploreBSource; + private System.Windows.Forms.Button btnExploreRDestination; + private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem enableDarkThemeToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem1; + private System.Windows.Forms.CheckBox chkOverwriteBackup; } } diff --git a/MicronSync/MainWindow.cs b/MicronSync/MainWindow.cs index b7fefc5..86f4e89 100644 --- a/MicronSync/MainWindow.cs +++ b/MicronSync/MainWindow.cs @@ -32,6 +32,7 @@ namespace MicronSync ProcessLicence(); PopulateRootLists(); ProcessArgs(args); + UseDarkTheme(Settings.Default.UseDarkTheme); labelDevBuild.Visible = false; // Comment out before releasing. } @@ -91,12 +92,15 @@ namespace MicronSync toolTip.SetToolTip(chkPurge, "This will COMPLETELY wipe clean the restore destination directory\n" + "prior to restoring from the selected backup."); toolTip.SetToolTip(chkBackup, "Enabling this option will create a backup of the restoration directory\n" + - "with the extension \".Backup\"."); + "with the extension \".Backup\". This backup will not be updated unless the overwrite option is enabled."); toolTip.SetToolTip(btnRepBackupSource, "Replicate path to restore destination."); toolTip.SetToolTip(btnRepBackupDest, "Replicate path to restore source."); toolTip.SetToolTip(btnRepRestoreSource, "Replicate path to backup destination."); toolTip.SetToolTip(btnRepRestoreDest, "Replicate path to backup source."); toolTip.SetToolTip(labelCompressionPreset, "Selecting a preset to use will automatically choose optimal compression settings."); + toolTip.SetToolTip(btnExploreBSource, "Browse to specified directory."); + toolTip.SetToolTip(btnExploreRDestination, "Browse to specified directory."); + toolTip.SetToolTip(chkOverwriteBackup, "Overwriting your backup will consistently create a previous backup prior to each restore task."); } private void PopulateRootLists() @@ -201,9 +205,11 @@ namespace MicronSync trackBar.Value = _MSConfig.CompressionLevel; chkBackup.Checked = _MSConfig.EnableBackup; chkPurge.Checked = _MSConfig.EnablePurge; + chkOverwriteBackup.Checked = _MSConfig.OverwriteBackup; UpTabSelection = _MSConfig.InBackupMode; UpBackupSizeValue = "N/A"; UpSourceSizeValue = "N/A"; + Width = _MSConfig.WindowWidth; } /// @@ -376,6 +382,97 @@ namespace MicronSync } } + /// + /// Show save changes dialog on exit. + /// + private void PromptSaveChanges() + { + // Reset value before proceeding. + hasCancelledExit = false; + + // Only prompt if there are unsaved changes. + if (!_MSConfig.userModifiedConfig) return; + DialogResult result; + result = MessageHandler.stdMessage(MessageHandler.msgCodes.MainWindow_SaveChanges, _MSConfig.openFile); + + // Save to currently open file or to new one if there isn't one loaded. + if (result == DialogResult.Yes) + { + if (!string.IsNullOrEmpty(_MSConfig.openFile)) + { _MSConfig.Save(); } + else + { + _MSConfig.openFile = + _CommonIO.SaveFile(null, CommonIO.FileType.ini); + } + + _MSConfig.Save(); + } + else if (result == DialogResult.Cancel) + hasCancelledExit = true; + } + + private void OpenWithExplorer(string path) + { + if (Directory.Exists(path)) + { + ProcessStartInfo psi = new ProcessStartInfo("explorer.exe", path); + Process.Start(psi); + } + else if (path == string.Empty || path == null) + { + MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_EmptyExplorePath, null); + } + else + { + MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_BadExplorePath, path); + } + } + + private void UseDarkTheme(bool darkTheme) + { + var darkColour = Color.FromArgb(64, 64, 64); + var lightColour = Color.White; + var darkText = Color.Black; + + if (darkTheme) + { + enableDarkThemeToolStripMenuItem.CheckState = CheckState.Checked; + Settings.Default.UseDarkTheme = true; + + // Backup Tab. + tabBackup.BackColor = darkColour; + labelBackupDest.ForeColor = lightColour; + groupBackupOptions.BackColor = darkColour; + groupBackupOptions.ForeColor = lightColour; + trackBar.BackColor = darkColour; + + // Restore Tab. + tabRestore.BackColor = darkColour; + labelRestoreDest.ForeColor = lightColour; + groupRestoreOptions.BackColor = darkColour; + groupRestoreOptions.ForeColor = lightColour; + } + else + { + enableDarkThemeToolStripMenuItem.CheckState = CheckState.Unchecked; + Settings.Default.UseDarkTheme = false; + + // Backup Tab. + tabBackup.BackColor = lightColour; + labelBackupDest.ForeColor = darkText; + groupBackupOptions.BackColor = lightColour; + groupBackupOptions.ForeColor = darkText; + trackBar.BackColor = lightColour; + + // Restore Tab. + tabRestore.BackColor = lightColour; + labelRestoreDest.ForeColor = darkText; + groupRestoreOptions.BackColor = lightColour; + groupRestoreOptions.ForeColor = darkText; + } + } + #endregion #region UI Functionality @@ -586,36 +683,6 @@ namespace MicronSync #endregion - /// - /// Show save changes dialog on exit. - /// - private void PromptSaveChanges() - { - // Reset value before proceeding. - hasCancelledExit = false; - - // Only prompt if there are unsaved changes. - if (!_MSConfig.userModifiedConfig) return; - DialogResult result; - result = MessageHandler.stdMessage(MessageHandler.msgCodes.MainWindow_SaveChanges, _MSConfig.openFile); - - // Save to currently open file or to new one if there isn't one loaded. - if (result == DialogResult.Yes) - { - if (!string.IsNullOrEmpty(_MSConfig.openFile)) - { _MSConfig.Save(); } - else - { - _MSConfig.openFile = - _CommonIO.SaveFile(null, CommonIO.FileType.ini); - } - - _MSConfig.Save(); - } - else if (result == DialogResult.Cancel) - hasCancelledExit = true; - } - #region Form private void tabControl_SelectedIndexChanged(object sender, EventArgs e) @@ -633,6 +700,7 @@ namespace MicronSync private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { + Settings.Default.Save(); PromptSaveChanges(); if (!hasCancelledExit) @@ -756,6 +824,11 @@ namespace MicronSync private void checkBackup_CheckedChanged(object sender, EventArgs e) { _MSConfig.EnableBackup = chkBackup.Checked; + + if (chkBackup.CheckState == CheckState.Checked) + chkOverwriteBackup.Enabled = true; + else + chkOverwriteBackup.Enabled = false; } private void trackBar_ValueChanged(object sender, EventArgs e) @@ -859,6 +932,34 @@ namespace MicronSync UpSourceSizeValue = "N/A"; } + private void btnExploreBSource_Click(object sender, EventArgs e) + { + OpenWithExplorer(_MSConfig.BackupSource); + } + + private void btnExploreRDestination_Click(object sender, EventArgs e) + { + OpenWithExplorer(_MSConfig.RestoreDestination); + } + + private void chkOverwriteBackup_CheckedChanged(object sender, EventArgs e) + { + _MSConfig.OverwriteBackup = chkOverwriteBackup.Checked; + } + + private void MainWindow_SizeChanged(object sender, EventArgs e) + { + _MSConfig.WindowWidth = Width; + } + + private void enableDarkThemeToolStripMenuItem_Click(object sender, EventArgs e) + { + if (enableDarkThemeToolStripMenuItem.CheckState == CheckState.Checked) + UseDarkTheme(true); + else + UseDarkTheme(false); + } + #region Drag and drop private void MainWindow_DragEnter(object sender, DragEventArgs e) diff --git a/MicronSync/ManageCfg.cs b/MicronSync/ManageCfg.cs index 4f14eea..68ab038 100644 --- a/MicronSync/ManageCfg.cs +++ b/MicronSync/ManageCfg.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics; using System.IO; using System.Reflection; -using System.Text.RegularExpressions; namespace MicronSync { @@ -79,6 +77,18 @@ namespace MicronSync } private bool _EnableBackup; + [SaveToConfig] + public bool OverwriteBackup + { + get { return _OverwriteBackup; } + set + { + _OverwriteBackup = value; + OnPropertyChanged(); + } + } + private bool _OverwriteBackup; + [SaveToConfig] public int CompressionLevel { @@ -91,17 +101,6 @@ namespace MicronSync } private int _CompressionLevel = 4; - [SaveToConfig] - public bool InBackupMode - { - get { return _InBackupMode; } - set - { - _InBackupMode = value; - } - } - private bool _InBackupMode = true; - [SaveToConfig] public string RootBackupSource { @@ -209,6 +208,25 @@ namespace MicronSync } private string _PathRestoreDestination = ""; + [SaveToConfig] + public bool InBackupMode + { + get { return _InBackupMode; } + set + { + _InBackupMode = value; + } + } + private bool _InBackupMode = true; + + [SaveToConfig] + public int WindowWidth + { + get { return _WindowWidth; } + set { _WindowWidth = value; } + } + private int _WindowWidth; + #region Temporary Values public string BackupSource @@ -296,6 +314,7 @@ namespace MicronSync public int Load() { int errors = 0; + bool validConfigFile = false; try { foreach (var item in GetType().GetProperties()) @@ -316,6 +335,8 @@ namespace MicronSync Version readValue = null; if (Version.TryParse(line.ToString().Replace(item.Name, "").TrimStart('='), out readValue)) errors += CheckConfigVersion(readValue); + + validConfigFile = true; } } } @@ -326,6 +347,13 @@ namespace MicronSync errors++; } + // Check config file is valid before continuing + if (!validConfigFile) + { + MessageHandler.errorMessage(MessageHandler.errCodes.Config_BadFile, openFile); + errors++; + } + return errors; } diff --git a/MicronSync/MicronSync.csproj b/MicronSync/MicronSync.csproj index e5d59bc..3aaa5a8 100644 --- a/MicronSync/MicronSync.csproj +++ b/MicronSync/MicronSync.csproj @@ -138,6 +138,7 @@ WorkerUI.cs + Form @@ -145,6 +146,11 @@ MainWindow.cs + + True + True + Settings.settings + @@ -181,6 +187,7 @@ Resources.resx True + Designer @@ -198,6 +205,10 @@ + + SettingsSingleFileGenerator + Settings.Designer.cs + diff --git a/MicronSync/Properties/AssemblyInfo.cs b/MicronSync/Properties/AssemblyInfo.cs index 866a9d0..ff84703 100644 --- a/MicronSync/Properties/AssemblyInfo.cs +++ b/MicronSync/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ using System.Runtime.InteropServices; // 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.2.5.0")] -[assembly: AssemblyFileVersion("1.2.5.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")] [assembly: NeutralResourcesLanguage("en-GB")] diff --git a/MicronSync/Settings.Designer.cs b/MicronSync/Settings.Designer.cs new file mode 100644 index 0000000..f1b080e --- /dev/null +++ b/MicronSync/Settings.Designer.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MicronSync { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] + public bool UseDarkTheme { + get { + return ((bool)(this["UseDarkTheme"])); + } + set { + this["UseDarkTheme"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] + public string UserLicenseKey { + get { + return ((string)(this["UserLicenseKey"])); + } + set { + this["UserLicenseKey"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] + public string UserMAC { + get { + return ((string)(this["UserMAC"])); + } + set { + this["UserMAC"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] + public string UserName { + get { + return ((string)(this["UserName"])); + } + set { + this["UserName"] = value; + } + } + } +} diff --git a/MicronSync/Settings.settings b/MicronSync/Settings.settings new file mode 100644 index 0000000..47b2430 --- /dev/null +++ b/MicronSync/Settings.settings @@ -0,0 +1,12 @@ + + + + + + False + + + + + + \ No newline at end of file diff --git a/MicronSync/app.config b/MicronSync/app.config new file mode 100644 index 0000000..fc9aa9a --- /dev/null +++ b/MicronSync/app.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + False + + + + + + + \ No newline at end of file diff --git a/MicronSync/bin/Release/MicronSync.exe b/MicronSync/bin/Release/MicronSync.exe index 5604335..d1a01d1 100644 Binary files a/MicronSync/bin/Release/MicronSync.exe and b/MicronSync/bin/Release/MicronSync.exe differ diff --git a/MicronSync/bin/Release/MicronSync.exe.config b/MicronSync/bin/Release/MicronSync.exe.config index 88fa402..fc9aa9a 100644 --- a/MicronSync/bin/Release/MicronSync.exe.config +++ b/MicronSync/bin/Release/MicronSync.exe.config @@ -1,6 +1,18 @@  - - - + + +
+ + + + + + False + + + + + + \ No newline at end of file diff --git a/MicronSync/bin/Release/MicronSync.pdb b/MicronSync/bin/Release/MicronSync.pdb index 7c2df54..ee86bfa 100644 Binary files a/MicronSync/bin/Release/MicronSync.pdb and b/MicronSync/bin/Release/MicronSync.pdb differ diff --git a/MicronSync/bin/Release/MicronSync.vshost.exe.config b/MicronSync/bin/Release/MicronSync.vshost.exe.config index 88fa402..fc9aa9a 100644 --- a/MicronSync/bin/Release/MicronSync.vshost.exe.config +++ b/MicronSync/bin/Release/MicronSync.vshost.exe.config @@ -1,6 +1,18 @@  - - - + + +
+ + + + + + False + + + + + + \ No newline at end of file