added and included MultiFormatTextBox in SendReceiveView

master
Jonas Arnold 3 years ago
parent c8c53221d3
commit 6651dfb381
  1. 68
      MultiTerm.Wpf.CustomControl/ExtendedTabControl/ExtendedTabControl.cs
  2. 41
      MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.cs
  3. 56
      MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml
  4. 1
      MultiTerm.Wpf.CustomControl/Themes/Generic.xaml
  5. 23
      MultiTerm.Wpf/View/SendReceiveView.xaml

@ -1,40 +1,39 @@
using System.Runtime.CompilerServices; using System.Windows;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
namespace MultiTerm.Wpf.CustomControl namespace MultiTerm.Wpf.CustomControl;
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.Controls"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.Controls;assembly=MultiTerm.Wpf.Controls"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:ExtendedTabControl/>
///
/// </summary>
public class ExtendedTabControl : TabControl
{ {
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.Controls"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.Controls;assembly=MultiTerm.Wpf.Controls"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:ExtendedTabControl/>
///
/// </summary>
public class ExtendedTabControl : TabControl
{
public static readonly RoutedEvent AddButtonClickedEvent; public static readonly RoutedEvent AddButtonClickedEvent;
#region Dotnet Properties #region Dotnet Properties
@ -74,5 +73,4 @@ namespace MultiTerm.Wpf.CustomControl
RoutedEventArgs args = new RoutedEventArgs(AddButtonClickedEvent); RoutedEventArgs args = new RoutedEventArgs(AddButtonClickedEvent);
RaiseEvent(args); RaiseEvent(args);
} }
}
} }

@ -0,0 +1,41 @@
using System.Windows;
using System.Windows.Controls;
namespace MultiTerm.Wpf.CustomControl;
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.CustomControl"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:MultiTerm.Wpf.CustomControl.MultiFormatTextBox;assembly=MultiTerm.Wpf.CustomControl.MultiFormatTextBox"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:MultiFormatTextBox/>
///
/// </summary>
public class MultiFormatTextBox : TextBox
{
static MultiFormatTextBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiFormatTextBox), new FrameworkPropertyMetadata(typeof(MultiFormatTextBox)));
}
}

@ -0,0 +1,56 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MultiTerm.Wpf.CustomControl">
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
<Style TargetType="{x:Type local:MultiFormatTextBox}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MultiFormatTextBox}">
<DockPanel LastChildFill="True">
<ComboBox DockPanel.Dock="Left" x:Name="comboBox" Width="60">
<ComboBoxItem>CHAR</ComboBoxItem>
<ComboBoxItem>HEX</ComboBoxItem>
<ComboBoxItem>BIN</ComboBoxItem>
</ComboBox>
<Border DockPanel.Dock="Right" x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Width="{TemplateBinding Width}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</Border>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

@ -6,6 +6,7 @@
<!-- below all xaml files for custom controls shall be added --> <!-- below all xaml files for custom controls shall be added -->
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MultiTerm.Wpf.CustomControl;component/ExtendedTabControl/ExtendedTabControl.xaml"/> <ResourceDictionary Source="/MultiTerm.Wpf.CustomControl;component/ExtendedTabControl/ExtendedTabControl.xaml"/>
<ResourceDictionary Source="/MultiTerm.Wpf.CustomControl;component/MultiFormatTextBox/MultiFormatTextBox.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

@ -6,6 +6,7 @@
xmlns:local="clr-namespace:MultiTerm.Wpf.View" xmlns:local="clr-namespace:MultiTerm.Wpf.View"
xmlns:protocol_serial="clr-namespace:MultiTerm.Protocols.Serial;assembly=MultiTerm.Protocols" xmlns:protocol_serial="clr-namespace:MultiTerm.Protocols.Serial;assembly=MultiTerm.Protocols"
xmlns:settings_view="clr-namespace:MultiTerm.Wpf.View.SettingsView" xmlns:settings_view="clr-namespace:MultiTerm.Wpf.View.SettingsView"
xmlns:custom_controls="clr-namespace:MultiTerm.Wpf.CustomControl;assembly=MultiTerm.Wpf.CustomControl"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
@ -14,11 +15,12 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50px"/> <RowDefinition Height="50px"/>
<RowDefinition Height="*"/> <RowDefinition Height="5*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Settings View Model --> <!-- Settings View Model -->
<GroupBox Header="Protocol Settings" Grid.Row="0" Grid.Column="0"> <GroupBox Header="Protocol Settings" Grid.Row="0" Grid.Column="0" Padding="5 1">
<!-- Register additional Settings ViewModels here --> <!-- Register additional Settings ViewModels here -->
<ContentControl Content="{Binding ProtocolSettings}"> <ContentControl Content="{Binding ProtocolSettings}">
<ContentControl.Resources> <ContentControl.Resources>
@ -28,5 +30,22 @@
</ContentControl.Resources> </ContentControl.Resources>
</ContentControl> </ContentControl>
</GroupBox> </GroupBox>
<GroupBox Header="Receive" Grid.Row="1" Padding="5">
</GroupBox>
<GroupBox Header="Send" Grid.Row="2" Padding="5">
<DockPanel>
<!-- Send text box -->
<DockPanel DockPanel.Dock="Top" LastChildFill="True">
<!--<TextBox Width="700"></TextBox>-->
<Button DockPanel.Dock="Right" Content="Send"/>
<custom_controls:MultiFormatTextBox DockPanel.Dock="Left"></custom_controls:MultiFormatTextBox>
</DockPanel>
<Separator/>
<RichTextBox DockPanel.Dock="Bottom">
</RichTextBox>
</DockPanel>
</GroupBox>
</Grid> </Grid>
</UserControl> </UserControl>

Loading…
Cancel
Save