新增实时按钮功能
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace XplorePlane.Controls
|
||||
{
|
||||
public class AnimatedSwitch : ToggleButton
|
||||
{
|
||||
static AnimatedSwitch()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(
|
||||
typeof(AnimatedSwitch),
|
||||
new FrameworkPropertyMetadata(typeof(AnimatedSwitch)));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OnBrushProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(OnBrush),
|
||||
typeof(Brush),
|
||||
typeof(AnimatedSwitch),
|
||||
new PropertyMetadata(new SolidColorBrush(Color.FromRgb(45, 204, 112))));
|
||||
|
||||
public static readonly DependencyProperty OffBrushProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(OffBrush),
|
||||
typeof(Brush),
|
||||
typeof(AnimatedSwitch),
|
||||
new PropertyMetadata(new SolidColorBrush(Color.FromRgb(205, 212, 218))));
|
||||
|
||||
public static readonly DependencyProperty ThumbBrushProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(ThumbBrush),
|
||||
typeof(Brush),
|
||||
typeof(AnimatedSwitch),
|
||||
new PropertyMetadata(Brushes.White));
|
||||
|
||||
public static readonly DependencyProperty SwitchWidthProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(SwitchWidth),
|
||||
typeof(double),
|
||||
typeof(AnimatedSwitch),
|
||||
new PropertyMetadata(44d));
|
||||
|
||||
public static readonly DependencyProperty SwitchHeightProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(SwitchHeight),
|
||||
typeof(double),
|
||||
typeof(AnimatedSwitch),
|
||||
new PropertyMetadata(24d));
|
||||
|
||||
public Brush OnBrush
|
||||
{
|
||||
get => (Brush)GetValue(OnBrushProperty);
|
||||
set => SetValue(OnBrushProperty, value);
|
||||
}
|
||||
|
||||
public Brush OffBrush
|
||||
{
|
||||
get => (Brush)GetValue(OffBrushProperty);
|
||||
set => SetValue(OffBrushProperty, value);
|
||||
}
|
||||
|
||||
public Brush ThumbBrush
|
||||
{
|
||||
get => (Brush)GetValue(ThumbBrushProperty);
|
||||
set => SetValue(ThumbBrushProperty, value);
|
||||
}
|
||||
|
||||
public double SwitchWidth
|
||||
{
|
||||
get => (double)GetValue(SwitchWidthProperty);
|
||||
set => SetValue(SwitchWidthProperty, value);
|
||||
}
|
||||
|
||||
public double SwitchHeight
|
||||
{
|
||||
get => (double)GetValue(SwitchHeightProperty);
|
||||
set => SetValue(SwitchHeightProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
{
|
||||
base.OnPreviewMouseLeftButtonDown(e);
|
||||
return;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
Focus();
|
||||
OnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None,
|
||||
ResourceDictionaryLocation.SourceAssembly)]
|
||||
[assembly: InternalsVisibleTo("XplorePlane.Tests")]
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:XplorePlane.Controls">
|
||||
|
||||
<Style TargetType="{x:Type controls:AnimatedSwitch}">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="ClickMode" Value="Press" />
|
||||
<Setter Property="IsThreeState" Value="False" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:AnimatedSwitch}">
|
||||
<Grid
|
||||
Width="{TemplateBinding SwitchWidth}"
|
||||
Height="{TemplateBinding SwitchHeight}"
|
||||
Background="Transparent"
|
||||
SnapsToDevicePixels="True">
|
||||
<Border
|
||||
x:Name="Track"
|
||||
Background="#D5DCE3"
|
||||
BorderBrush="#C9D1D8"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12" />
|
||||
|
||||
<Border
|
||||
x:Name="Thumb"
|
||||
Width="18"
|
||||
Height="18"
|
||||
Margin="3"
|
||||
HorizontalAlignment="Left"
|
||||
Background="{TemplateBinding ThumbBrush}"
|
||||
CornerRadius="9">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="10"
|
||||
Direction="270"
|
||||
Opacity="0.2"
|
||||
ShadowDepth="1" />
|
||||
</Border.Effect>
|
||||
<Border.RenderTransform>
|
||||
<TranslateTransform x:Name="ThumbTranslate" X="0" />
|
||||
</Border.RenderTransform>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="ThumbTranslate"
|
||||
Storyboard.TargetProperty="X"
|
||||
To="20"
|
||||
Duration="0:0:0.18">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<CubicEase EasingMode="EaseInOut" />
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
<ColorAnimation
|
||||
Storyboard.TargetName="Track"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||||
To="#2DCC70"
|
||||
Duration="0:0:0.18">
|
||||
<ColorAnimation.EasingFunction>
|
||||
<CubicEase EasingMode="EaseInOut" />
|
||||
</ColorAnimation.EasingFunction>
|
||||
</ColorAnimation>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsChecked" Value="False">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="ThumbTranslate"
|
||||
Storyboard.TargetProperty="X"
|
||||
To="0"
|
||||
Duration="0:0:0.18">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<CubicEase EasingMode="EaseInOut" />
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
<ColorAnimation
|
||||
Storyboard.TargetName="Track"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
|
||||
To="#D5DCE3"
|
||||
Duration="0:0:0.18">
|
||||
<ColorAnimation.EasingFunction>
|
||||
<CubicEase EasingMode="EaseInOut" />
|
||||
</ColorAnimation.EasingFunction>
|
||||
</ColorAnimation>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="Track" Property="Opacity" Value="0.55" />
|
||||
<Setter TargetName="Thumb" Property="Opacity" Value="0.8" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Thumb" Property="Effect">
|
||||
<Setter.Value>
|
||||
<DropShadowEffect
|
||||
BlurRadius="12"
|
||||
Direction="270"
|
||||
Opacity="0.24"
|
||||
ShadowDepth="1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:XplorePlane.Controls"
|
||||
xmlns:spreadsheet="clr-namespace:Telerik.Windows.Controls.Spreadsheet;assembly=Telerik.Windows.Controls.Spreadsheet"
|
||||
xmlns:spreadsheetControls="clr-namespace:Telerik.Windows.Controls.Spreadsheet.Controls;assembly=Telerik.Windows.Controls.Spreadsheet"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
@@ -117,13 +118,20 @@
|
||||
SmallImage="/Assets/Icons/stop.png"
|
||||
Text="停止" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<telerik:RadRibbonToggleButton
|
||||
telerik:ScreenTip.Description="控制主界面实时图像是否随探测器新帧刷新"
|
||||
telerik:ScreenTip.Title="主界面实时"
|
||||
IsChecked="{Binding IsMainViewportRealtimeEnabled, Mode=TwoWay}"
|
||||
Size="Medium"
|
||||
SmallImage="/Assets/Icons/detector2.png"
|
||||
<StackPanel Width="52">
|
||||
<controls:AnimatedSwitch
|
||||
Width="44"
|
||||
Height="24"
|
||||
Margin="4,10,4,4"
|
||||
HorizontalAlignment="Center"
|
||||
ToolTip="主界面实时"
|
||||
IsChecked="True"
|
||||
SwitchWidth="44"
|
||||
SwitchHeight="24" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
FontSize="11"
|
||||
Text="实时" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
@@ -318,7 +326,7 @@
|
||||
SmallImage="/Assets/Icons/spiral.png" />
|
||||
</telerik:RadRibbonGroup>
|
||||
</telerik:RadRibbonTab>
|
||||
<telerik:RadRibbonTab Header="硬件">
|
||||
<telerik:RadRibbonTab Header="设置">
|
||||
<telerik:RadRibbonGroup
|
||||
telerik:ScreenTip.Description="Show the Alignment tab of the Format Cells dialog box."
|
||||
telerik:ScreenTip.Title="Format Cells: Alignment"
|
||||
@@ -393,29 +401,7 @@
|
||||
Text="PLC 地址" />
|
||||
</StackPanel>
|
||||
</telerik:RadRibbonGroup>
|
||||
</telerik:RadRibbonTab>
|
||||
<telerik:RadRibbonTab Header="关于">
|
||||
<telerik:RadRibbonGroup Header="关于">
|
||||
<telerik:RadRibbonGroup.Variants>
|
||||
<telerik:GroupVariant Priority="0" Variant="Large" />
|
||||
</telerik:RadRibbonGroup.Variants>
|
||||
<telerik:RadRibbonButton
|
||||
Size="Large"
|
||||
SmallImage="/Assets/Icons/tools.png"
|
||||
Command="{Binding OpenLibraryVersionsCommand}"
|
||||
Text="关于 XplorePlane" />
|
||||
</telerik:RadRibbonGroup>
|
||||
<telerik:RadRibbonGroup Header="帮助">
|
||||
<telerik:RadRibbonGroup.Variants>
|
||||
<telerik:GroupVariant Priority="0" Variant="Large" />
|
||||
</telerik:RadRibbonGroup.Variants>
|
||||
<telerik:RadRibbonButton
|
||||
Size="Large"
|
||||
SmallImage="/Assets/Icons/message.png"
|
||||
Command="{Binding OpenUserManualCommand}"
|
||||
Text="帮助文档" />
|
||||
</telerik:RadRibbonGroup>
|
||||
<telerik:RadRibbonGroup Header="设置">
|
||||
<telerik:RadRibbonGroup Header="多语言">
|
||||
<telerik:RadRibbonGroup.Variants>
|
||||
<telerik:GroupVariant Priority="0" Variant="Large" />
|
||||
</telerik:RadRibbonGroup.Variants>
|
||||
@@ -435,6 +421,27 @@
|
||||
Text="查看日志" />
|
||||
</telerik:RadRibbonGroup>
|
||||
</telerik:RadRibbonTab>
|
||||
<telerik:RadRibbonTab Header="关于">
|
||||
<telerik:RadRibbonGroup Header="关于">
|
||||
<telerik:RadRibbonGroup.Variants>
|
||||
<telerik:GroupVariant Priority="0" Variant="Large" />
|
||||
</telerik:RadRibbonGroup.Variants>
|
||||
|
||||
|
||||
<telerik:RadRibbonButton
|
||||
Size="Large"
|
||||
SmallImage="/Assets/Icons/message.png"
|
||||
Command="{Binding OpenUserManualCommand}"
|
||||
Text="帮助文档" />
|
||||
<telerik:RadRibbonButton
|
||||
Size="Large"
|
||||
SmallImage="/Assets/Icons/tools.png"
|
||||
Command="{Binding OpenLibraryVersionsCommand}"
|
||||
Text="关于" />
|
||||
</telerik:RadRibbonGroup>
|
||||
|
||||
|
||||
</telerik:RadRibbonTab>
|
||||
|
||||
<telerik:RadRibbonView.ContextualGroups>
|
||||
<telerik:RadRibbonContextualGroup
|
||||
|
||||
@@ -32,12 +32,6 @@
|
||||
Background="White"
|
||||
ImageSource="{Binding ImageSource}" />
|
||||
|
||||
<Border Grid.Row="2" Height="24" Padding="8,0" Background="#1E1E1E">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="11"
|
||||
Foreground="#F2F2F2"
|
||||
Text="{Binding ImageInfo}" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user