Procházet zdrojové kódy

Layers show something

Equbuxu před 3 roky
rodič
revize
e12dec051d

+ 0 - 1
src/PixiEditor/Models/DocumentModels/ActionAccumulator.cs

@@ -6,7 +6,6 @@ using PixiEditor.ChangeableDocument.Actions.Undo;
 using PixiEditor.ChangeableDocument.ChangeInfos;
 using PixiEditor.Models.Rendering;
 using PixiEditor.Models.Rendering.RenderInfos;
-using PixiEditor.ViewModels.Prototype;
 using PixiEditor.ViewModels.SubViewModels.Document;
 
 namespace PixiEditor.Models.DocumentModels;

+ 0 - 1
src/PixiEditor/Models/DocumentModels/DocumentStructureHelper.cs

@@ -1,6 +1,5 @@
 using PixiEditor.ChangeableDocument.Actions.Generated;
 using PixiEditor.ChangeableDocument.Enums;
-using PixiEditor.ViewModels.Prototype;
 using PixiEditor.ViewModels.SubViewModels.Document;
 
 namespace PixiEditor.Models.DocumentModels;

+ 0 - 1
src/PixiEditor/Models/DocumentModels/DocumentUpdater.cs

@@ -8,7 +8,6 @@ using PixiEditor.ChangeableDocument.ChangeInfos.Root;
 using PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditor.Models.BitmapActions;
-using PixiEditor.ViewModels.Prototype;
 using PixiEditor.ViewModels.SubViewModels.Document;
 using SkiaSharp;
 

+ 0 - 1
src/PixiEditor/Models/Rendering/WriteableBitmapUpdater.cs

@@ -6,7 +6,6 @@ using PixiEditor.ChangeableDocument.Changeables.Interfaces;
 using PixiEditor.ChangeableDocument.Rendering;
 using PixiEditor.Models.DocumentModels;
 using PixiEditor.Models.Rendering.RenderInfos;
-using PixiEditor.ViewModels.Prototype;
 using PixiEditor.ViewModels.SubViewModels.Document;
 using SkiaSharp;
 

+ 1 - 1
src/PixiEditor/ViewModels/Prototype/DocumentTransformViewModel.cs → src/PixiEditor/ViewModels/SubViewModels/Document/DocumentTransformViewModel.cs

@@ -2,7 +2,7 @@
 using ChunkyImageLib.DataHolders;
 using PixiEditor.Views.UserControls.TransformOverlay;
 
-namespace PixiEditor.ViewModels.Prototype;
+namespace PixiEditor.ViewModels.SubViewModels.Document;
 #nullable enable
 internal class DocumentTransformViewModel : INotifyPropertyChanged
 {

+ 0 - 1
src/PixiEditor/ViewModels/SubViewModels/Document/DocumentViewModel.cs

@@ -10,7 +10,6 @@ using PixiEditor.Helpers;
 using PixiEditor.Models.BitmapActions;
 using PixiEditor.Models.DocumentModels;
 using PixiEditor.Models.Position;
-using PixiEditor.ViewModels.Prototype;
 using SkiaSharp;
 
 namespace PixiEditor.ViewModels.SubViewModels.Document;

+ 1 - 2
src/PixiEditor/ViewModels/Prototype/FolderViewModel.cs → src/PixiEditor/ViewModels/SubViewModels/Document/FolderViewModel.cs

@@ -1,8 +1,7 @@
 using System.Collections.ObjectModel;
 using PixiEditor.Models.DocumentModels;
-using PixiEditor.ViewModels.SubViewModels.Document;
 
-namespace PixiEditor.ViewModels.Prototype;
+namespace PixiEditor.ViewModels.SubViewModels.Document;
 #nullable enable
 internal class FolderViewModel : StructureMemberViewModel
 {

+ 1 - 2
src/PixiEditor/ViewModels/Prototype/LayerViewModel.cs → src/PixiEditor/ViewModels/SubViewModels/Document/LayerViewModel.cs

@@ -1,8 +1,7 @@
 using PixiEditor.ChangeableDocument.Actions.Generated;
 using PixiEditor.Models.DocumentModels;
-using PixiEditor.ViewModels.SubViewModels.Document;
 
-namespace PixiEditor.ViewModels.Prototype;
+namespace PixiEditor.ViewModels.SubViewModels.Document;
 #nullable enable
 internal class LayerViewModel : StructureMemberViewModel
 {

+ 1 - 2
src/PixiEditor/ViewModels/Prototype/StructureMemberViewModel.cs → src/PixiEditor/ViewModels/SubViewModels/Document/StructureMemberViewModel.cs

@@ -6,10 +6,9 @@ using PixiEditor.ChangeableDocument.Actions.Generated;
 using PixiEditor.ChangeableDocument.Enums;
 using PixiEditor.Helpers;
 using PixiEditor.Models.DocumentModels;
-using PixiEditor.ViewModels.SubViewModels.Document;
 using SkiaSharp;
 
-namespace PixiEditor.ViewModels.Prototype;
+namespace PixiEditor.ViewModels.SubViewModels.Document;
 #nullable enable
 internal abstract class StructureMemberViewModel : INotifyPropertyChanged
 {

+ 5 - 11
src/PixiEditor/ViewModels/SubViewModels/Main/LayersViewModel.cs

@@ -1,7 +1,7 @@
 using System.Windows.Input;
 using PixiEditor.Helpers;
-using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
+using PixiEditor.Models.Commands.Attributes.Evaluators;
 
 namespace PixiEditor.ViewModels.SubViewModels.Main;
 
@@ -10,14 +10,8 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
 {
     public RelayCommand SetActiveLayerCommand { get; set; }
 
-    public RelayCommand NewLayerCommand { get; set; }
-
-    public RelayCommand NewGroupCommand { get; set; }
-
     public RelayCommand CreateGroupFromActiveLayersCommand { get; set; }
 
-    public RelayCommand DeleteSelectedCommand { get; set; }
-
     public RelayCommand DeleteGroupCommand { get; set; }
 
     public RelayCommand DeleteLayersCommand { get; set; }
@@ -42,8 +36,6 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
         : base(owner)
     {
         SetActiveLayerCommand = new RelayCommand(SetActiveLayer);
-        NewLayerCommand = new RelayCommand(NewLayer, CanCreateNewLayer);
-        NewGroupCommand = new RelayCommand(NewGroup, CanCreateNewLayer);
         CreateGroupFromActiveLayersCommand = new RelayCommand(CreateGroupFromActiveLayers, CanCreateGroupFromSelected);
         DeleteLayersCommand = new RelayCommand(DeleteActiveLayers, CanDeleteActiveLayers);
         DuplicateLayerCommand = new RelayCommand(DuplicateLayer, CanDuplicateLayer);
@@ -55,7 +47,6 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
         MergeWithBelowCommand = new RelayCommand(MergeWithBelow, CanMergeWithBelow);
         RenameGroupCommand = new RelayCommand(RenameGroup);
         DeleteGroupCommand = new RelayCommand(DeleteGroup, CanDeleteGroup);
-        DeleteSelectedCommand = new RelayCommand(DeleteSelected, CanDeleteSelected);
     }
 
     public void CreateGroupFromActiveLayers(object parameter)
@@ -63,6 +54,7 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
 
     }
 
+    [Evaluator.CanExecute("PixiEditor.Layer.CanDeleteSelected")]
     public bool CanDeleteSelected(object parameter)
     {
         /*
@@ -92,6 +84,7 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
         return false;
     }
 
+    [Command.Basic("PixiEditor.Layer.DeleteSelected", "Delete selected layer/folder", "", CanExecute = "PixiEditor.Layer.CanDeleteSelected")]
     public void DeleteSelected(object parameter)
     {
         /*
@@ -127,7 +120,8 @@ internal class LayersViewModel : SubViewModel<ViewModelMain>
     {
     }
 
-    public void NewGroup(object parameter)
+    [Command.Basic("PixiEditor.Layer.NewFolder", "New Folder", "Create new folder", CanExecute = "PixiEditor.HasDocument")]
+    public void NewFolder(object parameter)
     {
 
     }

+ 2 - 1
src/PixiEditor/Views/MainWindow.xaml

@@ -665,7 +665,8 @@
                                             CanDockAsTabbedDocument="True"
                                             CanFloat="True">
                                             <layerUserControls:LayersManager
-                                                OpacityInputEnabled="{Binding BitmapManager.ActiveDocument, 
+                                                StructureRoot="{Binding DocumentManagerSubViewModel.ActiveDocument.StructureRoot}"
+                                                OpacityInputEnabled="{Binding DocumentManagerSubViewModel.ActiveDocument, 
                     Converter={converters:NotNullToBoolConverter}}">
                                             </layerUserControls:LayersManager>
                                         </LayoutAnchorable>

+ 11 - 8
src/PixiEditor/Views/UserControls/Layers/LayerGroupControl.xaml → src/PixiEditor/Views/UserControls/Layers/LayerFolderControl.xaml

@@ -1,17 +1,20 @@
-<UserControl x:Class="PixiEditor.Views.UserControls.Layers.LayerGroupControl"
+<UserControl x:Class="PixiEditor.Views.UserControls.Layers.LayerFolderControl"
              x:ClassModifier="internal"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:behaviors="clr-namespace:PixiEditor.Helpers.Behaviours" xmlns:userControls="clr-namespace:PixiEditor.Views" xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters" xmlns:helpers="clr-namespace:PixiEditor.Helpers.UI"
+             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
+             xmlns:behaviors="clr-namespace:PixiEditor.Helpers.Behaviours" xmlns:userControls="clr-namespace:PixiEditor.Views" 
+             xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters" xmlns:helpers="clr-namespace:PixiEditor.Helpers.UI"
              xmlns:userControls1="clr-namespace:PixiEditor.Views.UserControls"
-             mc:Ignorable="d" Focusable="True"
-             d:DesignHeight="60" d:DesignWidth="250" Name="groupControl" DragEnter="GroupControl_DragEnter" DragLeave="GroupControl_DragLeave" DragDrop.Drop="GroupControl_DragLeave">
+             mc:Ignorable="d" 
+             Focusable="True"
+             d:DesignHeight="60" d:DesignWidth="250" Name="folderControl" DragEnter="FolderControl_DragEnter" DragLeave="FolderControl_DragLeave" DragDrop.Drop="FolderControl_DragLeave">
     <UserControl.Resources>
         <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
     </UserControl.Resources>
-    <Border BorderThickness="0 0 0 0.5" BorderBrush="Gray" MinWidth="60" Focusable="True" Tag="{Binding ElementName=groupControl}" MouseDown="Border_MouseDown">
+    <Border BorderThickness="0 0 0 0.5" BorderBrush="Gray" MinWidth="60" Focusable="True" Tag="{Binding ElementName=folderControl}" MouseDown="Border_MouseDown">
         <i:Interaction.Behaviors>
             <behaviors:ClearFocusOnClickBehavior/>
         </i:Interaction.Behaviors>
@@ -30,7 +33,7 @@
                 </Grid.ColumnDefinitions>
                 <CheckBox Style="{StaticResource ImageCheckBox}" VerticalAlignment="Center"
                       IsThreeState="False" HorizontalAlignment="Center" Click="CheckBox_Checked"
-                      IsChecked="{Binding Path=IsVisibleUndoTriggerable, ElementName=groupControl}" Grid.Column="0" Height="16"/>
+                      IsChecked="{Binding Path=IsVisibleUndoTriggerable, ElementName=folderControl}" Grid.Column="0" Height="16"/>
 
                 <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Left">
                     <Rectangle Width="{Binding Path=(helpers:TreeViewItemHelper.Indent).Value, Mode=OneWay, RelativeSource={RelativeSource AncestorType=ItemsPresenter}}" Fill="Transparent" StrokeThickness="0"/>
@@ -38,10 +41,10 @@
                     <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
                         <Border Width="30" Height="30" BorderThickness="1" BorderBrush="Black" Background="{StaticResource MainColor}"
                            Margin="5, 0, 10, 0">
-                            <Image Source="{Binding PreviewImage, ElementName=groupControl}" Stretch="Uniform" Width="20" Height="20">
+                            <Image Source="{Binding PreviewImage, ElementName=folderControl}" Stretch="Uniform" Width="20" Height="20">
                                 <RenderOptions.BitmapScalingMode>
                                     <MultiBinding Converter="{converters:WidthToBitmapScalingModeConverter}">
-                                        <Binding Path="PreviewImage.PixelWidth" ElementName="groupControl"/>
+                                        <Binding Path="PreviewImage.PixelWidth" ElementName="folderControl"/>
                                         <Binding RelativeSource="{RelativeSource Mode=Self}" Path="ActualWidth"/>
                                     </MultiBinding>
                                 </RenderOptions.BitmapScalingMode>

+ 16 - 21
src/PixiEditor/Views/UserControls/Layers/LayerGroupControl.xaml.cs → src/PixiEditor/Views/UserControls/Layers/LayerFolderControl.xaml.cs

@@ -6,29 +6,24 @@ using PixiEditor.ViewModels.SubViewModels.Main;
 
 namespace PixiEditor.Views.UserControls.Layers;
 
-/// <summary>
-/// Interaction logic for LayerFolder.xaml.
-/// </summary>
-internal partial class LayerGroupControl : UserControl
+internal partial class LayerFolderControl : UserControl
 {
-    public Guid GroupGuid
+    public static readonly DependencyProperty GroupGuidProperty =
+        DependencyProperty.Register(nameof(FolderGuid), typeof(Guid), typeof(LayerFolderControl), new PropertyMetadata(Guid.NewGuid()));
+    public Guid FolderGuid
     {
-        get { return (Guid)GetValue(GroupGuidProperty); }
-        set { SetValue(GroupGuidProperty, value); }
+        get => (Guid)GetValue(GroupGuidProperty);
+        set => SetValue(GroupGuidProperty, value);
     }
 
-    public static readonly DependencyProperty GroupGuidProperty =
-        DependencyProperty.Register(nameof(GroupGuid), typeof(Guid), typeof(LayerGroupControl), new PropertyMetadata(Guid.NewGuid()));
-
+    public static readonly DependencyProperty LayersViewModelProperty =
+        DependencyProperty.Register(nameof(LayersViewModel), typeof(LayersViewModel), typeof(LayerFolderControl), new PropertyMetadata(default(LayersViewModel)));
     public LayersViewModel LayersViewModel
     {
         get { return (LayersViewModel)GetValue(LayersViewModelProperty); }
         set { SetValue(LayersViewModelProperty, value); }
     }
 
-    public static readonly DependencyProperty LayersViewModelProperty =
-        DependencyProperty.Register(nameof(LayersViewModel), typeof(LayersViewModel), typeof(LayerGroupControl), new PropertyMetadata(default(LayersViewModel)));
-
     public bool IsVisibleUndoTriggerable
     {
         get { return (bool)GetValue(IsVisibleUndoTriggerableProperty); }
@@ -36,7 +31,7 @@ internal partial class LayerGroupControl : UserControl
     }
 
     public static readonly DependencyProperty IsVisibleUndoTriggerableProperty =
-        DependencyProperty.Register(nameof(IsVisibleUndoTriggerable), typeof(bool), typeof(LayerGroupControl), new PropertyMetadata(true));
+        DependencyProperty.Register(nameof(IsVisibleUndoTriggerable), typeof(bool), typeof(LayerFolderControl), new PropertyMetadata(true));
 
     public float GroupOpacity
     {
@@ -45,10 +40,10 @@ internal partial class LayerGroupControl : UserControl
     }
 
     public static readonly DependencyProperty GroupOpacityProperty =
-        DependencyProperty.Register(nameof(GroupOpacity), typeof(float), typeof(LayerGroupControl), new PropertyMetadata(1f));
+        DependencyProperty.Register(nameof(GroupOpacity), typeof(float), typeof(LayerFolderControl), new PropertyMetadata(1f));
 
 
-    public static string LayerGroupControlDataName = typeof(LayerGroupControl).FullName;
+    public static string LayerGroupControlDataName = typeof(LayerFolderControl).FullName;
     public static string LayerContainerDataName = typeof(LayerStructureItemContainer).FullName;
 
     public string GroupName
@@ -58,7 +53,7 @@ internal partial class LayerGroupControl : UserControl
     }
 
     public static readonly DependencyProperty GroupNameProperty =
-        DependencyProperty.Register(nameof(GroupName), typeof(string), typeof(LayerGroupControl), new PropertyMetadata(default(string)));
+        DependencyProperty.Register(nameof(GroupName), typeof(string), typeof(LayerFolderControl), new PropertyMetadata(default(string)));
 
     public WriteableBitmap PreviewImage
     {
@@ -67,9 +62,9 @@ internal partial class LayerGroupControl : UserControl
     }
 
     public static readonly DependencyProperty PreviewImageProperty =
-        DependencyProperty.Register(nameof(PreviewImage), typeof(WriteableBitmap), typeof(LayerGroupControl), new PropertyMetadata(default(WriteableBitmap)));
+        DependencyProperty.Register(nameof(PreviewImage), typeof(WriteableBitmap), typeof(LayerFolderControl), new PropertyMetadata(default(WriteableBitmap)));
 
-    public LayerGroupControl()
+    public LayerFolderControl()
     {
         InitializeComponent();
     }
@@ -253,12 +248,12 @@ internal partial class LayerGroupControl : UserControl
         }
     }*/
 
-    private void GroupControl_DragEnter(object sender, DragEventArgs e)
+    private void FolderControl_DragEnter(object sender, DragEventArgs e)
     {
         middleDropGrid.Visibility = Visibility.Visible;
     }
 
-    private void GroupControl_DragLeave(object sender, DragEventArgs e)
+    private void FolderControl_DragLeave(object sender, DragEventArgs e)
     {
         middleDropGrid.Visibility = Visibility.Collapsed;
     }

+ 4 - 4
src/PixiEditor/Views/UserControls/Layers/LayerItem.xaml.cs

@@ -143,9 +143,9 @@ internal partial class LayerItem : UserControl
         Grid item = sender as Grid;
         RemoveDragEffect(item);
 
-        if (e.Data.GetDataPresent(LayerGroupControl.LayerContainerDataName))
+        if (e.Data.GetDataPresent(LayerFolderControl.LayerContainerDataName))
         {
-            var data = (LayerStructureItemContainer)e.Data.GetData(LayerGroupControl.LayerContainerDataName);
+            var data = (LayerStructureItemContainer)e.Data.GetData(LayerFolderControl.LayerContainerDataName);
             //Guid layer = data.Layer.GuidValue;
             //var doc = data.LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument;
 
@@ -157,9 +157,9 @@ internal partial class LayerItem : UserControl
             }*/
         }
 
-        if (e.Data.GetDataPresent(LayerGroupControl.LayerGroupControlDataName))
+        if (e.Data.GetDataPresent(LayerFolderControl.LayerGroupControlDataName))
         {
-            var data = (LayerGroupControl)e.Data.GetData(LayerGroupControl.LayerGroupControlDataName);
+            var data = (LayerFolderControl)e.Data.GetData(LayerFolderControl.LayerGroupControlDataName);
             //Guid folder = data.GroupGuid;
 
             //var document = data.LayersViewModel.Owner.BitmapManager.ActiveDocument;

+ 21 - 21
src/PixiEditor/Views/UserControls/Layers/LayersManager.xaml

@@ -4,9 +4,11 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:docVm="clr-namespace:PixiEditor.ViewModels.SubViewModels.Document"
              xmlns:ui="clr-namespace:PixiEditor.Helpers.UI"
              xmlns:vws="clr-namespace:PixiEditor.Views" 
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters" 
+             xmlns:commands="clr-namespace:PixiEditor.Models.Commands.XAML" 
              xmlns:layerUserControls="clr-namespace:PixiEditor.Views.UserControls.Layers"
              xmlns:userControls="clr-namespace:PixiEditor.Views.UserControls"
              mc:Ignorable="d"
@@ -19,7 +21,7 @@
         </Grid.RowDefinitions>
         <DockPanel Background="{StaticResource MainColor}" Grid.Row="0" HorizontalAlignment="Stretch">
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
-                <!--<Button Command="{Binding LayerCommandsViewModel.NewLayerCommand, ElementName=layersManager}" 
+                <Button Command="{commands:Command PixiEditor.Layer.New}" 
                         Height="24" Width="24" Cursor="Hand" ToolTip="New Layer"
                         CommandParameter="{Binding Path=SelectedItem, ElementName=layersManager}"
                                                 HorizontalAlignment="Stretch" Margin="5"
@@ -28,7 +30,7 @@
                         <ImageBrush ImageSource="/Images/Layer-add.png"/>
                     </Button.Background>
                 </Button>
-                <Button Command="{Binding LayerCommandsViewModel.NewGroupCommand, ElementName=layersManager}" 
+                <Button Command="{commands:Command PixiEditor.Layer.NewFolder}" 
                         CommandParameter="{Binding Path=SelectedItem, ElementName=layersManager}"
                         Height="24" Width="24" ToolTip="New Group" Cursor="Hand"
                                                 HorizontalAlignment="Stretch" Margin="5"
@@ -37,14 +39,14 @@
                         <ImageBrush ImageSource="/Images/Folder-add.png"/>
                     </Button.Background>
                 </Button>
-                <Button Command="{Binding LayerCommandsViewModel.DeleteSelectedCommand, ElementName=layersManager}"
+                <Button Command="{commands:Command PixiEditor.Layer.DeleteSelected}"
                         CommandParameter="{Binding ElementName=layersManager, Path=SelectedItem}" Height="24" Width="24" ToolTip="Delete selected" Cursor="Hand"
                                                 HorizontalAlignment="Stretch" Margin="5"
                                                 Style="{StaticResource ToolButtonStyle}">
                     <Button.Background>
                         <ImageBrush ImageSource="/Images/Trash.png"/>
                     </Button.Background>
-                </Button>-->
+                </Button>
             </StackPanel>
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Margin="0,0,10,0" HorizontalAlignment="Right" Focusable="True">
                 <Label Content="Opacity" Foreground="White" VerticalAlignment="Center"/>
@@ -66,31 +68,29 @@
                 Converter={BoolToVisibilityConverter}}" 
                 Background="{StaticResource MainColor}" 
                 Grid.Row="3" VerticalAlignment="Bottom"/>
-            <!--<TreeView DockPanel.Dock="Top" Name="treeView" ItemsSource="{Binding CachedLayerTreeRoot, ElementName=layersManager}"  SelectedItemChanged="TreeView_SelectedItemChanged">
+            <TreeView DockPanel.Dock="Top" Name="treeView" ItemsSource="{Binding StructureRoot.Children, ElementName=layersManager}"  SelectedItemChanged="TreeView_SelectedItemChanged">
                 <TreeView.ItemsPanel>
                     <ItemsPanelTemplate>
                         <ui:ReversedOrderStackPanel/>
                     </ItemsPanelTemplate>
                 </TreeView.ItemsPanel>
                 <TreeView.Resources>
-                    <HierarchicalDataTemplate DataType="{x:Type layers:LayerGroup}" ItemsSource="{Binding Items}">
-                        <layerUserControls:LayerGroupControl GroupName="{Binding Name}" MouseDown="SelectActiveItem"
-                                             IsVisibleUndoTriggerable="{Binding StructureData.IsVisible}" 
-                                             GroupOpacity="{Binding StructureData.Opacity}"
-                                             LayersViewModel="{Binding LayerCommandsViewModel, ElementName=layersManager}" 
-                                             GroupGuid="{Binding GuidValue}"
-                                             MouseMove="LayerGroup_MouseMove"/>
-                    </HierarchicalDataTemplate>-->
-            <!--<DataTemplate DataType="{x:Type layers:Layer}">
-                        <layerUserControls:LayerStructureItemContainer    
+                    <HierarchicalDataTemplate DataType="{x:Type docVm:FolderViewModel}" ItemsSource="{Binding Children}">
+                        <layerUserControls:LayerFolderControl 
+                            GroupName="{Binding NameBindable}" 
+                            IsVisibleUndoTriggerable="{Binding IsVisibleBindable}" 
+                            GroupOpacity="{Binding OpacityBindable}"
+                            FolderGuid="{Binding GuidValue}"
+                            MouseDown="SelectActiveItem"
+                            MouseMove="LayerGroup_MouseMove"/>
+                    </HierarchicalDataTemplate>
+                    <DataTemplate DataType="{x:Type docVm:LayerViewModel}">
+                        <layerUserControls:LayerStructureItemContainer
                             MouseDown="SelectActiveItem"
-                            MouseMove="LayerStructureItemContainer_MouseMove" 
-                            ContainerIndex="{Binding Converter={converters:IndexOfConverter}}"
-                            LayerCommandsViewModel="{Binding LayerCommandsViewModel, ElementName=layersManager}"/>
-                    </DataTemplate>-->
-            <!--
+                            MouseMove="LayerStructureItemContainer_MouseMove"/>
+                    </DataTemplate>
                 </TreeView.Resources>
-            </TreeView>-->
+            </TreeView>
             <Border Name="dropBorder" DragEnter="Grid_DragEnter" DragLeave="Grid_DragLeave" AllowDrop="True" Drop="Grid_Drop" Background="Transparent" BorderThickness="0, 5, 0, 0"></Border>
         </DockPanel>
     </Grid>

+ 16 - 17
src/PixiEditor/Views/UserControls/Layers/LayersManager.xaml.cs

@@ -2,41 +2,40 @@
 using System.Windows.Controls;
 using System.Windows.Media;
 using PixiEditor.Models.Controllers;
+using PixiEditor.ViewModels.SubViewModels.Document;
 
 namespace PixiEditor.Views.UserControls.Layers;
 
-/// <summary>
-/// Interaction logic for LayersManager.xaml.
-/// </summary>
 internal partial class LayersManager : UserControl
 {
+
+    public static readonly DependencyProperty SelectedItemProperty =
+        DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(LayersManager), new PropertyMetadata(0));
     public object SelectedItem
     {
         get { return (object)GetValue(SelectedItemProperty); }
         set { SetValue(SelectedItemProperty, value); }
     }
 
-    public static readonly DependencyProperty SelectedItemProperty =
-        DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(LayersManager), new PropertyMetadata(0));
 
-    /*
-    public LayersViewModel LayerCommandsViewModel
-    {
-        get { return (LayersViewModel)GetValue(LayerCommandsViewModelProperty); }
-        set { SetValue(LayerCommandsViewModelProperty, value); }
-    }
-    
-    public static readonly DependencyProperty LayerCommandsViewModelProperty =
-        DependencyProperty.Register(nameof(LayerCommandsViewModel), typeof(LayersViewModel), typeof(LayersManager), new PropertyMetadata(default(LayersViewModel), ViewModelChanged));
-    */
+    public static readonly DependencyProperty OpacityInputEnabledProperty =
+        DependencyProperty.Register(nameof(OpacityInputEnabled), typeof(bool), typeof(LayersManager), new PropertyMetadata(false));
+
     public bool OpacityInputEnabled
     {
         get { return (bool)GetValue(OpacityInputEnabledProperty); }
         set { SetValue(OpacityInputEnabledProperty, value); }
     }
 
-    public static readonly DependencyProperty OpacityInputEnabledProperty =
-        DependencyProperty.Register(nameof(OpacityInputEnabled), typeof(bool), typeof(LayersManager), new PropertyMetadata(false));
+    public static readonly DependencyProperty StructureRootProperty =
+        DependencyProperty.Register(nameof(StructureRoot), typeof(FolderViewModel), typeof(LayersManager), new(null));
+
+    public FolderViewModel StructureRoot
+    {
+        get => (FolderViewModel)GetValue(StructureRootProperty);
+        set => SetValue(StructureRootProperty, value);
+    }
+
 
     public LayersManager()
     {