Skip to content

Commit

Permalink
Merge pull request DevChatter#77 from DevChatter/benrick/ui-updates
Browse files Browse the repository at this point in the history
More UI updates
  • Loading branch information
benrick authored May 8, 2020
2 parents bb99ef2 + 67f9f6e commit 56d072b
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 140 deletions.
37 changes: 33 additions & 4 deletions src/InteractiveSeven/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" >
<Application.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key="BackgroundKey" Color="#FF282828" />
<FontFamily x:Key="FontAwesome">/InteractiveSeven;component/Assets/FontAwesome5_Free-Solid-900.otf#Font Awesome 5 Free Solid</FontFamily>

<Style x:Key="HeaderTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="22" />
<Setter Property="FontFamily" Value="Verdana, sans-serif;" />
Expand All @@ -18,14 +18,43 @@
<Setter Property="FontFamily" Value="Verdana, sans-serif;" />
</Style>

<Style x:Key="TabHeaderIconBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource FontAwesome}" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Style x:Key="TabHeaderStyle" TargetType="StackPanel">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="Margin" Value="3 4 3 4" />
</Style>

<Style TargetType="TabItem" BasedOn="{StaticResource MahApps.Styles.TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border Name="Border" BorderThickness="0,0,0,0" CornerRadius="2,15,0,0" Margin="2,0,2,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="5,2,5,2" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MahApps.Brushes.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.IdealForeground}" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MahApps.Brushes.ThemeBackground}" />
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.ThemeForeground}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<lvc:BoolToOnOffConverter x:Key="BoolToOnOffConverter" />
<lvc:BoolToVisibilityConverter x:Key="BoolToHiddenConverter" TrueValue="Visible" FalseValue="Hidden" />
<lvc:UriValueConverter x:Key="UriValueConverter" />
<lvc:ColorValueConverter x:Key="ColorValueConverter" />
<lvc:MenuColorNameConverter x:Key="MenuColorNameConverter" />
<lvc:ColorToSolidBrushValueConverter x:Key="ColorToSolidBrushValueConverter" />
<lvc:ConnectionValueConverter x:Key="ConnectionValueConverter" />
<lvc:CommandWordsValueConverter x:Key="CommandWordsValueConverter" />
<lvc:MenuColorsToImageSourceConverter x:Key="MenuColorsToImageSourceConverter" />
Expand Down
44 changes: 44 additions & 0 deletions src/InteractiveSeven/Behaviors/SelectAllTextOnFocusBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.Xaml.Behaviors;
using System.Windows.Controls;
using System.Windows.Input;

namespace InteractiveSeven.Behaviors
{
public class SelectAllTextOnFocusBehavior : Behavior<TextBox>
{
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;
}
}
}
}
Loading

0 comments on commit 56d072b

Please sign in to comment.