diff --git a/src/InteractiveSeven/App.xaml b/src/InteractiveSeven/App.xaml index 6a715955..fec1b0f8 100644 --- a/src/InteractiveSeven/App.xaml +++ b/src/InteractiveSeven/App.xaml @@ -2,12 +2,12 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lvc="clr-namespace:InteractiveSeven.ValueConverters" - xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" Startup="App_OnStartup" Exit="App_OnExit" > /InteractiveSeven;component/Assets/FontAwesome5_Free-Solid-900.otf#Font Awesome 5 Free Solid + - + + + + + diff --git a/src/InteractiveSeven/Behaviors/SelectAllTextOnFocusBehavior.cs b/src/InteractiveSeven/Behaviors/SelectAllTextOnFocusBehavior.cs new file mode 100644 index 00000000..81e1f493 --- /dev/null +++ b/src/InteractiveSeven/Behaviors/SelectAllTextOnFocusBehavior.cs @@ -0,0 +1,44 @@ +using Microsoft.Xaml.Behaviors; +using System.Windows.Controls; +using System.Windows.Input; + +namespace InteractiveSeven.Behaviors +{ + public class SelectAllTextOnFocusBehavior : Behavior + { + protected override void OnAttached() + { + base.OnAttached(); + AssociatedObject.GotKeyboardFocus += AssociatedObjectGotKeyboardFocus; + AssociatedObject.GotMouseCapture += AssociatedObjectGotMouseCapture; + AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObjectPreviewMouseLeftButtonDown; + } + + protected override void OnDetaching() + { + base.OnDetaching(); + AssociatedObject.GotKeyboardFocus -= AssociatedObjectGotKeyboardFocus; + AssociatedObject.GotMouseCapture -= AssociatedObjectGotMouseCapture; + AssociatedObject.PreviewMouseLeftButtonDown -= AssociatedObjectPreviewMouseLeftButtonDown; + } + + private void AssociatedObjectGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AssociatedObject.SelectAll(); + } + + private void AssociatedObjectGotMouseCapture(object sender, MouseEventArgs e) + { + AssociatedObject.SelectAll(); + } + + private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!AssociatedObject.IsKeyboardFocusWithin) + { + AssociatedObject.Focus(); + e.Handled = true; + } + } + } +} \ No newline at end of file diff --git a/src/InteractiveSeven/MainWindow.xaml b/src/InteractiveSeven/MainWindow.xaml index 75373473..6f3541b8 100644 --- a/src/InteractiveSeven/MainWindow.xaml +++ b/src/InteractiveSeven/MainWindow.xaml @@ -3,10 +3,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:wpfTool="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit" - xmlns:interactiveSeven="clr-namespace:InteractiveSeven" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" + xmlns:b="http://schemas.microsoft.com/xaml/behaviors" + xmlns:behaviors="clr-namespace:InteractiveSeven.Behaviors" mc:Ignorable="d" BorderThickness="0" GlowBrush="{DynamicResource MahApps.Brushes.Accent}" @@ -17,20 +17,20 @@ - + @@ -43,6 +43,7 @@ HorizontalAlignment="Left" FontSize="20" /> + @@ -58,60 +59,84 @@ + + MinHeight="464" VerticalAlignment="Stretch" Margin="5" + VerticalContentAlignment="Stretch" MinWidth="580"> - + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -129,11 +154,11 @@ - + - - - - + - - - + + + + diff --git a/src/InteractiveSeven/MainWindow.xaml.cs b/src/InteractiveSeven/MainWindow.xaml.cs index ec38e67f..41d74167 100644 --- a/src/InteractiveSeven/MainWindow.xaml.cs +++ b/src/InteractiveSeven/MainWindow.xaml.cs @@ -44,8 +44,8 @@ private void ChangeSettingsButtonClick(object sender, RoutedEventArgs e) _settingsWindow = new SettingsWindow(ViewModel.SettingsViewModel); _settingsWindow.Owner = this; _settingsWindow.Closed += (o, args) => _settingsWindow = null; - _settingsWindow.Left = Left + ActualWidth / 3.0; - _settingsWindow.Top = Top + ActualHeight / 3.0; + _settingsWindow.Left = Left + ActualWidth / 6.0; + _settingsWindow.Top = Top + ActualHeight / 6.0; _settingsWindow.Show(); } @@ -61,8 +61,8 @@ private void ChangeAppStyleButtonClick(object sender, RoutedEventArgs e) _accentThemeTestWindow = new AccentStyleWindow(); _accentThemeTestWindow.Owner = this; _accentThemeTestWindow.Closed += (o, args) => _accentThemeTestWindow = null; - _accentThemeTestWindow.Left = Left + ActualWidth / 2.0; - _accentThemeTestWindow.Top = Top + ActualHeight / 2.0; + _accentThemeTestWindow.Left = Left + ActualWidth / 4.0; + _accentThemeTestWindow.Top = Top + ActualHeight / 4.0; _accentThemeTestWindow.Show(); } } diff --git a/src/InteractiveSeven/SettingsWindow.xaml b/src/InteractiveSeven/SettingsWindow.xaml index 550006f3..e831f402 100644 --- a/src/InteractiveSeven/SettingsWindow.xaml +++ b/src/InteractiveSeven/SettingsWindow.xaml @@ -37,9 +37,9 @@ - + - + @@ -93,12 +93,12 @@ - + - + - + @@ -147,12 +147,12 @@ - + - + - + @@ -296,12 +296,12 @@ - + - + - + @@ -383,12 +383,12 @@ - + - + - + @@ -594,12 +594,12 @@ - + - + - + @@ -608,7 +608,7 @@ - + @@ -664,9 +664,9 @@ - + - + @@ -686,9 +686,9 @@ - + - + @@ -708,9 +708,9 @@ - + - + @@ -730,9 +730,9 @@ - + - + @@ -774,9 +774,9 @@ + - + @@ -799,9 +799,9 @@ - + - + @@ -822,16 +822,16 @@ - + - + - + - + @@ -897,12 +897,12 @@ - + - + - + @@ -933,7 +933,7 @@ - + diff --git a/src/InteractiveSeven/ValueConverters/BoolToOnOffConverter.cs b/src/InteractiveSeven/ValueConverters/BoolToOnOffConverter.cs new file mode 100644 index 00000000..588c5ea4 --- /dev/null +++ b/src/InteractiveSeven/ValueConverters/BoolToOnOffConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace InteractiveSeven.ValueConverters +{ + [ValueConversion(typeof(bool), typeof(string))] + public sealed class BoolToOnOffConverter : IValueConverter + { + public object Convert(object value, Type targetType, + object parameter, CultureInfo culture) + { + if (!(value is bool)) + return null; + return (bool)value ? "On" : "Off"; + } + + public object ConvertBack(object value, Type targetType, + object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/InteractiveSeven/ValueConverters/ColorToSolidBrushValueConverter.cs b/src/InteractiveSeven/ValueConverters/ColorToSolidBrushValueConverter.cs new file mode 100644 index 00000000..d9c941ef --- /dev/null +++ b/src/InteractiveSeven/ValueConverters/ColorToSolidBrushValueConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace InteractiveSeven.ValueConverters +{ + public class ColorToSolidBrushValueConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is System.Drawing.Color drawColor) + { + return new SolidColorBrush(Color.FromRgb(drawColor.R, drawColor.G, drawColor.B)); + } + return new SolidColorBrush(Color.FromRgb(0, 0, 0)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/InteractiveSeven/ValueConverters/MenuColorNameConverter.cs b/src/InteractiveSeven/ValueConverters/MenuColorNameConverter.cs new file mode 100644 index 00000000..0d1b9a42 --- /dev/null +++ b/src/InteractiveSeven/ValueConverters/MenuColorNameConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace InteractiveSeven.ValueConverters +{ + public class MenuColorNameConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is System.Drawing.Color color) + { + string colorName = color.IsNamedColor ? color.Name : $"#{color.Name[2..]}"; + return $"{colorName} | R:{color.R} G:{color.G} B:{color.B}"; + } + return "Unexpected Binding"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} \ No newline at end of file