2025-07-16 12:19

This commit is contained in:
wang-yin1
2025-07-16 12:20:02 +08:00
parent ca823a9294
commit 25d7fc3330
13 changed files with 801 additions and 305 deletions

View File

@@ -0,0 +1,25 @@
<UserControl x:Class="VisionFrame.Base.Controls.CameraBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VisionFrame.Base.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="viewport" Background="Transparent"
MouseLeftButtonDown="viewport_MouseLeftButtonDown"
MouseLeftButtonUp="viewport_MouseLeftButtonUp"
MouseRightButtonUp="viewport_MouseRightButtonUp"
MouseMove="viewport_MouseMove"
MouseLeave="viewport_MouseLeave"
MouseWheel="viewport_MouseWheel">
<Canvas ClipToBounds="True">
<Grid x:Name="imagebox">
<Image x:Name="image"/>
</Grid>
<!--<Rectangle x:Name="rect" Stroke="Red" StrokeThickness="1" Fill="Transparent"/>-->
<TextBlock x:Name="rectLabel" Foreground="Green" FontSize="12"/>
</Canvas>
<TextBlock x:Name="textblock" Foreground="Green" Text="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="15"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,258 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VisionFrame.Base.Controls
{
/// <summary>
/// 选框事件数据实体
/// </summary>
public class RectEventArgs : RoutedEventArgs
{
public Rect SelectRect { get; }
public double X { get; }
public double Y { get; }
public double Zoom { get; }
public RectEventArgs(RoutedEvent routedEvent, object source, Rect selectRect, double x, double y, double zoom)
: base(routedEvent, source)
{
SelectRect = selectRect;
X = x;
Y = y;
Zoom = zoom;
}
}
/// <summary>
/// CameraBox.xaml 的交互逻辑
/// </summary>
public partial class CameraBox : UserControl
{
/// <summary>
/// 图像源
/// </summary>
public System.Windows.Media.ImageSource ImageSource
{
get { return (System.Windows.Media.ImageSource)GetValue(ImageSourceProperty); }
set { SetValue(ImageSourceProperty, value); }
}
public static readonly DependencyProperty ImageSourceProperty =
DependencyProperty.Register("ImageSource", typeof(System.Windows.Media.ImageSource), typeof(CameraBox), new PropertyMetadata(callback));
private static void callback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is CameraBox box)
{
var source = e.NewValue as System.Windows.Media.ImageSource;
if (source != null)
{
box.image.Source = source;
}
}
}
/// <summary>
/// 鼠标是否框选图像
/// </summary>
public bool IsMouseSelect
{
get { return (bool)GetValue(IsMouseSelectProperty); }
set { SetValue(IsMouseSelectProperty, value); }
}
public static readonly DependencyProperty IsMouseSelectProperty =
DependencyProperty.Register("IsMouseSelect", typeof(bool), typeof(CameraBox), new PropertyMetadata(false));
//定义路由事件
public static readonly RoutedEvent RectChangedEvent
= EventManager.RegisterRoutedEvent("RectChanged",
RoutingStrategy.Bubble,
typeof(RoutedEventHandler),
typeof(CameraBox));
/// <summary>
/// 选框更改事件
/// </summary>
public event RoutedEventHandler RectChanged
{
add { AddHandler(RectChangedEvent, value); }
remove { RemoveHandler(RectChangedEvent, value); }
}
protected virtual void OnRectChangedEvent(RectEventArgs e)
{
RaiseEvent(e);
}
//public void ClearSelectRect()
//{
// rect.Width = 0;
// rect.Height = 0;
// Canvas.SetLeft(rect, StartPoint.X);
// Canvas.SetTop(rect, StartPoint.Y);
//}
public TransformGroup TransformGroup { get; private set; } = new TransformGroup();
private ScaleTransform scaleTransform = new ScaleTransform();//缩放
private TranslateTransform translateTransform = new TranslateTransform();//平移
private Point MousePoint = new Point(-1, -1);
private Point StartPoint = new Point(0, 0);
private Point MouseDownPoint = new Point(0, 0);//鼠标按下位置
private double scale = 1;//默认放大倍数
private int viewportWidth = 0;
private int viewportHeight = 0;
private int imageBoxWidth = 0;
private int imageBoxHeight = 0;
private bool mousePressed = false;
public double Scale { get; set; } = 1;
/// <summary>
/// 鼠标框选区域
/// </summary>
public Rect SelectRect { get; private set; }
public CameraBox()
{
InitializeComponent();
Loaded += CameraBox_Loaded;
}
private void CameraBox_Loaded(object sender, RoutedEventArgs e)
{
SetTransform();
Loaded -= CameraBox_Loaded;//只加载一次SetTransform()
}
/// <summary>
/// 根据viewport尺寸设置图像的缩放和平移
/// </summary>
private void SetTransform()
{
TransformGroup.Children.Add(scaleTransform);
TransformGroup.Children.Add(translateTransform);
imagebox.RenderTransform = TransformGroup;
viewportWidth = (int)viewport.ActualWidth;
viewportHeight = (int)viewport.ActualHeight;
imageBoxWidth = (int)imagebox.ActualWidth;
imageBoxHeight = (int)imagebox.ActualHeight;
scale = Math.Min(1.0 * viewportWidth / imageBoxWidth, 1.0 * viewportHeight / imageBoxHeight);//最初放大比
scaleTransform.ScaleX = scale;
scaleTransform.ScaleY = scale;
var translateX = (viewportWidth - imageBoxWidth * scale) / 2;
var translateY = (viewportHeight - imageBoxHeight * scale) / 2;
translateTransform.X = translateX;
translateTransform.Y = translateY;
textblock.Text = $"({Math.Round(translateX)},{Math.Round(translateY)}) Zoom:{scale}";
}
//鼠标右键弹起:还原图像
private void viewport_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
scaleTransform.ScaleX = scale;//还原最初放大比
scaleTransform.ScaleY = scale;
var translateX = (viewportWidth - imageBoxWidth * scale) / 2;
var translateY = (viewportHeight - imageBoxHeight * scale) / 2;
translateTransform.X = translateX;
translateTransform.Y = translateY;
}
//鼠标左键按下
private void viewport_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
mousePressed = true;
MouseDownPoint = e.GetPosition(viewport);
////选框初始位置
//StartPoint = e.GetPosition(viewport);
//rect.Width = 0;
//rect.Height = 0;
//Canvas.SetLeft(rect, StartPoint.X);
//Canvas.SetTop(rect, StartPoint.Y);
////选框坐标显示
//rectLabel.Text = string.Empty;
//Canvas.SetLeft(rectLabel, StartPoint.X);
//Canvas.SetTop(rectLabel, StartPoint.Y);
//viewport.CaptureMouse();
}
//鼠标移动
private void viewport_MouseMove(object sender, MouseEventArgs e)
{
Point point = e.GetPosition(viewport);
MousePoint = point;//更新鼠标位置
if (!mousePressed)
return;
if (IsMouseSelect)
{
////表示框选图像
//rect.Width = point.X - StartPoint.X < 0 ? 0 : point.X - StartPoint.X;
//rect.Height = point.Y - StartPoint.Y < 0 ? 0 : point.Y - StartPoint.Y;
//SelectRect = new Rect(StartPoint.X, StartPoint.Y, rect.Width, rect.Height);
//rectLabel.Text = $"{SelectRect}";
//Canvas.SetLeft(rectLabel, SelectRect.X + SelectRect.Width);
//Canvas.SetTop(rectLabel, StartPoint.Y);
//if (SelectRect.Width + SelectRect.Height == 0)
//{
// rectLabel.Text = string.Empty;
//}
}
else
{
//表示移动图像
translateTransform.X += point.X - MouseDownPoint.X;
translateTransform.Y += point.Y - MouseDownPoint.Y;
MouseDownPoint = point;
textblock.Text = $"({Math.Round(translateTransform.X)},{Math.Round(translateTransform.Y)}) Zoom:{scale}";
}
}
//鼠标左键弹起
private void viewport_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
mousePressed = false;
MouseDownPoint = e.GetPosition(viewport);
viewport.ReleaseMouseCapture();
if (IsMouseSelect)
{
OnRectChangedEvent(new RectEventArgs(RectChangedEvent, this, SelectRect, translateTransform.X, translateTransform.Y, scaleTransform.ScaleX));
}
}
private void viewport_MouseLeave(object sender, MouseEventArgs e)
{
MousePoint = new Point(-1, -1);
}
//放大缩小图像
private void viewport_MouseWheel(object sender, MouseWheelEventArgs e)
{
double scale = e.Delta * 0.0005;
Point point = e.GetPosition(viewport);
Point inverse = TransformGroup.Inverse.Transform(point);
if ((scaleTransform.ScaleX + scale < 0.1) || (scaleTransform.ScaleX + scale > 2))
{
return;
}
scaleTransform.ScaleX += scale;
scaleTransform.ScaleY += scale;
translateTransform.X = -1 * (inverse.X * scaleTransform.ScaleX - point.X);
translateTransform.Y = -1 * (inverse.Y * scaleTransform.ScaleY - point.Y);
textblock.Text = $"({Math.Round(translateTransform.X)},{Math.Round(translateTransform.Y)}) Zoom:{scale}";
}
}
}

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0-windows</TargetFramework> <TargetFramework>net9.0-windows</TargetFramework>

View File

@@ -7,7 +7,7 @@
<ResourceDictionary> <ResourceDictionary>
<FontFamily x:Key="Iconfont">./Assets/Fonts/#iconfont</FontFamily> <FontFamily x:Key="Iconfont">./Assets/Fonts/#iconfont</FontFamily>
<FontFamily x:Key="Iconfonts">./Assetss/Fonts/#iconfont</FontFamily>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0" x:Key="lgb"> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" x:Key="lgb">
<GradientStop Color="#bbd7ff" Offset="0"/> <GradientStop Color="#bbd7ff" Offset="0"/>
<GradientStop Color="#0FFF" Offset="1"/> <GradientStop Color="#0FFF" Offset="1"/>

View File

@@ -1,24 +1,24 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button"> <Style TargetType="Button">
<Setter Property="Width" Value="50"/> <Setter Property="Width" Value="50" />
<Setter Property="Height" Value="30"/> <Setter Property="Height" Value="30" />
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#1777FF"/> <Setter Property="Background" Value="#1777FF" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}" CornerRadius="5">
CornerRadius="5"> <Border Name="bor" Background="Transparent">
<Border Background="Transparent" Name="bor"> <ContentPresenter
<ContentPresenter VerticalAlignment="Center" Margin="10,5"
HorizontalAlignment="Center" Margin="10,5"/> HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border> </Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bor" Property="Background" Value="#1000"/> <Setter TargetName="bor" Property="Background" Value="#1000" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@@ -26,44 +26,48 @@
</Setter> </Setter>
</Style> </Style>
<Style TargetType="Button" x:Key="TitleButtonStyle"> <Style x:Key="TitleButtonStyle" TargetType="Button">
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/> <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
<Setter Property="Margin" Value="0,5"/> <Setter Property="Margin" Value="0,5" />
<Setter Property="FontSize" Value="18"/> <Setter Property="FontSize" Value="18" />
<Setter Property="FontFamily" Value="{DynamicResource Iconfont}"/> <Setter Property="FontFamily" Value="{DynamicResource Iconfont}" />
<Setter Property="Foreground" Value="#888"/> <Setter Property="Foreground" Value="#888" />
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"> <Border Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" <ContentPresenter
HorizontalAlignment="Center" Margin="10,5"/> Margin="10,5"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#1000"/> <Setter Property="Background" Value="#1000" />
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style TargetType="Button" x:Key="DeleteElementButtonStyle"> <Style x:Key="DeleteElementButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Red"/> <Setter Property="Background" Value="Red" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}" CornerRadius="20">
<Border
Name="border"
Background="Transparent"
CornerRadius="20"> CornerRadius="20">
<Border Background="Transparent" Name="border" CornerRadius="20"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border> </Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#2000"/> <Setter TargetName="border" Property="Background" Value="#2000" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@@ -71,47 +75,48 @@
</Setter> </Setter>
</Style> </Style>
<Style TargetType="Button" x:Key="ToolButtonStyle"> <Style x:Key="ToolButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="3,2"/> <Setter Property="Margin" Value="3,2" />
<Setter Property="Width" Value="24"/> <Setter Property="Width" Value="24" />
<Setter Property="FontSize" Value="14"/> <Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="{DynamicResource Iconfont}"/> <Setter Property="FontFamily" Value="{DynamicResource Iconfont}" />
<Setter Property="Foreground" Value="#888"/> <Setter Property="Foreground" Value="#888" />
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}" CornerRadius="5">
CornerRadius="5"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#4FFF"/> <Setter Property="Background" Value="#4FFF" />
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style TargetType="ToggleButton" x:Key="ElementArgsButtonStyle"> <Style x:Key="ElementArgsButtonStyle" TargetType="ToggleButton">
<Setter Property="Background" Value="#156FEE"/> <Setter Property="Background" Value="#156FEE" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToggleButton"> <ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}" CornerRadius="20"> <Border Background="{TemplateBinding Background}" CornerRadius="20">
<Border Background="Transparent" Name="border" CornerRadius="20"> <Border
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/> Name="border"
Background="Transparent"
CornerRadius="20">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border> </Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#2000"/> <Setter TargetName="border" Property="Background" Value="#2000" />
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="#2000"/> <Setter TargetName="border" Property="Background" Value="#2000" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>

View File

@@ -1,45 +1,55 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF"/> <SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC"/> <SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC" />
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060"/> <SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060" />
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false"/> <Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false"/> <Setter Property="Focusable" Value="false" />
<Setter Property="ClickMode" Value="Press"/> <Setter Property="ClickMode" Value="Press" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}"> <ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot" <Border
x:Name="templateRoot"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="#DDDDDD" BorderBrush="#DDDDDD"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3"> CornerRadius="3">
<Border x:Name="splitBorder" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" <Border
SnapsToDevicePixels="true" Margin="0" HorizontalAlignment="Right" x:Name="splitBorder"
BorderThickness="1" BorderBrush="Transparent"> Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
<Path Data="M0 0 4 4 8 0" Stroke="#CCC" StrokeThickness="1" Margin="0"
VerticalAlignment="Center" Name="path" HorizontalAlignment="Right"
Width="8" HorizontalAlignment="Center" BorderBrush="Transparent"
RenderTransformOrigin="0.5,0.5"/> BorderThickness="1"
SnapsToDevicePixels="true">
<Path
Name="path"
Width="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0 0 4 4 8 0"
RenderTransformOrigin="0.5,0.5"
Stroke="#CCC"
StrokeThickness="1" />
</Border> </Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true"> <Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="templateRoot" Value="green"/> <Setter TargetName="templateRoot" Property="BorderBrush" Value="green" />
</Trigger> </Trigger>
<Trigger Property="IsKeyboardFocused" Value="true"> <Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="templateRoot" Value="green"/> <Setter TargetName="templateRoot" Property="BorderBrush" Value="green" />
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="path" Property="RenderTransform"> <Setter TargetName="path" Property="RenderTransform">
<Setter.Value> <Setter.Value>
<RotateTransform Angle="180"/> <RotateTransform Angle="180" />
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Trigger> </Trigger>
@@ -52,48 +62,73 @@
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"> <ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true"> <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*" />
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> <ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" <Popup
x:Name="PART_Popup"
Grid.ColumnSpan="2"
Margin="1"
AllowsTransparency="true"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom"
Placement="Bottom" VerticalOffset="1"> PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
<Border x:Name="dropDownBorder" VerticalOffset="1">
BorderBrush="#DDD" <Border
BorderThickness="1" CornerRadius="5" x:Name="dropDownBorder"
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"> Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
<ScrollViewer x:Name="DropDownScrollViewer" BorderBrush="#DDD"
Background="Transparent" BorderThickness="0"> BorderThickness="1"
CornerRadius="5">
<ScrollViewer
x:Name="DropDownScrollViewer"
Background="Transparent"
BorderThickness="0">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"> <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> <Canvas
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" x:Name="canvas"
Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="opaqueRect"
Width="{Binding ActualWidth, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"
RadiusX="7" RadiusY="7"/> Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}"
RadiusX="7"
RadiusY="7" />
</Canvas> </Canvas>
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" <ItemsPresenter
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="ItemsPresenter"
Margin="3"/> Margin="3"
KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
</Popup> </Popup>
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" <ToggleButton
x:Name="toggleButton"
Grid.ColumnSpan="2"
Background="White"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Background="White" Grid.ColumnSpan="2"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboBoxToggleButton}"/> Style="{StaticResource ComboBoxToggleButton}" />
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" <ContentPresenter
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}" Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
IsHitTestVisible="false" Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" IsHitTestVisible="false"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<!--<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"> <!--<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
@@ -101,54 +136,59 @@
<Setter Property="Background" TargetName="shadow" Value="#71000000"/> <Setter Property="Background" TargetName="shadow" Value="#71000000"/>
</Trigger>--> </Trigger>-->
<Trigger Property="HasItems" Value="false"> <Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/> <Setter TargetName="dropDownBorder" Property="Height" Value="95" />
</Trigger> </Trigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/> <Condition Property="IsGrouping" Value="true" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/> <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/> <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</MultiTrigger> </MultiTrigger>
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false"> <Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/> <Setter TargetName="opaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/> <Setter TargetName="opaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
<Style TargetType="{x:Type ComboBox}"> <Style TargetType="{x:Type ComboBox}">
<Setter Property="Background" Value="White"/> <Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="#333"/> <Setter Property="Foreground" Value="#333" />
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Padding" Value="6,3,5,3"/> <Setter Property="Padding" Value="6,3,5,3" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/> <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="ScrollViewer.PanningMode" Value="Both"/> <Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/> <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}"/> <Setter Property="Template" Value="{StaticResource ComboBoxTemplate}" />
</Style> </Style>
<Style TargetType="ComboBoxItem"> <Style TargetType="ComboBoxItem">
<Setter Property="Height" Value="30"/> <Setter Property="Height" Value="30" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ComboBoxItem"> <ControlTemplate TargetType="ComboBoxItem">
<Border Background="White" BorderBrush="Transparent" BorderThickness="1" CornerRadius="3" <Border
Margin="1" Name="border"> Name="border"
<ContentPresenter VerticalAlignment="Center" Margin="3"/> Margin="1"
Background="White"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="3">
<ContentPresenter Margin="3" VerticalAlignment="Center" />
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#111F71E5"/> <Setter TargetName="border" Property="Background" Value="#111F71E5" />
<Setter TargetName="border" Property="BorderBrush" Value="#551F71E5"/> <Setter TargetName="border" Property="BorderBrush" Value="#551F71E5" />
</Trigger> </Trigger>
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<Setter TargetName="border" Property="Background" Value="#1F71E5"/> <Setter TargetName="border" Property="Background" Value="#1F71E5" />
<Setter TargetName="border" Property="BorderBrush" Value="#1F71E5"/> <Setter TargetName="border" Property="BorderBrush" Value="#1F71E5" />
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>

View File

@@ -36,7 +36,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="TabItem"> <ControlTemplate TargetType="TabItem">
<Grid Background="{TemplateBinding Background}" Height="26"> <Grid Background="{TemplateBinding Background}" Height="30" Margin="0,5,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition/> <ColumnDefinition/>
@@ -63,7 +63,8 @@
Background="#DFFF" Background="#DFFF"
BorderThickness="0" BorderThickness="0"
Foreground="#1f71e5" Foreground="#1f71e5"
Margin="0,2"> Margin="0,2"
>
<TextBox.InputBindings> <TextBox.InputBindings>
<KeyBinding Key="Return" <KeyBinding Key="Return"
Command="{Binding AcceptTitleCommand}"/> Command="{Binding AcceptTitleCommand}"/>
@@ -229,7 +230,7 @@
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" <Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true"
KeyboardNavigation.TabNavigation="Local"> KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="26"/> <RowDefinition Height="35"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -239,8 +240,11 @@
<ScrollViewer VerticalScrollBarVisibility="Disabled" <ScrollViewer VerticalScrollBarVisibility="Disabled"
HorizontalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible"
Style="{StaticResource TabScrollViewerStyle}"> Style="{StaticResource TabScrollViewerStyle}">
<TabPanel x:Name="headerPanel" Background="Transparent" <TabPanel x:Name="headerPanel" Background="Transparent"
IsItemsHost="true" Margin="2,2,2,0"
Margin="40,0,0,0"
IsItemsHost="true"
KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/> KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
</ScrollViewer> </ScrollViewer>
<ToggleButton Grid.Column="1" Name="tb_tabs" <ToggleButton Grid.Column="1" Name="tb_tabs"
@@ -248,7 +252,9 @@
Content="&#xe600;" Content="&#xe600;"
FontFamily="{DynamicResource Iconfont}"/> FontFamily="{DynamicResource Iconfont}"/>
<Border x:Name="contentPanel" Background="{TemplateBinding Background}" <Border x:Name="contentPanel"
Margin="0,2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Grid.ColumnSpan="2" KeyboardNavigation.DirectionalNavigation="Contained" Grid.ColumnSpan="2" KeyboardNavigation.DirectionalNavigation="Contained"

Binary file not shown.

View File

@@ -708,7 +708,7 @@ namespace VisionFrame.ViewModels
return; return;
Thread.Sleep(1000); //Thread.Sleep(1000);
stopwatch.Stop(); stopwatch.Stop();
node.Duration = stopwatch.ElapsedMilliseconds; node.Duration = stopwatch.ElapsedMilliseconds;

View File

@@ -35,9 +35,7 @@ namespace VisionFrame.ViewModels
public ObservableCollection<FlowTabViewModel> FlowTabList { get; set; } = public ObservableCollection<FlowTabViewModel> FlowTabList { get; set; } =
new ObservableCollection<FlowTabViewModel>() new ObservableCollection<FlowTabViewModel>()
{ {
new FlowTabViewModel(){ Title="新建流程(1)"},
new FlowTabViewModel(){ Title="新建流程(2)"},
new FlowTabViewModel(){ Title="新建流程(3)"},
}; };
public ICommand NewFlowCommand { get; set; } public ICommand NewFlowCommand { get; set; }
@@ -71,14 +69,6 @@ namespace VisionFrame.ViewModels
TargetModel="ImageCapture;ImageCapture.HalconImageNodeModel", TargetModel="ImageCapture;ImageCapture.HalconImageNodeModel",
W=150, W=150,
H=34}, H=34},
new ComponentModel{ Icon="\ue621",Name="Basler"},
new ComponentModel{ Icon="\ue621",Name="康耐视"},
new ComponentModel{ Icon="\ue621",Name="基恩士"},
new ComponentModel{ Icon="\ue621",Name="海康"},
new ComponentModel{ Icon="\ue621",Name="大华"},
new ComponentModel{ Icon="\ue621",Name="大疆/DJI"},
new ComponentModel{ Icon="\ue621",Name="Optronis"},
new ComponentModel{ Icon="\ue621",Name="大恒"},
} }
}); });
CatalogList.Add(new CatalogModel() CatalogList.Add(new CatalogModel()

View File

@@ -7,6 +7,7 @@
xmlns:extensions="clr-namespace:VisionFrame.Extensions" xmlns:extensions="clr-namespace:VisionFrame.Extensions"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:n="clr-namespace:VisionFrame.Nodes" xmlns:n="clr-namespace:VisionFrame.Nodes"
xmlns:controls="clr-namespace:VisionFrame.Base.Controls;assembly=VisionFrame.Base"
xmlns:base="clr-namespace:VisionFrame.Base.TemplateSelector;assembly=VisionFrame.Base" xmlns:base="clr-namespace:VisionFrame.Base.TemplateSelector;assembly=VisionFrame.Base"
xmlns:c="clr-namespace:VisionFrame.Base.Converter;assembly=VisionFrame.Base" xmlns:c="clr-namespace:VisionFrame.Base.Converter;assembly=VisionFrame.Base"
mc:Ignorable="d" mc:Ignorable="d"

View File

@@ -1,65 +1,85 @@
<Window x:Class="VisionFrame.Views.MainView" <Window
x:Class="VisionFrame.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VisionFrame.Views" xmlns:local="clr-namespace:VisionFrame.Views"
mc:Ignorable="d" Name="win" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowStartupLocation="CenterScreen" Name="win"
FontWeight="ExtraLight" Title="运动视觉框架"
Width="1300"
Height="750"
FontSize="12" FontSize="12"
Title="运动视觉框架" Height="750" Width="1300"> FontWeight="ExtraLight"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<WindowChrome.WindowChrome> <WindowChrome.WindowChrome>
<WindowChrome NonClientFrameEdges="None" UseAeroCaptionButtons="False"/> <WindowChrome NonClientFrameEdges="None" UseAeroCaptionButtons="False" />
</WindowChrome.WindowChrome> </WindowChrome.WindowChrome>
<Window.Background> <Window.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#DCEAFC" Offset="0"/> <GradientStop Offset="0" Color="#DCEAFC" />
<GradientStop Color="#FFFFFF" Offset="0.5"/> <GradientStop Offset="0.5" Color="#FFFFFF" />
<GradientStop Color="#DCEAFC" Offset="1"/> <GradientStop Offset="1" Color="#DCEAFC" />
</LinearGradientBrush> </LinearGradientBrush>
</Window.Background> </Window.Background>
<Window.Resources> <Window.Resources>
<ControlTemplate TargetType="RadioButton" x:Key="CatalogButtonTemp"> <ControlTemplate x:Key="CatalogButtonTemp" TargetType="RadioButton">
<Grid> <Grid>
<Border Background="Transparent" <Border
Height="40" Margin="0,2" Name="border"
Name="border"> Height="40"
<TextBlock Text="{Binding Icon}" Margin="0,2"
FontFamily="{StaticResource Iconfont}" Background="Transparent">
FontSize="22" Foreground="White" <TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center"/> FontFamily="{StaticResource Iconfont}"
FontSize="22"
Foreground="White"
Text="{Binding Icon}" />
</Border> </Border>
<Canvas Name="canvas" Visibility="Collapsed" Background="Transparent" <Canvas
Width="60"> Name="canvas"
<Polygon Points="5 0 0 4 5 8" Width="60"
Fill="#DD1f71e5" Background="Transparent"
Visibility="Collapsed">
<Polygon
Canvas.Left="50" Canvas.Left="50"
Canvas.Top="10"/> Canvas.Top="10"
<Border MaxWidth="200" Height="60" Canvas.Left="55" Fill="#DD1f71e5"
Background="#DD1f71e5" CornerRadius="5" Points="5 0 0 4 5 8" />
<Border
Canvas.Left="55"
Height="60"
MaxWidth="200"
Background="#DD1f71e5"
CornerRadius="5"
TextBlock.Foreground="White"> TextBlock.Foreground="White">
<StackPanel Margin="10,0" VerticalAlignment="Center"> <StackPanel Margin="10,0" VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" FontWeight="Bold" Margin="0,0,0,5"/> <TextBlock
<Border Height="1" Background="#3FFF"/> Margin="0,0,0,5"
<TextBlock Text="{Binding Description}" FontWeight="Bold"
Text="{Binding Name}" />
<Border Height="1" Background="#3FFF" />
<TextBlock
Margin="0,5,0,0"
Foreground="#9FFF" Foreground="#9FFF"
TextTrimming="CharacterEllipsis" Margin="0,5,0,0"/> Text="{Binding Description}"
TextTrimming="CharacterEllipsis" />
</StackPanel> </StackPanel>
</Border> </Border>
</Canvas> </Canvas>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#2FFF"/> <Setter TargetName="border" Property="Background" Value="#2FFF" />
<!--<Setter TargetName="canvas" Property="Visibility" Value="Visible"/>--> <!--<Setter TargetName="canvas" Property="Visibility" Value="Visible"/>-->
<Trigger.EnterActions> <Trigger.EnterActions>
<BeginStoryboard> <BeginStoryboard>
<Storyboard> <Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="canvas" <ObjectAnimationUsingKeyFrames Storyboard.TargetName="canvas" Storyboard.TargetProperty="Visibility">
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value> <DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility> <Visibility>Collapsed</Visibility>
@@ -78,8 +98,7 @@
<Trigger.ExitActions> <Trigger.ExitActions>
<BeginStoryboard> <BeginStoryboard>
<Storyboard> <Storyboard>
<ObjectAnimationUsingKeyFrames <ObjectAnimationUsingKeyFrames Storyboard.TargetName="canvas" Storyboard.TargetProperty="Visibility">
Storyboard.TargetName="canvas" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value> <DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility> <Visibility>Collapsed</Visibility>
@@ -91,149 +110,253 @@
</Trigger.ExitActions> </Trigger.ExitActions>
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="#6FFF"/> <Setter TargetName="border" Property="Background" Value="#6FFF" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
<Style x:Key="ExpandedButtonStyle" TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Name="border" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#1000" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Storyboard x:Key="sb_menu_retract">
<DoubleAnimation
Storyboard.TargetName="grid_sub_menu"
Storyboard.TargetProperty="Width"
To="0"
Duration="0:0:0.3" />
</Storyboard>
<Storyboard x:Key="sb_menu_expand">
<DoubleAnimation
Storyboard.TargetName="grid_sub_menu"
Storyboard.TargetProperty="Width"
Duration="0:0:0.3" />
</Storyboard>
</Window.Resources> </Window.Resources>
<Grid ClipToBounds="True"> <Grid ClipToBounds="True">
<Ellipse Width="500" Height="500" Fill="{StaticResource lgb}" <Ellipse
VerticalAlignment="Top" HorizontalAlignment="Left" Width="500"
Margin="200,-80,0,0" Opacity="0.6"> Height="500"
</Ellipse> Margin="200,-80,0,0"
<Ellipse Width="400" Height="400" Fill="{StaticResource lgb}" HorizontalAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="-80,-250,0,0"> Fill="{StaticResource lgb}"
</Ellipse> Opacity="0.6" />
<Ellipse
Width="400"
Height="400"
Margin="-80,-250,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Fill="{StaticResource lgb}" />
<!--窗口内容部分--> <!-- 窗口内容部分 -->
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50"/> <RowDefinition Height="50" />
<RowDefinition/> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!--Logo+Title--> <!-- Logo+Title -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" <StackPanel
VerticalAlignment="Center"> HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<!--<Image Source="../Assets/Images/Logo_64.png" Width="30" <!--<Image Source="../Assets/Images/Logo_64.png" Width="30"
Effect="{StaticResource dse}" Effect="{StaticResource dse}"
Margin="10,0"/>--> Margin="10,0"/>-->
<TextBlock FontSize="14" FontFamily="YouYuan" <TextBlock
Foreground="#555" Effect="{StaticResource dse}" VerticalAlignment="Center"
VerticalAlignment="Center"> Effect="{StaticResource dse}"
<Run Text=" "/> FontFamily="YouYuan"
<Run Text=" "/> FontSize="14"
<Run Text="运动视觉流程控制系统"/> Foreground="#555">
<Run Text="v1.0" FontFamily="Microsoft YaHei" FontSize="9"/> <Run Text=" " />
<Run Text=" " />
<Run Text="运动视觉流程控制系统" />
<Run
FontFamily="Microsoft YaHei"
FontSize="9"
Text="v1.0" />
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
<!--Title部分控制按钮--> <!-- Title部分控制按钮 -->
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right"> <StackPanel
<Button Content="&#xe617;" Style="{StaticResource TitleButtonStyle}" HorizontalAlignment="Right"
Command="{Binding NewFlowCommand}"/> VerticalAlignment="Top"
<Button Content="&#xeabe;" Style="{StaticResource TitleButtonStyle}" Orientation="Horizontal">
Command="{Binding OpenFlowCommand}"/>
<Button Content="&#xe60f;" Style="{StaticResource TitleButtonStyle}" <Button
Command="{Binding SaveFlowCommand}"/> Command="{Binding NewFlowCommand}"
<Button Content="&#xe9d4;" Style="{StaticResource TitleButtonStyle}"/> Content="&#xe617;"
<Border Height="16" Width="1" Background="#CCC" Margin="5,0" VerticalAlignment="Center"/> Style="{StaticResource TitleButtonStyle}" />
<Button Content="&#xea6e;" Style="{StaticResource TitleButtonStyle}"/> <Button
<Button Content="&#xea76;" Style="{StaticResource TitleButtonStyle}"/> Command="{Binding OpenFlowCommand}"
<Border Height="16" Width="1" Background="#CCC" Margin="5,0"/> Content="&#xeabe;"
<Button Content="&#xe669;" Style="{StaticResource TitleButtonStyle}"/> Style="{StaticResource TitleButtonStyle}" />
<Button Content="&#xe618;" Style="{StaticResource TitleButtonStyle}"/> <Button
<Border Height="16" Width="1" Background="#CCC" Margin="5,0"/> Command="{Binding SaveFlowCommand}"
<TextBlock Text="&#xe80a;" FontFamily="{StaticResource Iconfont}" VerticalAlignment="Center" Content="&#xe60f;"
FontSize="18" Margin="3,0" Foreground=" #1f71e5"/> Style="{StaticResource TitleButtonStyle}" />
<TextBlock Text="&lt;未登录&gt;" VerticalAlignment="Center" Margin="3,0"/> <Button Content="&#xe9d4;" Style="{StaticResource TitleButtonStyle}" />
<Border Height="16" Width="1" Background="#CCC" Margin="5,0"/> <Border
<Button Content="&#xe65a;" Style="{StaticResource TitleButtonStyle}" Width="1"
FontSize="14" Margin="0" Height="16"
Command="{Binding MinimizeCommand}"/> Margin="5,0"
<Button Content="&#xe692;" Style="{StaticResource TitleButtonStyle}" VerticalAlignment="Center"
FontSize="14" Margin="0" Background="#CCC" />
Command="{Binding MaximizeCommand}"/> <Button Content="&#xea6e;" Style="{StaticResource TitleButtonStyle}" />
<Button Content="&#xe660;" Style="{StaticResource TitleButtonStyle}" <Button Content="&#xea76;" Style="{StaticResource TitleButtonStyle}" />
FontSize="14" Margin="0,0,5,0" <Border
Click="Button_Click"/> Width="1"
Height="16"
Margin="5,0"
Background="#CCC" />
<Button Content="&#xe669;" Style="{StaticResource TitleButtonStyle}" />
<Button Content="&#xe618;" Style="{StaticResource TitleButtonStyle}" />
<Border
Width="1"
Height="16"
Margin="5,0"
Background="#CCC" />
<TextBlock
Margin="3,0"
VerticalAlignment="Center"
FontFamily="{StaticResource Iconfont}"
FontSize="18"
Foreground=" #1f71e5"
Text="&#xe80a;" />
<TextBlock
Margin="3,0"
VerticalAlignment="Center"
Text="&lt;未登录&gt;" />
<Border
Width="1"
Height="16"
Margin="5,0"
Background="#CCC" />
<Button
Margin="0"
Command="{Binding MinimizeCommand}"
Content="&#xe65a;"
FontSize="14"
Style="{StaticResource TitleButtonStyle}" />
<Button
Margin="0"
Command="{Binding MaximizeCommand}"
Content="&#xe692;"
FontSize="14"
Style="{StaticResource TitleButtonStyle}" />
<Button
Margin="0,0,5,0"
Click="Button_Click"
Content="&#xe660;"
FontSize="14"
Style="{StaticResource TitleButtonStyle}" />
</StackPanel> </StackPanel>
<!--流程相关交互--> <!-- 流程相关交互 -->
<Grid Grid.Row="1" Margin="10,0,10,10"> <Grid Grid.Row="1" Margin="10,0,10,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="45"/> <ColumnDefinition Width="55" />
<ColumnDefinition Width="150"/> <ColumnDefinition Width="auto" />
<ColumnDefinition/> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Background="#1f71e5" CornerRadius="10,0,0,10"/> <Border Background="#1f71e5" CornerRadius="10,0,0,10" />
<Border Background="#8FFF" Grid.Column="1"/> <Border Grid.Column="1" Background="#8FFF" />
<!--组件类别--> <!-- 组件类别 -->
<ItemsControl ItemsSource="{Binding CatalogList}" <ItemsControl
Margin="0,8" Margin="0,8"
Panel.ZIndex="10"> Panel.ZIndex="10"
ItemsSource="{Binding CatalogList}">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<RadioButton GroupName="A" <RadioButton
Command="{Binding DataContext.CatalogItemCommand, RelativeSource={RelativeSource AncestorType=Window}}"
CommandParameter="{Binding}"
GroupName="A"
IsChecked="{Binding IsSelected}" IsChecked="{Binding IsSelected}"
Template="{StaticResource CatalogButtonTemp}" Template="{StaticResource CatalogButtonTemp}" />
Command="{Binding DataContext.CatalogItemCommand,RelativeSource={RelativeSource AncestorType=Window}}"
CommandParameter="{Binding}">
</RadioButton>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<!--组件列表--> <!-- 组件列表 -->
<Grid Grid.Column="1"> <Grid
Name="grid_sub_menu"
Grid.Column="1"
Width="150">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"/> <RowDefinition Height="30" />
<RowDefinition/> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Height="1" Background="#1000" VerticalAlignment="Bottom"/> <Border
Height="1"
VerticalAlignment="Bottom"
Background="#1000" />
<TextBlock Text="{Binding CurrentCatalog.Name}" <TextBlock
VerticalAlignment="Center" Margin="5,0" Margin="5,0"
FontWeight="Bold" Foreground="#666"/> VerticalAlignment="Center"
FontWeight="Bold"
Foreground="#666"
Text="{Binding CurrentCatalog.Name}" />
<ItemsControl ItemsSource="{Binding CurrentCatalog.Components}" <ItemsControl
Grid.Row="1" VerticalAlignment="Top"> Grid.Row="1"
VerticalAlignment="Top"
ItemsSource="{Binding CurrentCatalog.Components}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<UniformGrid Columns="2"/> <UniformGrid Columns="2" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border Background="Transparent" <Border
Width="55" VerticalAlignment="Center" Name="border"
HorizontalAlignment="Center" Width="55"
CornerRadius="5"
Margin="0,5" Margin="0,5"
Name="border"> HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
CornerRadius="5">
<Border.InputBindings> <Border.InputBindings>
<MouseBinding MouseAction="LeftClick" <MouseBinding
Command="{Binding DataContext.ComponentItemCommand,ElementName=win}" Command="{Binding DataContext.ComponentItemCommand, ElementName=win}"
CommandParameter="{Binding ElementName=border}"/> CommandParameter="{Binding ElementName=border}"
MouseAction="LeftClick" />
</Border.InputBindings> </Border.InputBindings>
<StackPanel Margin="0,5"> <StackPanel Margin="0,5">
<TextBlock Text="{Binding Icon}" <TextBlock
HorizontalAlignment="Center"
FontFamily="{StaticResource Iconfont}" FontFamily="{StaticResource Iconfont}"
FontSize="30" FontSize="30"
Foreground="#771f71e5" Foreground="#771f71e5"
HorizontalAlignment="Center"/> Text="{Binding Icon}" />
<TextBlock Text="{Binding Name}" <TextBlock
FontSize="10"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Foreground="#C000"/> FontSize="10"
Foreground="#C000"
Text="{Binding Name}" />
</StackPanel> </StackPanel>
</Border> </Border>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#1000"/> <Setter TargetName="border" Property="Background" Value="#1000" />
</Trigger> </Trigger>
</DataTemplate.Triggers> </DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
@@ -241,25 +364,69 @@
</ItemsControl> </ItemsControl>
</Grid> </Grid>
<!--流程页-->
<TabControl Style="{DynamicResource TabControlStyle}" Grid.Column="2"
Margin="3,0,0,0" BorderThickness="0,1,0,0" <!-- 流程页 -->
BorderBrush="#1f71e5" <TabControl
Grid.Column="2"
Margin="3,0,0,0"
Background="Transparent" Background="Transparent"
BorderBrush="#1f71e5"
BorderThickness="0,1,0,0"
ItemsSource="{Binding FlowTabList}" ItemsSource="{Binding FlowTabList}"
SelectedIndex="0"> SelectedIndex="0"
Style="{DynamicResource TabControlStyle}">
<TabControl.ItemContainerStyle> <TabControl.ItemContainerStyle>
<Style TargetType="TabItem" BasedOn="{StaticResource FlowTabStyle}"> <Style BasedOn="{StaticResource FlowTabStyle}" TargetType="TabItem">
<Setter Property="Header" Value="{Binding Title}"/> <Setter Property="Header" Value="{Binding Title}" />
<Setter Property="IsSelected" Value="{Binding IsCurrent}"/> <Setter Property="IsSelected" Value="{Binding IsCurrent}" />
</Style> </Style>
</TabControl.ItemContainerStyle> </TabControl.ItemContainerStyle>
<TabControl.ContentTemplate> <TabControl.ContentTemplate>
<DataTemplate> <DataTemplate>
<local:FlowTabView/> <local:FlowTabView />
</DataTemplate> </DataTemplate>
</TabControl.ContentTemplate> </TabControl.ContentTemplate>
</TabControl> </TabControl>
<ToggleButton
Name="tb_menu_switch"
Grid.Column="2"
Width="35"
Height="35"
Margin="5,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
IsChecked="False"
IsThreeState="False"
Style="{StaticResource ExpandedButtonStyle}"
ToolTip="展开/收缩菜单"
WindowChrome.IsHitTestVisibleInChrome="True">
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource sb_menu_retract}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource sb_menu_expand}" />
</EventTrigger>
</ToggleButton.Triggers>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{StaticResource Iconfonts}"
FontSize="16"
Foreground="Orange"
RenderTransformOrigin="0.5,0.5"
Text="&#xe67d;">
<TextBlock.RenderTransform>
<RotateTransform Angle="90" />
</TextBlock.RenderTransform>
</TextBlock>
</ToggleButton>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -14,6 +14,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Assetss\Fonts\iconfont.ttf" />
<None Remove="Assets\Fonts\iconfont.ttf" /> <None Remove="Assets\Fonts\iconfont.ttf" />
<None Remove="Assets\Images\Logo_64.png" /> <None Remove="Assets\Images\Logo_64.png" />
</ItemGroup> </ItemGroup>
@@ -29,6 +30,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Assetss\Fonts\iconfont.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Assets\Fonts\iconfont.ttf" /> <Resource Include="Assets\Fonts\iconfont.ttf" />
<Resource Include="Assets\Images\Logo_64.png" /> <Resource Include="Assets\Images\Logo_64.png" />
</ItemGroup> </ItemGroup>