diff --git a/MicronSync/Components/CommonIO.cs b/MicronSync/Components/CommonIO.cs
index 0dd0c92..1c23f45 100644
--- a/MicronSync/Components/CommonIO.cs
+++ b/MicronSync/Components/CommonIO.cs
@@ -8,28 +8,10 @@ namespace MicronSync
///
public class CommonIO : IDisposable
{
- ///
- /// 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;
- }
-
public enum FileType { sz, ini }
+ #region Filesystem
+
public string SaveFile(string originalPath, FileType f)
{
var file = new System.Windows.Forms.SaveFileDialog();
@@ -88,22 +70,39 @@ namespace MicronSync
return newPath;
}
+ ///
+ /// 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;
+ }
+
+ #endregion
+
+ #region String manipulation
+
public string CalculateDirectoryModifyDate (string dir)
{
string result = null;
- try
- {
- if (Directory.Exists(dir))
- result = string.Format("{0} - {1}",
- Directory.GetLastWriteTime(dir).ToShortDateString(),
- Directory.GetLastWriteTime(dir).ToLongTimeString());
- else
- result = "N/A";
- }
- catch (System.Exception)
- {
- throw;
- }
+ if (Directory.Exists(dir))
+ result = string.Format("{0} - {1}",
+ Directory.GetLastWriteTime(dir).ToShortDateString(),
+ Directory.GetLastWriteTime(dir).ToLongTimeString());
+ else
+ result = "N/A";
return result;
}
@@ -111,23 +110,18 @@ namespace MicronSync
public string CalculateFileModifyDate(string file)
{
string result = null;
- try
- {
- if (File.Exists(file))
- result = string.Format("{0} - {1}",
- File.GetLastWriteTime(file).ToShortDateString(),
- File.GetLastWriteTime(file).ToLongTimeString());
- else
- result = "N/A";
- }
- catch (System.Exception)
- {
- throw;
- }
+ if (File.Exists(file))
+ result = string.Format("{0} - {1}",
+ File.GetLastWriteTime(file).ToShortDateString(),
+ File.GetLastWriteTime(file).ToLongTimeString());
+ else
+ result = "N/A";
return result;
}
+ #endregion.
+
#region Filesystem Modification
public enum endResult
@@ -135,7 +129,7 @@ namespace MicronSync
ClearEntireDirectory_Error,
CopyEntireDirectory_Error,
Default,
- FileNotExist,
+ RenameEntireDirectory_Error,
}
public endResult ClearEntireDirectory(string dir)
@@ -167,6 +161,23 @@ namespace MicronSync
return _endResult;
}
+ public endResult RenameEntireDirectory(string dir, string newName)
+ {
+ endResult _endResult = endResult.Default;
+
+ try
+ {
+ Directory.Move(dir, Path.Combine(
+ Path.GetDirectoryName(dir), newName));
+ }
+ catch (Exception)
+ {
+ _endResult = endResult.RenameEntireDirectory_Error;
+ }
+
+ return _endResult;
+ }
+
public endResult CopyEntireDirectory(string src, string dst)
{
endResult _endResult = endResult.Default;
@@ -187,32 +198,24 @@ namespace MicronSync
// Copy all files to destination.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
- {
File.Copy(Path.Combine(src, file.Name),
Path.Combine(dst, file.Name));
- }
// Repeat for subdirectories.
foreach (DirectoryInfo subDir in dirs)
- {
CopyEntireDirectory(subDir.FullName,
Path.Combine(dst, subDir.Name));
- }
-
}
catch (Exception)
{
_endResult = endResult.CopyEntireDirectory_Error;
}
-
+
return _endResult;
}
#endregion
- public void Dispose()
- {
- GC.Collect();
- }
+ public void Dispose() { GC.Collect(); }
}
}
diff --git a/MicronSync/Components/AboutBox.Designer.cs b/MicronSync/Components/Forms/AboutBox.Designer.cs
similarity index 100%
rename from MicronSync/Components/AboutBox.Designer.cs
rename to MicronSync/Components/Forms/AboutBox.Designer.cs
diff --git a/MicronSync/Components/AboutBox.cs b/MicronSync/Components/Forms/AboutBox.cs
similarity index 100%
rename from MicronSync/Components/AboutBox.cs
rename to MicronSync/Components/Forms/AboutBox.cs
diff --git a/MicronSync/Components/AboutBox.resx b/MicronSync/Components/Forms/AboutBox.resx
similarity index 100%
rename from MicronSync/Components/AboutBox.resx
rename to MicronSync/Components/Forms/AboutBox.resx
diff --git a/MicronSync/Components/Forms/ChangeLog.Designer.cs b/MicronSync/Components/Forms/ChangeLog.Designer.cs
new file mode 100644
index 0000000..3cb2688
--- /dev/null
+++ b/MicronSync/Components/Forms/ChangeLog.Designer.cs
@@ -0,0 +1,80 @@
+namespace MicronSync.Components
+{
+ partial class ChangeLog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ 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.richTextBox = new System.Windows.Forms.RichTextBox();
+ this.labelVersionInfo = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // richTextBox
+ //
+ this.richTextBox.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.richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ 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.TabIndex = 0;
+ this.richTextBox.Text = "";
+ //
+ // labelVersionInfo
+ //
+ this.labelVersionInfo.AutoSize = true;
+ this.labelVersionInfo.Location = new System.Drawing.Point(13, 13);
+ this.labelVersionInfo.Name = "labelVersionInfo";
+ this.labelVersionInfo.Size = new System.Drawing.Size(45, 13);
+ this.labelVersionInfo.TabIndex = 1;
+ this.labelVersionInfo.Text = "Version:";
+ //
+ // ChangeLog
+ //
+ 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, 411);
+ this.Controls.Add(this.labelVersionInfo);
+ this.Controls.Add(this.richTextBox);
+ this.MinimumSize = new System.Drawing.Size(400, 450);
+ this.Name = "ChangeLog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "MicronSync - Change Log";
+ this.Load += new System.EventHandler(this.ChangeLog_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.RichTextBox richTextBox;
+ private System.Windows.Forms.Label labelVersionInfo;
+ }
+}
\ No newline at end of file
diff --git a/MicronSync/Components/Forms/ChangeLog.cs b/MicronSync/Components/Forms/ChangeLog.cs
new file mode 100644
index 0000000..9105a3b
--- /dev/null
+++ b/MicronSync/Components/Forms/ChangeLog.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Windows.Forms;
+
+namespace MicronSync.Components
+{
+ public partial class ChangeLog : Form
+ {
+ public ChangeLog()
+ {
+ InitializeComponent();
+ }
+
+ private void ChangeLog_Load(object sender, System.EventArgs e)
+ {
+ var assembly = Assembly.GetExecutingAssembly();
+
+ labelVersionInfo.Text = $"MicronSync: {assembly.GetName().Version}";
+
+ using (Stream steam = assembly.GetManifestResourceStream("MicronSync.Components.Forms.ChangeLog.txt"))
+ using (StreamReader sr = new StreamReader(steam, true))
+ {
+ List listChangelog = new List();
+
+ string currentLine;
+ while (!string.IsNullOrEmpty(
+ currentLine = sr.ReadLine()))
+ {
+ if (currentLine.Contains(@"//"))
+ {
+ currentLine = currentLine.Remove(currentLine.IndexOf(@"//"));
+ if (!string.IsNullOrEmpty(currentLine))
+ listChangelog.Add(currentLine);
+ }
+ else
+ listChangelog.Add(currentLine);
+ }
+
+ richTextBox.Text = string.Join(Environment.NewLine, listChangelog);
+ }
+ }
+ }
+}
diff --git a/MicronSync/Components/NewRegKeyUI.resx b/MicronSync/Components/Forms/ChangeLog.resx
similarity index 100%
rename from MicronSync/Components/NewRegKeyUI.resx
rename to MicronSync/Components/Forms/ChangeLog.resx
diff --git a/MicronSync/Components/Forms/ChangeLog.txt b/MicronSync/Components/Forms/ChangeLog.txt
new file mode 100644
index 0000000..80a89e0
--- /dev/null
+++ b/MicronSync/Components/Forms/ChangeLog.txt
@@ -0,0 +1,20 @@
+// Comments are denoted at the beginning of a line with two forward slashes.
+//
+[Bug Fixes]
+- Fixed new pre-backup algorithm from placing backup inside of source directory when the path ended with a "\".
+
+***[MicronSync 1.1.0.0]***
+[New Features]
+- Inclusion of a changelog (the very thing you currently have open!)
+- Ability to replicate destination and source paths between backup and restore tabs.
+- Drag and drop interface for 7-Zip archives and directories for more rapid operation.
+
+[Enhancements]
+- Automatic save prompt only appears when a change has been made to the configuration since the last save.
+- Paths are now validated ahead of attempting job operation.
+- User interface adjustments.
+- Shortcut keys for file menu!
+- Source directory pre-backups are a lot faster due to much more efficient algorithm (depending on settings used).
+
+[Bug Fixes]
+- Directories could be confused as files when checking paths are not in one another.
\ No newline at end of file
diff --git a/MicronSync/Components/DonationUI.Designer.cs b/MicronSync/Components/Forms/DonationUI.Designer.cs
similarity index 100%
rename from MicronSync/Components/DonationUI.Designer.cs
rename to MicronSync/Components/Forms/DonationUI.Designer.cs
diff --git a/MicronSync/Components/DonationUI.cs b/MicronSync/Components/Forms/DonationUI.cs
similarity index 100%
rename from MicronSync/Components/DonationUI.cs
rename to MicronSync/Components/Forms/DonationUI.cs
diff --git a/MicronSync/Components/DonationUI.resx b/MicronSync/Components/Forms/DonationUI.resx
similarity index 100%
rename from MicronSync/Components/DonationUI.resx
rename to MicronSync/Components/Forms/DonationUI.resx
diff --git a/MicronSync/Components/Forms/DropUI.Designer.cs b/MicronSync/Components/Forms/DropUI.Designer.cs
new file mode 100644
index 0000000..4031a39
--- /dev/null
+++ b/MicronSync/Components/Forms/DropUI.Designer.cs
@@ -0,0 +1,227 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace MicronSync.Components.Forms
+{
+ partial class DropUI
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ 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.tabControl = new System.Windows.Forms.TabControl();
+ this.tabProcess = new System.Windows.Forms.TabPage();
+ this.labelIdentify = new System.Windows.Forms.Label();
+ this.tabSz = new System.Windows.Forms.TabPage();
+ this.textReadSz = new System.Windows.Forms.TextBox();
+ this.btnSzUseBackup = new System.Windows.Forms.Button();
+ this.btnSzUseRestore = new System.Windows.Forms.Button();
+ this.labelSz = new System.Windows.Forms.Label();
+ this.tabDir = new System.Windows.Forms.TabPage();
+ this.textReadPath = new System.Windows.Forms.TextBox();
+ this.btnDirRestore = new System.Windows.Forms.Button();
+ this.btnDirBackup = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.tabControl.SuspendLayout();
+ this.tabProcess.SuspendLayout();
+ this.tabSz.SuspendLayout();
+ this.tabDir.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // tabControl
+ //
+ this.tabControl.Controls.Add(this.tabProcess);
+ this.tabControl.Controls.Add(this.tabSz);
+ this.tabControl.Controls.Add(this.tabDir);
+ this.tabControl.Location = new System.Drawing.Point(13, 13);
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.Size = new System.Drawing.Size(474, 166);
+ this.tabControl.TabIndex = 0;
+ //
+ // tabProcess
+ //
+ this.tabProcess.Controls.Add(this.labelIdentify);
+ this.tabProcess.Location = new System.Drawing.Point(4, 22);
+ this.tabProcess.Name = "tabProcess";
+ this.tabProcess.Padding = new System.Windows.Forms.Padding(3);
+ this.tabProcess.Size = new System.Drawing.Size(466, 140);
+ this.tabProcess.TabIndex = 0;
+ this.tabProcess.Text = "Identification";
+ this.tabProcess.UseVisualStyleBackColor = true;
+ //
+ // labelIdentify
+ //
+ this.labelIdentify.AutoSize = true;
+ this.labelIdentify.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.labelIdentify.Location = new System.Drawing.Point(50, 56);
+ this.labelIdentify.Name = "labelIdentify";
+ this.labelIdentify.Size = new System.Drawing.Size(354, 31);
+ this.labelIdentify.TabIndex = 0;
+ this.labelIdentify.Text = "Identifying dropped item...";
+ //
+ // tabSz
+ //
+ this.tabSz.Controls.Add(this.textReadSz);
+ this.tabSz.Controls.Add(this.btnSzUseBackup);
+ this.tabSz.Controls.Add(this.btnSzUseRestore);
+ this.tabSz.Controls.Add(this.labelSz);
+ this.tabSz.Location = new System.Drawing.Point(4, 22);
+ this.tabSz.Name = "tabSz";
+ this.tabSz.Padding = new System.Windows.Forms.Padding(3);
+ this.tabSz.Size = new System.Drawing.Size(466, 140);
+ this.tabSz.TabIndex = 1;
+ this.tabSz.Text = "7-Zip File";
+ this.tabSz.UseVisualStyleBackColor = true;
+ //
+ // textReadSz
+ //
+ this.textReadSz.Location = new System.Drawing.Point(80, 60);
+ this.textReadSz.Name = "textReadSz";
+ this.textReadSz.ReadOnly = true;
+ this.textReadSz.Size = new System.Drawing.Size(307, 20);
+ this.textReadSz.TabIndex = 3;
+ //
+ // btnSzUseBackup
+ //
+ this.btnSzUseBackup.Location = new System.Drawing.Point(225, 90);
+ this.btnSzUseBackup.Name = "btnSzUseBackup";
+ this.btnSzUseBackup.Size = new System.Drawing.Size(162, 23);
+ this.btnSzUseBackup.TabIndex = 2;
+ this.btnSzUseBackup.Text = "Overwrite file with new backup";
+ this.btnSzUseBackup.UseVisualStyleBackColor = true;
+ this.btnSzUseBackup.Click += new System.EventHandler(this.btnSzUseBackup_Click);
+ //
+ // btnSzUseRestore
+ //
+ this.btnSzUseRestore.Location = new System.Drawing.Point(80, 90);
+ this.btnSzUseRestore.Name = "btnSzUseRestore";
+ this.btnSzUseRestore.Size = new System.Drawing.Size(139, 23);
+ this.btnSzUseRestore.TabIndex = 1;
+ this.btnSzUseRestore.Text = "Restore from backup file";
+ this.btnSzUseRestore.UseVisualStyleBackColor = true;
+ this.btnSzUseRestore.Click += new System.EventHandler(this.btnSzUseRestore_Click);
+ //
+ // labelSz
+ //
+ this.labelSz.AutoSize = true;
+ this.labelSz.Location = new System.Drawing.Point(115, 30);
+ this.labelSz.Name = "labelSz";
+ this.labelSz.Size = new System.Drawing.Size(233, 13);
+ this.labelSz.TabIndex = 0;
+ this.labelSz.Text = "Please choose what to do with the following file:";
+ //
+ // tabDir
+ //
+ this.tabDir.Controls.Add(this.textReadPath);
+ this.tabDir.Controls.Add(this.btnDirRestore);
+ this.tabDir.Controls.Add(this.btnDirBackup);
+ this.tabDir.Controls.Add(this.label1);
+ this.tabDir.Location = new System.Drawing.Point(4, 22);
+ this.tabDir.Name = "tabDir";
+ this.tabDir.Padding = new System.Windows.Forms.Padding(3);
+ this.tabDir.Size = new System.Drawing.Size(466, 140);
+ this.tabDir.TabIndex = 2;
+ this.tabDir.Text = "Directory";
+ this.tabDir.UseVisualStyleBackColor = true;
+ //
+ // textReadPath
+ //
+ this.textReadPath.Location = new System.Drawing.Point(80, 60);
+ this.textReadPath.Name = "textReadPath";
+ this.textReadPath.ReadOnly = true;
+ this.textReadPath.Size = new System.Drawing.Size(307, 20);
+ this.textReadPath.TabIndex = 6;
+ //
+ // btnDirRestore
+ //
+ this.btnDirRestore.Location = new System.Drawing.Point(225, 90);
+ this.btnDirRestore.Name = "btnDirRestore";
+ this.btnDirRestore.Size = new System.Drawing.Size(162, 23);
+ this.btnDirRestore.TabIndex = 5;
+ this.btnDirRestore.Text = "Restore to path";
+ this.btnDirRestore.UseVisualStyleBackColor = true;
+ this.btnDirRestore.Click += new System.EventHandler(this.btnDirRestore_Click);
+ //
+ // btnDirBackup
+ //
+ this.btnDirBackup.Location = new System.Drawing.Point(80, 90);
+ this.btnDirBackup.Name = "btnDirBackup";
+ this.btnDirBackup.Size = new System.Drawing.Size(139, 23);
+ this.btnDirBackup.TabIndex = 4;
+ this.btnDirBackup.Text = "Backup this path";
+ this.btnDirBackup.UseVisualStyleBackColor = true;
+ this.btnDirBackup.Click += new System.EventHandler(this.btnDirBackup_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(115, 30);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(241, 13);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "Please choose what to do with the following path:";
+ //
+ // DropUI
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(499, 191);
+ this.Controls.Add(this.tabControl);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "DropUI";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "MicronSync - Dropped item";
+ this.Shown += new System.EventHandler(this.DropUI_Shown);
+ this.tabControl.ResumeLayout(false);
+ this.tabProcess.ResumeLayout(false);
+ this.tabProcess.PerformLayout();
+ this.tabSz.ResumeLayout(false);
+ this.tabSz.PerformLayout();
+ this.tabDir.ResumeLayout(false);
+ this.tabDir.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private TabControl tabControl;
+ private TabPage tabProcess;
+ private Label labelIdentify;
+ private TabPage tabSz;
+ private TabPage tabDir;
+ private Button btnSzUseBackup;
+ private Button btnSzUseRestore;
+ private Label labelSz;
+ private Button btnDirRestore;
+ private Button btnDirBackup;
+ private Label label1;
+ private TextBox textReadSz;
+ private TextBox textReadPath;
+ }
+}
\ No newline at end of file
diff --git a/MicronSync/Components/Forms/DropUI.cs b/MicronSync/Components/Forms/DropUI.cs
new file mode 100644
index 0000000..cd86ccf
--- /dev/null
+++ b/MicronSync/Components/Forms/DropUI.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace MicronSync.Components.Forms
+{
+ public partial class DropUI : Form
+ {
+ public static string dropData { get; set; }
+ public DropAction DropResult = DropAction.Cancelled; // Default behaviour
+ public enum DropAction
+ {
+ SzUseRestore,
+ SzUseBackup,
+ DirUseBackup,
+ DirUseRestore,
+ LoadConfig,
+ UnsupportedData,
+ Cancelled
+ }
+
+ public DropUI() { InitializeComponent(); }
+
+ private void DropUI_Shown(object sender, EventArgs e)
+ {
+ BringToFront();
+
+ // Idenfify dropped data
+ FileAttributes attr = File.GetAttributes(DropUI.dropData);
+ if (dropData.EndsWith(".ini"))
+ {
+ DropResult = DropAction.LoadConfig;
+ Close();
+ }
+ else if (dropData.EndsWith(".7z"))
+ LoadSzHandler();
+ else if (attr == FileAttributes.Directory)
+ LoadDirHandler();
+ else
+ {
+ DropResult = DropAction.UnsupportedData;
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_BadConfigFile, null);
+ Close();
+ }
+ }
+
+ private void LoadDirHandler()
+ {
+ textReadPath.Text = dropData;
+ tabControl.TabPages.Remove(tabProcess);
+ tabControl.TabPages.Remove(tabSz);
+ }
+
+ private void LoadSzHandler()
+ {
+ textReadSz.Text = dropData;
+ tabControl.TabPages.Remove(tabProcess);
+ tabControl.TabPages.Remove(tabDir);
+ }
+
+ #region Form UI
+
+ private void btnDirBackup_Click(object sender, EventArgs e)
+ {
+ DropResult = DropAction.DirUseBackup;
+ Close();
+ }
+
+ private void btnDirRestore_Click(object sender, EventArgs e)
+ {
+ DropResult = DropAction.DirUseRestore;
+ Close();
+ }
+
+ private void btnSzUseRestore_Click(object sender, EventArgs e)
+ {
+ DropResult = DropAction.SzUseRestore;
+ Close();
+ }
+
+ private void btnSzUseBackup_Click(object sender, EventArgs e)
+ {
+ DropResult = DropAction.SzUseBackup;
+ Close();
+ }
+
+ #endregion
+ }
+}
diff --git a/MicronSync/Components/WorkerUI.resx b/MicronSync/Components/Forms/DropUI.resx
similarity index 100%
rename from MicronSync/Components/WorkerUI.resx
rename to MicronSync/Components/Forms/DropUI.resx
diff --git a/MicronSync/Components/NewRegKeyUI.Designer.cs b/MicronSync/Components/Forms/NewRegKeyUI.Designer.cs
similarity index 100%
rename from MicronSync/Components/NewRegKeyUI.Designer.cs
rename to MicronSync/Components/Forms/NewRegKeyUI.Designer.cs
diff --git a/MicronSync/Components/NewRegKeyUI.cs b/MicronSync/Components/Forms/NewRegKeyUI.cs
similarity index 100%
rename from MicronSync/Components/NewRegKeyUI.cs
rename to MicronSync/Components/Forms/NewRegKeyUI.cs
diff --git a/MicronSync/Components/Forms/NewRegKeyUI.resx b/MicronSync/Components/Forms/NewRegKeyUI.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MicronSync/Components/Forms/NewRegKeyUI.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/MicronSync/Components/WorkerUI.Designer.cs b/MicronSync/Components/Forms/WorkerUI.Designer.cs
similarity index 97%
rename from MicronSync/Components/WorkerUI.Designer.cs
rename to MicronSync/Components/Forms/WorkerUI.Designer.cs
index 3b15881..913f771 100644
--- a/MicronSync/Components/WorkerUI.Designer.cs
+++ b/MicronSync/Components/Forms/WorkerUI.Designer.cs
@@ -61,6 +61,7 @@
this.Controls.Add(this.labelProcessing);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "WorkerUI";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "MicronSync";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WorkerUI_FormClosing);
this.Load += new System.EventHandler(this.WorkerUI_Load);
diff --git a/MicronSync/Components/WorkerUI.cs b/MicronSync/Components/Forms/WorkerUI.cs
similarity index 76%
rename from MicronSync/Components/WorkerUI.cs
rename to MicronSync/Components/Forms/WorkerUI.cs
index 9053bda..99ac846 100644
--- a/MicronSync/Components/WorkerUI.cs
+++ b/MicronSync/Components/Forms/WorkerUI.cs
@@ -59,42 +59,37 @@ namespace MicronSync.Components
private void LmzaRestore_DoWork(object sender, DoWorkEventArgs e)
{
- // Only continue if file exists!
- bool fileExists = false;
- if (File.Exists(_ManageConfig_RO.RestoreSource))
- fileExists = true;
- else
- _endResultCIO = CommonIO.endResult.FileNotExist;
-
- // Only continue if above is true.
- if (fileExists)
+ // Process params.
+ using (CommonIO cio = new CommonIO())
{
- // 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)
{
- if (_ManageConfig_RO.EnableBackup)
- {
- _endResultCIO = cio.CopyEntireDirectory(_ManageConfig_RO.RestoreDestination,
- _ManageConfig_RO.RestoreDestination + ".Backup");
- }
- if (_ManageConfig_RO.EnablePurge)
- _endResultCIO = cio.ClearEntireDirectory(_ManageConfig_RO.RestoreDestination);
+ _endResultCIO = cio.RenameEntireDirectory(_ManageConfig_RO.RestoreDestination,
+ _ManageConfig_RO.RestoreDestination + ".Backup");
+ Directory.CreateDirectory(_ManageConfig_RO.RestoreDestination);
}
- if (_endResultCIO == CommonIO.endResult.Default)
+ if (_ManageConfig_RO.EnablePurge)
+ _endResultCIO = cio.ClearEntireDirectory(_ManageConfig_RO.RestoreDestination);
+ }
+
+ if (_endResultCIO == CommonIO.endResult.Default)
_endResultLMZA = lmzaParser.ExtractPackage(
Path.GetFileName(_ManageConfig_RO.RestoreSource),
Path.GetDirectoryName(_ManageConfig_RO.RestoreSource),
_ManageConfig_RO.RestoreDestination,
"");
- }
}
#endregion
#region Form Functionality
- private bool canClose = false;
+ private bool canClose;
private void WorkerUI_Load(object sender, EventArgs e)
{
diff --git a/MicronSync/Components/Forms/WorkerUI.resx b/MicronSync/Components/Forms/WorkerUI.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MicronSync/Components/Forms/WorkerUI.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/MicronSync/Components/MessageHandler.cs b/MicronSync/Components/MessageHandler.cs
index 68c5a98..c95ccf5 100644
--- a/MicronSync/Components/MessageHandler.cs
+++ b/MicronSync/Components/MessageHandler.cs
@@ -32,6 +32,8 @@ namespace MicronSync
NewRegKeyUI_InvalidKey,
NewRegKeyUI_PirateKey,
MainWindow_BadConfigFile,
+ MainWindow_BadConfigFile_FromEXE,
+ MainWindow_DirectoryNotFound,
}
///
@@ -68,7 +70,7 @@ namespace MicronSync
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case errCodes.MainWindow_DstWithinSrc:
- MessageBox.Show($"Your destination and source paths cannot be within one-another. Please enter valid paths and try again.", "MicronSync",
+ MessageBox.Show($"You cannot create a backup inside of the folder you're tying to backup. Please enter a valid path and try again.", "MicronSync",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case errCodes.MainWindow_RestoreError:
@@ -91,6 +93,10 @@ namespace MicronSync
MessageBox.Show($"The backup file specified does not exist.", "MicronSync",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
+ case errCodes.MainWindow_DirectoryNotFound:
+ MessageBox.Show($"The backup directory specified does not exist.", "MicronSync",
+ MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ break;
case errCodes.NewRegKeyUI_InvalidKey:
MessageBox.Show($"The key you have entered is invalid. Please ensure you have typed it in the correct format.", "MicronSync",
MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -100,7 +106,11 @@ namespace MicronSync
MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
case errCodes.MainWindow_BadConfigFile:
- MessageBox.Show($"Unable to load configuration, unsupported file.", "MicronSync",
+ MessageBox.Show($"Unsupported data.\nPlease only drop configs, directories or 7-Zip files!", "MicronSync",
+ MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ break;
+ case errCodes.MainWindow_BadConfigFile_FromEXE:
+ MessageBox.Show($"Unsupported data.\nOnly config files are supported when loaded directly from application!", "MicronSync",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
@@ -136,7 +146,7 @@ namespace MicronSync
MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
case msgCodes.MainWindow_SaveChanges:
- _dialogResult = MessageBox.Show($"Save changes to file before exiting?\n{info}", "MicronSync",
+ _dialogResult = MessageBox.Show($"There are currently unsaved changes, would you like to save before exiting?\n{info}", "MicronSync",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
break;
}
diff --git a/MicronSync/Confused/bin/Release/MicronSync.exe b/MicronSync/Confused/bin/Release/MicronSync.exe
index b1ffa2c..c14b947 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 10e981c..142316a 100644
--- a/MicronSync/MainWindow.Designer.cs
+++ b/MicronSync/MainWindow.Designer.cs
@@ -44,6 +44,8 @@
this.labelBackupDate = new System.Windows.Forms.Label();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabBackup = new System.Windows.Forms.TabPage();
+ this.btnRepBackupDest = new System.Windows.Forms.Button();
+ this.btnRepBackupSource = new System.Windows.Forms.Button();
this.labelLastChange = new System.Windows.Forms.Label();
this.groupBackupOptions = new System.Windows.Forms.GroupBox();
this.labelMaxCompression = new System.Windows.Forms.Label();
@@ -55,6 +57,8 @@
this.labelBackupDest = new System.Windows.Forms.Label();
this.textBackupDest = new System.Windows.Forms.TextBox();
this.tabRestore = new System.Windows.Forms.TabPage();
+ this.btnRepRestoreDest = new System.Windows.Forms.Button();
+ this.btnRepRestoreSource = new System.Windows.Forms.Button();
this.labelLastBackup = new System.Windows.Forms.Label();
this.labelRestoreSource = new System.Windows.Forms.Label();
this.btnRestoreBrowseDest = new System.Windows.Forms.Button();
@@ -71,14 +75,16 @@
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.websiteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = 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();
- this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.labelDevBuild = new System.Windows.Forms.Label();
this.groupRestoreOptions.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar)).BeginInit();
this.statusStrip.SuspendLayout();
@@ -210,7 +216,7 @@
//
this.tabControl.Controls.Add(this.tabBackup);
this.tabControl.Controls.Add(this.tabRestore);
- this.tabControl.Location = new System.Drawing.Point(13, 64);
+ this.tabControl.Location = new System.Drawing.Point(12, 38);
this.tabControl.Multiline = true;
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
@@ -219,6 +225,8 @@
//
// tabBackup
//
+ this.tabBackup.Controls.Add(this.btnRepBackupDest);
+ this.tabBackup.Controls.Add(this.btnRepBackupSource);
this.tabBackup.Controls.Add(this.labelLastChange);
this.tabBackup.Controls.Add(this.groupBackupOptions);
this.tabBackup.Controls.Add(this.labelBackupSource);
@@ -237,6 +245,26 @@
this.tabBackup.Text = "Backup";
this.tabBackup.UseVisualStyleBackColor = true;
//
+ // btnRepBackupDest
+ //
+ this.btnRepBackupDest.Location = new System.Drawing.Point(366, 50);
+ this.btnRepBackupDest.Name = "btnRepBackupDest";
+ this.btnRepBackupDest.Size = new System.Drawing.Size(24, 20);
+ this.btnRepBackupDest.TabIndex = 31;
+ this.btnRepBackupDest.Text = ">";
+ this.btnRepBackupDest.UseVisualStyleBackColor = true;
+ this.btnRepBackupDest.Click += new System.EventHandler(this.btnRepBackupDest_Click);
+ //
+ // btnRepBackupSource
+ //
+ this.btnRepBackupSource.Location = new System.Drawing.Point(366, 12);
+ this.btnRepBackupSource.Name = "btnRepBackupSource";
+ this.btnRepBackupSource.Size = new System.Drawing.Size(24, 20);
+ this.btnRepBackupSource.TabIndex = 30;
+ this.btnRepBackupSource.Text = ">";
+ this.btnRepBackupSource.UseVisualStyleBackColor = true;
+ this.btnRepBackupSource.Click += new System.EventHandler(this.btnRepBackupSource_Click);
+ //
// labelLastChange
//
this.labelLastChange.AutoSize = true;
@@ -289,7 +317,7 @@
//
// btnBackupBrowseDest
//
- this.btnBackupBrowseDest.Location = new System.Drawing.Point(360, 51);
+ this.btnBackupBrowseDest.Location = new System.Drawing.Point(334, 50);
this.btnBackupBrowseDest.Name = "btnBackupBrowseDest";
this.btnBackupBrowseDest.Size = new System.Drawing.Size(30, 20);
this.btnBackupBrowseDest.TabIndex = 5;
@@ -299,15 +327,15 @@
//
// textBackupSource
//
- this.textBackupSource.Location = new System.Drawing.Point(84, 13);
+ this.textBackupSource.Location = new System.Drawing.Point(84, 12);
this.textBackupSource.Name = "textBackupSource";
- this.textBackupSource.Size = new System.Drawing.Size(271, 20);
+ this.textBackupSource.Size = new System.Drawing.Size(244, 20);
this.textBackupSource.TabIndex = 2;
this.textBackupSource.TextChanged += new System.EventHandler(this.textBackupSource_TextChanged);
//
// btnBackupBrowseSource
//
- this.btnBackupBrowseSource.Location = new System.Drawing.Point(360, 13);
+ this.btnBackupBrowseSource.Location = new System.Drawing.Point(334, 12);
this.btnBackupBrowseSource.Name = "btnBackupBrowseSource";
this.btnBackupBrowseSource.Size = new System.Drawing.Size(30, 20);
this.btnBackupBrowseSource.TabIndex = 3;
@@ -326,14 +354,17 @@
//
// textBackupDest
//
- this.textBackupDest.Location = new System.Drawing.Point(84, 51);
+ this.textBackupDest.Location = new System.Drawing.Point(84, 50);
this.textBackupDest.Name = "textBackupDest";
- this.textBackupDest.Size = new System.Drawing.Size(270, 20);
+ this.textBackupDest.Size = new System.Drawing.Size(244, 20);
this.textBackupDest.TabIndex = 4;
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.btnRepRestoreDest);
+ this.tabRestore.Controls.Add(this.btnRepRestoreSource);
this.tabRestore.Controls.Add(this.labelLastBackup);
this.tabRestore.Controls.Add(this.labelRestoreSource);
this.tabRestore.Controls.Add(this.btnRestoreBrowseDest);
@@ -352,6 +383,26 @@
this.tabRestore.Text = "Restore";
this.tabRestore.UseVisualStyleBackColor = true;
//
+ // btnRepRestoreDest
+ //
+ this.btnRepRestoreDest.Location = new System.Drawing.Point(366, 50);
+ this.btnRepRestoreDest.Name = "btnRepRestoreDest";
+ this.btnRepRestoreDest.Size = new System.Drawing.Size(24, 20);
+ this.btnRepRestoreDest.TabIndex = 33;
+ this.btnRepRestoreDest.Text = "<";
+ this.btnRepRestoreDest.UseVisualStyleBackColor = true;
+ this.btnRepRestoreDest.Click += new System.EventHandler(this.btnRepRestoreDest_Click);
+ //
+ // btnRepRestoreSource
+ //
+ this.btnRepRestoreSource.Location = new System.Drawing.Point(366, 12);
+ this.btnRepRestoreSource.Name = "btnRepRestoreSource";
+ this.btnRepRestoreSource.Size = new System.Drawing.Size(24, 20);
+ this.btnRepRestoreSource.TabIndex = 32;
+ this.btnRepRestoreSource.Text = "<";
+ this.btnRepRestoreSource.UseVisualStyleBackColor = true;
+ this.btnRepRestoreSource.Click += new System.EventHandler(this.btnRepRestoreSource_Click);
+ //
// labelLastBackup
//
this.labelLastBackup.AutoSize = true;
@@ -372,7 +423,7 @@
//
// btnRestoreBrowseDest
//
- this.btnRestoreBrowseDest.Location = new System.Drawing.Point(360, 51);
+ this.btnRestoreBrowseDest.Location = new System.Drawing.Point(334, 50);
this.btnRestoreBrowseDest.Name = "btnRestoreBrowseDest";
this.btnRestoreBrowseDest.Size = new System.Drawing.Size(30, 20);
this.btnRestoreBrowseDest.TabIndex = 27;
@@ -382,15 +433,16 @@
//
// textRestoreSource
//
- this.textRestoreSource.Location = new System.Drawing.Point(84, 13);
+ this.textRestoreSource.Location = new System.Drawing.Point(84, 12);
this.textRestoreSource.Name = "textRestoreSource";
- this.textRestoreSource.Size = new System.Drawing.Size(271, 20);
+ this.textRestoreSource.Size = new System.Drawing.Size(244, 20);
this.textRestoreSource.TabIndex = 23;
this.textRestoreSource.TextChanged += new System.EventHandler(this.textRestoreSource_TextChanged);
+ this.textRestoreSource.Validating += new System.ComponentModel.CancelEventHandler(this.textRestoreSource_Validating);
//
// btnRestoreBrowseSource
//
- this.btnRestoreBrowseSource.Location = new System.Drawing.Point(360, 13);
+ this.btnRestoreBrowseSource.Location = new System.Drawing.Point(334, 12);
this.btnRestoreBrowseSource.Name = "btnRestoreBrowseSource";
this.btnRestoreBrowseSource.Size = new System.Drawing.Size(30, 20);
this.btnRestoreBrowseSource.TabIndex = 26;
@@ -409,16 +461,17 @@
//
// textRestoreDest
//
- this.textRestoreDest.Location = new System.Drawing.Point(84, 51);
+ this.textRestoreDest.Location = new System.Drawing.Point(84, 50);
this.textRestoreDest.Name = "textRestoreDest";
- this.textRestoreDest.Size = new System.Drawing.Size(270, 20);
+ this.textRestoreDest.Size = new System.Drawing.Size(244, 20);
this.textRestoreDest.TabIndex = 25;
this.textRestoreDest.TextChanged += new System.EventHandler(this.textRestoreDest_TextChanged);
+ this.textRestoreDest.Validating += new System.ComponentModel.CancelEventHandler(this.textRestoreDest_Validating);
//
// labelDescription
//
this.labelDescription.AutoSize = true;
- this.labelDescription.Location = new System.Drawing.Point(24, 35);
+ this.labelDescription.Location = new System.Drawing.Point(13, 265);
this.labelDescription.Name = "labelDescription";
this.labelDescription.Size = new System.Drawing.Size(63, 13);
this.labelDescription.TabIndex = 18;
@@ -426,7 +479,7 @@
//
// textDescription
//
- this.textDescription.Location = new System.Drawing.Point(101, 32);
+ this.textDescription.Location = new System.Drawing.Point(104, 262);
this.textDescription.Name = "textDescription";
this.textDescription.Size = new System.Drawing.Size(311, 20);
this.textDescription.TabIndex = 0;
@@ -436,6 +489,7 @@
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
+ this.changelogToolStripMenuItem,
this.aboutToolStripMenuItem,
this.registerToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
@@ -462,19 +516,21 @@
// newToolStripMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
- this.newToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
+ this.newToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
+ this.toolStripSeparator1.Size = new System.Drawing.Size(192, 6);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
- this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
+ this.openToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.openToolStripMenuItem.Text = "Open...";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
@@ -482,29 +538,47 @@
//
this.saveToolStripMenuItem.Enabled = false;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
- this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
+ this.saveToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
+ // saveAsToolStripMenuItem
+ //
+ this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
+ this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
+ | System.Windows.Forms.Keys.S)));
+ this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
+ this.saveAsToolStripMenuItem.Text = "Save As...";
+ this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
+ //
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
- this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
+ this.toolStripSeparator2.Size = new System.Drawing.Size(192, 6);
//
// websiteToolStripMenuItem
//
this.websiteToolStripMenuItem.Name = "websiteToolStripMenuItem";
- this.websiteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.websiteToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.websiteToolStripMenuItem.Text = "Website...";
this.websiteToolStripMenuItem.Click += new System.EventHandler(this.websiteToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
- this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
+ this.exitToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
+ // changelogToolStripMenuItem
+ //
+ this.changelogToolStripMenuItem.Name = "changelogToolStripMenuItem";
+ this.changelogToolStripMenuItem.Size = new System.Drawing.Size(83, 20);
+ this.changelogToolStripMenuItem.Text = "Change Log";
+ this.changelogToolStripMenuItem.Click += new System.EventHandler(this.changelogToolStripMenuItem_Click);
+ //
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
@@ -518,8 +592,8 @@
this.enterDonationKeyToolStripMenuItem,
this.donateToolStripMenuItem});
this.registerToolStripMenuItem.Name = "registerToolStripMenuItem";
- this.registerToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
- this.registerToolStripMenuItem.Text = "Register";
+ this.registerToolStripMenuItem.Size = new System.Drawing.Size(69, 20);
+ this.registerToolStripMenuItem.Text = "[Register]";
//
// enterDonationKeyToolStripMenuItem
//
@@ -535,12 +609,15 @@
this.donateToolStripMenuItem.Text = "Donate...";
this.donateToolStripMenuItem.Click += new System.EventHandler(this.donateToolStripMenuItem_Click);
//
- // saveAsToolStripMenuItem
+ // labelDevBuild
//
- this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
- this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.saveAsToolStripMenuItem.Text = "Save As...";
- this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
+ 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(331, 6);
+ this.labelDevBuild.Name = "labelDevBuild";
+ this.labelDevBuild.Size = new System.Drawing.Size(96, 13);
+ this.labelDevBuild.TabIndex = 23;
+ this.labelDevBuild.Text = "Development Build";
//
// MainWindow
//
@@ -549,6 +626,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(434, 316);
+ this.Controls.Add(this.labelDevBuild);
this.Controls.Add(this.labelDescription);
this.Controls.Add(this.textDescription);
this.Controls.Add(this.tabControl);
@@ -633,6 +711,12 @@
private System.Windows.Forms.ToolStripMenuItem donateToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem websiteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem changelogToolStripMenuItem;
+ private System.Windows.Forms.Button btnRepBackupDest;
+ private System.Windows.Forms.Button btnRepBackupSource;
+ private System.Windows.Forms.Button btnRepRestoreDest;
+ private System.Windows.Forms.Button btnRepRestoreSource;
+ private System.Windows.Forms.Label labelDevBuild;
}
}
diff --git a/MicronSync/MainWindow.cs b/MicronSync/MainWindow.cs
index b548131..2f30baf 100644
--- a/MicronSync/MainWindow.cs
+++ b/MicronSync/MainWindow.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
+using MicronSync.Components.Forms;
namespace MicronSync
{
@@ -14,12 +15,9 @@ namespace MicronSync
public static string[] args { get; set; }
private readonly CommonIO _CommonIO = new CommonIO();
private readonly ParseUserInput _ParseUserInput = new ParseUserInput();
- private bool isLoading = false;
+ private bool isLoading;
- public MainWindow()
- {
- InitializeComponent();
- }
+ public MainWindow() { InitializeComponent(); }
#region Startup events
@@ -31,23 +29,26 @@ namespace MicronSync
CreateTooltips();
ProcessLicence();
ProcessArgs(args);
+ labelDevBuild.Visible = false; // Comment out before releasing.
}
- private void ProcessArgs(string[] args)
+ ///
+ /// Process args passed directly to the executable.
+ ///
+ ///
+ private void ProcessArgs(IReadOnlyCollection args)
{
List listArgs = new List();
- if (args.Length > 0)
+ if (args.Count > 0)
{
foreach (var item in args)
- {
listArgs.Add(" " + item);
- }
string fullPath = String.Join(String.Empty, listArgs.ToArray())
.TrimStart()
.TrimEnd();
- OpenConfig(false, fullPath);
+ OpenConfig(false, fullPath, true);
}
}
@@ -59,7 +60,6 @@ namespace MicronSync
{
Licencer _Licencer = new Licencer();
- //Debug.WriteLine("DEBUG New key: " + _Licencer.CreateNewKey());
Licencer.isRegistered = _Licencer.CheckForExistingLicence();
if (!Licencer.isRegistered)
_Licencer.ShowDonationPrompt();
@@ -89,41 +89,46 @@ namespace MicronSync
"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\".");
+ 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.");
}
#endregion
+ #region Functions
+
///
/// Open an existing configuration file.
///
- ///
+ ///
///
- private void OpenConfig(bool useFileSelector, string file)
+ private void OpenConfig(bool useFileSelector, string fileToLoad, bool fromExe)
{
isLoading = true;
- ///
- string loadedFile;
- // Load file selector if a file has already been specified.
- if (useFileSelector)
- loadedFile = _CommonIO.OpenFile(null, CommonIO.FileType.ini);
- else
- loadedFile = file;
+ // Load file selector if a file has not been specified.
+ string loadedFile = useFileSelector ? _CommonIO.OpenFile(null, CommonIO.FileType.ini) : fileToLoad;
+ if(!string.IsNullOrEmpty(loadedFile))
if (loadedFile.EndsWith(".ini"))
{
- _MSConfig = new MSConfig();
- _MSConfig.openFile = loadedFile;
+ _MSConfig = new MSConfig {openFile = loadedFile};
_MSConfig.Load();
UpdateWithConfig();
// Set titlebar name.
UpdateTitlebar = loadedFile;
+ UpdateStatus = "Load successful";
saveToolStripMenuItem.Enabled = true;
}
else
- { MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_BadConfigFile, null); }
- ///
+ if (!fromExe)
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_BadConfigFile, null);
+ else
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_BadConfigFile_FromEXE, null);
+ //
isLoading = false;
}
@@ -141,6 +146,8 @@ namespace MicronSync
trackBar.Value = _MSConfig.CompressionLevel;
chkBackup.Checked = _MSConfig.EnableBackup;
chkPurge.Checked = _MSConfig.EnablePurge;
+
+ _MSConfig.userModifiedConfig = false;
}
///
@@ -153,69 +160,61 @@ namespace MicronSync
bool isSysArch64;
// Determine system architecture.
- try
+ if (IntPtr.Size == 8)
{
- if (IntPtr.Size == 8)
- {
- // x64
- isSysArch64 = true;
- Debug.Write("DEBUG: 64-bit system detected\n");
- }
- else
- {
- // x32
- isSysArch64 = false;
- Debug.Write("DEBUG: 32-bit system detected\n");
- }
+ // x64
+ isSysArch64 = true;
+ Debug.Write("DEBUG: 64-bit system detected\n");
+ }
+ else
+ {
+ // x32
+ isSysArch64 = false;
+ Debug.Write("DEBUG: 32-bit system detected\n");
}
- catch (Exception) { throw; }
// Check 7-zip is installed on system.
string sevenZipRegPath = @"SOFTWARE\7-Zip\";
string sevenZipRegValueName = "Path";
- try
+ if (isSysArch64)
{
- if (isSysArch64 == true)
- {
- // x64
- var regPath64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
- var regKey64 = regPath64?.OpenSubKey(sevenZipRegPath);
- var value64 = regKey64?.GetValue(sevenZipRegValueName);
+ // x64
+ var regPath64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
+ var regKey64 = regPath64?.OpenSubKey(sevenZipRegPath);
+ var value64 = regKey64?.GetValue(sevenZipRegValueName);
- if (File.Exists(value64 + "7z.exe"))
- {
- LMZAParser.szExePath = value64 + "7z.exe";
- LMZAParser.szWorkDir = Convert.ToString(value64);
- Debug.Write("DEBUG: 7-Zip exists\n");
- }
- else
- {
- MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_SZNotInstalled, null);
- errors++;
- }
+ if (File.Exists(value64 + "7z.exe"))
+ {
+ LMZAParser.szExePath = value64 + "7z.exe";
+ LMZAParser.szWorkDir = Convert.ToString(value64);
+ Debug.Write("DEBUG: 7-Zip exists\n");
}
else
{
- // x32
- var regPath32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
- var regKey32 = regPath32?.OpenSubKey(sevenZipRegPath);
- var value32 = regKey32?.GetValue(sevenZipRegValueName);
-
- if (File.Exists(value32 + "7z.exe"))
- {
- LMZAParser.szExePath = value32 + "7z.exe";
- LMZAParser.szWorkDir = Convert.ToString(value32);
- Debug.Write("DEBUG: 7-Zip exists\n");
- }
- else
- {
- MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_SZNotInstalled, null);
- errors++;
- }
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_SZNotInstalled, null);
+ errors++;
+ }
+ }
+ else
+ {
+ // x32
+ var regPath32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
+ var regKey32 = regPath32?.OpenSubKey(sevenZipRegPath);
+ var value32 = regKey32?.GetValue(sevenZipRegValueName);
+
+ if (File.Exists(value32 + "7z.exe"))
+ {
+ LMZAParser.szExePath = value32 + "7z.exe";
+ LMZAParser.szWorkDir = Convert.ToString(value32);
+ Debug.Write("DEBUG: 7-Zip exists\n");
+ }
+ else
+ {
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_SZNotInstalled, null);
+ errors++;
}
}
- catch (Exception) { throw; }
return errors;
}
@@ -226,11 +225,8 @@ namespace MicronSync
private void BackupButtonQualifier()
{
int count = 0;
-
- if (!string.IsNullOrEmpty(_MSConfig.BackupSource))
- count++;
- if (!string.IsNullOrEmpty(_MSConfig.BackupDestination))
- count++;
+ if (!string.IsNullOrEmpty(_MSConfig.BackupSource)) count++;
+ if (!string.IsNullOrEmpty(_MSConfig.BackupDestination)) count++;
if (count == 2)
{
@@ -250,11 +246,8 @@ namespace MicronSync
private void RestoreButtonQualifier()
{
int count = 0;
-
- if (!string.IsNullOrEmpty(_MSConfig.RestoreSource))
- count++;
- if (!string.IsNullOrEmpty(_MSConfig.RestoreDestination))
- count++;
+ if (!string.IsNullOrEmpty(_MSConfig.RestoreSource)) count++;
+ if (!string.IsNullOrEmpty(_MSConfig.RestoreDestination)) count++;
if (count == 2)
{
@@ -318,15 +311,11 @@ namespace MicronSync
break;
case CommonIO.endResult.Default:
break;
- case CommonIO.endResult.FileNotExist:
- MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_ArchiveNotFound, null);
- statusLabel.Text = "Failed to locate archive";
- break;
- default:
- break;
}
}
+ #endregion
+
#region UI Functionality
private string UpdateStatus
@@ -358,16 +347,26 @@ namespace MicronSync
menuStrip1.Items.RemoveByKey("registerToolStripMenuItem");
}
+ ///
+ /// Show save changes dialog on exit.
+ ///
private void PromptSaveChanges()
{
+ // Only prompt if there are unsaved changes.
+ if (!_MSConfig.userModifiedConfig) return;
DialogResult result;
+ result = MessageHandler.stdMessage(MessageHandler.msgCodes.MainWindow_SaveChanges, _MSConfig.openFile);
- if (!string.IsNullOrEmpty(_MSConfig.openFile))
+ // Save to currently open file or to new one if there isn't one loaded.
+ if (result == DialogResult.Yes)
{
- result = MessageHandler.stdMessage(MessageHandler.msgCodes.MainWindow_SaveChanges, _MSConfig.openFile);
+ if (!string.IsNullOrEmpty( _MSConfig.openFile))
+ { _MSConfig.Save(); }
+ else
+ { _MSConfig.openFile =
+ _CommonIO.SaveFile(null, CommonIO.FileType.ini); }
- if (result == DialogResult.Yes)
- _MSConfig.Save();
+ _MSConfig.Save();
}
}
@@ -413,6 +412,31 @@ namespace MicronSync
RestoreButtonQualifier();
}
+ private void textRestoreDest_Validating(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if (textRestoreDest.Text.EndsWith("\\"))
+ textRestoreDest.Text =
+ textRestoreDest.Text.Remove(textRestoreDest.Text.Length - 1);
+ }
+
+ private void textBackupDest_Validating(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ string t = textBackupDest.Text;
+
+ if (!t.EndsWith(".7z") && !t.EndsWith("\\"))
+ if (t.Length > 4)
+ textBackupDest.Text += ".7z";
+ }
+
+ private void textRestoreSource_Validating(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ string t = textRestoreSource.Text;
+
+ if (!t.EndsWith(".7z") && !t.EndsWith("\\"))
+ if(t.Length > 4)
+ textRestoreSource.Text += ".7z";
+ }
+
private void btnBackupBrowseSource_Click(object sender, EventArgs e)
{
textBackupSource.Text = _CommonIO.BrowseFolder(
@@ -473,7 +497,7 @@ namespace MicronSync
private void btnRestore_Click(object sender, EventArgs e)
{
bool errors =
- _ParseUserInput.IsAllUserInputValid(
+ _ParseUserInput.IsValidationInvalid(
_MSConfig.RestoreSource,
_MSConfig.RestoreDestination,
false);
@@ -491,7 +515,7 @@ namespace MicronSync
private void btnBackup_Click(object sender, EventArgs e)
{
bool errors =
- _ParseUserInput.IsAllUserInputValid(
+ _ParseUserInput.IsValidationInvalid(
_MSConfig.BackupSource,
_MSConfig.BackupDestination,
true);
@@ -506,20 +530,83 @@ namespace MicronSync
}
}
+ #region Drag and drop
+
private void MainWindow_DragEnter(object sender, DragEventArgs e)
{
+ BringToFront();
+
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Link;
}
private void MainWindow_DragDrop(object sender, DragEventArgs e)
{
- string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
- OpenConfig(false, files[0]);
+ string[] allDropData = (string[])e.Data.GetData(DataFormats.FileDrop);
+ DropUI dropUi = new DropUI();
+ DropUI.dropData = allDropData[0];
+ dropUi.ShowDialog();
+
+ switch (dropUi.DropResult)
+ {
+ case DropUI.DropAction.SzUseRestore:
+ textRestoreSource.Text = DropUI.dropData;
+ tabControl.SelectedTab = tabRestore;
+ break;
+ case DropUI.DropAction.SzUseBackup:
+ textBackupDest.Text = DropUI.dropData;
+ tabControl.SelectedTab = tabBackup;
+ break;
+ case DropUI.DropAction.DirUseBackup:
+ textBackupSource.Text = DropUI.dropData;
+ tabControl.SelectedTab = tabBackup;
+ break;
+ case DropUI.DropAction.DirUseRestore:
+ textRestoreDest.Text = DropUI.dropData;
+ tabControl.SelectedTab = tabRestore;
+ break;
+ case DropUI.DropAction.LoadConfig:
+ OpenConfig(false, DropUI.dropData, false);
+ break;
+ case DropUI.DropAction.UnsupportedData:
+ break;
+ case DropUI.DropAction.Cancelled:
+ break;
+ }
}
#endregion
+ #region Path Replication
+
+ private void btnRepBackupSource_Click(object sender, EventArgs e)
+ {
+ textRestoreDest.Text = textBackupSource.Text;
+ tabControl.SelectedTab = tabRestore;
+ }
+
+ private void btnRepBackupDest_Click(object sender, EventArgs e)
+ {
+ textRestoreSource.Text = textBackupDest.Text;
+ tabControl.SelectedTab = tabRestore;
+ }
+
+ private void btnRepRestoreSource_Click(object sender, EventArgs e)
+ {
+ textBackupDest.Text = textRestoreSource.Text;
+ tabControl.SelectedTab = tabBackup;
+ }
+
+ private void btnRepRestoreDest_Click(object sender, EventArgs e)
+ {
+ textBackupSource.Text = textRestoreDest.Text;
+ tabControl.SelectedTab = tabBackup;
+ }
+
+ #endregion
+
+ #endregion
+
#region Menubar
private void newToolStripMenuItem_Click(object sender, EventArgs e)
@@ -528,17 +615,21 @@ namespace MicronSync
_MSConfig = new MSConfig();
UpdateWithConfig();
+
+ UpdateStatus = "New job";
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
- OpenConfig(true, null);
+ OpenConfig(true, null, false);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(_MSConfig.openFile))
_MSConfig.Save();
+
+ UpdateStatus = "Save successful";
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
@@ -549,6 +640,7 @@ namespace MicronSync
{
_MSConfig.openFile = saveFile;
_MSConfig.Save();
+ UpdateStatus = "Save successful";
}
UpdateTitlebar = saveFile;
@@ -585,14 +677,21 @@ namespace MicronSync
Process.Start(DonationUI.websiteUrl);
}
+ private void changelogToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ ChangeLog cl = new ChangeLog();
+ cl.ShowDialog();
+ }
+
#endregion
#endregion
}
- public partial class ParseUserInput
+ public class ParseUserInput
{
- private readonly string[] restrictedDirs =
+ #region Private values
+ private readonly List restrictedDirs = new List
{
@"C:\Windows",
@"C:\Program",
@@ -602,83 +701,105 @@ namespace MicronSync
private readonly int minPathLength = 4;
- private bool IsDirectoryAllowed (string input)
+ private bool IsDirectoryAllowed(string input)
{
int errors = 0;
- int position = 0;
-
foreach (var dir in restrictedDirs)
- {
- if (input.StartsWith(restrictedDirs[position]))
+ if (input.StartsWith(dir))
errors++;
- position++;
+ return errors == 0;
+ }
+
+ private bool IsDstWithinSrcPath(string path, string file)
+ {
+ var fileRoot = Path.GetDirectoryName(file);
+ return fileRoot.StartsWith(path);
+ }
+
+ #endregion
+
+ #region Validation
+
+ public bool IsValidationInvalid(string src, string dst, bool isBackupMode)
+ {
+ int errors = TestGeneralUserInput(src, dst);
+
+ if (isBackupMode)
+ errors += TestBackupUserInput(src, dst);
+ else
+ errors += TestRestoreUserInput(src);
+
+ // Prompt user to replace backup if one already exists.
+ if (errors == 0)
+ {
+ if (!isBackupMode) return errors != 0;
+ if (!File.Exists(dst)) return errors != 0;
+ DialogResult _dialogResult = MessageHandler.stdMessage(
+ MessageHandler.msgCodes.MainWindow_Warn_OverwriteFile, dst);
+
+ if (_dialogResult == DialogResult.No)
+ errors++;
+ else
+ File.Delete(dst);
}
- bool result = false;
- if (errors == 0)
- result = true;
-
- return result;
+ return errors != 0;
}
- private bool IsDstWithinSrcPath (string src, string dst)
+ private int TestGeneralUserInput(string src, string dst)
{
- bool result = false;
- if (dst.StartsWith(src))
- result = true;
+ int errors = 0;
- return result;
- }
-
- public bool IsAllUserInputValid(string src, string dst, bool isBackupMode)
- {
- bool result = false;
-
- // Test directories.
if (!IsDirectoryAllowed(src))
{
- MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_RestrictedPath,
- src);
- result = true;
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_RestrictedPath, src);
+ errors++;
}
else if (!IsDirectoryAllowed(dst))
{
- MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_RestrictedPath,
- dst);
- result = true;
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_RestrictedPath, dst);
+ errors++;
}
- else if (src.Length < minPathLength ||
- dst.Length < minPathLength)
+ else if (src.Length < minPathLength || dst.Length < minPathLength)
{
MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_PathRootInvalid, null);
- result = true;
+ errors++;
}
- else if (IsDstWithinSrcPath(src, dst))
+
+ return errors;
+ }
+
+ private int TestRestoreUserInput(string src)
+ {
+ int errors = 0;
+
+ if (!File.Exists(src))
+ {
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_ArchiveNotFound, null);
+ errors++;
+ }
+
+ return errors;
+ }
+
+ private int TestBackupUserInput(string src, string dst)
+ {
+ int errors = 0;
+ if (IsDstWithinSrcPath(src, dst))
{
MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_DstWithinSrc, null);
- result = true;
+ errors++;
}
-
- // Prompt user to replace backup if one already exists.
- if (isBackupMode)
+ else if (!Directory.Exists(src))
{
- if (File.Exists(dst))
- {
- DialogResult _dialogResult =
- MessageHandler.stdMessage(MessageHandler.msgCodes.MainWindow_Warn_OverwriteFile, dst);
-
- if (_dialogResult == DialogResult.Yes)
- {
- File.Delete(dst);
- result = false;
- }
- else
- result = true;
- }
+ MessageHandler.errorMessage(MessageHandler.errCodes.MainWindow_DirectoryNotFound, null);
+ errors++;
}
- return result;
+ return errors;
}
+
+ #endregion
}
}
diff --git a/MicronSync/ManageCfg.cs b/MicronSync/ManageCfg.cs
index 77318ed..ce855b2 100644
--- a/MicronSync/ManageCfg.cs
+++ b/MicronSync/ManageCfg.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using System.IO;
using System.Reflection;
@@ -7,8 +8,21 @@ namespace MicronSync
///
/// Settings to store.
///
- public class Values
+ [Obfuscation(Exclude =true, ApplyToMembers = true)]
+ public class Values : INotifyPropertyChanged
{
+ ///
+ /// Flags value to be included in configuration.
+ ///
+ internal class SaveToConfigAttribute : Attribute { }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ protected void OnPropertyChanged()
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ userModifiedConfig = true;
+ }
+
[SaveToConfig]
public Version MSVersion
{
@@ -19,35 +33,104 @@ namespace MicronSync
}
[SaveToConfig]
- public string Description { get; set; }
+ public string Description
+ {
+ get { return _Description; }
+ set
+ {
+ _Description = value;
+ OnPropertyChanged();
+ }
+ }
+ private string _Description;
[SaveToConfig]
- public string BackupSource { get; set; }
+ public string BackupSource
+ {
+ get { return _BackupSource; }
+ set
+ {
+ _BackupSource = value;
+ OnPropertyChanged();
+ }
+ }
+ private string _BackupSource;
[SaveToConfig]
- public string BackupDestination { get; set; }
+ public string BackupDestination
+ {
+ get { return _BackupDestination; }
+ set
+ {
+ _BackupDestination = value;
+ OnPropertyChanged();
+ }
+ }
+ private string _BackupDestination;
[SaveToConfig]
- public string RestoreSource { get; set; }
+ public string RestoreSource
+ {
+ get { return _RestoreSource; }
+ set
+ {
+ _RestoreSource = value;
+ OnPropertyChanged();
+ }
+ }
+ private string _RestoreSource;
[SaveToConfig]
- public string RestoreDestination { get; set; }
+ public string RestoreDestination
+ {
+ get { return _RestoreDestintation; }
+ set
+ {
+ _RestoreDestintation = value;
+ OnPropertyChanged();
+ }
+ }
+ private string _RestoreDestintation;
[SaveToConfig]
- public bool EnablePurge { get; set; }
+ public bool EnablePurge
+ {
+ get { return _EnablePurge; }
+ set
+ {
+ _EnablePurge = value;
+ OnPropertyChanged();
+ }
+ }
+ private bool _EnablePurge;
[SaveToConfig]
- public bool EnableBackup { get; set; }
+ public bool EnableBackup
+ {
+ get { return _EnableBackup; }
+ set
+ {
+ _EnableBackup = value;
+ OnPropertyChanged();
+ }
+ }
+ private bool _EnableBackup;
[SaveToConfig]
- public int CompressionLevel { get; set; } = 4;
+ public int CompressionLevel
+ {
+ get { return _CompressionLevel; }
+ set
+ {
+ _CompressionLevel = value;
+ OnPropertyChanged();
+ }
+ }
+ private int _CompressionLevel = 4;
public string openFile { get; set; }
- ///
- /// Flags value to be included in configuration.
- ///
- internal class SaveToConfigAttribute : Attribute{}
+ public bool userModifiedConfig { get; set; } = false;
}
public class MSConfig : Values
@@ -64,13 +147,9 @@ namespace MicronSync
StreamWriter writer = new StreamWriter(openFile, true);
foreach (var item in GetType().GetProperties())
- {
foreach (var attr in item.GetCustomAttributes(true))
- {
if (item.GetValue(this) != null && item.CanRead)
- writer.WriteLine(String.Format("{0}={1}",item.Name,item.GetValue(this)));
- }
- }
+ writer.WriteLine($"{item.Name}={item.GetValue(this)}");
writer.Close();
}
catch (Exception)
@@ -79,6 +158,7 @@ namespace MicronSync
errors++;
}
+ userModifiedConfig = false;
return errors;
}
@@ -88,25 +168,21 @@ namespace MicronSync
try
{
foreach (var item in GetType().GetProperties())
+ foreach (var attr in item.GetCustomAttributes(true))
{
- foreach (var attr in item.GetCustomAttributes(true))
- {
- ///
- string line;
- using (StreamReader reader = new StreamReader(openFile, true))
+ ///
+ string line;
+ using (StreamReader reader = new StreamReader(openFile, true))
+ while (!string.IsNullOrEmpty(
+ line = reader.ReadLine()))
{
- while (!string.IsNullOrEmpty(
- line = reader.ReadLine()))
+ if (line.StartsWith(item.Name) && item.CanWrite)
{
- if (line.StartsWith(item.Name) && item.CanWrite)
- {
- string readValue = line.ToString().Replace(item.Name, "").TrimStart('=');
- item.SetValue(this, Convert.ChangeType(readValue, item.PropertyType));
- }
+ string readValue = line.ToString().Replace(item.Name, "").TrimStart('=');
+ item.SetValue(this, Convert.ChangeType(readValue, item.PropertyType));
}
}
///
- }
}
}
catch (Exception)
diff --git a/MicronSync/MicronSync.csproj b/MicronSync/MicronSync.csproj
index 707cdac..c2d7680 100644
--- a/MicronSync/MicronSync.csproj
+++ b/MicronSync/MicronSync.csproj
@@ -92,32 +92,44 @@
-
+
Form
-
+
AboutBox.cs
-
-
+
Form
-
+
+ ChangeLog.cs
+
+
+
+ Form
+
+
DonationUI.cs
+
+ Form
+
+
+ DropUI.cs
+
-
+
Form
-
+
NewRegKeyUI.cs
-
+
Form
-
+
WorkerUI.cs
@@ -129,16 +141,22 @@
-
+
AboutBox.cs
-
+
+ ChangeLog.cs
+
+
DonationUI.cs
-
+
+ DropUI.cs
+
+
NewRegKeyUI.cs
-
+
WorkerUI.cs
@@ -169,6 +187,7 @@
+
diff --git a/MicronSync/Properties/AssemblyInfo.cs b/MicronSync/Properties/AssemblyInfo.cs
index b18c8ed..d3682f1 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.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.1")]
+[assembly: AssemblyFileVersion("1.1.0.1")]
[assembly: NeutralResourcesLanguage("en-GB")]
diff --git a/MicronSync/bin/Release/MicronSync.exe b/MicronSync/bin/Release/MicronSync.exe
index acdba48..192a33c 100644
Binary files a/MicronSync/bin/Release/MicronSync.exe and b/MicronSync/bin/Release/MicronSync.exe differ
diff --git a/MicronSync/bin/Release/MicronSync.pdb b/MicronSync/bin/Release/MicronSync.pdb
index bcba05d..5ff56fe 100644
Binary files a/MicronSync/bin/Release/MicronSync.pdb and b/MicronSync/bin/Release/MicronSync.pdb differ