|
@@ -1,5 +1,6 @@
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using PixiEditor.Models.Controllers;
|
|
|
using PixiEditor.Models.Enums;
|
|
@@ -76,4 +77,81 @@ internal partial class LayersManager : UserControl
|
|
|
{
|
|
|
((Border)sender).BorderBrush = Brushes.Transparent;
|
|
|
}
|
|
|
+
|
|
|
+ private static int TraverseRange(Guid bound1, Guid bound2, FolderViewModel root, Action<StructureMemberViewModel> action, int matches = 0)
|
|
|
+ {
|
|
|
+ if (matches == 2)
|
|
|
+ return 2;
|
|
|
+ foreach (StructureMemberViewModel child in root.Children)
|
|
|
+ {
|
|
|
+ if (child is FolderViewModel innerFolder)
|
|
|
+ {
|
|
|
+ matches = TraverseRange(bound1, bound2, innerFolder, action, matches);
|
|
|
+ }
|
|
|
+ if (matches == 1)
|
|
|
+ action(child);
|
|
|
+ if (matches == 2)
|
|
|
+ return 2;
|
|
|
+ if (child.GuidValue == bound1 || child.GuidValue == bound2)
|
|
|
+ {
|
|
|
+ matches++;
|
|
|
+ if (matches == 1)
|
|
|
+ action(child);
|
|
|
+ if (matches == 2)
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return matches;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void HandleMouseDown(StructureMemberViewModel memberVM)
|
|
|
+ {
|
|
|
+ if (ActiveDocument is null)
|
|
|
+ return;
|
|
|
+ if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
|
|
+ {
|
|
|
+ if (memberVM.Selection == StructureMemberSelectionType.Hard)
|
|
|
+ return;
|
|
|
+ else if (memberVM.Selection == StructureMemberSelectionType.Soft)
|
|
|
+ ActiveDocument.RemoveSoftSelectedMember(memberVM.GuidValue);
|
|
|
+ else if (memberVM.Selection == StructureMemberSelectionType.None)
|
|
|
+ ActiveDocument.AddSoftSelectedMember(memberVM.GuidValue);
|
|
|
+ }
|
|
|
+ else if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
|
|
+ {
|
|
|
+ if (ActiveDocument.SelectedStructureMember is null || ActiveDocument.SelectedStructureMember.GuidValue == memberVM.GuidValue)
|
|
|
+ return;
|
|
|
+ ActiveDocument.ClearSoftSelectedMembers();
|
|
|
+ TraverseRange(
|
|
|
+ ActiveDocument.SelectedStructureMember.GuidValue,
|
|
|
+ memberVM.GuidValue,
|
|
|
+ ActiveDocument.StructureRoot,
|
|
|
+ static member =>
|
|
|
+ {
|
|
|
+ if (member.Selection == StructureMemberSelectionType.None)
|
|
|
+ member.Document.AddSoftSelectedMember(member.GuidValue);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ActiveDocument.SetSelectedMember(memberVM.GuidValue);
|
|
|
+ ActiveDocument.ClearSoftSelectedMembers();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FolderControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.ChangedButton is not MouseButton.Left)
|
|
|
+ return;
|
|
|
+ FolderControl control = (FolderControl)sender;
|
|
|
+ HandleMouseDown(control.Folder);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LayerControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.ChangedButton is not MouseButton.Left)
|
|
|
+ return;
|
|
|
+ LayerControl? control = (LayerControl)sender;
|
|
|
+ HandleMouseDown(control.Layer);
|
|
|
+ }
|
|
|
}
|