diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 16c6fa2..77deaaa 100644 Binary files a/.vs/DataOrganizer/v16/.suo and b/.vs/DataOrganizer/v16/.suo differ diff --git a/DataOrganizer/DataOrganizer.csproj b/DataOrganizer/DataOrganizer.csproj index 110b378..f28885e 100644 --- a/DataOrganizer/DataOrganizer.csproj +++ b/DataOrganizer/DataOrganizer.csproj @@ -78,6 +78,12 @@ + + Form + + + FileManager.cs + Form @@ -106,6 +112,9 @@ + + FileManager.cs + FileViewer.cs @@ -149,4 +158,8 @@ + + + + \ No newline at end of file diff --git a/DataOrganizer/FileManager.Designer.cs b/DataOrganizer/FileManager.Designer.cs new file mode 100644 index 0000000..4143bab --- /dev/null +++ b/DataOrganizer/FileManager.Designer.cs @@ -0,0 +1,274 @@ +namespace DataOrganizer +{ + partial class FileManager + { + /// + /// 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.MainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.MainMenuStrip = new System.Windows.Forms.MenuStrip(); + this.SelectProfileComboBoxMainMenu = new System.Windows.Forms.ToolStripComboBox(); + this.ManageMainMenuStrip = new System.Windows.Forms.ToolStripMenuItem(); + this.ProfilesManageMainMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.NamingPatternsManageMainMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.SelectFolderGroupComboBoxMainMenu = new System.Windows.Forms.ToolStripComboBox(); + this.FolderGroupTreeView = new System.Windows.Forms.TreeView(); + this.DiffViewTreeView = new System.Windows.Forms.TreeView(); + this.Panel1 = new System.Windows.Forms.Panel(); + this.FileDetailsGroupBox = new System.Windows.Forms.GroupBox(); + this.DiffResultsGroupBox = new System.Windows.Forms.GroupBox(); + this.ScanSelectedFolderGroupButton = new System.Windows.Forms.Button(); + this.CompareAgainstGroupBox = new System.Windows.Forms.GroupBox(); + this.CompareAgainstProfileComboBox = new System.Windows.Forms.ComboBox(); + this.CompareAgainstFolderGroupComboBox = new System.Windows.Forms.ComboBox(); + this.CompareButton = new System.Windows.Forms.Button(); + this.MainLayoutPanel.SuspendLayout(); + this.MainMenuStrip.SuspendLayout(); + this.Panel1.SuspendLayout(); + this.CompareAgainstGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // MainLayoutPanel + // + this.MainLayoutPanel.ColumnCount = 3; + this.MainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); + this.MainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34F)); + this.MainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); + this.MainLayoutPanel.Controls.Add(this.MainMenuStrip, 0, 0); + this.MainLayoutPanel.Controls.Add(this.FolderGroupTreeView, 0, 2); + this.MainLayoutPanel.Controls.Add(this.DiffViewTreeView, 2, 2); + this.MainLayoutPanel.Controls.Add(this.Panel1, 0, 1); + this.MainLayoutPanel.Controls.Add(this.FileDetailsGroupBox, 1, 2); + this.MainLayoutPanel.Controls.Add(this.DiffResultsGroupBox, 1, 3); + this.MainLayoutPanel.Controls.Add(this.CompareAgainstGroupBox, 2, 1); + this.MainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.MainLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.MainLayoutPanel.Name = "MainLayoutPanel"; + this.MainLayoutPanel.RowCount = 4; + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.MainLayoutPanel.Size = new System.Drawing.Size(1278, 844); + this.MainLayoutPanel.TabIndex = 0; + // + // MainMenuStrip + // + this.MainLayoutPanel.SetColumnSpan(this.MainMenuStrip, 3); + this.MainMenuStrip.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); + this.MainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + this.MainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ManageMainMenuStrip, + this.SelectProfileComboBoxMainMenu, + this.SelectFolderGroupComboBoxMainMenu}); + this.MainMenuStrip.Location = new System.Drawing.Point(0, 0); + this.MainMenuStrip.Name = "MainMenuStrip"; + this.MainMenuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; + this.MainMenuStrip.Size = new System.Drawing.Size(1278, 37); + this.MainMenuStrip.TabIndex = 0; + this.MainMenuStrip.Text = "menuStrip1"; + // + // SelectProfileComboBoxMainMenu + // + this.SelectProfileComboBoxMainMenu.BackColor = System.Drawing.Color.Gainsboro; + this.SelectProfileComboBoxMainMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.SelectProfileComboBoxMainMenu.Name = "SelectProfileComboBoxMainMenu"; + this.SelectProfileComboBoxMainMenu.Size = new System.Drawing.Size(200, 33); + // + // ManageMainMenuStrip + // + this.ManageMainMenuStrip.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ProfilesManageMainMenu, + this.NamingPatternsManageMainMenu}); + this.ManageMainMenuStrip.Name = "ManageMainMenuStrip"; + this.ManageMainMenuStrip.Size = new System.Drawing.Size(92, 33); + this.ManageMainMenuStrip.Text = "&Manage"; + // + // ProfilesManageMainMenu + // + this.ProfilesManageMainMenu.Name = "ProfilesManageMainMenu"; + this.ProfilesManageMainMenu.Size = new System.Drawing.Size(270, 34); + this.ProfilesManageMainMenu.Text = "&Profiles"; + this.ProfilesManageMainMenu.Click += new System.EventHandler(this.ProfilesManageMainMenu_Click); + // + // NamingPatternsManageMainMenu + // + this.NamingPatternsManageMainMenu.Name = "NamingPatternsManageMainMenu"; + this.NamingPatternsManageMainMenu.Size = new System.Drawing.Size(270, 34); + this.NamingPatternsManageMainMenu.Text = "&Naming Patterns"; + this.NamingPatternsManageMainMenu.Click += new System.EventHandler(this.NamingPatternsManageMainMenu_Click); + // + // SelectFolderGroupComboBoxMainMenu + // + this.SelectFolderGroupComboBoxMainMenu.BackColor = System.Drawing.Color.Gainsboro; + this.SelectFolderGroupComboBoxMainMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.SelectFolderGroupComboBoxMainMenu.Name = "SelectFolderGroupComboBoxMainMenu"; + this.SelectFolderGroupComboBoxMainMenu.Size = new System.Drawing.Size(200, 33); + // + // FolderGroupTreeView + // + this.FolderGroupTreeView.BackColor = System.Drawing.Color.WhiteSmoke; + this.FolderGroupTreeView.Dock = System.Windows.Forms.DockStyle.Fill; + this.FolderGroupTreeView.FullRowSelect = true; + this.FolderGroupTreeView.Location = new System.Drawing.Point(3, 203); + this.FolderGroupTreeView.Name = "FolderGroupTreeView"; + this.MainLayoutPanel.SetRowSpan(this.FolderGroupTreeView, 2); + this.FolderGroupTreeView.ShowLines = false; + this.FolderGroupTreeView.Size = new System.Drawing.Size(415, 638); + this.FolderGroupTreeView.TabIndex = 1; + this.FolderGroupTreeView.TabStop = false; + // + // DiffViewTreeView + // + this.DiffViewTreeView.BackColor = System.Drawing.Color.WhiteSmoke; + this.DiffViewTreeView.Dock = System.Windows.Forms.DockStyle.Fill; + this.DiffViewTreeView.Location = new System.Drawing.Point(858, 203); + this.DiffViewTreeView.Name = "DiffViewTreeView"; + this.MainLayoutPanel.SetRowSpan(this.DiffViewTreeView, 2); + this.DiffViewTreeView.Size = new System.Drawing.Size(417, 638); + this.DiffViewTreeView.TabIndex = 2; + // + // Panel1 + // + this.Panel1.Controls.Add(this.ScanSelectedFolderGroupButton); + this.Panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.Panel1.Location = new System.Drawing.Point(3, 43); + this.Panel1.Name = "Panel1"; + this.Panel1.Size = new System.Drawing.Size(415, 154); + this.Panel1.TabIndex = 3; + // + // FileDetailsGroupBox + // + this.FileDetailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.FileDetailsGroupBox.Location = new System.Drawing.Point(424, 203); + this.FileDetailsGroupBox.Name = "FileDetailsGroupBox"; + this.FileDetailsGroupBox.Size = new System.Drawing.Size(428, 315); + this.FileDetailsGroupBox.TabIndex = 5; + this.FileDetailsGroupBox.TabStop = false; + this.FileDetailsGroupBox.Text = "File Details:"; + // + // DiffResultsGroupBox + // + this.DiffResultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.DiffResultsGroupBox.Location = new System.Drawing.Point(424, 524); + this.DiffResultsGroupBox.Name = "DiffResultsGroupBox"; + this.DiffResultsGroupBox.Size = new System.Drawing.Size(428, 317); + this.DiffResultsGroupBox.TabIndex = 6; + this.DiffResultsGroupBox.TabStop = false; + this.DiffResultsGroupBox.Text = "Diff Results:"; + // + // ScanSelectedFolderGroupButton + // + this.ScanSelectedFolderGroupButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ScanSelectedFolderGroupButton.Enabled = false; + this.ScanSelectedFolderGroupButton.Location = new System.Drawing.Point(227, 111); + this.ScanSelectedFolderGroupButton.Name = "ScanSelectedFolderGroupButton"; + this.ScanSelectedFolderGroupButton.Size = new System.Drawing.Size(185, 40); + this.ScanSelectedFolderGroupButton.TabIndex = 0; + this.ScanSelectedFolderGroupButton.Text = "Scan for Changes"; + this.ScanSelectedFolderGroupButton.UseVisualStyleBackColor = true; + // + // CompareAgainstGroupBox + // + this.CompareAgainstGroupBox.Controls.Add(this.CompareButton); + this.CompareAgainstGroupBox.Controls.Add(this.CompareAgainstFolderGroupComboBox); + this.CompareAgainstGroupBox.Controls.Add(this.CompareAgainstProfileComboBox); + this.CompareAgainstGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.CompareAgainstGroupBox.Location = new System.Drawing.Point(858, 43); + this.CompareAgainstGroupBox.Name = "CompareAgainstGroupBox"; + this.CompareAgainstGroupBox.Size = new System.Drawing.Size(417, 154); + this.CompareAgainstGroupBox.TabIndex = 7; + this.CompareAgainstGroupBox.TabStop = false; + this.CompareAgainstGroupBox.Text = "Compare Against:"; + // + // CompareAgainstProfileComboBox + // + this.CompareAgainstProfileComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CompareAgainstProfileComboBox.FormattingEnabled = true; + this.CompareAgainstProfileComboBox.Location = new System.Drawing.Point(6, 34); + this.CompareAgainstProfileComboBox.Name = "CompareAgainstProfileComboBox"; + this.CompareAgainstProfileComboBox.Size = new System.Drawing.Size(200, 28); + this.CompareAgainstProfileComboBox.TabIndex = 0; + // + // CompareAgainstFolderGroupComboBox + // + this.CompareAgainstFolderGroupComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CompareAgainstFolderGroupComboBox.FormattingEnabled = true; + this.CompareAgainstFolderGroupComboBox.Location = new System.Drawing.Point(6, 83); + this.CompareAgainstFolderGroupComboBox.Name = "CompareAgainstFolderGroupComboBox"; + this.CompareAgainstFolderGroupComboBox.Size = new System.Drawing.Size(200, 28); + this.CompareAgainstFolderGroupComboBox.TabIndex = 1; + // + // CompareButton + // + this.CompareButton.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.CompareButton.Enabled = false; + this.CompareButton.Location = new System.Drawing.Point(301, 109); + this.CompareButton.Name = "CompareButton"; + this.CompareButton.Size = new System.Drawing.Size(107, 41); + this.CompareButton.TabIndex = 2; + this.CompareButton.Text = "Compare"; + this.CompareButton.UseVisualStyleBackColor = true; + // + // FileManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1278, 844); + this.Controls.Add(this.MainLayoutPanel); + this.Name = "FileManager"; + this.Text = "File Manager"; + this.MainLayoutPanel.ResumeLayout(false); + this.MainLayoutPanel.PerformLayout(); + this.MainMenuStrip.ResumeLayout(false); + this.MainMenuStrip.PerformLayout(); + this.Panel1.ResumeLayout(false); + this.CompareAgainstGroupBox.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel MainLayoutPanel; + private System.Windows.Forms.MenuStrip MainMenuStrip; + private System.Windows.Forms.ToolStripComboBox SelectProfileComboBoxMainMenu; + private System.Windows.Forms.ToolStripMenuItem ManageMainMenuStrip; + private System.Windows.Forms.ToolStripMenuItem ProfilesManageMainMenu; + private System.Windows.Forms.ToolStripMenuItem NamingPatternsManageMainMenu; + private System.Windows.Forms.ToolStripComboBox SelectFolderGroupComboBoxMainMenu; + private System.Windows.Forms.TreeView FolderGroupTreeView; + private System.Windows.Forms.TreeView DiffViewTreeView; + private System.Windows.Forms.Panel Panel1; + private System.Windows.Forms.GroupBox FileDetailsGroupBox; + private System.Windows.Forms.GroupBox DiffResultsGroupBox; + private System.Windows.Forms.Button ScanSelectedFolderGroupButton; + private System.Windows.Forms.GroupBox CompareAgainstGroupBox; + private System.Windows.Forms.ComboBox CompareAgainstProfileComboBox; + private System.Windows.Forms.ComboBox CompareAgainstFolderGroupComboBox; + private System.Windows.Forms.Button CompareButton; + } +} \ No newline at end of file diff --git a/DataOrganizer/FileManager.cs b/DataOrganizer/FileManager.cs new file mode 100644 index 0000000..351c780 --- /dev/null +++ b/DataOrganizer/FileManager.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DataOrganizer +{ + public partial class FileManager : Form + { + private List Profiles { get; set; } = new List(); + private List FolderGroups { get; set; } = new List(); + private Snapshot ActiveSnapshot { get; set; } + + public FileManager() + { + InitializeComponent(); + + SelectProfileComboBoxMainMenu.SelectedIndexChanged += SelectProfileComboBoxMainMenu_SelectedIndexChanged; + SelectFolderGroupComboBoxMainMenu.SelectedIndexChanged += SelectFolderGroupComboBoxMainMenu_SelectedIndexChanged; + CompareAgainstProfileComboBox.SelectedIndexChanged += CompareAgainstProfileComboBox_SelectedIndexChanged; + CompareAgainstFolderGroupComboBox.SelectedIndexChanged += CompareAgainstFolderGroupComboBox_SelectedIndexChanged; + CompareButton.Click += CompareButton_Click; + + PopulateProfileComboBox(); + } + + private void CompareButton_Click(object sender, EventArgs e) + { + var db = new DB(); + var p = GetProfileToCompare(); + var f = GetFolderGroupToCompare(); + + } + + private void CompareAgainstProfileComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + ClearDiffResults(); + + CompareAgainstFolderGroupComboBox.Items.Clear(); + + var profile = GetProfileToCompare(); + + foreach(var folder in profile.FolderGroups) + CompareAgainstFolderGroupComboBox.Items.Add(folder.Name); + + if(profile.FolderGroups.Count > 0) CompareAgainstFolderGroupComboBox.SelectedIndex = 0; + } + + private void CompareAgainstFolderGroupComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + ClearDiffResults(); + + CompareButton.Enabled = ScanSelectedFolderGroupButton.Enabled; + } + + private void SelectFolderGroupComboBoxMainMenu_SelectedIndexChanged(object sender, EventArgs e) + { + ClearForm(true); + + var db = new DB(); + var folderGroup = GetSelectedFolderGroup(); + + var files = db.GetFilesForProfileByFolderGroup(GetSelectedProfile().Id, folderGroup.Id); + ActiveSnapshot = new Snapshot(files, folderGroup); + + foreach(var orgFolder in ActiveSnapshot.Root.Folders.Values) + { + FolderGroupTreeView.Nodes.Add(BuildTreeNode(orgFolder)); + } + + ScanSelectedFolderGroupButton.Enabled = files.Count > 0; + CompareButton.Enabled = files.Count > 0; + } + + private TreeNode BuildTreeNode(Folder folder) + { + var node = new TreeNode(folder.Name) { Name = folder.FullPath }; + + foreach(var dir in folder.Folders.Values) + { + node.Nodes.Add(BuildTreeNode(dir)); + } + + foreach(var file in folder.Files.Values) + { + node.Nodes.Add(new TreeNode(file.Name) { Name = file.FullPath }); + } + + return node; + } + + private void SelectProfileComboBoxMainMenu_SelectedIndexChanged(object sender, EventArgs e) + { + ClearForm(); + + FolderGroups = GetSelectedProfile().FolderGroups; + + SelectFolderGroupComboBoxMainMenu.Items.Clear(); + CompareAgainstProfileComboBox.Items.Clear(); + + foreach (var folder in FolderGroups) + SelectFolderGroupComboBoxMainMenu.Items.Add(folder.Name); + + if (FolderGroups.Count > 0) SelectFolderGroupComboBoxMainMenu.SelectedIndex = 0; + + if(Profiles.Count > 1) + { + foreach(var profile in Profiles) + if(profile.Name != SelectProfileComboBoxMainMenu.Text) + CompareAgainstProfileComboBox.Items.Add(profile.Name); + + CompareAgainstProfileComboBox.SelectedIndex = 0; + } + } + + private void ClearForm(bool isFolderGroupChange = false) + { + FolderGroupTreeView.Nodes.Clear(); + DiffViewTreeView.Nodes.Clear(); + if (!isFolderGroupChange) + { + CompareAgainstProfileComboBox.Items.Clear(); + CompareAgainstFolderGroupComboBox.Items.Clear(); + } + CompareButton.Enabled = false; + ScanSelectedFolderGroupButton.Enabled = false; + } + + private void ClearDiffResults() + { + DiffViewTreeView.Nodes.Clear(); + } + + private void PopulateProfileComboBox() + { + var db = new DB(); + Profiles = db.GetProfiles(); + SelectProfileComboBoxMainMenu.Items.Clear(); + + foreach(var profile in Profiles) + SelectProfileComboBoxMainMenu.Items.Add(profile.Name); + + if(Profiles.Count > 0) SelectProfileComboBoxMainMenu.SelectedIndex = 0; + } + + private void RefreshForm() + { + ClearForm(); + + PopulateProfileComboBox(); + } + + private DB.Profile GetSelectedProfile() + { + return Profiles[SelectProfileComboBoxMainMenu.SelectedIndex]; + } + + private DB.FolderGroup GetSelectedFolderGroup() + { + return FolderGroups[SelectFolderGroupComboBoxMainMenu.SelectedIndex]; + } + + private DB.Profile GetProfileToCompare() + { + return Profiles.First(x => x.Name == CompareAgainstProfileComboBox.Text); + } + + private DB.FolderGroup GetFolderGroupToCompare() + { + return GetProfileToCompare().FolderGroups.First(x => x.Name == CompareAgainstFolderGroupComboBox.Text); + + } + + private void ProfilesManageMainMenu_Click(object sender, EventArgs e) + { + var form = new ProfileManager(); + form.ShowDialog(); + + RefreshForm(); + } + + private void NamingPatternsManageMainMenu_Click(object sender, EventArgs e) + { + var form = new NamingConventionManager(); + form.ShowDialog(); + } + } +} diff --git a/DataOrganizer/FileManager.resx b/DataOrganizer/FileManager.resx new file mode 100644 index 0000000..e6884dd --- /dev/null +++ b/DataOrganizer/FileManager.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/DataOrganizer/MainForm.Designer.cs b/DataOrganizer/MainForm.Designer.cs index 46d971a..b4d67d9 100644 --- a/DataOrganizer/MainForm.Designer.cs +++ b/DataOrganizer/MainForm.Designer.cs @@ -36,6 +36,7 @@ this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteDBToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.manageNamingPatternsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newFileManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainMenu.SuspendLayout(); this.SuspendLayout(); // @@ -57,7 +58,8 @@ this.FileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ManageProfilesFileMainMenu, this.FileManagerFileMainMenu, - this.manageNamingPatternsToolStripMenuItem}); + this.manageNamingPatternsToolStripMenuItem, + this.newFileManagerToolStripMenuItem}); this.FileMainMenu.Name = "FileMainMenu"; this.FileMainMenu.Size = new System.Drawing.Size(54, 29); this.FileMainMenu.Text = "&File"; @@ -112,6 +114,13 @@ this.manageNamingPatternsToolStripMenuItem.Text = "Manage &Naming Patterns"; this.manageNamingPatternsToolStripMenuItem.Click += new System.EventHandler(this.manageNamingPatternsToolStripMenuItem_Click); // + // newFileManagerToolStripMenuItem + // + this.newFileManagerToolStripMenuItem.Name = "newFileManagerToolStripMenuItem"; + this.newFileManagerToolStripMenuItem.Size = new System.Drawing.Size(314, 34); + this.newFileManagerToolStripMenuItem.Text = "New File Manager"; + this.newFileManagerToolStripMenuItem.Click += new System.EventHandler(this.newFileManagerToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -140,6 +149,7 @@ private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteDBToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem manageNamingPatternsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem newFileManagerToolStripMenuItem; } } diff --git a/DataOrganizer/MainForm.cs b/DataOrganizer/MainForm.cs index 3cd25a1..d1607ad 100644 --- a/DataOrganizer/MainForm.cs +++ b/DataOrganizer/MainForm.cs @@ -40,5 +40,11 @@ namespace DataOrganizer var form = new NamingConventionManager(); form.ShowDialog(); } + + private void newFileManagerToolStripMenuItem_Click(object sender, EventArgs e) + { + var form = new FileManager(); + form.ShowDialog(); + } } } diff --git a/DataOrganizer/Snapshot.cs b/DataOrganizer/Snapshot.cs index dd8d7ba..8c8af3d 100644 --- a/DataOrganizer/Snapshot.cs +++ b/DataOrganizer/Snapshot.cs @@ -211,6 +211,51 @@ namespace DataOrganizer } } + public SnapshotComparsion Diff(Snapshot snapshot) + { + return Compare(this, snapshot); + } + + private SnapshotComparsion Compare(Snapshot a, Snapshot b) + { + var newFiles = new List(); + var modifiedFiles = new List(); + var deletedFiles = new List(); + var existingFiles = a.Files.Values.Except(b.Files.Values); + var newOrgFolders = new List(); + + foreach (var file in b.Files) + if (!a.Files.ContainsKey(file.Key)) newFiles.Add(file.Value); + + foreach (var folder in b.OrganizationFolders) + { + if (!a.OrganizationFolders.ContainsKey(folder.Key) && folder.Key != a.Root.FullPath) + { + newOrgFolders.Add(b.Directories[folder.Key]); + } + } + + foreach (var existingFile in existingFiles) + { + if (!b.Files.ContainsKey(existingFile.FullPath)) + { + deletedFiles.Add(existingFile); + } + else if (existingFile.ModifiedDate != b.Files[existingFile.FullPath].ModifiedDate) + { + modifiedFiles.Add(b.Files[existingFile.FullPath]); + } + } + + return new SnapshotComparsion() + { + NewFiles = newFiles, + ModifiedFiles = modifiedFiles, + DeletedFiles = deletedFiles, + NewOrganizationalFolders = newOrgFolders + }; + } + public struct Duplicate { public DB.DBFileSnapshot File; @@ -394,6 +439,9 @@ namespace DataOrganizer public class SnapshotComparsion { - + public List NewFiles { get; set; } + public List ModifiedFiles { get; set; } + public List DeletedFiles { get; set; } + public List NewOrganizationalFolders { get; set; } } }