Tweaked the profile manager because I just can't leave well enough alone. Now it will name the folder group based on the path chosen, the user has no control over this.

This commit is contained in:
Admin
2020-11-09 11:41:04 -06:00
parent 297b70c76c
commit 9f090b0539
3 changed files with 33 additions and 59 deletions
+16 -20
View File
@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -30,7 +31,6 @@ namespace DataOrganizer
NewContentLocationTextBox.TextChanged += ToggleAddOrUpdateButton;
MachineNameTextBox.TextChanged += MachineNameTextBox_TextChanged;
FolderGroupPathTextBox.TextChanged += ToggleGroupInsertButton;
FolderGroupNameTextBox.TextChanged += ToggleGroupInsertButton;
FolderGroupListView.MouseClick += FolderGroupListView_MouseClick;
deleteMenuItem.Click += DeleteMenuItem_Click;
@@ -90,7 +90,7 @@ namespace DataOrganizer
private void ToggleGroupInsertButton(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(FolderGroupNameTextBox.Text) && !string.IsNullOrEmpty(FolderGroupPathTextBox.Text))
if (!string.IsNullOrEmpty(FolderGroupPathTextBox.Text))
InsertGroupName.Enabled = true;
else
InsertGroupName.Enabled = false;
@@ -207,34 +207,30 @@ namespace DataOrganizer
private void InsertGroupName_Click(object sender, EventArgs e)
{
var groupName = FolderGroupNameTextBox.Text.Trim();
var dir = new DirectoryInfo(FolderGroupPathTextBox.Text);
var groupName = dir.Name;
if(!string.IsNullOrEmpty(groupName))
if (!FolderGroupListView.Items.ContainsKey(groupName))//!FolderGroupsTreeView.Nodes.ContainsKey(groupName))
{
if (!FolderGroupListView.Items.ContainsKey(groupName))//!FolderGroupsTreeView.Nodes.ContainsKey(groupName))
var item = new ListViewItem(groupName);
item.SubItems.Add(FolderGroupPathTextBox.Text);
FolderGroupListView.Items.Add(item);
if (IsUpdating)
{
var item = new ListViewItem(groupName);
item.SubItems.Add(FolderGroupPathTextBox.Text);
var db = new DB();
FolderGroupListView.Items.Add(item);
GetCurrentProfile(out DB.Profile profile);
var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text);
if (IsUpdating)
{
var db = new DB();
GetCurrentProfile(out DB.Profile profile);
var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text);
profile.FolderGroups.Add(new DB.FolderGroup { Name = groupName, Id = newId, Path = FolderGroupPathTextBox.Text });
}
profile.FolderGroups.Add(new DB.FolderGroup { Name = groupName, Id = newId, Path = FolderGroupPathTextBox.Text });
}
}
FolderGroupNameTextBox.Text = string.Empty;
FolderGroupPathTextBox.Text = string.Empty;
FolderGroupNameTextBox.Focus();
FolderGroupPathButton.Focus();
}
private bool GetCurrentProfile(out DB.Profile profile)