fixed text width by applying monospaced font (Consolas) to all data

master
Jonas Arnold 3 years ago
parent 7bbaa54ea6
commit 21d4dc9b0e
  1. 29
      MultiTerm.Wpf.CustomControl/MultiFormatDataView/MultiFormatDataView.xaml
  2. 10
      MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml

@ -11,18 +11,16 @@
<SolidColorBrush x:Key="CHAR_Background" Color="#B4FFFF"/> <SolidColorBrush x:Key="CHAR_Background" Color="#B4FFFF"/>
<SolidColorBrush x:Key="HEX_Background" Color="#C8C8FF"/> <SolidColorBrush x:Key="HEX_Background" Color="#C8C8FF"/>
<SolidColorBrush x:Key="BIN_Background" Color="#B4FFB4"/> <SolidColorBrush x:Key="BIN_Background" Color="#B4FFB4"/>
<!-- Value Converters -->
<!-- n/a -->
<!-- Styling for all data items -->
<Style x:Key="DataContainerFontStyle" TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="ExtraLight"/>
</Style>
<!-- Data Template for Data Container -->
<DataTemplate x:Key="dataContainerTemplate" DataType="vm:IDataViewModel"> <DataTemplate x:Key="dataContainerTemplate" DataType="vm:IDataViewModel">
<DataTemplate.Resources>
<!-- Styling for all labels (data items) -->
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="ExtraLight"/>
</Style>
</DataTemplate.Resources>
<StackPanel Orientation="Vertical" Margin="0" x:Name="ItemStackPanel"> <StackPanel Orientation="Vertical" Margin="0" x:Name="ItemStackPanel">
<StackPanel.Triggers> <StackPanel.Triggers>
<EventTrigger SourceName="ItemStackPanel" RoutedEvent="Loaded"> <EventTrigger SourceName="ItemStackPanel" RoutedEvent="Loaded">
@ -58,7 +56,8 @@
<Border BorderThickness="0"> <Border BorderThickness="0">
<Label Content="{Binding DisplayStringChar}" Padding="0" Margin="2 0" VerticalAlignment="Center"> <Label Content="{Binding DisplayStringChar}" Padding="0" Margin="2 0" VerticalAlignment="Center">
<Label.Style> <Label.Style>
<Style TargetType="Label"> <!-- extend label type with specific setters -->
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource DataContainerFontStyle}">
<Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="HorizontalAlignment" Value="Left"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding ElementName=cbHex,Path=IsChecked}" Value="True"> <DataTrigger Binding="{Binding ElementName=cbHex,Path=IsChecked}" Value="True">
@ -91,7 +90,8 @@
</Border> </Border>
<!-- Hexadecimal --> <!-- Hexadecimal -->
<Border BorderThickness="0" Background="{StaticResource HEX_Background}"> <Border BorderThickness="0" Background="{StaticResource HEX_Background}">
<Label Content="{Binding DisplayStringHex}" HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0" Margin="2 0"/> <Label Content="{Binding DisplayStringHex}" Style="{StaticResource DataContainerFontStyle}"
HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0" Margin="2 0"/>
<Border.Style> <Border.Style>
<Style TargetType="Border"> <Style TargetType="Border">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed"/>
@ -105,7 +105,8 @@
</Border> </Border>
<!-- Binary --> <!-- Binary -->
<Border BorderThickness="0" Background="{StaticResource BIN_Background}"> <Border BorderThickness="0" Background="{StaticResource BIN_Background}">
<Label Content="{Binding DisplayStringBin}" HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0" Margin="2"/> <Label Content="{Binding DisplayStringBin}" Style="{StaticResource DataContainerFontStyle}"
HorizontalAlignment="Right" VerticalAlignment="Center" Padding="0" Margin="2"/>
<Border.Style> <Border.Style>
<Style TargetType="Border"> <Style TargetType="Border">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed"/>
@ -158,7 +159,7 @@
<!-- Show only when other checkboxes than "Characters" is checked --> <!-- Show only when other checkboxes than "Characters" is checked -->
<TextBox.Style> <TextBox.Style>
<Style TargetType="TextBox"> <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DataContainerFontStyle}">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding ElementName=cbCharacter,Path=IsChecked}" Value="True"> <DataTrigger Binding="{Binding ElementName=cbCharacter,Path=IsChecked}" Value="True">

@ -7,13 +7,21 @@
<SolidColorBrush x:Key="MultiFormatTextBox.CHAR.Background" Color="#B4EBEB"/> <SolidColorBrush x:Key="MultiFormatTextBox.CHAR.Background" Color="#B4EBEB"/>
<SolidColorBrush x:Key="MultiFormatTextBox.HEX.Background" Color="#C8C8FF"/> <SolidColorBrush x:Key="MultiFormatTextBox.HEX.Background" Color="#C8C8FF"/>
<SolidColorBrush x:Key="MultiFormatTextBox.BIN.Background" Color="#C8FFC8"/> <SolidColorBrush x:Key="MultiFormatTextBox.BIN.Background" Color="#C8FFC8"/>
<!-- Styling for text -->
<Style x:Key="TextFontStyle" TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="ExtraLight"/>
</Style>
</Style.Resources> </Style.Resources>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type local:MultiFormatTextBox}"> <ControlTemplate TargetType="{x:Type local:MultiFormatTextBox}">
<DockPanel LastChildFill="True"> <DockPanel LastChildFill="True">
<ComboBox DockPanel.Dock="Left" x:Name="PART_ComboBox" Width="70"></ComboBox> <ComboBox DockPanel.Dock="Left" x:Name="PART_ComboBox" Width="70"></ComboBox>
<RichTextBox DockPanel.Dock="Right" VerticalContentAlignment="Center" x:Name="PART_RichTextBox"></RichTextBox> <RichTextBox DockPanel.Dock="Right" VerticalContentAlignment="Center" x:Name="PART_RichTextBox"
Style="{StaticResource TextFontStyle}"></RichTextBox>
</DockPanel> </DockPanel>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

Loading…
Cancel
Save