Skip to content

Commit

Permalink
Make TextEnhancementView.xaml look better
Browse files Browse the repository at this point in the history
  • Loading branch information
haefele committed Oct 21, 2023
1 parent dcc582f commit 326bda2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/ChatPrisma/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ResourceDictionary Source="/Themes/ToolTipStyles.xaml" />
<ResourceDictionary Source="/Themes/ContextMenuStyles.xaml" />
<ResourceDictionary Source="/Themes/ButtonStyles.xaml" />
<ResourceDictionary Source="/Themes/TextBoxStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
12 changes: 12 additions & 0 deletions src/ChatPrisma/Themes/Attached.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,16 @@ public static double GetGroupBoxOpacity(DependencyObject element)
{
return (double)element.GetValue(GroupBoxOpacityProperty);
}

public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached(
"Placeholder", typeof(string), typeof(Attached), new PropertyMetadata(default(string)));

public static void SetPlaceholder(DependencyObject element, string value)
{
element.SetValue(PlaceholderProperty, value);
}
public static string GetPlaceholder(DependencyObject element)
{
return (string)element.GetValue(PlaceholderProperty);
}
}
38 changes: 38 additions & 0 deletions src/ChatPrisma/Themes/TextBoxStyles.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:themes="clr-namespace:ChatPrisma.Themes">
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="CaretBrush" Value="White"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<GroupBox>
<Grid Margin="-10, -8, -10, -10" x:Name="BackgroundGrid" Background="#05FFFFFF">
<Grid Margin="6,7,6,2">
<TextBlock Text="{Binding Path=(themes:Attached.Placeholder), RelativeSource={RelativeSource TemplatedParent}}"
Margin="2, 0, 0, 0"
Foreground="Gray"
Visibility="{DXBinding '@p.Text != null and @p.Text.Length > 0 ? $Visibility.Collapsed : $Visibility.Visible'}" />

<ScrollViewer x:Name="PART_ContentHost"
VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"
HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"/>
</Grid>

<Rectangle Name="BottomLine" Height="2" VerticalAlignment="Bottom" Fill="#00C2FC" Visibility="Collapsed" />
</Grid>
</GroupBox>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="BottomLine" Property="Visibility" Value="Visible"/>
<Setter TargetName="BackgroundGrid" Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
43 changes: 16 additions & 27 deletions src/ChatPrisma/Views/TextEnhancement/TextEnhancementView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ChatPrisma.Views.TextEnhancement"
xmlns:fluentIcons="clr-namespace:FluentIcons.WPF;assembly=FluentIcons.WPF"
xmlns:fluentIconsCommon="clr-namespace:FluentIcons.Common;assembly=FluentIcons.Common"
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:themes="clr-namespace:ChatPrisma.Themes"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand All @@ -18,39 +17,29 @@
Loaded="TextEnhancementView_OnLoaded"
DataContextChanged="TextEnhancementView_OnDataContextChanged"
>
<Grid>
<Grid themes:Spacing.Vertical="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<GroupBox Grid.Row="0">
<GroupBox Grid.Row="0" Header="Text" themes:Attached.Icon="TextEditStyle">
<emoji:TextBlock Text="{Binding CurrentText}"
TextWrapping="Wrap"/>
</GroupBox>

<Grid Grid.Row="1" Margin="0, 10, 0, 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBox x:Name="InstructionTextBox"
Grid.Column="0"
Text="{Binding Instruction, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ApplyInstructionCommand}" />
<KeyBinding Key="Enter" Modifiers="Control" Command="{Binding AcceptTextCommand}" />
<KeyBinding Key="Escape" Command="{Binding ApplyInstructionCancelCommand}" />
</TextBox.InputBindings>
</TextBox>
<Button Grid.Column="1"
Command="{Binding ApplyInstructionCommand}"
ToolTip="{DXBinding 'AutoPaste ? `Der Text wird automatisch eingetragen.` : `Der Text wird nur in die Zwischenablage kopiert, Sie müssen ihn selbst einfügen.`'}">
<Grid>
<fluentIcons:SymbolIcon Symbol="{DXBinding 'AutoPaste ? $fluentIconsCommon:Symbol.Send : $fluentIconsCommon:Symbol.Copy'}" />
</Grid>
</Button>
</Grid>
<GroupBox Grid.Row="1" Header="Änderungen" themes:Attached.Icon="InkingTool">
<Grid>
<TextBox x:Name="InstructionTextBox"
themes:Attached.Placeholder="Anweisung"
Text="{Binding Instruction, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ApplyInstructionCommand}" />
<KeyBinding Key="Enter" Modifiers="Control" Command="{Binding AcceptTextCommand}" />
<KeyBinding Key="Escape" Command="{Binding ApplyInstructionCancelCommand}" />
</TextBox.InputBindings>
</TextBox>
</Grid>
</GroupBox>
</Grid>
</UserControl>

0 comments on commit 326bda2

Please sign in to comment.