You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WPF_Practice/PacticeSolution/BlurText/MainWindow.xaml.cs

53 lines
1.3 KiB

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
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 BlurText
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private readonly int _width = 150;
private Timer _timer;
public MainWindow()
{
InitializeComponent();
_timer = new Timer();
_timer.Interval = 10;
_timer.Elapsed += _timer_Elapsed;
_timer.Start();
}
private int _tmpLeftMargin;
private void _timer_Elapsed(object? sender, ElapsedEventArgs e)
{
_tmpLeftMargin++;
if (_tmpLeftMargin >= 150)
_tmpLeftMargin = -1 * _width;
Dispatcher.Invoke(DispatcherPriority.Normal, () =>
{
tbMain.Margin = new Thickness(_tmpLeftMargin, 0, 0, 0);
});
}
}
}