Procházet zdrojové kódy

Fixed collapsed state

flabbet před 3 roky
rodič
revize
12d4fb2d71

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

@@ -0,0 +1,19 @@
+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;
+        }
+    }
+}

+ 1 - 1
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml

@@ -48,7 +48,7 @@
                         </Button.Background>
                     </Button>
                     </StackPanel>
-                    <CheckBox Focusable="False" Panel.ZIndex="10" Name="VisibilityCheckbox" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
+                    <CheckBox Focusable="False" IsChecked="{Binding ElementName=uc, Path=IsCollapsed}" Panel.ZIndex="10" Name="VisibilityCheckbox" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
                         <CheckBox.Triggers>
                             <EventTrigger RoutedEvent="CheckBox.Checked">
                                 <BeginStoryboard>

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

@@ -54,6 +54,20 @@ namespace PixiEditor.Views.UserControls.Palettes
         public static readonly DependencyProperty HintColorProperty =
             DependencyProperty.Register("HintColor", typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
 
+
+
+        public bool IsCollapsed
+        {
+            get { return (bool)GetValue(IsCollapsedProperty); }
+            set { SetValue(IsCollapsedProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for IsCollapsed.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty IsCollapsedProperty =
+            DependencyProperty.Register("IsCollapsed", typeof(bool), typeof(ColorReplacer), new PropertyMetadata(false));
+
+
+
         private void UIElement_OnDrop(object sender, DragEventArgs e)
         {
             if (e.Data.GetDataPresent(PaletteColor.PaletteColorDaoFormat))

+ 2 - 1
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml

@@ -49,7 +49,8 @@
         <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">
+        <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}">