Bläddra i källkod

#37 Update UI for dynamic thumbnail input boxes

Ruben 4 år sedan
förälder
incheckning
9f2173bcb6

+ 3 - 2
PicView/Views/UserControls/Misc/ThumbnailOutputUC.xaml.cs

@@ -17,12 +17,13 @@ namespace PicView.Views.UserControls
 {
     public partial class ThumbnailOutputUC : UserControl
     {
-        public ThumbnailOutputUC(int i, string folderPath, string filename)
+        public ThumbnailOutputUC(int i, string folderPath, string filename, string value)
         {
             InitializeComponent();
 
-            OutPutString.Text = $"Thumbnail {i} output folder";
+            OutPutString.Text = $"Thumbnail {i} destination";
             OutPutStringBox.Text = folderPath + @"\" + filename;
+            ValueBox.Text = value;
          }
     }
 }

+ 3 - 6
PicView/Views/Windows/ResizeWindow.xaml

@@ -233,18 +233,15 @@
             <StackPanel Margin="0,10,0,5" Orientation="Horizontal">
 
                 <TextBlock Text="Generate Thumbnails" />
-                <ComboBox MinWidth="65">
-                    <ComboBoxItem Content="0" />
+                <ComboBox x:Name="ThumbnailsComboBox" MinWidth="65">
+                    <ComboBoxItem Content="0" IsSelected="True" />
                     <ComboBoxItem Content="1" />
                     <ComboBoxItem Content="2" />
-                    <ComboBoxItem Content="3" IsSelected="True" />
+                    <ComboBoxItem Content="3" />
                     <ComboBoxItem Content="4" />
                     <ComboBoxItem Content="5" />
                     <ComboBoxItem Content="6" />
                     <ComboBoxItem Content="7" />
-                    <ComboBoxItem Content="8" />
-                    <ComboBoxItem Content="9" />
-                    <ComboBoxItem Content="10" />
                 </ComboBox>
             </StackPanel>
 

+ 67 - 8
PicView/Views/Windows/ResizeWindow.xaml.cs

@@ -3,7 +3,9 @@ using PicView.UILogic;
 using PicView.UILogic.Sizing;
 using System.IO;
 using System.Windows;
+using System.Windows.Controls;
 using System.Windows.Input;
+using static PicView.UILogic.Sizing.WindowSizing;
 
 namespace PicView.Views.Windows
 {
@@ -31,18 +33,61 @@ namespace PicView.Views.Windows
                     OutputFolderInput.Text = SourceFolderInput.Text + @"\Processed Pictures";
                 }
 
-                //GenerateThumbnailsCB.SelectionChanged += delegate
-                //{
+                ThumbnailsComboBox.SelectionChanged += delegate
+                {
+                    var selected = (ComboBoxItem)ThumbnailsComboBox.SelectedItem;
+                    if (int.TryParse(selected?.Content.ToString(), out var count)) 
+                    {
+                        GeneratedThumbnailsContainer.Children.Clear();
 
-                //};
+                        if (count <= 0) { return; }
 
-                for (int i = 1; i <= 5; i++)
-                {
-                    GeneratedThumbnailsContainer.Children.Add(new UserControls.ThumbnailOutputUC(i, OutputFolderInput.Text, "xl"));
-                }
+                        var size = new string[count + 1];
+                        var newSize = new string[size.Length]; 
+                        switch (count)
+                        {
+                            case 7: 
+                                size[7] = "xxs"; size[6] = "xs"; size[5] = "small"; size[4] = "medium"; size[3] = "large"; size[2] = "xl"; size[1] = "xxl";
+                                newSize[7] = "20"; newSize[6] = "30"; newSize[5] = "40"; newSize[4] = "50"; newSize[3] = "60"; newSize[2] = "70"; newSize[1] = "80"; 
+                                break;
+
+                            case 6: 
+                                size[6] = "xxs"; size[5] = "xs"; size[4] = "small"; size[3] = "medium"; size[2] = "large"; size[1] = "xl";
+                                newSize[6] = "20"; newSize[5] = "30"; newSize[4] = "40"; newSize[3] = "50"; newSize[2] = "60"; newSize[1] = "70";
+                                break;
+
+                            case 5: 
+                                size[5] = "xs"; size[4] = "small"; size[3] = "medium"; size[2] = "large"; size[1] = "xl";
+                                newSize[5] = "20"; newSize[4] = "30"; newSize[3] = "50"; newSize[2] = "60"; newSize[1] = "70";
+                                break;
+
+                            case 4: 
+                                size[4] = "xs"; size[3] = "small"; size[2] = "medium"; size[1] = "large";
+                                newSize[4] = "25"; newSize[3] = "40"; newSize[2] = "50"; newSize[1] = "70";
+                                break;
+
+                            case 3: 
+                                size[3] = "small"; size[2] = "medium"; size[1] = "large";
+                                newSize[3] = "25"; newSize[2] = "50"; newSize[1] = "70";
+                                break;
+
+                            case 2: 
+                                size[1] = "small"; size[2] = "medium";
+                                newSize[1] = "30"; newSize[2] = "50";
+                                break;
 
-                
+                            case 1: default: 
+                                size[1] = "small";
+                                newSize[1] = "30";
+                                break;
+                        }
 
+                        for (int i = 1; i <= count; i++)
+                        {
+                            GeneratedThumbnailsContainer.Children.Add(new UserControls.ThumbnailOutputUC(i, OutputFolderInput.Text, size[i], newSize[i]));
+                        }
+                    }
+                };
 
                 MouseLeftButtonDown += (_, e) =>
                 { if (e.LeftButton == MouseButtonState.Pressed) { DragMove(); } };
@@ -58,5 +103,19 @@ namespace PicView.Views.Windows
                 TitleBar.MouseLeftButtonDown += delegate { DragMove(); };
             };
         }
+
+        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
+        {
+            if (sizeInfo == null || !sizeInfo.WidthChanged && !sizeInfo.HeightChanged)
+            {
+                return;
+            }
+
+            //Keep position when size has changed
+            Top += ((sizeInfo.PreviousSize.Height / MonitorInfo.DpiScaling) - (sizeInfo.NewSize.Height / MonitorInfo.DpiScaling)) / 2;
+            Left += ((sizeInfo.PreviousSize.Width / MonitorInfo.DpiScaling) - (sizeInfo.NewSize.Width / MonitorInfo.DpiScaling)) / 2;
+
+            base.OnRenderSizeChanged(sizeInfo);
+        }
     }
 }