flabbet 3 jaren geleden
bovenliggende
commit
96427f4aeb

BIN
PixiEditor/Images/Processing.gif


+ 3 - 0
PixiEditor/PixiEditor.csproj

@@ -152,6 +152,7 @@
 		<None Remove="Images\PixiEditorLogo.png" />
 		<None Remove="Images\PixiParserLogo.png" />
 		<None Remove="Images\Placeholder.png" />
+		<None Remove="Images\Processing.gif" />
 		<None Remove="Images\SelectImage.png" />
 		<None Remove="Images\SocialMedia\DiscordIcon.png" />
 		<None Remove="Images\SocialMedia\DonateIcon.png" />
@@ -202,6 +203,7 @@
 		<PackageReference Include="PixiEditor.Parser.Skia" Version="2.0.0" />
 		<PackageReference Include="SkiaSharp" Version="2.80.3" />
 		<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
+		<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
 		<PackageReference Include="WriteableBitmapEx">
 			<Version>1.6.8</Version>
 		</PackageReference>
@@ -224,6 +226,7 @@
 		<Resource Include="Images\PixiEditorLogo.png" />
 		<Resource Include="Images\PixiParserLogo.png" />
 		<Resource Include="Images\Placeholder.png" />
+		<Resource Include="Images\Processing.gif" />
 		<Resource Include="Images\SocialMedia\DiscordIcon.png" />
 		<Resource Include="Images\SocialMedia\DonateIcon.png" />
 		<Resource Include="Images\SocialMedia\GitHubIcon.png" />

+ 2 - 2
PixiEditor/Properties/AssemblyInfo.cs

@@ -50,5 +50,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.1.7.0")]
-[assembly: AssemblyFileVersion("0.1.7.0")]
+[assembly: AssemblyVersion("0.1.7.1")]
+[assembly: AssemblyFileVersion("0.1.7.1")]

+ 5 - 1
PixiEditor/Views/Dialogs/LospecPalettesBrowser.xaml

@@ -5,6 +5,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PixiEditor.Views.UserControls.Lospec" xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              mc:Ignorable="d" 
+             xmlns:gif="http://wpfanimatedgif.codeplex.com"
              Title="Palettes Browser" WindowStartupLocation="CenterScreen" MinWidth="200" Height="600" Width="800" WindowStyle="None"
              Name="lospecPalettesBrowser">
     <Window.Resources>
@@ -35,7 +36,10 @@
             <TextBlock Text="Couldn't fetch palettes" Foreground="White" FontSize="20" HorizontalAlignment="Center" 
                        VerticalAlignment="Center" Visibility="{Binding ElementName=itemsControl, 
                 Path=Visibility, Converter={converters:OppositeVisibilityConverter}}"/>
-            <ScrollViewer Margin="5" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+            <Image gif:ImageBehavior.AnimatedSource="/Images/Processing.gif" HorizontalAlignment="Center" VerticalAlignment="Center"
+                   Visibility="{Binding ElementName=lospecPalettesBrowser, Path=IsFetching, Converter={StaticResource BoolToVisibilityConverter}}"
+                   Height="50" gif:ImageBehavior.AnimationSpeedRatio="1.5"/>
+            <ScrollViewer Margin="5" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" ScrollChanged="ScrollViewer_ScrollChanged">
                 <ItemsControl Name="itemsControl" ItemsSource="{Binding ElementName=lospecPalettesBrowser, Path=PaletteList.Palettes}" 
                           Visibility="{Binding ElementName=lospecPalettesBrowser, Path=PaletteList.FetchedCorrectly,
                 Converter={StaticResource BoolToVisibilityConverter}}">

+ 31 - 1
PixiEditor/Views/Dialogs/LospecPalettesBrowser.xaml.cs

@@ -25,6 +25,8 @@ namespace PixiEditor.Views.Dialogs
     public partial class LospecPalettesBrowser : Window
     {
         public event ListFetched OnListFetched;
+        private int _currentPage = 0;
+
         public PaletteList PaletteList
         {
             get { return (PaletteList)GetValue(PaletteListProperty); }
@@ -45,6 +47,17 @@ namespace PixiEditor.Views.Dialogs
         public static readonly DependencyProperty ImportPaletteCommandProperty =
             DependencyProperty.Register("ImportPaletteCommand", typeof(ICommand), typeof(LospecPalettesBrowser));
 
+        public bool IsFetching
+        {
+            get { return (bool)GetValue(IsFetchingProperty); }
+            set { SetValue(IsFetchingProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for IsFetching.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty IsFetchingProperty =
+            DependencyProperty.Register("IsFetching", typeof(bool), typeof(LospecPalettesBrowser), new PropertyMetadata(false));
+
+
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         {
             e.CanExecute = true;
@@ -61,13 +74,30 @@ namespace PixiEditor.Views.Dialogs
             InitializeComponent();
         }
 
-        public async void FetchPalettes()
+        public async Task FetchPalettes()
         {
+            IsFetching = true;
             if (PaletteList == null)
             {
                 PaletteList = await LospecPaletteFetcher.FetchPage(0);
                 OnListFetched.Invoke(PaletteList);
             }
+
+            IsFetching = false;
+        }
+
+        private async void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
+        {
+            if (PaletteList == null) return;
+            var scrollViewer = (ScrollViewer)sender;
+            if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)
+            {
+                _currentPage++;
+                var newPalettes = await LospecPaletteFetcher.FetchPage(_currentPage);
+                PaletteList.Palettes.AddRange(newPalettes.Palettes);
+                PaletteList = PaletteList;
+                OnListFetched.Invoke(PaletteList);
+            }
         }
     }
 }

+ 2 - 1
PixiEditor/Views/MainWindow.xaml

@@ -343,7 +343,8 @@
                                     <avalondock:LayoutAnchorable ContentId="palette" Title="Palette" CanHide="False"
                                                                  CanClose="False" CanAutoHide="False"
                                                                  CanDockAsTabbedDocument="False" CanFloat="True">
-                                        <usercontrols:PaletteViewer Colors="{Binding BitmapManager.ActiveDocument.Palette}"
+                                        <usercontrols:PaletteViewer IsEnabled="{Binding DocumentSubViewModel.Owner.BitmapManager.ActiveDocument,
+                                        Converter={converters:NotNullToBoolConverter}}" Colors="{Binding BitmapManager.ActiveDocument.Palette}"
                                                               SelectColorCommand="{Binding ColorsSubViewModel.SelectColorCommand}"
                                                                     ImportPaletteCommand="{Binding ColorsSubViewModel.ImportPaletteCommand}"/>
                                     </avalondock:LayoutAnchorable>

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

@@ -19,7 +19,7 @@
             <DockPanel VerticalAlignment="Center" Margin="0 5 0 0">
                 <local:PaletteColorAdder DockPanel.Dock="Left" Margin="5 0 0 0" 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" 
+                <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/Globe.png"/>

+ 1 - 1
PixiEditor/Views/UserControls/PaletteViewer.xaml.cs

@@ -181,7 +181,7 @@ namespace PixiEditor.Views.UserControls
             };
 
             browser.Show();
-            browser.FetchPalettes();
+            await browser.FetchPalettes();
         }
     }
 }