添加middleware
This commit is contained in:
23
middleware/zdhsys/Control/ClearDevice.xaml
Normal file
23
middleware/zdhsys/Control/ClearDevice.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="zdhsys.Control.ClearDevice"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="100">
|
||||
<Grid>
|
||||
<Border x:Name="bd" CornerRadius="10" Margin="3" Background="White" BorderBrush="#4E89FF" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="lbName" Content="清洗设备" Style="{StaticResource CommonStyleBold}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<Image x:Name="img" Grid.Row="1" Height="40" Width="40"/>
|
||||
<Label x:Name="lbStatus" Grid.Row="2" Content="自检中..." FontSize="12" Foreground="#4E89FF" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
36
middleware/zdhsys/Control/ClearDevice.xaml.cs
Normal file
36
middleware/zdhsys/Control/ClearDevice.xaml.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// ClearDevice.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ClearDevice : UserControl
|
||||
{
|
||||
public ClearDevice()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void SetUI(string name,string status,string path)
|
||||
{
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
lbName.Content = name;
|
||||
lbStatus.Content = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
middleware/zdhsys/Control/ColorButton.xaml
Normal file
13
middleware/zdhsys/Control/ColorButton.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="zdhsys.Control.ColorButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
d:DesignHeight="20" d:DesignWidth="20">
|
||||
<Grid x:Name="gd" Background="Green">
|
||||
<Label x:Name="lb_gou" Content="√" Visibility="Hidden" FontSize="15" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Padding="0"></Label>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
52
middleware/zdhsys/Control/ColorButton.xaml.cs
Normal file
52
middleware/zdhsys/Control/ColorButton.xaml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// ColorButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ColorButton : UserControl
|
||||
{
|
||||
public ColorButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
public bool isCheck = false;
|
||||
public void SetUI(string hexColor)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexColor);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
gd.Background = brush;
|
||||
}
|
||||
public void SetIsCheck(bool flag)
|
||||
{
|
||||
isCheck = flag;
|
||||
lb_gou.Visibility = isCheck ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//isCheck = !isCheck;
|
||||
//lb_gou.Visibility = isCheck ? Visibility.Visible : Visibility.Hidden;
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
middleware/zdhsys/Control/DevButton.xaml
Normal file
27
middleware/zdhsys/Control/DevButton.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="100">
|
||||
<Grid>
|
||||
<Border x:Name="bd" CornerRadius="5" Margin="3" Background="White" BorderBrush="#0080FF" BorderThickness="2">
|
||||
<Button x:Name="btn" Background="Transparent">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="img" HorizontalAlignment="Right" Width="15" Height="15" Margin="3"/>
|
||||
<Label x:Name="tbk" Grid.Column="2" Content="Button" VerticalAlignment="Center" HorizontalContentAlignment="Left" Margin="0"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
82
middleware/zdhsys/Control/DevButton.xaml.cs
Normal file
82
middleware/zdhsys/Control/DevButton.xaml.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevButton : UserControl
|
||||
{
|
||||
public DevButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
Image img;
|
||||
Label tbk;
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="path">图标相对路径</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string hexBG,string hexBd,string path,string hexTxt,string txt)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBd);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
|
||||
img = btn.Template.FindName("img", btn) as Image;
|
||||
tbk = btn.Template.FindName("tbk", btn) as Label;
|
||||
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
|
||||
btn.Click += Btn_Click;
|
||||
}
|
||||
/// <summary>
|
||||
/// 按钮单击事件传递
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
20
middleware/zdhsys/Control/DevButton0.xaml
Normal file
20
middleware/zdhsys/Control/DevButton0.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevButton0"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="100">
|
||||
<Grid>
|
||||
<Border x:Name="bd" CornerRadius="5" Margin="3" Background="White" BorderBrush="#0080FF" BorderThickness="2">
|
||||
<Button x:Name="btn" Background="Transparent">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Label x:Name="tbk" Content="Button" HorizontalContentAlignment="Center" Margin="3"/>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
71
middleware/zdhsys/Control/DevButton0.xaml.cs
Normal file
71
middleware/zdhsys/Control/DevButton0.xaml.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevButton0 : UserControl
|
||||
{
|
||||
public DevButton0()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
Label tbk;
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="path">图标相对路径</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string hexBG,string hexBd,string hexTxt,string txt)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBd);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
|
||||
tbk = btn.Template.FindName("tbk", btn) as Label;
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
|
||||
btn.Click += Btn_Click;
|
||||
}
|
||||
/// <summary>
|
||||
/// 按钮单击事件传递
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
middleware/zdhsys/Control/DevButton1.xaml
Normal file
22
middleware/zdhsys/Control/DevButton1.xaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevButton1"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
d:DesignHeight="30" d:DesignWidth="100">
|
||||
<Grid>
|
||||
<Border x:Name="bd" CornerRadius="5" Margin="3" Background="White" BorderBrush="#0080FF" BorderThickness="2">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="img" HorizontalAlignment="Right" Height="15" Width="15" Margin="3,0,3,0"/>
|
||||
<Label x:Name="tbk" Grid.Column="2" Padding="0" Content="Btn" VerticalAlignment="Center" HorizontalContentAlignment="Left" Margin="3,0,3,0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
72
middleware/zdhsys/Control/DevButton1.xaml.cs
Normal file
72
middleware/zdhsys/Control/DevButton1.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevButton1 : UserControl
|
||||
{
|
||||
public DevButton1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="path">图标相对路径</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string hexBG,string hexBd,string path,string hexTxt,string txt)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBd);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
if (img != null)
|
||||
{
|
||||
img.Source = bitmapImage;
|
||||
}
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
if (tbk != null)
|
||||
{
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
middleware/zdhsys/Control/DevButton2.xaml
Normal file
18
middleware/zdhsys/Control/DevButton2.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevButton2"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
d:DesignHeight="40" d:DesignWidth="100">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="img" HorizontalAlignment="Right" Width="15" Height="15" Margin="0,0,3,0"/>
|
||||
<Label x:Name="tbk" Grid.Column="2" Content="Button" VerticalAlignment="Center" HorizontalContentAlignment="Left" Margin="0,0,0,0"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
62
middleware/zdhsys/Control/DevButton2.xaml.cs
Normal file
62
middleware/zdhsys/Control/DevButton2.xaml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevButton2 : UserControl
|
||||
{
|
||||
public DevButton2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
public string Text;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="path">图标相对路径</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string path,string hexTxt,string txt)
|
||||
{
|
||||
Text = txt;
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
middleware/zdhsys/Control/DevDevice.xaml
Normal file
20
middleware/zdhsys/Control/DevDevice.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevDevice"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
MouseEnter="UserControl_MouseEnter"
|
||||
MouseLeave="UserControl_MouseLeave"
|
||||
d:DesignHeight="70" d:DesignWidth="40">
|
||||
<Grid Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="img"/>
|
||||
<Label x:Name="dev_name" Content="设备1" Margin="0,0,0,0" FontSize="12" Foreground="#333333" Grid.Row="1" Height="25" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
82
middleware/zdhsys/Control/DevDevice.xaml.cs
Normal file
82
middleware/zdhsys/Control/DevDevice.xaml.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
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;
|
||||
using zdhsys.Popup;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevDevice.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevDevice : UserControl
|
||||
{
|
||||
public DevDevice()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string DevName = "";
|
||||
|
||||
public void SetUI(string devName,string path)
|
||||
{
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
dev_name.Content = devName;
|
||||
DevName = devName;
|
||||
}
|
||||
|
||||
HomeDeviceInfo info;
|
||||
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Point p = GlobalUnitils.GetScreenPosition(this);
|
||||
Console.WriteLine(p.X + " - " + p.Y);
|
||||
info = new HomeDeviceInfo(p);
|
||||
info.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
Point p = GlobalUnitils.GetScreenPosition(this);
|
||||
//Console.WriteLine(p.X + " - " + p.Y);
|
||||
info = new HomeDeviceInfo(p);
|
||||
info.SetUI(DevName, "断开", "POS", "无");
|
||||
info.Show();
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
middleware/zdhsys/Control/DevLiquid.xaml
Normal file
51
middleware/zdhsys/Control/DevLiquid.xaml
Normal file
@@ -0,0 +1,51 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevLiquid"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border x:Name="bd" CornerRadius="10" Margin="3" Background="White" BorderBrush="#4E89FF" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="2.5*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lbName" Content="清洗设备" Margin="20,0,0,0" Style="{StaticResource CommonStyleBold}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lbStatus" Grid.Column="1" Content="自检中..." Margin="0,0,20,0" FontSize="12" Foreground="#4E89FF" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<Grid x:Name="gd" Grid.Row="1" Margin="10,0,10,0" VerticalAlignment="Center">
|
||||
|
||||
</Grid>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lbTemp" Content="26.5℃" Margin="0,0,0,0" Foreground="#FF0000" FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lbTime" Grid.Column="1" Content="2023.02.31" Margin="0,0,20,0" FontSize="12" Foreground="#4E89FF" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Name="lbDaogui" Content="导轨1" Foreground="#333333" FontSize="12" FontWeight="Bold"/>
|
||||
<Border Grid.Column="1" Margin="0,0,10,0" Height="15" CornerRadius="5" BorderThickness="4" Background="#C4D1FF" BorderBrush="#C4D1FF"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
54
middleware/zdhsys/Control/DevLiquid.xaml.cs
Normal file
54
middleware/zdhsys/Control/DevLiquid.xaml.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevLiquid.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevLiquid : UserControl
|
||||
{
|
||||
public DevLiquid()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetUI(int num, string path, string name, string status, string temp, string time,string daogui)
|
||||
{
|
||||
double wid = ActualWidth;
|
||||
double wids = wid / (num + 1);
|
||||
Console.WriteLine("wids=" + wids);
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
DevDevice newButton = new DevDevice();
|
||||
int index = i + 1;
|
||||
newButton.SetUI("设备" + index, path);
|
||||
// 在 Grid 的列定义中增加一个新列
|
||||
//gd.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
|
||||
gd.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(wids) });
|
||||
|
||||
// 将新按钮添加到 Grid 的新列
|
||||
Grid.SetColumn(newButton, i);
|
||||
gd.Children.Add(newButton);
|
||||
}
|
||||
|
||||
lbName.Content = name;
|
||||
lbStatus.Content = status;
|
||||
lbTemp.Content = !string.IsNullOrEmpty(temp) ? temp + "℃" : "";
|
||||
lbTime.Content = time;
|
||||
lbDaogui.Content = daogui;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
middleware/zdhsys/Control/DevOperation.xaml
Normal file
20
middleware/zdhsys/Control/DevOperation.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevOperation"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="40" d:DesignWidth="200">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:DevButton2 Grid.Column="0" x:Name="btn_details"/>
|
||||
<local:DevButton2 Grid.Column="1" x:Name="btn_edit" Margin="10,0,10,0"/>
|
||||
<local:DevButton2 Grid.Column="2" x:Name="btn_del"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
68
middleware/zdhsys/Control/DevOperation.xaml.cs
Normal file
68
middleware/zdhsys/Control/DevOperation.xaml.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevOperation.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevOperation : UserControl
|
||||
{
|
||||
public DevOperation()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public event RoutedEventHandler Click_Details;
|
||||
public event RoutedEventHandler Click_Update;
|
||||
public event RoutedEventHandler Click_Delete;
|
||||
public object obj;
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_details.SetUI("\\Image\\details.png", "#027AFF", "详情");
|
||||
btn_del.SetUI("\\Image\\delete.png", "#FF0000", "删除");
|
||||
btn_edit.SetUI("\\Image\\edit.png", "#027AFF", "修改");
|
||||
|
||||
btn_details.Click += Btn_Click;
|
||||
btn_del.Click += Btn_Click;
|
||||
btn_edit.Click += Btn_Click;
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevButton2 btn = sender as DevButton2;
|
||||
if(btn.Text == "详情")
|
||||
{
|
||||
if (Click_Details != null)
|
||||
{
|
||||
Click_Details.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (btn.Text == "修改")
|
||||
{
|
||||
if (Click_Update != null)
|
||||
{
|
||||
Click_Update.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (btn.Text == "删除")
|
||||
{
|
||||
if (Click_Delete != null)
|
||||
{
|
||||
Click_Delete.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
middleware/zdhsys/Control/DevOperation2.xaml
Normal file
18
middleware/zdhsys/Control/DevOperation2.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevOperation2"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="40" d:DesignWidth="150">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:DevButton2 Grid.Column="0" x:Name="btn_edit" Margin="0,0,0,0"/>
|
||||
<local:DevButton2 Grid.Column="1" x:Name="btn_del"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
58
middleware/zdhsys/Control/DevOperation2.xaml.cs
Normal file
58
middleware/zdhsys/Control/DevOperation2.xaml.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevOperation.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevOperation2 : UserControl
|
||||
{
|
||||
public DevOperation2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public event RoutedEventHandler Click_Update;
|
||||
public event RoutedEventHandler Click_Delete;
|
||||
public object obj;
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_del.SetUI("\\Image\\delete.png", "#FF0000", "删除");
|
||||
btn_edit.SetUI("\\Image\\edit.png", "#027AFF", "修改");
|
||||
|
||||
btn_del.Click += Btn_Click;
|
||||
btn_edit.Click += Btn_Click;
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevButton2 btn = sender as DevButton2;
|
||||
if (btn.Text == "修改")
|
||||
{
|
||||
if (Click_Update != null)
|
||||
{
|
||||
Click_Update.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (btn.Text == "删除")
|
||||
{
|
||||
if (Click_Delete != null)
|
||||
{
|
||||
Click_Delete.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
middleware/zdhsys/Control/DevOperation3.xaml
Normal file
18
middleware/zdhsys/Control/DevOperation3.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevOperation3"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="40" d:DesignWidth="150">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:DevButton2 Grid.Column="0" x:Name="btn_edit" Margin="0,0,2,0"/>
|
||||
<local:DevButton2 Grid.Column="1" x:Name="btn_del"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
60
middleware/zdhsys/Control/DevOperation3.xaml.cs
Normal file
60
middleware/zdhsys/Control/DevOperation3.xaml.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevOperation.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevOperation3 : UserControl
|
||||
{
|
||||
public DevOperation3()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public event RoutedEventHandler Click_Up;
|
||||
public event RoutedEventHandler Click_Down;
|
||||
public object obj;
|
||||
private readonly string move_up = "上移";
|
||||
private readonly string move_down = "下移";
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_del.SetUI("\\Image\\move_up.png", "#FF0000", move_up);
|
||||
btn_edit.SetUI("\\Image\\move_down.png", "#027AFF", move_down);
|
||||
|
||||
btn_del.Click += Btn_Click;
|
||||
btn_edit.Click += Btn_Click;
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DevButton2 btn = sender as DevButton2;
|
||||
if (btn.Text == move_up)
|
||||
{
|
||||
if (Click_Up != null)
|
||||
{
|
||||
Click_Up.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (btn.Text == move_down)
|
||||
{
|
||||
if (Click_Down != null)
|
||||
{
|
||||
Click_Down.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
middleware/zdhsys/Control/DevPaging.xaml
Normal file
38
middleware/zdhsys/Control/DevPaging.xaml
Normal file
@@ -0,0 +1,38 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevPaging"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="30" d:DesignWidth="520">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="common" TargetType="Control">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="15"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label x:Name="lb_all" Content="共22条" Style="{StaticResource common}"/>
|
||||
<ComboBox x:Name="cbb" Background="White" Style="{StaticResource common}" Margin="20,0,0,0"/>
|
||||
<Button x:Name="btn_left" Click="btn_left_Click" Background="Transparent" Width="30" Height="30" Margin="20,0,0,0" Style="{StaticResource NoBorderButtonStyle2}">
|
||||
<StackPanel Margin="7,0,0,0">
|
||||
<Image x:Name="img_left" Width="15" Height="15" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="btn_1" Content="1" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<Button x:Name="btn_2" Content="2" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<Button x:Name="btn_3" Content="3" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<Button x:Name="btn_4" Content="4" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<Button x:Name="btn_5" Content="5" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<Button x:Name="btn_Right" Click="btn_Right_Click" Background="Transparent" Width="30" Height="30" Margin="5,0,0,0" Style="{StaticResource NoBorderButtonStyle2}">
|
||||
<StackPanel Margin="0,0,8,0">
|
||||
<Image x:Name="img_right" Width="15" Height="15" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="btn_go" Click="btn_go_Click" Content="前往" Foreground="#333333" Background="Transparent" Width="35" Margin="20,0,0,0" Style="{StaticResource NoBorderButtonStyle2}"/>
|
||||
<TextBox x:Name="txt" HorizontalContentAlignment="Center" PreviewTextInput="txt_PreviewTextInput" Foreground="#333333" Width="40" Height="20" Margin="10,0,0,0"/>
|
||||
<Label Content="页" Style="{StaticResource common}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
300
middleware/zdhsys/Control/DevPaging.xaml.cs
Normal file
300
middleware/zdhsys/Control/DevPaging.xaml.cs
Normal file
@@ -0,0 +1,300 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevPaging.xaml 的交互逻辑
|
||||
/// 本控件为自定义分页控件
|
||||
/// </summary>
|
||||
public partial class DevPaging : UserControl
|
||||
{
|
||||
public DevPaging()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
InitUI();
|
||||
}
|
||||
public event RoutedEventHandler Click;
|
||||
private void InitUI()
|
||||
{
|
||||
img_left.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Image\\arrowLeft.png")); ;
|
||||
img_right.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Image\\arrowRight.png"));
|
||||
|
||||
cbb.Items.Add("10条/页");
|
||||
cbb.Items.Add("20条/页");
|
||||
cbb.Items.Add("30条/页");
|
||||
cbb.SelectedIndex = 0;
|
||||
cbb.SelectionChanged += Cbb_SelectionChanged;
|
||||
btn_1.Click += Btn_Click;
|
||||
btn_2.Click += Btn_Click;
|
||||
btn_3.Click += Btn_Click;
|
||||
btn_4.Click += Btn_Click;
|
||||
btn_5.Click += Btn_Click;
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button btn = sender as Button;
|
||||
int p = int.Parse(btn.Content.ToString());
|
||||
page = p;
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Cbb_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SetNum(all_num);
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页,每页显示数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int getPageNum()
|
||||
{
|
||||
if (cbb.SelectedIndex == 1)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
else if (cbb.SelectedIndex == 2)
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
return 10;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中页--默认为第1页就算没数据也是。
|
||||
/// </summary>
|
||||
public int page = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
public int all_page;
|
||||
|
||||
/// <summary>
|
||||
/// 记录总条数
|
||||
/// </summary>
|
||||
public int all_num;
|
||||
|
||||
/// <summary>
|
||||
/// 设置记录总数
|
||||
/// </summary>
|
||||
/// <param name="num"></param>
|
||||
public void SetNum(int num)
|
||||
{
|
||||
all_num = num;
|
||||
lb_all.Content = "共" + num + "条";
|
||||
int pageSingle = getPageNum();
|
||||
double d = num * 1.0 / pageSingle;
|
||||
int pg = (int)d;
|
||||
if (d > pg)
|
||||
{
|
||||
pg++;
|
||||
}
|
||||
all_page = pg;
|
||||
//先全部放开。
|
||||
btn_1.Visibility = Visibility.Visible;
|
||||
btn_2.Visibility = Visibility.Visible;
|
||||
btn_3.Visibility = Visibility.Visible;
|
||||
btn_4.Visibility = Visibility.Visible;
|
||||
btn_5.Visibility = Visibility.Visible;
|
||||
btn_1.Content = 1;
|
||||
btn_2.Content = 2;
|
||||
btn_3.Content = 3;
|
||||
btn_4.Content = 4;
|
||||
btn_5.Content = 5;
|
||||
if (pg == 0)
|
||||
{
|
||||
btn_1.Visibility = Visibility.Collapsed;
|
||||
btn_2.Visibility = Visibility.Collapsed;
|
||||
btn_3.Visibility = Visibility.Collapsed;
|
||||
btn_4.Visibility = Visibility.Collapsed;
|
||||
btn_5.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (pg == 1)
|
||||
{
|
||||
btn_2.Visibility = Visibility.Collapsed;
|
||||
btn_3.Visibility = Visibility.Collapsed;
|
||||
btn_4.Visibility = Visibility.Collapsed;
|
||||
btn_5.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (pg == 2)
|
||||
{
|
||||
btn_3.Visibility = Visibility.Collapsed;
|
||||
btn_4.Visibility = Visibility.Collapsed;
|
||||
btn_5.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (pg == 3)
|
||||
{
|
||||
btn_4.Visibility = Visibility.Collapsed;
|
||||
btn_5.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (pg == 4)
|
||||
{
|
||||
btn_5.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
//这里多做一个判断,就是删除了之后,当数量已经不能支撑当前页数,就减1
|
||||
if (num == 0)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getPageNum() * (page - 1) >= num)
|
||||
{
|
||||
if (page > 1)
|
||||
{
|
||||
page--;
|
||||
}
|
||||
//if (Click != null)
|
||||
//{
|
||||
// Click.Invoke(this, null);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_go_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txt.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int p = int.Parse(txt.Text);
|
||||
// 如果超出范围,就显示当前页码
|
||||
if (p <= 0 || p > all_page)
|
||||
{
|
||||
txt.Text = page.ToString();
|
||||
return;
|
||||
}
|
||||
//设置当前页码
|
||||
page = p;
|
||||
|
||||
if (all_page < 5)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//处理跳转页码
|
||||
//判断页码是否在当前显示的范围。如果是的话,就不处理
|
||||
if (btn_1.Content.ToString() == p.ToString()
|
||||
|| btn_2.Content.ToString() == p.ToString()
|
||||
|| btn_3.Content.ToString() == p.ToString()
|
||||
|| btn_4.Content.ToString() == p.ToString()
|
||||
|| btn_5.Content.ToString() == p.ToString())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (p + 2 <= all_page)
|
||||
{
|
||||
btn_3.Content = page;
|
||||
btn_4.Content = page + 1;
|
||||
btn_5.Content = page + 2;
|
||||
}
|
||||
else if (p + 1 == all_page)
|
||||
{
|
||||
btn_3.Content = page - 1;
|
||||
btn_4.Content = page;
|
||||
btn_5.Content = page + 1;
|
||||
}
|
||||
else if (p == all_page)
|
||||
{
|
||||
btn_3.Content = page - 2;
|
||||
btn_4.Content = page - 1;
|
||||
btn_5.Content = page;
|
||||
}
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只能输入整数
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void txt_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
if (!int.TryParse(e.Text, out _))
|
||||
{
|
||||
e.Handled = true; // 阻止输入
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_left_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (page == 1)
|
||||
{
|
||||
return;//最小值了。
|
||||
}
|
||||
page--;
|
||||
txt.Text = page.ToString();
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
flush();
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
//这里要判断一下,如果页面上没有这个页码的话,就刷新一下按钮的显示
|
||||
//判断页码是否在当前显示的范围。如果是的话,就不处理
|
||||
if (btn_1.Content.ToString() == page.ToString()
|
||||
|| btn_2.Content.ToString() == page.ToString()
|
||||
|| btn_3.Content.ToString() == page.ToString()
|
||||
|| btn_4.Content.ToString() == page.ToString()
|
||||
|| btn_5.Content.ToString() == page.ToString())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (page + 2 <= all_page)
|
||||
{
|
||||
btn_3.Content = page;
|
||||
btn_4.Content = page + 1;
|
||||
btn_5.Content = page + 2;
|
||||
}
|
||||
else if (page + 1 == all_page)
|
||||
{
|
||||
btn_3.Content = page - 1;
|
||||
btn_4.Content = page;
|
||||
btn_5.Content = page + 1;
|
||||
}
|
||||
else if (page == all_page)
|
||||
{
|
||||
btn_3.Content = page - 2;
|
||||
btn_4.Content = page - 1;
|
||||
btn_5.Content = page;
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Right_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (page == all_page)
|
||||
{
|
||||
return;
|
||||
}
|
||||
page++;
|
||||
txt.Text = page.ToString();
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
middleware/zdhsys/Control/DevRobot.xaml
Normal file
23
middleware/zdhsys/Control/DevRobot.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevRobot"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
MouseEnter="UserControl_MouseEnter"
|
||||
MouseLeave="UserControl_MouseLeave"
|
||||
d:DesignHeight="100" d:DesignWidth="80">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="lbName" Content="导轨机器人" Style="{StaticResource CommonStyleBold}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<Image x:Name="img" Grid.Row="1" Height="40" Width="40"/>
|
||||
<Label x:Name="lbStatus" Grid.Row="2" Content="自检中..." FontSize="12" Foreground="#4E89FF" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
95
middleware/zdhsys/Control/DevRobot.xaml.cs
Normal file
95
middleware/zdhsys/Control/DevRobot.xaml.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
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;
|
||||
using zdhsys.entity;
|
||||
using zdhsys.Popup;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevRobot.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevRobot : UserControl
|
||||
{
|
||||
public DevRobot()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetUI(string name, string status, string path)
|
||||
{
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
lbName.Content = name;
|
||||
lbStatus.Content = status;
|
||||
DevName = name;
|
||||
}
|
||||
HomeDeviceInfo info;
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Point p = GlobalUnitils.GetScreenPosition(this);
|
||||
Console.WriteLine(p.X + " - " + p.Y);
|
||||
info = new HomeDeviceInfo(p);
|
||||
info.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public string DevName = "";
|
||||
public Heart ht;
|
||||
public RobotHeart rh;
|
||||
|
||||
private void UserControl_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
Point p = GlobalUnitils.GetScreenPosition(this);
|
||||
info = new HomeDeviceInfo(p);
|
||||
if (ht != null)
|
||||
{
|
||||
info.SetUI(DevName, ht.rob_sta == 0 ? "空闲" : "执行中", ht.ID + "", rh.cmd + "");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.SetUI(DevName, "断开", "", "");
|
||||
}
|
||||
info.Show();
|
||||
}
|
||||
|
||||
private void UserControl_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Close();
|
||||
info = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
middleware/zdhsys/Control/DevTextBox.xaml
Normal file
44
middleware/zdhsys/Control/DevTextBox.xaml
Normal file
@@ -0,0 +1,44 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevTextBox"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="50" d:DesignWidth="100">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="FlatTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="BorderBrush" Value="Gray"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
CornerRadius="5">
|
||||
<ScrollViewer x:Name="PART_ContentHost"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="PART_ContentHost" Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter TargetName="PART_ContentHost" Property="Background" Value="LightBlue"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="White" VerticalAlignment="Center">
|
||||
<TextBox Padding="5,0,0,0" Height="30" x:Name="textBox" Style="{StaticResource FlatTextBoxStyle}" Foreground="Gray" Text="请输入姓名" GotFocus="TextBox_GotFocus" LostFocus="TextBox_GotFocus" VerticalContentAlignment="Center" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
81
middleware/zdhsys/Control/DevTextBox.xaml.cs
Normal file
81
middleware/zdhsys/Control/DevTextBox.xaml.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevTextBox.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevTextBox : UserControl
|
||||
{
|
||||
public DevTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private string Tips = "";
|
||||
public void SetUI(string tips)
|
||||
{
|
||||
textBox.Text = tips;
|
||||
Tips = tips;
|
||||
}
|
||||
|
||||
public string Text()
|
||||
{
|
||||
if (textBox.Text == Tips) return "";
|
||||
return textBox.Text;
|
||||
}
|
||||
|
||||
public void SetText(string text)
|
||||
{
|
||||
textBox.Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置只能输入数字
|
||||
/// </summary>
|
||||
public void SetNumber()
|
||||
{
|
||||
textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
|
||||
}
|
||||
|
||||
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// 只允许输入数字和一些特殊按键
|
||||
if (!((Key.D0 <= e.Key && e.Key <= Key.D9) || // 数字键盘上的数字
|
||||
(Key.NumPad0 <= e.Key && e.Key <= Key.NumPad9) || // 主键盘上的数字
|
||||
e.Key == Key.Back || // 退格键
|
||||
e.Key == Key.Delete || // 删除键
|
||||
e.Key == Key.Tab || // Tab 键
|
||||
e.Key == Key.Left || e.Key == Key.Right)) // 左右方向键
|
||||
{
|
||||
e.Handled = true; // 拦截非数字键
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (textBox.Text == Tips)
|
||||
{
|
||||
textBox.Text = "";
|
||||
textBox.Foreground = Brushes.Black;
|
||||
}
|
||||
else if (string.IsNullOrEmpty(textBox.Text))
|
||||
{
|
||||
textBox.Text = Tips;
|
||||
textBox.Foreground = Brushes.Gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
middleware/zdhsys/Control/DeviceGroup.xaml
Normal file
39
middleware/zdhsys/Control/DeviceGroup.xaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<UserControl x:Class="zdhsys.Control.DeviceGroup"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Border x:Name="bd" CornerRadius="10" Margin="3" Background="White" BorderBrush="#4E89FF" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1.5*"/>
|
||||
<RowDefinition Height="2.5*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lbName" Content="清洗设备" Margin="20,0,0,0" Style="{StaticResource CommonStyleBold}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lbStatus" Grid.Column="1" Content="自检中..." Margin="0,0,20,0" FontSize="12" Foreground="#4E89FF" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<Grid x:Name="gd" Grid.Row="1" Margin="10,0,10,0" VerticalAlignment="Center">
|
||||
|
||||
</Grid>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="lbTemp" Content="26.5℃" Margin="20,0,0,0" Foreground="#FF0000" FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lbTime" Grid.Column="1" Content="2023.02.31" Margin="0,0,20,0" FontSize="12" Foreground="#333333" HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
61
middleware/zdhsys/Control/DeviceGroup.xaml.cs
Normal file
61
middleware/zdhsys/Control/DeviceGroup.xaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DeviceGroup.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DeviceGroup : UserControl
|
||||
{
|
||||
public DeviceGroup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetUI(int num,string path,string name,string status,string temp,string time)
|
||||
{
|
||||
Console.WriteLine("DeviceGroup width="+this.ActualWidth);
|
||||
double wid = ActualWidth;
|
||||
double wids = wid / (num + 1);
|
||||
Console.WriteLine("wids=" + wids);
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
DevDevice newButton = new DevDevice();
|
||||
int index = i + 1;
|
||||
newButton.SetUI("设备" + index, path);
|
||||
// 在 Grid 的列定义中增加一个新列
|
||||
//gd.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
|
||||
gd.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(wids) });
|
||||
|
||||
// 将新按钮添加到 Grid 的新列
|
||||
Grid.SetColumn(newButton, i);
|
||||
gd.Children.Add(newButton);
|
||||
}
|
||||
|
||||
lbName.Content = name;
|
||||
lbStatus.Content = status;
|
||||
if(!string.IsNullOrEmpty(temp))
|
||||
{
|
||||
lbTemp.Content = temp + "℃";
|
||||
}
|
||||
else
|
||||
{
|
||||
lbTemp.Content = "";
|
||||
}
|
||||
lbTime.Content = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
middleware/zdhsys/Control/DeviceTab.xaml
Normal file
20
middleware/zdhsys/Control/DeviceTab.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="zdhsys.Control.DeviceTab"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="30" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80*"/>
|
||||
<ColumnDefinition Width="80*"/>
|
||||
<ColumnDefinition Width="80*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:TabButton x:Name="btn_device" Grid.Column="0"/>
|
||||
<local:TabButton x:Name="btn_device_group" Grid.Column="1" Visibility="Hidden"/>
|
||||
<local:TabButton x:Name="btn_class" Grid.Column="2" Visibility="Hidden"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
75
middleware/zdhsys/Control/DeviceTab.xaml.cs
Normal file
75
middleware/zdhsys/Control/DeviceTab.xaml.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DeviceTab.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DeviceTab : UserControl
|
||||
{
|
||||
public DeviceTab()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click_Device;
|
||||
public event RoutedEventHandler Click_DeviceGroup;
|
||||
public event RoutedEventHandler Click_Class;
|
||||
|
||||
public string str_1 = "设备管理";
|
||||
public string str_2 = "设备组管理";
|
||||
public string str_3 = "类别管理";
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_device.SetUI(str_1);
|
||||
btn_device.Click += Btn_Click;
|
||||
btn_device.SetCheck(true);
|
||||
|
||||
|
||||
btn_device_group.SetUI(str_2);
|
||||
btn_device_group.Click += Btn_Click;
|
||||
btn_device_group.SetCheck(false);
|
||||
|
||||
btn_class.SetUI(str_3);
|
||||
btn_class.Click += Btn_Click;
|
||||
btn_class.SetCheck(false);
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TabButton tab = sender as TabButton;
|
||||
if (tab.Text == str_1)
|
||||
{
|
||||
btn_device.SetCheck(true);
|
||||
btn_device_group.SetCheck(false);
|
||||
btn_class.SetCheck(false);
|
||||
if (Click_Device != null)
|
||||
{
|
||||
Click_Device.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (tab.Text == str_2)
|
||||
{
|
||||
btn_device.SetCheck(false);
|
||||
btn_device_group.SetCheck(true);
|
||||
btn_class.SetCheck(false);
|
||||
if (Click_DeviceGroup != null)
|
||||
{
|
||||
Click_DeviceGroup.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (tab.Text == str_3)
|
||||
{
|
||||
btn_device.SetCheck(false);
|
||||
btn_device_group.SetCheck(false);
|
||||
btn_class.SetCheck(true);
|
||||
if (Click_Class != null)
|
||||
{
|
||||
Click_Class.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
middleware/zdhsys/Control/DevpButton.xaml
Normal file
49
middleware/zdhsys/Control/DevpButton.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<UserControl x:Class="zdhsys.Control.DevpButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="150">
|
||||
<Grid>
|
||||
<Button x:Name="btn" Click="btn_Click" Background="LightBlue" BorderBrush="Transparent">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="img" HorizontalAlignment="Right" Width="15" Height="15" Margin="5"/>
|
||||
<TextBlock x:Name="tbk" Grid.Column="2" Text="Button Text" VerticalAlignment="Center" Margin="5"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button x:Name="btn2" Click="btn_Click" Background="White" BorderBrush="Transparent">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid>
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="5">
|
||||
<Grid>
|
||||
<Image x:Name="img2" Width="15" Height="15"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
189
middleware/zdhsys/Control/DevpButton.xaml.cs
Normal file
189
middleware/zdhsys/Control/DevpButton.xaml.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevpButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DevpButton : UserControl
|
||||
{
|
||||
public DevpButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool flag = false; // 是否选中
|
||||
private bool max = true; // 是大,还是小
|
||||
// 按钮文本
|
||||
public string btnName = "主页";
|
||||
|
||||
Image img;
|
||||
Image img2;
|
||||
TextBlock tbk;
|
||||
// 把单击事件传出去。
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
// 配色
|
||||
string hex1 = "#98A3FE";
|
||||
string hex2 = "#FFFFFF";
|
||||
string hex3 = "#465785";
|
||||
private static string basePath = "\\Image\\menu\\";
|
||||
// 白色ICO
|
||||
string imgPath = basePath + "主页.png";
|
||||
// 黑色ICO
|
||||
string imgPath2 = basePath + "主页2.png";
|
||||
|
||||
// 封装主菜单所有ICO切换
|
||||
public void Set_Name(string name)
|
||||
{
|
||||
InitUI();
|
||||
btnName = name;
|
||||
switch (btnName)
|
||||
{
|
||||
case "主页":
|
||||
imgPath = basePath + "主页.png";
|
||||
imgPath2 = basePath + "主页2.png";
|
||||
break;
|
||||
case "配方管理":
|
||||
imgPath = basePath + "配方.png";
|
||||
imgPath2 = basePath + "配方2.png";
|
||||
break;
|
||||
case "流程管理":
|
||||
imgPath = basePath + "流程.png";
|
||||
imgPath2 = basePath + "流程2.png";
|
||||
break;
|
||||
case "设备管理":
|
||||
imgPath = basePath + "设备.png";
|
||||
imgPath2 = basePath + "设备2.png";
|
||||
break;
|
||||
case "数据管理":
|
||||
imgPath = basePath + "数据.png";
|
||||
imgPath2 = basePath + "数据2.png";
|
||||
break;
|
||||
}
|
||||
updateUI(hex2, hex3, imgPath2);
|
||||
}
|
||||
|
||||
|
||||
// 大小按钮单击事件
|
||||
private void btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
flag = true;
|
||||
if (flag)
|
||||
{
|
||||
if (max)
|
||||
updateUI(hex1, hex2, imgPath);
|
||||
else
|
||||
updateUI2(hex1, imgPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max)
|
||||
updateUI(hex2, hex3, imgPath2);
|
||||
else
|
||||
updateUI2(hex2, imgPath2);
|
||||
}
|
||||
if(Click != null)
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
|
||||
// 更新大按钮界面
|
||||
private void updateUI(string hexValue, string hex, string path)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexValue);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
btn.Background = brush;
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img.Source = bitmapImage;
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hex);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Text = btnName;
|
||||
// 这里加长一点,与其它4个中文的文本长度对齐。
|
||||
if(btnName == "主页")
|
||||
{
|
||||
tbk.Text = "主页" + '\u00A0' + '\u00A0' + '\u00A0' + '\u00A0' + '\u00A0' + '\u00A0' + '\u00A0';
|
||||
}
|
||||
tbk.FontSize = 15;
|
||||
tbk.FontFamily = new FontFamily("Microsoft YaHei");
|
||||
tbk.FontWeight = FontWeights.Bold;
|
||||
}
|
||||
// 更新小按钮界面
|
||||
private void updateUI2(string hexValue, string path)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexValue);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
btn2.Background = brush;
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
img2.Source = bitmapImage;
|
||||
}
|
||||
|
||||
// 取消选中状态
|
||||
public void setFocus(bool check)
|
||||
{
|
||||
flag = check;
|
||||
if (flag)
|
||||
{
|
||||
if (max)
|
||||
updateUI(hex1, hex2, imgPath);
|
||||
else
|
||||
updateUI2(hex1, imgPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max)
|
||||
updateUI(hex2, hex3, imgPath2);
|
||||
else
|
||||
updateUI2(hex2, imgPath2);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置大小状态
|
||||
public void setCollapsed(bool see)
|
||||
{
|
||||
if (see)
|
||||
{
|
||||
this.Width = 150;
|
||||
btn.Visibility = Visibility.Visible;
|
||||
btn2.Visibility = Visibility.Collapsed;
|
||||
max = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Width = 25;
|
||||
btn.Visibility = Visibility.Collapsed;
|
||||
btn2.Visibility = Visibility.Visible;
|
||||
max = false;
|
||||
}
|
||||
setFocus(flag);
|
||||
}
|
||||
|
||||
private void InitUI()
|
||||
{
|
||||
// 找出控件里面子控件
|
||||
img = btn.Template.FindName("img", btn) as Image;
|
||||
img2 = btn2.Template.FindName("img2", btn2) as Image;
|
||||
tbk = btn.Template.FindName("tbk", btn) as TextBlock;
|
||||
|
||||
//小状态的按钮,先隐藏。 这里注意:如果在代码里面写了隐藏,上面的img2就会找不到。为null
|
||||
//只能先获取对象,后做隐藏处理。
|
||||
btn2.Visibility = Visibility.Collapsed;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
middleware/zdhsys/Control/FlowButton.xaml
Normal file
18
middleware/zdhsys/Control/FlowButton.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="zdhsys.Control.FlowButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
MouseDoubleClick="UserControl_MouseDoubleClick"
|
||||
d:DesignHeight="80" d:DesignWidth="120">
|
||||
<Grid>
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform x:Name="translateTransform" />
|
||||
</Grid.RenderTransform>
|
||||
<Border x:Name="bd" CornerRadius="5" Margin="3" Background="White" BorderBrush="#0080FF" BorderThickness="2">
|
||||
<Label x:Name="tbk" Grid.Column="2" Content="Button" VerticalAlignment="Center" HorizontalContentAlignment="Center" Margin="0"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
97
middleware/zdhsys/Control/FlowButton.xaml.cs
Normal file
97
middleware/zdhsys/Control/FlowButton.xaml.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowButton : UserControl
|
||||
{
|
||||
public FlowButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click;
|
||||
public object obj;
|
||||
public long ID;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string hexBG, string hexBd, string hexTxt, string txt)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBd);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
}
|
||||
|
||||
|
||||
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#region 拖动
|
||||
|
||||
//private bool isDragging;
|
||||
//private Point startPoint;
|
||||
//protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
//{
|
||||
// base.OnMouseLeftButtonDown(e);
|
||||
|
||||
// isDragging = true;
|
||||
// startPoint = e.GetPosition(this);
|
||||
// bd.CaptureMouse();
|
||||
//}
|
||||
|
||||
//protected override void OnMouseMove(MouseEventArgs e)
|
||||
//{
|
||||
// base.OnMouseMove(e);
|
||||
|
||||
// if (isDragging)
|
||||
// {
|
||||
// Point endPoint = e.GetPosition(this);
|
||||
// double offsetX = endPoint.X - startPoint.X;
|
||||
// double offsetY = endPoint.Y - startPoint.Y;
|
||||
|
||||
// translateTransform.X += offsetX;
|
||||
// translateTransform.Y += offsetY;
|
||||
|
||||
// startPoint = endPoint;
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
|
||||
//{
|
||||
// base.OnMouseLeftButtonUp(e);
|
||||
|
||||
// isDragging = false;
|
||||
|
||||
// bd.ReleaseMouseCapture();
|
||||
//}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
19
middleware/zdhsys/Control/FlowButton2.xaml
Normal file
19
middleware/zdhsys/Control/FlowButton2.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<UserControl x:Class="zdhsys.Control.FlowButton2"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
MouseRightButtonDown="UserControl_MouseRightButtonDown"
|
||||
d:DesignHeight="80" d:DesignWidth="120">
|
||||
<Grid x:Name="gd">
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform x:Name="translateTransform" />
|
||||
</Grid.RenderTransform>
|
||||
<Border x:Name="bd" CornerRadius="6" Margin="6" Background="White" BorderBrush="#0080FF" BorderThickness="2">
|
||||
<Label x:Name="tbk" Grid.Column="2" Content="Button" VerticalAlignment="Center" HorizontalContentAlignment="Center" Margin="0"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
302
middleware/zdhsys/Control/FlowButton2.xaml.cs
Normal file
302
middleware/zdhsys/Control/FlowButton2.xaml.cs
Normal file
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using zdhsys.Unitils;
|
||||
|
||||
namespace zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// DevButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowButton2 : UserControl
|
||||
{
|
||||
public FlowButton2()
|
||||
{
|
||||
InitializeComponent();
|
||||
//ID = GlobalUnitils.GetNowTime(DateTime.Now);
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click;
|
||||
/// <summary>
|
||||
/// 绑定设备实体用
|
||||
/// </summary>
|
||||
public object obj;
|
||||
/// <summary>
|
||||
/// 流程ID。 因为会有设备重复的情况,不适合使用设备的ID做为唯一
|
||||
/// </summary>
|
||||
public long ID;
|
||||
//背景颜色
|
||||
public string tempHexBG = "";
|
||||
//边框颜色
|
||||
public string tempHexBd = "";
|
||||
//字体颜色
|
||||
public string tempHexTxt = "";
|
||||
//文本内容
|
||||
public string tempTxt = "";
|
||||
//操作指令
|
||||
public int CMD = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮样式
|
||||
/// </summary>
|
||||
/// <param name="hexBG">按钮背景色</param>
|
||||
/// <param name="hexBd">按钮边框色</param>
|
||||
/// <param name="hexTxt">按钮文本颜色</param>
|
||||
/// <param name="txt">按钮文本</param>
|
||||
public void SetUI(string hexBG, string hexBd, string hexTxt, string txt)
|
||||
{
|
||||
tempHexBG = hexBG;
|
||||
tempHexBd = hexBd;
|
||||
tempHexTxt = hexTxt;
|
||||
tempTxt = txt;
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBd);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tbk.Content = txt;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置背景色和边框颜色
|
||||
/// </summary>
|
||||
/// <param name="hexBG"></param>
|
||||
public void SetBackColor(string hexBG)
|
||||
{
|
||||
tempHexBG = hexBG;
|
||||
tempHexBd = hexBG;
|
||||
Color color = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
bd.Background = brush;
|
||||
|
||||
Color color1 = (Color)ColorConverter.ConvertFromString(hexBG);
|
||||
SolidColorBrush brush1 = new SolidColorBrush(color1);
|
||||
bd.BorderBrush = brush1;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置字体颜色
|
||||
/// </summary>
|
||||
/// <param name="hexTxt"></param>
|
||||
public void SetForeColor(string hexTxt)
|
||||
{
|
||||
Color color2 = (Color)ColorConverter.ConvertFromString(hexTxt);
|
||||
SolidColorBrush brush2 = new SolidColorBrush(color2);
|
||||
tbk.Foreground = brush2;
|
||||
tempHexTxt = hexTxt;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置显示文本内容
|
||||
/// </summary>
|
||||
/// <param name="txt"></param>
|
||||
public void SetText(string txt)
|
||||
{
|
||||
tbk.Content = txt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回控件的内部坐标
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Point getPoint()
|
||||
{
|
||||
Point p = new Point(0, 0)
|
||||
{
|
||||
X = startPoint.X - translateTransform.X,
|
||||
Y = startPoint.Y - translateTransform.Y
|
||||
};
|
||||
return p;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取当前单击位置是否有画线的情况
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getEllipse()
|
||||
{
|
||||
Point p = getPoint();
|
||||
for (int i = 0; i < ps.Count; i++)
|
||||
{
|
||||
if (ps[i].Data.FillContains(p))
|
||||
{
|
||||
//Console.WriteLine($" ellipse name={ps[i].Name}");
|
||||
return ps[i].Name;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回当前控件的相对坐标
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Point getTranslateTransform()
|
||||
{
|
||||
return new Point(translateTransform.X, translateTransform.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置当前控件的相对坐标
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public void SetTranslateTransform(Point p)
|
||||
{
|
||||
translateTransform.X += p.X;
|
||||
translateTransform.Y += p.Y;
|
||||
}
|
||||
|
||||
#region 拖动
|
||||
//是否拖拽
|
||||
private bool isDragging;
|
||||
/// <summary>
|
||||
/// 当前单击坐标
|
||||
/// </summary>
|
||||
public Point startPoint;
|
||||
/// <summary>
|
||||
/// 单击圆的位置名称
|
||||
/// </summary>
|
||||
public string clickName;
|
||||
/// <summary>
|
||||
/// 鼠标按下
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
startPoint = e.GetPosition(this);
|
||||
bool flag = false;
|
||||
Point p = new Point(0, 0)
|
||||
{
|
||||
X = startPoint.X - translateTransform.X,
|
||||
Y = startPoint.Y - translateTransform.Y
|
||||
};
|
||||
//过滤掉4个圆。点击这4个圆,不移动当前控件。
|
||||
for (int i = 0; i < ps.Count; i++)
|
||||
{
|
||||
if (ps[i].Data.FillContains(p))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
isDragging = true;
|
||||
_ = bd.CaptureMouse();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标移动
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (isDragging)
|
||||
{
|
||||
Point endPoint = e.GetPosition(this);
|
||||
double offsetX = endPoint.X - startPoint.X;
|
||||
double offsetY = endPoint.Y - startPoint.Y;
|
||||
|
||||
translateTransform.X += offsetX;
|
||||
translateTransform.Y += offsetY;
|
||||
|
||||
startPoint = endPoint;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标松开
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonUp(e);
|
||||
isDragging = false;
|
||||
startPoint = e.GetPosition(this);
|
||||
bd.ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 保存4个圆的路径。用于判断是否点击了这些圆,哪个圆
|
||||
/// </summary>
|
||||
private static List<Path> ps = new List<Path>();
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ps.Add(AddEllipse("left", new Point(7, 40)));
|
||||
ps.Add(AddEllipse("top", new Point(60, 7)));
|
||||
ps.Add(AddEllipse("right", new Point(113, 40)));
|
||||
ps.Add(AddEllipse("bottom", new Point(60, 73)));
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回左上右下的圆心坐标。可用于主界面画线的时候用到
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public Point getStartPointByName(string name)
|
||||
{
|
||||
if (name == "left")
|
||||
{
|
||||
return new Point(7, 40);
|
||||
}
|
||||
else if (name == "top")
|
||||
{
|
||||
return new Point(60, 7);
|
||||
}
|
||||
else if (name == "right")
|
||||
{
|
||||
return new Point(113, 40);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Point(60, 73);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加圆型路径
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
private Path AddEllipse(string name, Point p)
|
||||
{
|
||||
// 创建圆形路径
|
||||
Path path = new Path
|
||||
{
|
||||
Stroke = new SolidColorBrush(Color.FromArgb(255, 2, 122, 255)),
|
||||
StrokeThickness = 2,
|
||||
Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255))
|
||||
};
|
||||
EllipseGeometry ellipse = new EllipseGeometry
|
||||
{
|
||||
Center = p, // 设置圆心坐标
|
||||
RadiusX = 6, // 半径
|
||||
RadiusY = 6
|
||||
};
|
||||
path.Data = ellipse;
|
||||
path.Name = name;
|
||||
// 添加路径到 Grid
|
||||
_ = gd.Children.Add(path);
|
||||
return path;
|
||||
}
|
||||
/// <summary>
|
||||
/// 右键编辑
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void UserControl_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
middleware/zdhsys/Control/ImageButton.xaml
Normal file
14
middleware/zdhsys/Control/ImageButton.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<UserControl x:Class="zdhsys.Control.ImageButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Background="White"
|
||||
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
|
||||
d:DesignHeight="40" d:DesignWidth="40">
|
||||
<Grid>
|
||||
<Image x:Name="img" Width="15" Height="15"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
47
middleware/zdhsys/Control/ImageButton.xaml.cs
Normal file
47
middleware/zdhsys/Control/ImageButton.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// ImageButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ImageButton : UserControl
|
||||
{
|
||||
public ImageButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public event RoutedEventHandler Click;
|
||||
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetUI(string path)
|
||||
{
|
||||
Uri imageUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + path);
|
||||
BitmapImage bitmapImage = new BitmapImage(imageUri);
|
||||
if (img != null)
|
||||
{
|
||||
img.Source = bitmapImage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
16
middleware/zdhsys/Control/MyControl.xaml
Normal file
16
middleware/zdhsys/Control/MyControl.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="zdhsys.Control.MyControl"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform x:Name="translateTransform" />
|
||||
</Grid.RenderTransform>
|
||||
<Label x:Name="myLabel" Content="Sample Text"
|
||||
Background="LightBlue" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
84
middleware/zdhsys/Control/MyControl.xaml.cs
Normal file
84
middleware/zdhsys/Control/MyControl.xaml.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// MyControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MyControl : UserControl
|
||||
{
|
||||
public MyControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool isDragging;
|
||||
private Point startPoint;
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
|
||||
isDragging = true;
|
||||
startPoint = e.GetPosition(this);
|
||||
|
||||
myLabel.CaptureMouse();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (isDragging)
|
||||
{
|
||||
//Point endPoint = e.GetPosition(this);
|
||||
Point endPoint = e.GetPosition((UIElement)Parent);
|
||||
//if (endPoint.X < 15 || endPoint.Y < 1) return;
|
||||
double offsetX = endPoint.X - startPoint.X;
|
||||
double offsetY = endPoint.Y - startPoint.Y;
|
||||
|
||||
double left = Canvas.GetLeft(this) + translateTransform.X;
|
||||
double top = Canvas.GetTop(this) + translateTransform.Y;
|
||||
double width = ActualWidth;
|
||||
double height = ActualHeight;
|
||||
|
||||
Console.WriteLine($"坐标: ({left}, {top}), 大小: {width} x {height}");
|
||||
if (left < 0)
|
||||
{
|
||||
translateTransform.X += Math.Abs(left);
|
||||
return;
|
||||
}
|
||||
if (top < -10)
|
||||
{
|
||||
translateTransform.Y += Math.Abs(top) - 10;
|
||||
return;
|
||||
}
|
||||
translateTransform.X += offsetX;
|
||||
translateTransform.Y += offsetY;
|
||||
Console.WriteLine("endPoint=" + endPoint.X + "," + endPoint.Y);
|
||||
startPoint = endPoint;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonUp(e);
|
||||
|
||||
isDragging = false;
|
||||
|
||||
myLabel.ReleaseMouseCapture();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
middleware/zdhsys/Control/OptionTab.xaml
Normal file
18
middleware/zdhsys/Control/OptionTab.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="zdhsys.Control.OptionTab"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="30" d:DesignWidth="200">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80*"/>
|
||||
<ColumnDefinition Width="80*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:TabButton x:Name="btn_Option" Grid.Column="0"/>
|
||||
<local:TabButton x:Name="btn_SubOption" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
69
middleware/zdhsys/Control/OptionTab.xaml.cs
Normal file
69
middleware/zdhsys/Control/OptionTab.xaml.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// OptionTab.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OptionTab : UserControl
|
||||
{
|
||||
public OptionTab()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click_Option;
|
||||
public event RoutedEventHandler Click_SubOption;
|
||||
|
||||
public string str_1 = "小瓶";
|
||||
public string str_2 = "大瓶";
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_Option.SetUI(str_1);
|
||||
btn_Option.Click += Btn_Click;
|
||||
btn_Option.SetCheck(true);
|
||||
|
||||
|
||||
btn_SubOption.SetUI(str_2);
|
||||
btn_SubOption.Click += Btn_Click;
|
||||
btn_SubOption.SetCheck(false);
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TabButton tab = sender as TabButton;
|
||||
if (tab.Text == str_1)
|
||||
{
|
||||
btn_Option.SetCheck(true);
|
||||
btn_SubOption.SetCheck(false);
|
||||
if (Click_Option != null)
|
||||
{
|
||||
Click_Option.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
else if (tab.Text == str_2)
|
||||
{
|
||||
btn_Option.SetCheck(false);
|
||||
btn_SubOption.SetCheck(true);
|
||||
if (Click_SubOption != null)
|
||||
{
|
||||
Click_SubOption.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
middleware/zdhsys/Control/SwitchButton.xaml
Normal file
24
middleware/zdhsys/Control/SwitchButton.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="zdhsys.Control.SwitchButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="30" d:DesignWidth="200">
|
||||
<Grid>
|
||||
<Border BorderThickness="1" BorderBrush="#027AFF" CornerRadius="15"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="bd_resp" BorderThickness="1" CornerRadius="15" Background="#027AFF">
|
||||
<Button x:Name="btn_resp" Height="28" Width="100" Click="btn_resp_Click" Content="反应类设备" Style="{StaticResource NoBorderButtonStyle0}" Foreground="White"/>
|
||||
</Border>
|
||||
<Border x:Name="bd_move" Grid.Column="1" BorderThickness="1" CornerRadius="15">
|
||||
<Button x:Name="btn_move" Height="28" Width="100" Click="btn_move_Click" Content="转移类设备" Style="{StaticResource NoBorderButtonStyle0}" Foreground="#027AFF"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
61
middleware/zdhsys/Control/SwitchButton.xaml.cs
Normal file
61
middleware/zdhsys/Control/SwitchButton.xaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// SwitchButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SwitchButton : UserControl
|
||||
{
|
||||
public SwitchButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool flagLeft = true;
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
private void btn_resp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_resp.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
|
||||
bd_resp.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#027AFF"));
|
||||
|
||||
btn_move.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#027AFF"));
|
||||
bd_move.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
|
||||
|
||||
flagLeft = true;
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_move_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btn_move.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
|
||||
bd_move.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#027AFF"));
|
||||
|
||||
btn_resp.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#027AFF"));
|
||||
bd_resp.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
|
||||
|
||||
flagLeft = false;
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
middleware/zdhsys/Control/TabButton.xaml
Normal file
17
middleware/zdhsys/Control/TabButton.xaml
Normal file
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="zdhsys.Control.TabButton"
|
||||
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:zdhsys.Control"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="35" d:DesignWidth="80">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="6*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button x:Name="btn" Click="btn_Click" Content="设备管理" Width="80" Style="{StaticResource NoBorderButtonStyle1}"/>
|
||||
<Border Name="bd" Grid.Row="1" Width="30" Height="3" BorderThickness="2" BorderBrush="#027AFF" Background="#027AFF" VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
67
middleware/zdhsys/Control/TabButton.xaml.cs
Normal file
67
middleware/zdhsys/Control/TabButton.xaml.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
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 zdhsys.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// TabButton.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TabButton : UserControl
|
||||
{
|
||||
public TabButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Click;
|
||||
|
||||
public string Text;
|
||||
public void SetUI(string content)
|
||||
{
|
||||
btn.Content = content;
|
||||
Text = content;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备选中状态
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void SetCheck(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString("#333333");
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
btn.Foreground = brush;
|
||||
bd.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString("#999999");
|
||||
SolidColorBrush brush = new SolidColorBrush(color);
|
||||
btn.Foreground = brush;
|
||||
bd.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Click != null)
|
||||
{
|
||||
Click.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user