94 lines
2.9 KiB
C#
94 lines
2.9 KiB
C#
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.Shapes;
|
|
using System.Windows.Threading;
|
|
|
|
namespace eDosStation
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for InstMessage.xaml
|
|
/// </summary>
|
|
public partial class InstMessage : Window
|
|
{
|
|
DispatcherTimer dispatcherTimer;
|
|
int UserSeconds;
|
|
public InstMessage(string Comments)
|
|
{
|
|
InitializeComponent();
|
|
AddComment(Comments);
|
|
}
|
|
|
|
public InstMessage(TextBlock tbComments)
|
|
{
|
|
InitializeComponent();
|
|
AddComment(tbComments);
|
|
}
|
|
|
|
public static Line GetFullWidthLine()
|
|
{
|
|
Line line = new Line() { Stroke = System.Windows.Media.Brushes.Blue };
|
|
Binding binding = new Binding("ActualWidth");
|
|
binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.FindAncestor, AncestorType = typeof(TextBlock) };
|
|
BindingOperations.SetBinding(line, Line.X2Property, binding);
|
|
return line;
|
|
}
|
|
|
|
private void BMsg_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void AddComment(TextBlock tbComments)
|
|
{
|
|
sComments.Children.Clear();
|
|
sComments.Children.Add(tbComments);
|
|
}
|
|
|
|
private void AddComment(string Comments)
|
|
{
|
|
TextBlock tb = new TextBlock(new Run(Comments));
|
|
tb.FontSize = 24;
|
|
tb.VerticalAlignment = VerticalAlignment.Center;
|
|
AddComment(tb);
|
|
}
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
sComments.Children.Clear();
|
|
}
|
|
|
|
private void SwitchToTask(object sender, EventArgs e)
|
|
{
|
|
if (--UserSeconds > 0 )
|
|
{
|
|
pUserSeconds.Value = UserSeconds;
|
|
}
|
|
else
|
|
{
|
|
dispatcherTimer.Stop();
|
|
dispatcherTimer.Tick -= SwitchToTask;
|
|
sComments.Children.Clear();
|
|
Close();
|
|
}
|
|
}
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
UserSeconds = 20;
|
|
pUserSeconds.Maximum = pUserSeconds.Value= UserSeconds;
|
|
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
|
|
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
|
|
dispatcherTimer.Tick += SwitchToTask;
|
|
dispatcherTimer.Start();
|
|
}
|
|
}
|
|
}
|