Przeglądaj źródła

增加矩阵 圆形

样式分支
fyf 2 lat temu
rodzic
commit
4b602cbb09
6 zmienionych plików z 302 dodań i 5 usunięć
  1. +20
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheEllipse.xaml
  2. +122
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheEllipse.xaml.cs
  3. +20
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRectangle.xaml
  4. +123
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRectangle.xaml.cs
  5. +7
    -5
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  6. +10
    -0
      BeDesignerSCADA/Themes/Styles.xaml

+ 20
- 0
BPASmartClient.SCADAControl/CustomerControls/TheEllipse.xaml Wyświetl plik

@@ -0,0 +1,20 @@
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheEllipse"
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:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
x:Name="root"
Foreground="#FF00EDFF"
BorderBrush="Transparent"
BorderThickness="4"
d:DesignHeight="450" d:DesignWidth="800">
<Ellipse Tag="Ellipse"
Fill="{Binding ElementName=root,Path=BJColor,Mode=TwoWay}"
Stroke="{Binding ElementName=root,Path=Foreground}"
StrokeThickness="{Binding ElementName=root,Path=BorderThickness}"
>
</Ellipse>
</UserControl>

+ 122
- 0
BPASmartClient.SCADAControl/CustomerControls/TheEllipse.xaml.cs Wyświetl plik

@@ -0,0 +1,122 @@
using BPASmartClient.Compiler;
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 BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheEllipse.xaml 的交互逻辑
/// </summary>
public partial class TheEllipse : UserControl, IExecutable
{
Ellipse LeftTog = null;
public TheEllipse()
{
InitializeComponent();
this.Loaded += TheEllipse_Loaded; ; ;
this.SizeChanged += TheEllipse_SizeChanged; ; ;
}

private void TheEllipse_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (LeftTog == null)
{
foreach (Ellipse tb in FindVisualChildren<Ellipse>(this))
{
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "Ellipse") LeftTog = tb;
}
}
}
}

public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}

foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}

private void TheEllipse_Loaded(object sender, RoutedEventArgs e)
{
if (this.ActualWidth <= 20)
{
Width = 80;
Height = 80;
}
}
public bool IsCheckedColor
{
get { return (bool)GetValue(IsCheckedProperty); }
set { SetValue(IsCheckedProperty, value); }
}
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(bool), typeof(TheEllipse), new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged)));
public Brush BJColor
{
get { return (Brush)GetValue(BJColorProperty); }
set { SetValue(BJColorProperty, value); }
}
public static readonly DependencyProperty BJColorProperty =
DependencyProperty.Register("BJColor", typeof(Brush), typeof(TheEllipse), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as TheEllipse)?.Refresh();
}
private void Refresh()
{
//if (LeftTog != null)
//{
// LeftTog.Fill = IsCheckedColor ? new SolidColorBrush(Colors.Transparent) : this.Foreground;
//}
}
public event EventHandler PropertyChange; //声明一个事件
public string ControlType => "控件";
private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
}
}
}
// <summary>
/// 运行事件
/// </summary>
public void Register()
{

}
}
}

+ 20
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRectangle.xaml Wyświetl plik

@@ -0,0 +1,20 @@
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheRectangle"
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:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
x:Name="root"
Foreground="#FF00EDFF"
BorderBrush="Transparent"
BorderThickness="4"
Tag="10"
d:DesignHeight="450" d:DesignWidth="800">
<Border Tag="border"
Background="{Binding ElementName=root,Path=BJColor,Mode=TwoWay}"
BorderBrush="{Binding ElementName=root,Path=Foreground}"
BorderThickness="{Binding ElementName=root,Path=BorderThickness}"
CornerRadius="{Binding ElementName=root,Path=Tag}"
/>
</UserControl>

+ 123
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRectangle.xaml.cs Wyświetl plik

@@ -0,0 +1,123 @@
using BPASmartClient.Compiler;
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 BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheRectangle.xaml 的交互逻辑
/// </summary>
public partial class TheRectangle : UserControl, IExecutable
{
Border LeftTog = null;

public TheRectangle()
{
InitializeComponent();
this.Loaded += TheRectangle_Loaded; ;
this.SizeChanged += TheRectangle_SizeChanged; ;
}

private void TheRectangle_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (LeftTog == null)
{
foreach (Border tb in FindVisualChildren<Border>(this))
{
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "border") LeftTog = tb;
}
}
}
}
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}

foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}

private void TheRectangle_Loaded(object sender, RoutedEventArgs e)
{
if (this.ActualWidth <= 20)
{
Width = 80;
Height = 80;
}
}
public bool IsCheckedColor
{
get { return (bool)GetValue(IsCheckedProperty); }
set { SetValue(IsCheckedProperty, value); }
}
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(bool), typeof(TheRectangle), new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged)));
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as TheRectangle)?.Refresh();
}
private void Refresh()
{
if (LeftTog != null)
{
LeftTog.Background = IsCheckedColor ? new SolidColorBrush(Colors.Transparent) : this.Foreground;
}
}

public Brush BJColor
{
get { return (Brush)GetValue(BJColorProperty); }
set { SetValue(BJColorProperty, value); }
}
public static readonly DependencyProperty BJColorProperty =
DependencyProperty.Register("BJColor", typeof(Brush), typeof(TheRectangle), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
public event EventHandler PropertyChange; //声明一个事件
public string ControlType => "控件";
private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
}
}
}
// <summary>
/// 运行事件
/// </summary>
public void Register()
{

}
}
}

+ 7
- 5
BeDesignerSCADA/Controls/MainCanvasPanel.xaml Wyświetl plik

@@ -225,9 +225,10 @@
<mypro:PropertyDefinition DisplayName="物料描述" Category="基本属性" DisplayOrder="2" Name="WLText" Description="物料描述"/>
<mypro:PropertyDefinition DisplayName="物料标题" Category="基本属性" DisplayOrder="2" Name="WLTitle" Description="物料标题"/>
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="2" Name="Title" Description="标题"/>
<mypro:PropertyDefinition DisplayName="运行状态" Category="基本属性" DisplayOrder="2" Name="Direction" Description="Direction"/>
<mypro:PropertyDefinition DisplayName="运行状态" Category="基本属性" DisplayOrder="2" Name="Direction" Description="Direction"/>
<mypro:PropertyDefinition DisplayName="Tag" Category="基本属性" DisplayOrder="2" Name="Tag" Description="Tag"/>


<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="MaxValue" Description="MaxValue"/>
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="MinValue" Description="MinValue"/>
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="Maximum" Description="Maximum"/>
@@ -265,10 +266,9 @@
<mypro:PropertyDefinition DisplayName="启动测试" Category="基本属性" DisplayOrder="9" Name="TestData"/>
<mypro:PropertyDefinition DisplayName="气缸左执行" Category="基本属性" DisplayOrder="10" Name="LeftTogIsChecked"/>
<mypro:PropertyDefinition DisplayName="气缸右执行" Category="基本属性" DisplayOrder="10" Name="RightTogIsChecked"/>
<mypro:PropertyDefinition DisplayName="背景透明" Category="基本属性" DisplayOrder="10" Name="IsCheckedColor"/>

<mypro:PropertyDefinition DisplayName="数据来源类型" Category="数据绑定模块" DisplayOrder="0" Name="DataSouceType"/>

<mypro:PropertyDefinition DisplayName="数据来源类型" Category="数据绑定模块" DisplayOrder="0" Name="DataSouceType"/>
<mypro:PropertyDefinition DisplayName="设备名称" Category="数据绑定模块" DisplayOrder="0" Name="DeviceName"/>
<mypro:PropertyDefinition DisplayName="接口类型" Category="数据绑定模块" DisplayOrder="1" Name="InterfaceMode"/>
@@ -292,6 +292,8 @@

<mypro:PropertyDefinition DisplayName="前景色" Category="颜色设置" Name="Foreground"/>
<mypro:PropertyDefinition DisplayName="背景色" Category="颜色设置" Name="Background"/>
<mypro:PropertyDefinition DisplayName="填充颜色" Category="颜色设置" Name="BJColor"/>

<mypro:PropertyDefinition DisplayName="边框色" Category="颜色设置" Name="BorderBrush"/>
<mypro:PropertyDefinition DisplayName="填充" Category="基本属性" DisplayOrder="5" Name="WaveFill"/>
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="WaveThickness"/>
@@ -312,7 +314,7 @@
</mypro:PropertyGrid.PropertyDefinitions>

<mypro:PropertyGrid.EditorDefinitions>
<mypro:EditorTemplateDefinition TargetProperties="Foreground,Background,BorderBrush,WaveFill,WaveStroke,Fill,Stroke">
<mypro:EditorTemplateDefinition TargetProperties="Foreground,Background,BorderBrush,WaveFill,WaveStroke,Fill,Stroke,BJColor">
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<mypro:ColorPicker SelectedColor="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={x:Static s:ColorToStringConverter.Instance}}" />


+ 10
- 0
BeDesignerSCADA/Themes/Styles.xaml Wyświetl plik

@@ -361,6 +361,16 @@
<Setter TargetName="txt" Property="Text" Value="气缸控件" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheRectangle">
<Setter TargetName="icon" Property="Kind" Value="AlphaGCircleOutline" />
<Setter TargetName="txt" Property="Text" Value="矩形" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheEllipse">
<Setter TargetName="icon" Property="Kind" Value="AlphaGCircleOutline" />
<Setter TargetName="txt" Property="Text" Value="圆形" />
</DataTrigger>

</DataTemplate.Triggers>
</DataTemplate>



Ładowanie…
Anuluj
Zapisz