-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add converters, models, and update project structure
- Loading branch information
1 parent
d420e17
commit 54b8968
Showing
19 changed files
with
1,017 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Windows.Input; | ||
|
||
namespace Libertix.Commands | ||
{ | ||
public class RelayCommand : ICommand | ||
{ | ||
private readonly Action<object> _execute; | ||
private readonly Func<object, bool> _canExecute; | ||
|
||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null) | ||
{ | ||
_execute = execute ?? throw new ArgumentNullException(nameof(execute)); | ||
_canExecute = canExecute; | ||
} | ||
|
||
public event EventHandler CanExecuteChanged | ||
{ | ||
add { CommandManager.RequerySuggested += value; } | ||
remove { CommandManager.RequerySuggested -= value; } | ||
} | ||
|
||
public bool CanExecute(object parameter) => _canExecute?.Invoke(parameter) ?? true; | ||
|
||
public void Execute(object parameter) => _execute(parameter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<UserControl x:Class="Libertix.Controls.ErrorPanel" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:converters="clr-namespace:Libertix.Converters" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<Style x:Key="CustomScrollBarThumb" TargetType="{x:Type Thumb}"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Thumb}"> | ||
<Rectangle Fill="#908caa" | ||
RadiusX="4" | ||
RadiusY="4"/> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style x:Key="CustomScrollBar" TargetType="{x:Type ScrollBar}"> | ||
<Setter Property="Width" Value="8"/> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type ScrollBar}"> | ||
<Grid> | ||
<Rectangle Fill="#363252" | ||
RadiusX="4" | ||
RadiusY="4"/> | ||
<Track x:Name="PART_Track" | ||
IsDirectionReversed="True"> | ||
<Track.Thumb> | ||
<Thumb Style="{StaticResource CustomScrollBarThumb}"/> | ||
</Track.Thumb> | ||
</Track> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style x:Key="CustomScrollViewer" TargetType="{x:Type ScrollViewer}"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type ScrollViewer}"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
<ScrollContentPresenter/> | ||
<ScrollBar x:Name="PART_VerticalScrollBar" | ||
Grid.Column="1" | ||
Value="{TemplateBinding VerticalOffset}" | ||
Maximum="{TemplateBinding ScrollableHeight}" | ||
ViewportSize="{TemplateBinding ViewportHeight}" | ||
Style="{StaticResource CustomScrollBar}"/> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</UserControl.Resources> | ||
|
||
<Border Background="#2a273f" | ||
BorderBrush="#eb6f92" | ||
BorderThickness="1" | ||
CornerRadius="8" | ||
MaxWidth="{Binding MaxWidth, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
MaxHeight="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource ScaleConverter}, ConverterParameter=0.8}" | ||
MinWidth="300"> | ||
|
||
<ScrollViewer Style="{StaticResource CustomScrollViewer}" | ||
VerticalScrollBarVisibility="Auto" | ||
Margin="40,30"> | ||
<StackPanel> | ||
<TextBlock Text="{Binding Title, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Foreground="#eb6f92" | ||
FontSize="32" | ||
FontWeight="Light" | ||
TextAlignment="Center" | ||
TextWrapping="Wrap" | ||
Margin="0,0,0,20"/> | ||
|
||
<TextBlock Text="{Binding Message, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Foreground="#e0def4" | ||
FontSize="16" | ||
TextAlignment="Center" | ||
TextWrapping="Wrap"/> | ||
|
||
<Expander Margin="0,20,0,0" | ||
BorderThickness="0" | ||
IsExpanded="True"> | ||
<Expander.Header> | ||
<TextBlock Text="System Requirements" | ||
Foreground="#908caa" | ||
FontSize="16" | ||
FontWeight="SemiBold"/> | ||
</Expander.Header> | ||
<Expander.Style> | ||
<Style TargetType="Expander"> | ||
<Style.Triggers> | ||
<Trigger Property="IsExpanded" Value="True"> | ||
<Setter Property="Header"> | ||
<Setter.Value> | ||
<TextBlock Text="System Requirements" | ||
Foreground="#908caa" | ||
FontSize="16" | ||
FontWeight="SemiBold"/> | ||
</Setter.Value> | ||
</Setter> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Expander.Style> | ||
<Border Background="#363252" | ||
CornerRadius="4" | ||
Padding="20" | ||
Margin="0,10,0,0"> | ||
<StackPanel> | ||
<!-- System Requirements --> | ||
<TextBlock Text="{Binding Details, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Foreground="#e0def4" | ||
FontFamily="Consolas" | ||
FontSize="14" | ||
TextWrapping="Wrap"/> | ||
|
||
<!-- Additional Space Needed --> | ||
<TextBlock Text="{Binding AdditionalDetails, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Foreground="#eb6f92" | ||
FontSize="14" | ||
FontWeight="SemiBold" | ||
Margin="0,10,0,0" | ||
TextWrapping="Wrap" | ||
Visibility="{Binding AdditionalDetails, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource StringToVisibilityConverter}}"/> | ||
</StackPanel> | ||
</Border> | ||
</Expander> | ||
|
||
<Button Content="{Binding ActionButtonText, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Style="{StaticResource ModernButton}" | ||
Width="250" | ||
Height="50" | ||
Margin="0,30,0,0" | ||
Command="{Binding ActionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
Visibility="{Binding ActionButtonText, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource StringToVisibilityConverter}}"/> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Border> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Windows; | ||
using System.Windows.Input; | ||
using System.Windows.Controls; | ||
|
||
namespace Libertix.Controls | ||
{ | ||
public partial class ErrorPanel : UserControl | ||
{ | ||
public static readonly DependencyProperty TitleProperty = | ||
DependencyProperty.Register("Title", typeof(string), typeof(ErrorPanel), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty MessageProperty = | ||
DependencyProperty.Register("Message", typeof(string), typeof(ErrorPanel), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty DetailsProperty = | ||
DependencyProperty.Register("Details", typeof(string), typeof(ErrorPanel), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty AdditionalDetailsProperty = | ||
DependencyProperty.Register("AdditionalDetails", typeof(string), typeof(ErrorPanel), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty ActionButtonTextProperty = | ||
DependencyProperty.Register("ActionButtonText", typeof(string), typeof(ErrorPanel), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty ActionCommandProperty = | ||
DependencyProperty.Register("ActionCommand", typeof(ICommand), typeof(ErrorPanel), new PropertyMetadata(null)); | ||
|
||
public string Title | ||
{ | ||
get => (string)GetValue(TitleProperty); | ||
set => SetValue(TitleProperty, value); | ||
} | ||
|
||
public string Message | ||
{ | ||
get => (string)GetValue(MessageProperty); | ||
set => SetValue(MessageProperty, value); | ||
} | ||
|
||
public string Details | ||
{ | ||
get => (string)GetValue(DetailsProperty); | ||
set => SetValue(DetailsProperty, value); | ||
} | ||
|
||
public string AdditionalDetails | ||
{ | ||
get => (string)GetValue(AdditionalDetailsProperty); | ||
set => SetValue(AdditionalDetailsProperty, value); | ||
} | ||
|
||
public string ActionButtonText | ||
{ | ||
get => (string)GetValue(ActionButtonTextProperty); | ||
set => SetValue(ActionButtonTextProperty, value); | ||
} | ||
|
||
public ICommand ActionCommand | ||
{ | ||
get => (ICommand)GetValue(ActionCommandProperty); | ||
set => SetValue(ActionCommandProperty, value); | ||
} | ||
|
||
public ErrorPanel() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Expander_Expanded(object sender, RoutedEventArgs e) | ||
{ | ||
if (sender is Expander expander) | ||
{ | ||
expander.BringIntoView(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace Libertix.Converters | ||
{ | ||
public class BoolToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return value is bool boolValue && boolValue ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return value is Visibility visibility && visibility == Visibility.Visible; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Windows.Data; | ||
|
||
namespace Libertix.Converters | ||
{ | ||
public class InverseBoolConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return value is bool boolValue ? !boolValue : true; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return value is bool boolValue ? !boolValue : true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace Libertix.Pages | ||
{ | ||
public class ResponsiveFontConverter : IMultiValueConverter | ||
{ | ||
public double SmallScreenSize { get; set; } | ||
public double DefaultSize { get; set; } | ||
|
||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (values[0] is double width) | ||
{ | ||
return width < 800 ? SmallScreenSize : DefaultSize; | ||
} | ||
return DefaultSize; | ||
} | ||
|
||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.