文件结构调整
This commit is contained in:
commit
ff1bf70124
8 files changed
+18
-14
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.UserControls.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_.UserControls"
|
||||
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>
|
||||
@@ -0,0 +1,127 @@
|
||||
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_.UserControls
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.UserControls.info"
|
||||
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_.UserControls"
|
||||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="300" Background="White">
|
||||
<Grid>
|
||||
<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 Text="{x:Static lang:Resources.Step}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,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 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"/>
|
||||
<StackPanel x:Name="log" Margin="0,300,0,0"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,49 @@
|
||||
using ScottPlot.Plottables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
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.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_.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// info.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class info : UserControl
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user