Browse Source

Starting working with Layers

flabbet 5 years ago
parent
commit
942585351b

+ 3 - 1
PixiEditorDotNetCore3/Models/Layers/Layer.cs

@@ -12,6 +12,7 @@ namespace PixiEditorDotNetCore3.Models.Layers
     public class Layer : BasicLayer
     public class Layer : BasicLayer
     {
     {
         private WriteableBitmap _layerBitmap;
         private WriteableBitmap _layerBitmap;
+        public string Name { get; set; }
 
 
         public WriteableBitmap LayerBitmap
         public WriteableBitmap LayerBitmap
         {
         {
@@ -23,8 +24,9 @@ namespace PixiEditorDotNetCore3.Models.Layers
             }
             }
         }
         }
 
 
-        public Layer(int width, int height)
+        public Layer(string name,int width, int height)
         {
         {
+            Name = name;
             Layer layer = LayerGenerator.Generate(width, height);
             Layer layer = LayerGenerator.Generate(width, height);
             LayerBitmap = layer.LayerBitmap;
             LayerBitmap = layer.LayerBitmap;
             Width = width;
             Width = width;

+ 1 - 0
PixiEditorDotNetCore3/Models/Layers/LayerGenerator.cs

@@ -46,5 +46,6 @@ namespace PixiEditorDotNetCore3.Models.Layers
             bitmap.Clear(System.Windows.Media.Colors.Transparent);
             bitmap.Clear(System.Windows.Media.Colors.Transparent);
             return bitmap;
             return bitmap;
         }
         }
+
     }
     }
 }
 }

+ 0 - 3
PixiEditorDotNetCore3/Models/Tools/Tools/CircleTool.cs

@@ -1,8 +1,5 @@
 using PixiEditorDotNetCore3.Models.Layers;
 using PixiEditorDotNetCore3.Models.Layers;
 using PixiEditorDotNetCore3.Models.Position;
 using PixiEditorDotNetCore3.Models.Position;
-using System;
-using System.Collections.Generic;
-using System.Text;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
 
 

+ 3 - 4
PixiEditorDotNetCore3/Styles/ThemeStyle.xaml

@@ -1,6 +1,5 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-                    xmlns:local="clr-namespace:PixiEditor.Styles">
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
 
     <Style TargetType="Button" x:Key="DarkRoundButton">
     <Style TargetType="Button" x:Key="DarkRoundButton">
         <Setter Property="Background" Value="#404040"/>
         <Setter Property="Background" Value="#404040"/>
@@ -46,8 +45,8 @@
     </Style>
     </Style>
 
 
     <Style TargetType="Button" x:Key="ToolButtonStyle">
     <Style TargetType="Button" x:Key="ToolButtonStyle">
-        <Setter Property="Height" Value="52"/>
-        <Setter Property="Width" Value="52"/>
+        <Setter Property="Height" Value="42"/>
+        <Setter Property="Width" Value="42"/>
         <Setter Property="VerticalAlignment" Value="Top"/>
         <Setter Property="VerticalAlignment" Value="Top"/>
         <Setter Property="HorizontalAlignment" Value="Center"/>
         <Setter Property="HorizontalAlignment" Value="Center"/>
         <Setter Property="Margin" Value="0,10,0,0"/>
         <Setter Property="Margin" Value="0,10,0,0"/>

+ 15 - 16
PixiEditorDotNetCore3/ViewModels/ViewModelMain.cs

@@ -26,7 +26,7 @@ namespace PixiEditor.ViewModels
 
 
         public ObservableCollection<Layer> Layers
         public ObservableCollection<Layer> Layers
         {
         {
-            get { return _layers; }
+            get => _layers;
             set { if (_layers != value) { _layers = value;} }
             set { if (_layers != value) { _layers = value;} }
         }
         }
 
 
@@ -56,7 +56,7 @@ namespace PixiEditor.ViewModels
 
 
         public Layer ActiveLayer //Active drawing layer
         public Layer ActiveLayer //Active drawing layer
         {
         {
-            get { return _activeLayer; }
+            get => _activeLayer;
             set {
             set {
                 _activeLayer = value;
                 _activeLayer = value;
                 RefreshImage();
                 RefreshImage();
@@ -66,14 +66,13 @@ namespace PixiEditor.ViewModels
 
 
         public LightLayer ActiveLightLayer
         public LightLayer ActiveLightLayer
         {
         {
-            get 
-            {
-                if (_activeLayer != null)
-                    return new LightLayer(
-                        _activeLayer.ConvertBitmapToBytes(), 
-                        ActiveLayer.Height, ActiveLayer.Width);
-                else
-                    return null;
+            get
+            {
+                if (_activeLayer != null)
+                    return new LightLayer(
+                        _activeLayer.ConvertBitmapToBytes(), 
+                        ActiveLayer.Height, ActiveLayer.Width);
+                return null;
             }
             }
             set => ActiveLayer = new Layer(BitmapConverter.BytesToWriteableBitmap(ActiveLayer.Width, ActiveLayer.Height,value.LayerBytes));
             set => ActiveLayer = new Layer(BitmapConverter.BytesToWriteableBitmap(ActiveLayer.Width, ActiveLayer.Height,value.LayerBytes));
         }
         }
@@ -82,7 +81,7 @@ namespace PixiEditor.ViewModels
 
 
         public double MouseXOnCanvas //Mouse X coordinate relative to canvas
         public double MouseXOnCanvas //Mouse X coordinate relative to canvas
         {
         {
-            get { return _mouseXonCanvas; }
+            get => _mouseXonCanvas;
             set { _mouseXonCanvas = value;  RaisePropertyChanged("MouseXonCanvas"); }
             set { _mouseXonCanvas = value;  RaisePropertyChanged("MouseXonCanvas"); }
         }
         }
 
 
@@ -90,7 +89,7 @@ namespace PixiEditor.ViewModels
 
 
         public double MouseYOnCanvas //Mouse Y coordinate relative to canvas
         public double MouseYOnCanvas //Mouse Y coordinate relative to canvas
         {
         {
-            get { return _mouseYonCanvas; }
+            get => _mouseYonCanvas;
             set { _mouseYonCanvas = value; RaisePropertyChanged("MouseYonCanvas"); }
             set { _mouseYonCanvas = value; RaisePropertyChanged("MouseYonCanvas"); }
         }
         }
 
 
@@ -99,7 +98,7 @@ namespace PixiEditor.ViewModels
 
 
         public Color PrimaryColor //Primary color, hooked with left mouse button
         public Color PrimaryColor //Primary color, hooked with left mouse button
         {
         {
-            get { return _primaryColor; }
+            get => _primaryColor;
             set
             set
             {
             {
                 if (_primaryColor != value)
                 if (_primaryColor != value)
@@ -114,7 +113,7 @@ namespace PixiEditor.ViewModels
 
 
         public Color SecondaryColor //Secondary color, hooked with right mouse button
         public Color SecondaryColor //Secondary color, hooked with right mouse button
         {
         {
-            get { return _secondaryColor; }
+            get => _secondaryColor;
             set { if (_secondaryColor != value) { _secondaryColor = value; RaisePropertyChanged("SecondaryColor"); } }
             set { if (_secondaryColor != value) { _secondaryColor = value; RaisePropertyChanged("SecondaryColor"); } }
         }
         }
 
 
@@ -293,7 +292,7 @@ namespace PixiEditor.ViewModels
             if (newFile.ShowDialog() == true)
             if (newFile.ShowDialog() == true)
             {
             {
                 Layers.Clear();
                 Layers.Clear();
-                Layers.Add(new Layer(newFile.Width, newFile.Height));
+                Layers.Add(new Layer("Base Layer",newFile.Width, newFile.Height));
                 ActiveImage = ImageGenerator.GenerateForPixelArts(newFile.Width, newFile.Height);
                 ActiveImage = ImageGenerator.GenerateForPixelArts(newFile.Width, newFile.Height);
                 ActiveLayer = Layers[0];
                 ActiveLayer = Layers[0];
             }
             }
@@ -335,7 +334,7 @@ namespace PixiEditor.ViewModels
             if (dialog.ShowDialog() == true)
             if (dialog.ShowDialog() == true)
             {
             {
                 Layers.Clear();
                 Layers.Clear();
-                Layers.Add(new Layer(dialog.FileWidth, dialog.FileHeight));
+                Layers.Add(new Layer("Base Layer",dialog.FileWidth, dialog.FileHeight));
                 ActiveImage = ImageGenerator.GenerateForPixelArts(dialog.FileWidth, dialog.FileHeight);
                 ActiveImage = ImageGenerator.GenerateForPixelArts(dialog.FileWidth, dialog.FileHeight);
                 ActiveLayer = Layers[0];
                 ActiveLayer = Layers[0];
                 ActiveLayer.LayerBitmap = Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight);
                 ActiveLayer.LayerBitmap = Importer.ImportImage(dialog.FilePath, dialog.FileWidth, dialog.FileHeight);

+ 13 - 3
PixiEditorDotNetCore3/Views/MainWindow.xaml

@@ -69,9 +69,9 @@
     </Window.InputBindings>
     </Window.InputBindings>
     <Grid>
     <Grid>
         <Grid.ColumnDefinitions>
         <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="70*"/>
+            <ColumnDefinition Width="60*"/>
             <ColumnDefinition Width="1420*"/>
             <ColumnDefinition Width="1420*"/>
-            <ColumnDefinition Width="110*"/>
+            <ColumnDefinition Width="150*"/>
         </Grid.ColumnDefinitions>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="30*"/>
             <RowDefinition Height="30*"/>
@@ -80,7 +80,7 @@
         </Grid.RowDefinitions>
         </Grid.RowDefinitions>
 
 
         <Border Grid.ColumnSpan="3" Background="#FF363434" Grid.Row="0" Height="30"/>
         <Border Grid.ColumnSpan="3" Background="#FF363434" Grid.Row="0" Height="30"/>
-        <WrapPanel Grid.ColumnSpan="2" Grid.RowSpan="2" Panel.ZIndex="100">
+        <WrapPanel Grid.ColumnSpan="2" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Panel.ZIndex="100">
             <vws:MenuButton Text="File" Margin="0,0,-140,0">
             <vws:MenuButton Text="File" Margin="0,0,-140,0">
                 <vws:MenuButton.Item>
                 <vws:MenuButton.Item>
                     <StackPanel>
                     <StackPanel>
@@ -197,5 +197,15 @@
             <xctk:ColorPicker Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" UsingAlphaChannel="True" AvailableColorsSortingMode="Alphabetical" ShowDropDownButton="False" Background="Transparent" BorderThickness="0" ShowRecentColors="True" Margin="0,0,4,5" SelectedColor="{Binding SecondaryColor, Mode=TwoWay}"/>
             <xctk:ColorPicker Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" UsingAlphaChannel="True" AvailableColorsSortingMode="Alphabetical" ShowDropDownButton="False" Background="Transparent" BorderThickness="0" ShowRecentColors="True" Margin="0,0,4,5" SelectedColor="{Binding SecondaryColor, Mode=TwoWay}"/>
         </Grid>
         </Grid>
 
 
+        <StackPanel Grid.Column="2" Grid.Row="1" Orientation="Vertical">
+            <ListView ItemsSource="{Binding Layers}">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <TextBlock Text="{Binding Name}"></TextBlock>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+        </StackPanel>
+
     </Grid>
     </Grid>
 </Window>
 </Window>