This commit is contained in:
sc committed 2024-11-05 00:04:09 +08:00
commit 5c7ed500b3
12 files changed
+1004 -40

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.RoilingTextBlock"
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:SunlightCentralizedControlManagement_SCCM_.View"
mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
d:DesignWidth="300" Height="30" >
<UserControl.Template>
<ControlTemplate TargetType="UserControl">
<Border BorderBrush="White"
BorderThickness="1"
Padding="2"
Background="White">
<Canvas x:Name="innerCanvas"
Width="Auto"
Height="Auto"
Background="White"
ClipToBounds="True">
<TextBlock x:Name="textBlock"
Width="Auto"
Height="Auto"
ClipToBounds="True"
TextAlignment="Center"
Canvas.Left="{Binding Left,Mode=TwoWay}"
Canvas.Top="{Binding Top,Mode=TwoWay}"
FontSize="{Binding FontSize,Mode=TwoWay}"
Text="{Binding Text,Mode=TwoWay}"
Foreground="{Binding Foreground,Mode=TwoWay}"/>
</Canvas>
</Border>
</ControlTemplate>
</UserControl.Template>
</UserControl>
+126
View File
@@ -0,0 +1,126 @@
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 System.Windows.Threading;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
/// <summary>
/// RoilingTextBlock.xaml 的交互逻辑
/// </summary>
public partial class RoilingTextBlock : UserControl
{
private bool canRoll = false;
private readonly double rollingInterval = 0.5;//每一步的偏移量
private double offset=6;//最大的偏移量
private TextBlock currentTextBlock = null;
private DispatcherTimer currentTimer = null;
public RoilingTextBlock()
{
InitializeComponent();
Loaded += RoilingTextBlock_Loaded;
}
void RoilingTextBlock_Loaded(object sender, RoutedEventArgs e)
{
if (this.currentTextBlock != null)
{
canRoll = this.currentTextBlock.ActualWidth > this.ActualWidth;
}
currentTimer = new System.Windows.Threading.DispatcherTimer();
currentTimer.Interval = TimeSpan.FromMilliseconds(100);
currentTimer.Tick += new EventHandler(currentTimer_Tick);
currentTimer.Start();
}
public override void OnApplyTemplate()
{
try
{
base.OnApplyTemplate();
currentTextBlock = this.GetTemplateChild("textBlock") as TextBlock;
}
catch (Exception)
{
}
}
void currentTimer_Tick(object sender, EventArgs e)
{
if (this.currentTextBlock != null && canRoll)
{
if (Math.Abs(Left) <= this.currentTextBlock.ActualWidth-offset)
{
Left-=rollingInterval;
}
else
{
Left = this.ActualHeight;
}
}
}
#region Dependency Properties
public static DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(RoilingTextBlock),
new PropertyMetadata(""));
public static new DependencyProperty FontSizeProperty =
DependencyProperty.Register("FontSize", typeof(double), typeof(RoilingTextBlock),
new PropertyMetadata(14D));
public static new readonly DependencyProperty ForegroundProperty =
DependencyProperty.Register("Foreground", typeof(Brush), typeof(RoilingTextBlock), new FrameworkPropertyMetadata(Brushes.Green));
public static DependencyProperty LeftProperty =
DependencyProperty.Register("Left", typeof(double), typeof(RoilingTextBlock), new PropertyMetadata(0D));
public static DependencyProperty TopProperty =
DependencyProperty.Register("Top", typeof(double), typeof(RoilingTextBlock), new PropertyMetadata(0D));
#endregion
#region Public Variables
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public new double FontSize
{
get { return (double)GetValue(FontSizeProperty); }
set { SetValue(FontSizeProperty, value); }
}
public new Brush Foreground
{
get { return (Brush)GetValue(ForegroundProperty); }
set { SetValue(ForegroundProperty, value); }
}
public double Left
{
get { return (double)GetValue(LeftProperty); }
set { SetValue(LeftProperty, value); }
}
public double Top
{
get { return (double)GetValue(TopProperty); }
set { SetValue(TopProperty, value); }
}
#endregion
}
}
+85 -23
View File
@@ -1,5 +1,8 @@
using System;
using DyeingComputer.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -12,7 +15,8 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
/// <summary>
@@ -24,36 +28,94 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
InitializeComponent();
}
View.info[] inf = new View.info[999]; //定义总览信息卡
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
TextBox textBox = new TextBox();
textBox.Text = "12431414";
// textBox.HorizontalAlignment = HorizontalAlignment.Left;
// textBox.VerticalAlignment = VerticalAlignment.Top;
textBox.Background =new SolidColorBrush( Color.FromRgb(100,100,100));
textBox.Width = 100;
textBox.Height = 200;
textBox.Margin = new Thickness( 5,5,0,0);
WholeView.Children.Add(textBox);
View.info[] inf = new View.info[60];
for (int i=1; i<50; i++)
/// <summary>
/// 生成总览信息卡
/// </summary>
//View.info[] inf = new View.info[999];
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
{
inf[i] = new View.info();
inf[i].Margin = new Thickness(5, 5, 0, 5);
inf[i].Width = 300;
inf[i].Height = 400;
inf[i].name.Text = i.ToString();
inf[i].temp.Text = "123c";
inf[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name",i.ToString()).ToString();
string State_ = Selet_Machines(MainWindowViewModel.Machines, "State", i.ToString()).ToString();
if (State_ == "101")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(100, 100, 100)); }
else if (State_ == "201")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
else if (State_ == "202")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)); }
else
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); }
inf[i].temp.Text = (Selet_Machines(MainWindowViewModel.Machines, "Temperature", i.ToString()) + "°C").ToString();
inf[i].Process.Text = Selet_Machines(MainWindowViewModel.Machines, "Process", i.ToString()).ToString();
inf[i].Step.Text = Selet_Machines(MainWindowViewModel.Machines, "Step", i.ToString()).ToString();
inf[i].Message.Text = Selet_Machines(MainWindowViewModel.Machines, "Message", i.ToString()).ToString();
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "Orders", i.ToString()).ToString();
inf[i].time.Text = Selet_Machines(MainWindowViewModel.Machines, "time", i.ToString()).ToString();
WholeView.Children.Add(inf[i]);
}
CountDown();
}
public static object Selet_Machines(DataTable DB,string name ,string key)//查询
{
try
{
lock (DB)
{
DataRow drEmployee = DB.Select("ID=" + key).First();;
object index = drEmployee.Field<object>(name);
return index;
}
}
catch (Exception)
{
// LogGing.LogGingDATA("SDTD:" + ex.ToString());
return "ERR";
}
}
private void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(1)//秒
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
}//时间周期初始化
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
{
string State_ = Selet_Machines(MainWindowViewModel.Machines, "State", i.ToString()).ToString();
if (State_ == "101")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(100, 100, 100)); }
else if (State_ == "201")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
else if (State_ == "202")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)); }
else
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); }
inf[i].temp.Text = (Selet_Machines(MainWindowViewModel.Machines, "Temperature", i.ToString()) + "°C").ToString();
inf[i].Process.Text = Selet_Machines(MainWindowViewModel.Machines, "Process", i.ToString()).ToString();
inf[i].Step.Text = Selet_Machines(MainWindowViewModel.Machines, "Step", i.ToString()).ToString();
inf[i].Message.Text = Selet_Machines(MainWindowViewModel.Machines, "Message", i.ToString()).ToString();
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "Orders", i.ToString()).ToString();
inf[i].time.Text = Selet_Machines(MainWindowViewModel.Machines, "time", i.ToString()).ToString();
}
}
}
}
+10 -11
View File
@@ -3,22 +3,21 @@
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:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Background="White">
<Grid>
<TextBlock x:Name="name" VerticalAlignment="Top" Height="50" Background="Red" Text="Machine" FontWeight="Bold" FontSize="36" />
<TextBlock x:Name="temp" VerticalAlignment="Top" Height="50" Text="000.0°C" FontWeight="Bold" FontSize="36" HorizontalAlignment="Right" Padding="5,0,5,0"/>
<TextBlock x:Name="name" VerticalAlignment="Top" Height="50" Background="#FF646464" Text="-----" FontWeight="Bold" FontSize="36" />
<TextBlock x:Name="temp" VerticalAlignment="Top" Height="50" Text="---.-°C" FontWeight="Bold" FontSize="36" HorizontalAlignment="Right" Padding="5,0,5,0"/>
<TextBlock Text="{x:Static lang:Resources.process}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,50,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="Process" Text="NO Information" Height="30" FontWeight="Bold" FontSize="24" Margin="120,50,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.Step}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,100,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="Step" Text="NO Information" Height="30" FontWeight="Bold" FontSize="24" Margin="120,100,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.message}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,150,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="Message" Text="NO Information" Height="30" FontWeight="Bold" FontSize="24" Margin="120,150,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.orders}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,200,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="Orders" Text="NO Information" Height="30" FontWeight="Bold" FontSize="24" Margin="120,200,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="time" Text="" Height="30" FontWeight="Bold" FontSize="24" Margin="5,250,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.orders}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,200,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="time" Text="----------------------------" Height="30" FontWeight="Bold" FontSize="24" Margin="5,250,5,0" VerticalAlignment="Top" Focusable="False"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Process" Text="NO Information" FontSize="21" Height="30" Margin="120,50,0,0" VerticalAlignment="Top"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Step" Text="NO Information" FontSize="21" Height="30" Margin="120,100,0,0" VerticalAlignment="Top"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Message" Text="NO Information" FontSize="21" Height="30" Margin="120,150,0,0" VerticalAlignment="Top"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Orders" Text="NO Information" FontSize="21" Height="30" Margin="120,200,0,0" VerticalAlignment="Top"/>
</Grid>
</UserControl>
+23 -3
View File
@@ -1,5 +1,7 @@
using System;
using ScottPlot.Plottables;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,9 +11,12 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
@@ -23,7 +28,22 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public info()
{
InitializeComponent();
CountDown();
}
}
private void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(10)//秒
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
}//时间周期初始化
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
}
}
}