|
| 1 | +<UserControl x:Class="OATControl.Controls.InlineSlider" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:convert="clr-namespace:OATControl.Converters" |
| 7 | + xmlns:local="clr-namespace:OATControl.Controls" |
| 8 | + Name="InlineSliderControl" |
| 9 | + mc:Ignorable="d" |
| 10 | + d:DesignHeight="30" d:DesignWidth="300"> |
| 11 | + |
| 12 | + <UserControl.Resources> |
| 13 | + |
| 14 | + <ResourceDictionary> |
| 15 | + <!--<ResourceDictionary.MergedDictionaries> |
| 16 | + <ResourceDictionary Source="pack://application:,,,/OATControl;component/Resources/Controls.xaml" /> |
| 17 | + </ResourceDictionary.MergedDictionaries>--> |
| 18 | + |
| 19 | + |
| 20 | + <convert:BoolToVisibilityConverter x:Key="BoolToVisibleConverter" Collapse="True" /> |
| 21 | + |
| 22 | + <LinearGradientBrush x:Key="UnsetBackground" StartPoint="0,0" EndPoint="0,1"> |
| 23 | + <GradientStop Color="{StaticResource USBGTop}" Offset="0" /> |
| 24 | + <GradientStop Color="{StaticResource USBGBottom}" Offset="1" /> |
| 25 | + </LinearGradientBrush> |
| 26 | + <LinearGradientBrush x:Key="SetBackground" StartPoint="0,0" EndPoint="0,1"> |
| 27 | + <GradientStop Color="{StaticResource SBGTop}" Offset="0" /> |
| 28 | + <GradientStop Color="{StaticResource SBGBottom}" Offset="1" /> |
| 29 | + </LinearGradientBrush> |
| 30 | + <LinearGradientBrush x:Key="SetBackgroundActive" StartPoint="0,0" EndPoint="0,1"> |
| 31 | + <GradientStop Color="{StaticResource SBGActTop}" Offset="0" /> |
| 32 | + <GradientStop Color="{StaticResource SBGActBottom}" Offset="1" /> |
| 33 | + </LinearGradientBrush> |
| 34 | + <LinearGradientBrush x:Key="ButtonBackground" StartPoint="0,0" EndPoint="0,1"> |
| 35 | + <GradientStop Color="{StaticResource ButtonBGTop}" Offset="0" /> |
| 36 | + <GradientStop Color="{StaticResource ButtonBGBottom}" Offset="1" /> |
| 37 | + </LinearGradientBrush> |
| 38 | + |
| 39 | + <LinearGradientBrush x:Key="ButtonBackgroundActive" StartPoint="0,0" EndPoint="0,1"> |
| 40 | + <GradientStop Color="{StaticResource ButtonBGActTop}" Offset="0" /> |
| 41 | + <GradientStop Color="{StaticResource ButtonBGActBottom}" Offset="1" /> |
| 42 | + </LinearGradientBrush> |
| 43 | + |
| 44 | + <SolidColorBrush x:Key="PromptBrush" Color="{StaticResource PromptColor}"/> |
| 45 | + <SolidColorBrush x:Key="PromptActBrush" Color="{StaticResource PromptActColor}"/> |
| 46 | + <SolidColorBrush x:Key="TextBrush" Color="{StaticResource TextColor}"/> |
| 47 | + <SolidColorBrush x:Key="SliderPosBrush" Color="{StaticResource SliderPosColor}"/> |
| 48 | + <SolidColorBrush x:Key="SliderBorderBrush" Color="{StaticResource SliderBorderColor}"/> |
| 49 | + |
| 50 | + <ControlTemplate x:Key="EditButtonTemplate"> |
| 51 | + <Border BorderBrush="Black" BorderThickness="1" Padding="2" CornerRadius="2" > |
| 52 | + <Border.Style> |
| 53 | + <Style TargetType="Border"> |
| 54 | + <Setter Property="Background" Value="{StaticResource ButtonBackground}" /> |
| 55 | + <Style.Triggers> |
| 56 | + <Trigger Property="IsMouseOver" Value="True"> |
| 57 | + <Setter Property="Background" Value="{StaticResource ButtonBackgroundActive}" /> |
| 58 | + </Trigger> |
| 59 | + </Style.Triggers> |
| 60 | + </Style> |
| 61 | + </Border.Style> |
| 62 | + <Viewbox > |
| 63 | + <Grid > |
| 64 | + <Polygon Fill="{StaticResource SliderBorderBrush}" StrokeThickness="0" Points="20,68 0,75 8,55" /> |
| 65 | + <Polygon Fill="{StaticResource SliderBorderBrush}" Stroke="Black" StrokeThickness="2" Points="62,0 75,13 62,26 49,13" /> |
| 66 | + <Polygon Fill="{StaticResource SliderBorderBrush}" Stroke="Black" StrokeThickness="2" Points="49,13 62,26 20,68 8,55" /> |
| 67 | + |
| 68 | + <Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="25,85 35,85 35,75 25,75" /> |
| 69 | + <Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="45,85 55,85 55,75 45,75" /> |
| 70 | + <Polygon Fill="{StaticResource SliderPosBrush}" StrokeThickness="0" Points="65,85 75,85 75,75 65,75" /> |
| 71 | + </Grid> |
| 72 | + </Viewbox> |
| 73 | + </Border> |
| 74 | + </ControlTemplate> |
| 75 | + |
| 76 | + </ResourceDictionary> |
| 77 | + |
| 78 | + </UserControl.Resources> |
| 79 | + |
| 80 | + <Grid VerticalAlignment="Top" Name="MainGrid" Background="Transparent" IsHitTestVisible="True" MouseDown="MainGrid_OnMouseButtonDown" MouseUp="MainGrid_OnMouseButtonUp" MouseMove="MainGrid_OnMouseMove"> |
| 81 | + <Grid.ColumnDefinitions> |
| 82 | + <ColumnDefinition Width="*"/> |
| 83 | + <ColumnDefinition Width="Auto"/> |
| 84 | + <ColumnDefinition Width="Auto"/> |
| 85 | + <ColumnDefinition Width="Auto"/> |
| 86 | + </Grid.ColumnDefinitions> |
| 87 | + <Grid.RowDefinitions> |
| 88 | + <RowDefinition Height="Auto" /> |
| 89 | + <RowDefinition Height="Auto" /> |
| 90 | + </Grid.RowDefinitions> |
| 91 | + <Grid Name="TrackPart" SizeChanged="TrackPart_OnSizeChanged"> |
| 92 | + <Grid.ColumnDefinitions> |
| 93 | + <ColumnDefinition Width="{Binding ElementName=InlineSliderControl, Path=SetPartWidth}"/> |
| 94 | + <ColumnDefinition Width="2"/> |
| 95 | + <ColumnDefinition Width="{Binding ElementName=InlineSliderControl, Path=UnsetPartWidth}"/> |
| 96 | + </Grid.ColumnDefinitions> |
| 97 | + <Border BorderBrush="{StaticResource SliderBorderBrush}" BorderThickness="1,1,0,1" CornerRadius="2,0,0,2" > |
| 98 | + <Rectangle RadiusX="2" RadiusY="2" Margin="0,0,-2,0"> |
| 99 | + <Rectangle.Style> |
| 100 | + <Style TargetType="Rectangle"> |
| 101 | + <Setter Property="Fill" Value="{StaticResource SetBackground}" /> |
| 102 | + <Style.Triggers> |
| 103 | + <DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver}" Value="True"> |
| 104 | + <Setter Property="Fill" Value="{StaticResource SetBackgroundActive}" /> |
| 105 | + </DataTrigger> |
| 106 | + </Style.Triggers> |
| 107 | + </Style> |
| 108 | + </Rectangle.Style> |
| 109 | + </Rectangle> |
| 110 | + </Border> |
| 111 | + |
| 112 | + <Border Grid.Column="2" BorderBrush="{StaticResource SliderBorderBrush}" BorderThickness="0,1,1,1" Name="UnsetBorder" CornerRadius="0,2,2,0"> |
| 113 | + <Rectangle Fill="{StaticResource UnsetBackground}" RadiusX="2" RadiusY="2" Margin="-2,0,0,0" /> |
| 114 | + </Border> |
| 115 | + |
| 116 | + <Border Grid.Column="1" BorderBrush="{StaticResource SliderPosBrush}" BorderThickness="1"> |
| 117 | + <Rectangle Fill="{StaticResource SliderPosBrush}" /> |
| 118 | + </Border> |
| 119 | + |
| 120 | + <Canvas Grid.Column="0" Name="TickCanvas" Grid.ColumnSpan="3" IsHitTestVisible="False" /> |
| 121 | + |
| 122 | + </Grid> |
| 123 | + |
| 124 | + <TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding ElementName=InlineSliderControl, Path=Prompt}" |
| 125 | + IsHitTestVisible="False" Padding="4,0,4,2" VerticalAlignment="Center"> |
| 126 | + <TextBlock.Style> |
| 127 | + <Style TargetType="TextBlock"> |
| 128 | + <Setter Property="Foreground" Value="{StaticResource PromptBrush}" /> |
| 129 | + <Style.Triggers> |
| 130 | + <DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver, Mode=OneWay}" Value="True"> |
| 131 | + <Setter Property="Foreground" Value="{StaticResource PromptActBrush}" /> |
| 132 | + </DataTrigger> |
| 133 | + </Style.Triggers> |
| 134 | + </Style> |
| 135 | + </TextBlock.Style> |
| 136 | + </TextBlock> |
| 137 | + <TextBox Grid.Column="0" Grid.Row="0" Name="ValueTextBox" |
| 138 | + |
| 139 | + IsHitTestVisible="False" |
| 140 | + HorizontalAlignment="Right" |
| 141 | + VerticalAlignment="Center" |
| 142 | + Background="Transparent" |
| 143 | + Padding="0,0,3,1" |
| 144 | + BorderThickness="0" |
| 145 | + IsReadOnly="True" |
| 146 | + Focusable="False" |
| 147 | + TextWrapping="NoWrap" |
| 148 | + KeyDown="ValueTextBox_OnKeyDown" |
| 149 | + LostFocus="ValueTextBox_OnLostFocus"> |
| 150 | + <TextBox.Style> |
| 151 | + <Style TargetType="TextBox"> |
| 152 | + <Setter Property="Foreground" Value="{StaticResource PromptBrush}" /> |
| 153 | + <Style.Triggers> |
| 154 | + <DataTrigger Binding="{Binding ElementName=MainGrid, Path=IsMouseOver, Mode=OneWay}" Value="True"> |
| 155 | + <Setter Property="Foreground" Value="{StaticResource PromptActBrush}" /> |
| 156 | + </DataTrigger> |
| 157 | + </Style.Triggers> |
| 158 | + </Style> |
| 159 | + </TextBox.Style> |
| 160 | + </TextBox> |
| 161 | + |
| 162 | + <Button Grid.Row="0" Grid.Column="1" Name="ButtonEdit" Content="Edit" Width="17" |
| 163 | + Click="ButtonBase_OnClick" Template="{StaticResource EditButtonTemplate}"/> |
| 164 | + |
| 165 | + <Canvas Grid.Row="1" Grid.Column="0" Name="TickLabelCanvas" /> |
| 166 | + |
| 167 | + </Grid> |
| 168 | +</UserControl> |
0 commit comments