Pārlūkot izejas kodu

Fix binding error, better collapsing

Equbuxu 3 gadi atpakaļ
vecāks
revīzija
343bd382e6

+ 0 - 19
PixiEditor/Helpers/Converters/IsCollapsedToRowSpanConverter.cs

@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PixiEditor.Helpers.Converters
-{
-    public class IsCollapsedToRowSpanConverter : SingleInstanceConverter<IsCollapsedToRowSpanConverter>
-    {
-        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            bool isCollapsed = (bool)value;
-
-            return isCollapsed ? 2 : 0;
-        }
-    }
-}

+ 7 - 7
PixiEditor/Views/UserControls/Layers/LayersManager.xaml

@@ -14,7 +14,6 @@
             <RowDefinition Height="37.5"/>
             <RowDefinition Height="15"/>
             <RowDefinition Height="1*"/>
-            <RowDefinition Height="40"/>
         </Grid.RowDefinitions>
         <DockPanel Background="{StaticResource MainColor}" Grid.Row="0" HorizontalAlignment="Stretch">
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
@@ -59,6 +58,13 @@
         </DockPanel>
         <Separator Grid.Row="1" Margin="0,-12, 0, 0" BorderBrush="{StaticResource DarkerAccentColor}" BorderThickness="2" />
         <DockPanel LastChildFill="True" Grid.Row="2" Margin="0, -12, 0, 0">
+            <layerUserControls:ReferenceLayer
+                DockPanel.Dock="Bottom"
+                Visibility="{Binding Path=OpacityInputEnabled, ElementName=layersManager, 
+                Converter={BoolToVisibilityConverter}}" 
+                Background="{StaticResource MainColor}" 
+                Layer="{Binding LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.ReferenceLayer, ElementName=layersManager, Mode=TwoWay}"
+                Grid.Row="3" VerticalAlignment="Bottom"/>
             <TreeView DockPanel.Dock="Top" Name="treeView" ItemsSource="{Binding CachedLayerTreeRoot, ElementName=layersManager}"  SelectedItemChanged="TreeView_SelectedItemChanged">
                 <TreeView.ItemsPanel>
                     <ItemsPanelTemplate>
@@ -86,11 +92,5 @@
             </TreeView>
             <Border Name="dropBorder" DragEnter="Grid_DragEnter" DragLeave="Grid_DragLeave" AllowDrop="True" Drop="Grid_Drop" Background="Transparent" BorderThickness="0, 5, 0, 0"></Border>
         </DockPanel>
-        <layerUserControls:ReferenceLayer 
-            Visibility="{Binding Path=OpacityInputEnabled, ElementName=layersManager, 
-            Converter={BoolToVisibilityConverter}}" 
-            Background="{StaticResource MainColor}" 
-            Layer="{Binding LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.ReferenceLayer, ElementName=layersManager, Mode=TwoWay}"
-            Grid.Row="3" VerticalAlignment="Bottom"/>
     </Grid>
 </UserControl>

+ 0 - 4
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml.cs

@@ -3,13 +3,9 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
-using PixiEditor.Helpers.Converters;
 
 namespace PixiEditor.Views.UserControls.Palettes
 {
-    /// <summary>
-    /// Interaction logic for ColorReplacer.xaml
-    /// </summary>
     public partial class ColorReplacer : UserControl
     {
         public SKColor ColorToReplace

+ 76 - 76
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml

@@ -9,99 +9,99 @@
              xmlns:helpers="clr-namespace:PixiEditor.Helpers"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="300" Name="paletteControl">
-    <Grid AllowDrop="True" PreviewDragEnter="Grid_PreviewDragEnter" PreviewDragLeave="Grid_PreviewDragLeave"
+    <DockPanel>
+        <palettes:ColorReplacer Grid.Row="3" VerticalAlignment="Bottom" x:Name="Replacer" DockPanel.Dock="Bottom"
+                                ReplaceColorsCommand="{Binding ElementName=paletteControl, Path=ReplaceColorsCommand}"
+                                HintColor="{Binding ElementName=paletteControl, Path=HintColor}"/>
+        <Grid AllowDrop="True" PreviewDragEnter="Grid_PreviewDragEnter" PreviewDragLeave="Grid_PreviewDragLeave"
           Drop="Grid_Drop">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="37.5"/>
-            <RowDefinition Height="5"/>
-            <RowDefinition Height="*"/>
-            <RowDefinition Height="50"/>
-        </Grid.RowDefinitions>
-        <StackPanel Orientation="Vertical" Grid.Row="0" Background="{StaticResource MainColor}">
-            <DockPanel VerticalAlignment="Center" Margin="0 5 0 0">
-                <palettes:PaletteColorAdder DockPanel.Dock="Left" Margin="5 0 0 0"
+            <Grid.RowDefinitions>
+                <RowDefinition Height="37.5"/>
+                <RowDefinition Height="5"/>
+                <RowDefinition Height="*"/>
+            </Grid.RowDefinitions>
+            <StackPanel Orientation="Vertical" Grid.Row="0" Background="{StaticResource MainColor}">
+                <DockPanel VerticalAlignment="Center" Margin="0 5 0 0">
+                    <palettes:PaletteColorAdder DockPanel.Dock="Left" Margin="5 0 0 0"
                                             Swatches="{Binding ElementName=paletteControl, Path=Swatches}"
                                             HintColor="{Binding ElementName=paletteControl, Path=HintColor}"
                                             Colors="{Binding ElementName=paletteControl, Path=Colors}"/>
-                <StackPanel Margin="0, 0, 5, 0" HorizontalAlignment="Right" Width="85" VerticalAlignment="Center" Orientation="Horizontal">
-                <Button Margin="0, 0, 5, 0" Style="{StaticResource ToolButtonStyle}" Click="BrowsePalettes_Click"
+                    <StackPanel Margin="0, 0, 5, 0" HorizontalAlignment="Right" Width="85" VerticalAlignment="Center" Orientation="Horizontal">
+                        <Button Margin="0, 0, 5, 0" Style="{StaticResource ToolButtonStyle}" Click="BrowsePalettes_Click"
                 Cursor="Hand" Height="24" Width="24" ToolTip="Browse Palettes">
-                        <Button.Background>
-                            <ImageBrush ImageSource="/Images/Database.png"/>
-                        </Button.Background>
-                    </Button>
-                    <Button Margin="0, 0, 5, 0" Style="{StaticResource ToolButtonStyle}" 
+                            <Button.Background>
+                                <ImageBrush ImageSource="/Images/Database.png"/>
+                            </Button.Background>
+                        </Button>
+                        <Button Margin="0, 0, 5, 0" Style="{StaticResource ToolButtonStyle}" 
                 Cursor="Hand" Height="24" Width="24"  ToolTip="Load Palette" Click="ImportPalette_OnClick">
-                    <Button.Background>
-                        <ImageBrush ImageSource="/Images/Folder.png"/>
-                    </Button.Background>
-                </Button>
-                <Button Height="24" Width="24" Margin="0" Style="{StaticResource ToolButtonStyle}" 
+                            <Button.Background>
+                                <ImageBrush ImageSource="/Images/Folder.png"/>
+                            </Button.Background>
+                        </Button>
+                        <Button Height="24" Width="24" Margin="0" Style="{StaticResource ToolButtonStyle}" 
                 Cursor="Hand" ToolTip="Save Palette" Click="SavePalette_OnClick">
-                    <Button.Background>
-                        <ImageBrush ImageSource="/Images/Save.png"/>
-                    </Button.Background>
-                </Button>
-                </StackPanel>
-            </DockPanel>
-    </StackPanel>
-        <Separator Grid.Row="1" Margin="0, 0, 0, 0" BorderBrush="{StaticResource DarkerAccentColor}" BorderThickness="2" />
-        <Grid Visibility="Hidden" Background="{StaticResource AccentColor}" Opacity="0.7" Grid.Row="2" Name="dragDropGrid">
-            <TextBlock Text="Drop palette here" Foreground="White" FontSize="32" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-        </Grid>
-        <ScrollViewer Grid.Row="2" Grid.RowSpan="{Binding ElementName=Replacer, Path=IsCollapsed, 
-            Converter={converters:IsCollapsedToRowSpanConverter}}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
-           <ItemsControl ItemsSource="{Binding Colors, ElementName=paletteControl}" AlternationCount="9999">
-               <d:ItemsControl.ItemsSource>
-                   <x:Array Type="{x:Type Color}">
-                       <Color R="0" G="0" B="0" A="255"/>
-                       <Color R="255" G="255" B="255" A="255"/>
-                       <Color R="255" G="255" B="255" A="150"/>
-                       <Color R="255" G="255" B="255" A="0"/>
-                       <Color R="255" G="0" B="0" A="255"/>
-                       <Color R="0" G="255" B="0" A="255"/>
-                       <Color R="0" G="0" B="255" A="255"/>
-                   </x:Array>
-               </d:ItemsControl.ItemsSource>
-               <ItemsControl.ItemsPanel>
-                   <ItemsPanelTemplate>
-                       <WrapPanel Margin="10" Orientation="Horizontal"
+                            <Button.Background>
+                                <ImageBrush ImageSource="/Images/Save.png"/>
+                            </Button.Background>
+                        </Button>
+                    </StackPanel>
+                </DockPanel>
+            </StackPanel>
+            <Separator Grid.Row="1" Margin="0, 0, 0, 0" BorderBrush="{StaticResource DarkerAccentColor}" BorderThickness="2" />
+            <Grid Visibility="Hidden" Background="{StaticResource AccentColor}" Opacity="0.7" Grid.Row="2" Name="dragDropGrid">
+                <TextBlock Text="Drop palette here" Foreground="White" FontSize="32" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+            </Grid>
+            <ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+                <ItemsControl ItemsSource="{Binding Colors, ElementName=paletteControl}" AlternationCount="9999">
+                    <d:ItemsControl.ItemsSource>
+                        <x:Array Type="{x:Type Color}">
+                            <Color R="0" G="0" B="0" A="255"/>
+                            <Color R="255" G="255" B="255" A="255"/>
+                            <Color R="255" G="255" B="255" A="150"/>
+                            <Color R="255" G="255" B="255" A="0"/>
+                            <Color R="255" G="0" B="0" A="255"/>
+                            <Color R="0" G="255" B="0" A="255"/>
+                            <Color R="0" G="0" B="255" A="255"/>
+                        </x:Array>
+                    </d:ItemsControl.ItemsSource>
+                    <ItemsControl.ItemsPanel>
+                        <ItemsPanelTemplate>
+                            <WrapPanel Margin="10" Orientation="Horizontal"
                                   HorizontalAlignment="Left" VerticalAlignment="Top"/>
-                   </ItemsPanelTemplate>
-               </ItemsControl.ItemsPanel>
-               <ItemsControl.ItemTemplate>
-                    <DataTemplate>
-                        <palettes:PaletteColor Cursor="Hand" ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them." AllowDrop="True" Color="{Binding}" 
+                        </ItemsPanelTemplate>
+                    </ItemsControl.ItemsPanel>
+                    <ItemsControl.ItemTemplate>
+                        <DataTemplate>
+                            <palettes:PaletteColor Cursor="Hand" ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them." AllowDrop="True" Color="{Binding}" 
                                                Margin="2.5"
                                             Drop="PaletteColor_Drop"
                                             AssociatedKey="{Binding Path=(ItemsControl.AlternationIndex), 
                 RelativeSource={RelativeSource TemplatedParent}, Converter={converters:IndexToAssociatedKeyConverter}}">
-                            <b:Interaction.Triggers>
-                                <b:EventTrigger EventName="MouseLeftButtonUp">
-                                    <b:InvokeCommandAction
+                                <b:Interaction.Triggers>
+                                    <b:EventTrigger EventName="MouseLeftButtonUp">
+                                        <b:InvokeCommandAction
                                     Command="{Binding SelectColorCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type palettes:PaletteViewer}}}"
                                     CommandParameter="{Binding}" />
-                                </b:EventTrigger>
-                            </b:Interaction.Triggers>
-                            <palettes:PaletteColor.ContextMenu>
-                                        <ContextMenu>
-                                    <MenuItem Header="Choose" Foreground="White" Click="MenuItem_OnClick"
+                                    </b:EventTrigger>
+                                </b:Interaction.Triggers>
+                                <palettes:PaletteColor.ContextMenu>
+                                    <ContextMenu>
+                                        <MenuItem Header="Choose" Foreground="White" Click="MenuItem_OnClick"
                                               CommandParameter="{Binding}"/>
-                                            <MenuItem Header="Remove" Foreground="White"
+                                        <MenuItem Header="Remove" Foreground="White"
                                                       Click="RemoveColorMenuItem_OnClick"
                                                       CommandParameter="{Binding}" />
-                                            <MenuItem Header="Replace" Foreground="White"
+                                        <MenuItem Header="Replace" Foreground="White"
                                                       CommandParameter="{Binding}"
                                                       Click="ReplaceColor_OnClick"/>
-                                        </ContextMenu>
-                                    </palettes:PaletteColor.ContextMenu>
-                                </palettes:PaletteColor>
-                    </DataTemplate>
-               </ItemsControl.ItemTemplate>
-            </ItemsControl>
-        </ScrollViewer>
-        <palettes:ColorReplacer Grid.Row="3" VerticalAlignment="Bottom" x:Name="Replacer"
-                                ReplaceColorsCommand="{Binding ElementName=paletteControl, Path=ReplaceColorsCommand}"
-                                HintColor="{Binding ElementName=paletteControl, Path=HintColor}"/>
-    </Grid>
+                                    </ContextMenu>
+                                </palettes:PaletteColor.ContextMenu>
+                            </palettes:PaletteColor>
+                        </DataTemplate>
+                    </ItemsControl.ItemTemplate>
+                </ItemsControl>
+            </ScrollViewer>
+        </Grid>
+    </DockPanel>
 </UserControl>