From 379aa34691edafc19fb236d74d1d3bdcdbbfdbdd Mon Sep 17 00:00:00 2001 From: Dreamcooled Date: Sun, 19 Jul 2015 15:43:34 +0200 Subject: [PATCH] Displayed Header of Episode/Non-Episode Lists to allow resizing. Added ConverterMagic so that the last columns always takes all available space. This closes #32. --- SjUpdater/MainWindow.xaml | 23 ++++++----- SjUpdater/SjUpdater.csproj | 1 + SjUpdater/SpecialDownloadList.xaml | 16 +++++--- .../GridViewWidthCalulationMultiConverter.cs | 40 +++++++++++++++++++ 4 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 SjUpdater/Utils/GridViewWidthCalulationMultiConverter.cs diff --git a/SjUpdater/MainWindow.xaml b/SjUpdater/MainWindow.xaml index be60027..60f8b6f 100644 --- a/SjUpdater/MainWindow.xaml +++ b/SjUpdater/MainWindow.xaml @@ -26,6 +26,7 @@ + @@ -713,14 +714,9 @@ - - - - + @@ -750,12 +746,21 @@ - + + + + + + + + - - + + diff --git a/SjUpdater/SjUpdater.csproj b/SjUpdater/SjUpdater.csproj index 945cb71..24fe5e7 100644 --- a/SjUpdater/SjUpdater.csproj +++ b/SjUpdater/SjUpdater.csproj @@ -156,6 +156,7 @@ + diff --git a/SjUpdater/SpecialDownloadList.xaml b/SjUpdater/SpecialDownloadList.xaml index 43b1230..82b6fc1 100644 --- a/SjUpdater/SpecialDownloadList.xaml +++ b/SjUpdater/SpecialDownloadList.xaml @@ -9,17 +9,13 @@ d:DesignHeight="300" d:DesignWidth="300"> + - - - - + @@ -54,6 +50,14 @@ + + + + + + diff --git a/SjUpdater/Utils/GridViewWidthCalulationMultiConverter.cs b/SjUpdater/Utils/GridViewWidthCalulationMultiConverter.cs new file mode 100644 index 0000000..370fb22 --- /dev/null +++ b/SjUpdater/Utils/GridViewWidthCalulationMultiConverter.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; + +//Code taken from: http://stackoverflow.com/questions/5573152/how-to-resize-a-certain-control-based-on-window-size-in-wpf#5573895 + +namespace SjUpdater.Utils +{ + public class GridViewWidthCalulationMultiConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, + object parameter, CultureInfo culture) + { + // do some sort of calculation + double totalWindowWidth; + double otherColumnsTotalWidth = 0; + double.TryParse(values[0].ToString(), out totalWindowWidth); + var arrayOfColumns = values[1] as IList; + + for (int i = 0; i < arrayOfColumns.Count - 1; i++) + { + otherColumnsTotalWidth += arrayOfColumns[i].ActualWidth; + } + + return (totalWindowWidth - otherColumnsTotalWidth) < 0 ? + 0 : (totalWindowWidth - otherColumnsTotalWidth); + } + + public object[] ConvertBack(object value, Type[] targetTypes, + object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +}