Skip to content

Commit

Permalink
Version 1.6
Browse files Browse the repository at this point in the history
Updated to .net7
New features and improvements
  • Loading branch information
poqdavid committed Feb 19, 2023
1 parent 379237b commit 917aaed
Show file tree
Hide file tree
Showing 48 changed files with 2,268 additions and 1,009 deletions.
20 changes: 6 additions & 14 deletions PotatoWallClient.xaml → App.xaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<Application
x:Class="PotatoWall.PotatoWallClientX"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="PotatoWallUI.xaml">
<Application x:Class="PotatoWall.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<materialDesign:BundledTheme
BaseTheme="Inherit"
PrimaryColor="BlueGrey"
SecondaryColor="Lime" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.BlueGrey.xaml" />
<materialDesign:BundledTheme BaseTheme="Inherit" PrimaryColor="BlueGrey" SecondaryColor="Lime"
ColorAdjustment="{materialDesign:ColorAdjustment}" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.CheckBox.xaml" />
Expand Down
44 changes: 44 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PotatoWall is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>.
*/

namespace PotatoWall;

using System.Windows;

/// <copyright file="App.xaml.cs" company="POQDavid">
/// Copyright (c) POQDavid. All rights reserved.
/// </copyright>
/// <author>POQDavid</author>
/// <summary>This is the App class.</summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
PotatoWallClient.InitializeComponent();

base.OnStartup(e);

PotatoWallClient.Run();
}

private void Application_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
PotatoWallClient.Logger.Information("I see loaded!!!");
}
}
2 changes: 1 addition & 1 deletion Converters/ComboBoxSelectedValueConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions Converters/DialogHostStackPanelHeightConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -29,7 +29,7 @@ public class DialogHostStackPanelHeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (double)value - double.Parse((string)parameter, Thread.CurrentThread.CurrentCulture);
return value.CastTo<double>() - double.Parse(parameter.CastTo<string>(), Thread.CurrentThread.CurrentCulture);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
4 changes: 2 additions & 2 deletions Converters/DialogHostStackPanelWidthConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -29,7 +29,7 @@ public class DialogHostStackPanelWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (double)value - double.Parse((string)parameter, Thread.CurrentThread.CurrentCulture);
return value.CastTo<double>() - double.Parse(parameter.CastTo<string>(), Thread.CurrentThread.CurrentCulture);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
49 changes: 49 additions & 0 deletions Converters/IntArrayConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PotatoWall is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>.
*/

namespace PotatoWall.Converters;

// <copyright file="IntArrayConverter.cs" company="POQDavid">
// Copyright (c) POQDavid. All rights reserved.
// </copyright>
// <author>POQDavid</author>
// <summary>This is the IntArrayConverter class.</summary>

public class IntArrayConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (targetType.FullName, value.GetType().FullName) switch
{
("System.String", "System.Int32[]") => value.CastTo<int[]>().ToCSV(),
("System.String", "System.UInt32[]") => value.CastTo<uint[]>().ToCSV(),
_ => throw new NotImplementedException("Not implemented."),
};
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (targetType.FullName, value.GetType().FullName) switch
{
("System.Int32[]", "System.String") => value.CastTo<string>().CSVToArray(true).Select(x => int.Parse(x)).ToArray(),
("System.UInt32[]", "System.String") => value.CastTo<string>().CSVToArray(true).Select(x => uint.Parse(x)).ToArray(),
_ => throw new NotImplementedException("Not implemented."),
};
}
}
2 changes: 1 addition & 1 deletion Converters/MultiConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
64 changes: 64 additions & 0 deletions Extensions/ArrayExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PotatoWall is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>.
*/

namespace PotatoWall.Extensions;

// <copyright file="ArrayExtensions.cs" company="POQDavid">
// Copyright (c) POQDavid. All rights reserved.
// </copyright>
// <author>POQDavid</author>
// <summary>This is the ArrayExtensions class.</summary>

public static class ArrayExtensions
{
/// <summary>
/// Returns a CSV string of the int array
/// </summary>
/// <param name="array"></param>
/// <returns>CSV string</returns>
public static string ToCSV(this int[] array)
{
return String.Join(", ", array);
}

/// <summary>
/// Returns a CSV string of the uint array
/// </summary>
/// <param name="array"></param>
/// <returns>CSV string</returns>
public static string ToCSV(this uint[] array)
{
return String.Join(", ", array);
}

/// <summary>
/// Returns a CSV string of the int array
/// </summary>
/// <param name="array"></param>
/// <param name="withoutspace">CSV without whitespace</param>
/// <returns>CSV string</returns>
public static string ToCSV(this int[] array, bool withoutspace)
{
return withoutspace switch
{
true => String.Join(",", array).RemoveWhitespace(),
false => String.Join(", ", array),
};
}
}
17 changes: 17 additions & 0 deletions Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace PotatoWall.Extensions;

public static class DictionaryExtensions
{
public static TValue Pop<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
{
if (dictionary.TryGetValue(key, out TValue temp))
{
dictionary.Remove(key);
return temp;
}
else
{
throw new KeyNotFoundException($"Key {key} not found in dictionary.");
}
}
}
2 changes: 1 addition & 1 deletion Extensions/DispatcherExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion Extensions/FlowDocumentExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
3 changes: 1 addition & 2 deletions Extensions/FrameworkElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand All @@ -25,7 +25,6 @@ namespace PotatoWall.Extensions;
// <author>POQDavid</author>
// <summary>This is the FrameworkElementExtensions class.</summary>

[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0004:Cast is redundant", Justification = "The cast is needed")]
public static class FrameworkElementExtensions
{
public static T GetTemplatedParent<T>(this FrameworkElement o) where T : DependencyObject
Expand Down
2 changes: 1 addition & 1 deletion Extensions/IntegralTypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion Extensions/ListBoxExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
69 changes: 69 additions & 0 deletions Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PotatoWall is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>.
*/

namespace PotatoWall.Extensions;

// <copyright file="ObjectExtensions.cs" company="POQDavid">
// Copyright (c) POQDavid. All rights reserved.
// </copyright>
// <author>POQDavid</author>
// <summary>This is the ObjectExtensions class.</summary>

public static class ObjectExtensions
{
/// <summary>
/// Cast's a System.Object to T
/// </summary>
/// <typeparam name="T">Type to cast to</typeparam>
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static T CastTo<T>(this object value)
{
if (value == null) throw new ArgumentNullException(nameof(value));

if (value is T t) return t;

throw new Exception($"Casting from {value.GetType().FullName} to {typeof(T).FullName} wasn't successful.");
}

/// <summary>
/// Cast's a System.Object to T
/// </summary>
/// <typeparam name="T">Type to cast to</typeparam>
/// <param name="value"></param>
/// <param name="success"></param>
/// <returns></returns>
public static T TryCastTo<T>(this object value, out bool success)
{
success = true;

if (value == null)
{
success = false;
return default;
}

if (value is T t)
return t;

success = false;
return default;
}
}
2 changes: 1 addition & 1 deletion Extensions/PaletteHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void ReplaceAccentColor(this PaletteHelper paletteHelper, string n
/// <param name="parentDictionary">The root dictionary to start searching at. Null means using Application.Current.Resources</param>
private static void ReplaceEntry(object entryName, object newValue, ResourceDictionary parentDictionary = null)
{
if (parentDictionary == null) { parentDictionary = Application.Current.Resources; }
parentDictionary ??= Application.Current.Resources;

if (parentDictionary.Contains(entryName))
{
Expand Down
2 changes: 1 addition & 1 deletion Extensions/ParagraphExtentions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/).
* Copyright (c) 2021 POQDavid
* Copyright (c) 2023 POQDavid
* Copyright (c) contributors
*
* PotatoWall is free software: you can redistribute it and/or modify
Expand Down
Loading

0 comments on commit 917aaed

Please sign in to comment.