Skip to content

Commit

Permalink
v1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
user413 committed Jun 8, 2023
1 parent 6ed5d31 commit 43de817
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 79 deletions.
9 changes: 6 additions & 3 deletions BackupHelper/BackupHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright>Copyright © Nain 2023</Copyright>
<FileVersion></FileVersion>
<ApplicationIcon>Resources\backup_helper_icon.ico</ApplicationIcon>
<Version>1.5.1</Version>
<Version>1.5.2</Version>
<Authors>Nain</Authors>
<Title>BackupHelper</Title>
<Description>Small .NET 7 app to facilitate backup of files and directories with advanced settings and binary comparison. These settings are saved into profiles.</Description>
Expand All @@ -34,11 +34,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FileControlUtility" Version="1.3.0" />
<PackageReference Include="FormsUtility" Version="1.1.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Library\FileControlUtility\FileControlUtility\FileControlUtility.csproj" />
<ProjectReference Include="..\..\..\Library\FormsUtility\FormsUtility\FormsUtility.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
13 changes: 7 additions & 6 deletions BackupHelper/Forms/FormEditOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BackupHelper.model;
using FileControlUtility;
using Nain;
using Nain.FormsUtility;

namespace BackupHelper
{
Expand Down Expand Up @@ -78,12 +79,12 @@ private void FillFields(Options option)
foreach (string txt in option.FilteredFileNamesAndExtensions)
listViewFilesAndExts.Items.Add(new ListViewItem(txt));

FormsUtility.ResizeListViewColumns(listViewFilesAndExts);
ListViewUtility.ResizeColumns(listViewFilesAndExts);

foreach (string txt in option.FilteredDirectories)
listViewDirs.Items.Add(new ListViewItem(txt));

FormsUtility.ResizeListViewColumns(listViewDirs);
ListViewUtility.ResizeColumns(listViewDirs);

if (option.FilteredFileNamesAndExtensions.Count > 0 && option.FilterFilesAndExts)
tabControlFilter.SelectedTab = tabPageFilterFilesAndExts;
Expand Down Expand Up @@ -285,7 +286,7 @@ private void ComboBoxMethod_DrawItem(object sender, DrawItemEventArgs args)
// args.DrawFocusRectangle();
//}

FormsUtility.DrawItem(comboBoxMethod, args, checkBoxDeleteUncommonFiles.Checked && args.Index == 3);
ComboBoxUtility.DrawItem(comboBoxMethod, args, checkBoxDeleteUncommonFiles.Checked && args.Index == 3);
}

private void ComboBoxMethod_SelectedIndexChanged(object sender, EventArgs args)
Expand Down Expand Up @@ -386,7 +387,7 @@ private void AddFilterFilesListViewItem()
}

listViewFilesAndExts.Items.Add(new ListViewItem(fileOrExt));
FormsUtility.ResizeListViewColumns(listViewFilesAndExts);
ListViewUtility.ResizeColumns(listViewFilesAndExts);
}
catch (Exception e)
{
Expand All @@ -413,7 +414,7 @@ private void AddFilterDirsListViewItem()
}

listViewDirs.Items.Add(new ListViewItem(dir));
FormsUtility.ResizeListViewColumns(listViewDirs);
ListViewUtility.ResizeColumns(listViewDirs);
}
catch (Exception e)
{
Expand Down Expand Up @@ -445,7 +446,7 @@ private void RemoveFilterListViewItem(ListView listView, string text)
return;
}

FormsUtility.ResizeListViewColumns(listView);
ListViewUtility.ResizeColumns(listView);
}

private ListViewItem FindListViewItem(ListView listView, string text)
Expand Down
74 changes: 40 additions & 34 deletions BackupHelper/Forms/FormOptionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Data;
using FileControlUtility;
using Nain.FormsUtility;

namespace BackupHelper
{
Expand Down Expand Up @@ -65,7 +66,7 @@ private void ListViewOptions_MouseUp(object sender, MouseEventArgs e)

private void ClickTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Invoke(new Action(() =>
Invoke(() =>
{
//if (e.Button != MouseButtons.Left) return;
if (ClickedItem == null)
Expand All @@ -88,7 +89,7 @@ private void ClickTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
EditSelectedOption();
}
}));
});
}

private void ListViewOptions_MouseDown(object sender, MouseEventArgs e)
Expand All @@ -113,44 +114,49 @@ private void ListViewOptions_MouseDown(object sender, MouseEventArgs e)

private void ListViewOptions_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(List<ListViewItem>)))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
//if (e.Data.GetDataPresent(typeof(List<ListViewItem>)))
// e.Effect = DragDropEffects.Move;
//else
// e.Effect = DragDropEffects.None;

ListViewUtility.DragEnter(e);
}

private void ListViewOptions_DragDrop(object sender, DragEventArgs args)
{
try
{
List<ListViewItem> selectedItems = (List<ListViewItem>)args.Data.GetData(typeof(List<ListViewItem>));
Point targetCoordinates = listViewOptions.PointToClient(new Point(args.X, args.Y));
ListViewItem targetItem = listViewOptions.GetItemAt(targetCoordinates.X, targetCoordinates.Y);

if (targetItem == null || selectedItems.Exists(i => i == targetItem) /*|| targetItem.Group != selectedItems[0].Group*/) return;

bool indexIsBehind = selectedItems.Last().Index < targetItem.Index;

try
{
foreach (ListViewItem i in selectedItems)
{
listViewOptions.Items.Remove(i);
i.Group = targetItem.Group;
}

for (int i = 0; i < selectedItems.Count; i++)
listViewOptions.Items.Insert(indexIsBehind ? targetItem.Index + 1 + i : targetItem.Index, selectedItems[i]);

//-- Due to a bug / makes items appear in the correct listview positions
//string tempGName = targetItem.Group.Header;
//targetItem.Group.Header = "tmp";
//targetItem.Group.Header = tempGName;
}
finally
{
UpdateOptionListViewIndexes();
}
//List<ListViewItem> selectedItems = (List<ListViewItem>)args.Data.GetData(typeof(List<ListViewItem>));
//Point targetCoordinates = listViewOptions.PointToClient(new Point(args.X, args.Y));
//ListViewItem targetItem = listViewOptions.GetItemAt(targetCoordinates.X, targetCoordinates.Y);

//if (targetItem == null || selectedItems.Exists(i => i == targetItem) /*|| targetItem.Group != selectedItems[0].Group*/) return;

//bool indexIsBehind = selectedItems.Last().Index < targetItem.Index;

//try
//{
// foreach (ListViewItem i in selectedItems)
// {
// listViewOptions.Items.Remove(i);
// i.Group = targetItem.Group;
// }

// for (int i = 0; i < selectedItems.Count; i++)
// listViewOptions.Items.Insert(indexIsBehind ? targetItem.Index + 1 + i : targetItem.Index, selectedItems[i]);

// //-- Due to a bug / makes items appear in the correct listview positions
// //string tempGName = targetItem.Group.Header;
// //targetItem.Group.Header = "tmp";
// //targetItem.Group.Header = tempGName;
//}
//finally
//{
// UpdateOptionListViewIndexes();
//}

ListViewUtility.DragDrop(listViewOptions, args);
UpdateOptionListViewIndexes();
}
catch (Exception e)
{
Expand Down
90 changes: 54 additions & 36 deletions BackupHelper/Forms/FormProfileMenu.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BackupHelper.model;
using BinanceAutoTrader;
using Nain.FormsUtility;
using System.Data;
using System.Reflection;

Expand Down Expand Up @@ -48,7 +49,7 @@ public FormProfileMenu()

private void ClickTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Invoke(new Action(() =>
Invoke(() =>
{
if (ClickedItem == null)
{
Expand All @@ -58,6 +59,7 @@ private void ClickTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
if (MouseDownCount == 1)
{
//perform dragdrop if no mouseup
if (MouseUpCount > 0) return;
List<ListViewItem> selectedItems = listViewProfile.SelectedItems.Cast<ListViewItem>().ToList();
Expand All @@ -66,11 +68,11 @@ private void ClickTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
listViewProfile.DoDragDrop(selectedItems, DragDropEffects.Move);
}
else
else //double click
{
OpenSelectedProfile();
}
}));
});
}

private void ListViewProfile_MouseUp(object sender, MouseEventArgs e)
Expand Down Expand Up @@ -102,44 +104,59 @@ private void ListViewProfile_MouseDown(object sender, MouseEventArgs e)

private void ListViewProfile_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(List<ListViewItem>)))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
//if (e.Data.GetDataPresent(typeof(List<ListViewItem>)))
// e.Effect = DragDropEffects.Move;
//else
// e.Effect = DragDropEffects.None;

ListViewUtility.DragEnter(e);
}

private void ListViewProfile_DragDrop(object sender, DragEventArgs args)
{
try
{
List<ListViewItem> selectedItems = (List<ListViewItem>)args.Data.GetData(typeof(List<ListViewItem>));
Point targetCoordinates = listViewProfile.PointToClient(new Point(args.X, args.Y));
ListViewItem targetItem = listViewProfile.GetItemAt(targetCoordinates.X, targetCoordinates.Y);

if (targetItem == null || selectedItems.Exists(i => i == targetItem) /*|| targetItem.Group != selectedItems[0].Group*/) return;

bool indexIsBehind = selectedItems.Last().Index < targetItem.Index;

try
{
foreach (ListViewItem i in selectedItems)
{
listViewProfile.Items.Remove(i);
i.Group = targetItem.Group;
}

for (int i = 0; i < selectedItems.Count; i++)
listViewProfile.Items.Insert(indexIsBehind ? targetItem.Index + 1 + i : targetItem.Index, selectedItems[i]);

//-- Due to a bug / makes items appear in the correct listview positions
string tempGName = targetItem.Group.Header;
targetItem.Group.Header = "tmp";
targetItem.Group.Header = tempGName;
}
finally
{
UpdateProfileListViewIndexes();
}
//List<ListViewItem> selectedItems = (List<ListViewItem>)args.Data.GetData(typeof(List<ListViewItem>));
//Point targetCoordinates = listViewProfile.PointToClient(new Point(args.X, args.Y));
//ListViewItem targetItem = listViewProfile.GetItemAt(targetCoordinates.X, targetCoordinates.Y);

//if (targetItem == null || selectedItems.Exists(i => i == targetItem) /*|| targetItem.Group != selectedItems[0].Group*/) return;

//bool indexIsBehind = selectedItems.Last().Index < targetItem.Index;

//try
//{
// foreach (ListViewItem i in selectedItems)
// {
// listViewProfile.Items.Remove(i);
// i.Group = targetItem.Group;
// }

// for (int i = 0; i < selectedItems.Count; i++)
// listViewProfile.Items.Insert(indexIsBehind ? targetItem.Index + 1 + i : targetItem.Index, selectedItems[i]);

// //string tempGName;
// ListViewGroup tempGroup;

// foreach (ListViewItem item in listViewProfile.Items)
// {
// //-- Due to a bug / makes items appear in the correct listview positions
// //tempGName = item.Group.Header;
// //item.Group.Header = "tmp";
// //item.Group.Header = tempGName;
// tempGroup = item.Group;
// item.Group = null;
// item.Group = tempGroup;
// item.Selected = false; //items need to be unselected
// }
//}
//finally
//{
// UpdateProfileListViewIndexes();
//}

ListViewUtility.DragDrop(listViewProfile, args);
UpdateProfileListViewIndexes();
}
catch (Exception e)
{
Expand Down Expand Up @@ -339,7 +356,8 @@ private void ButtonOpenLogFile_Click(object sender, EventArgs args)
{
try
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log.txt",
UseShellExecute = true
});
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.5.2

Fixed/altered:
- Rearrange profiles - fixed

## 1.5.1

New features:
Expand Down

0 comments on commit 43de817

Please sign in to comment.