mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-01 22:26:14 +08:00
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using CRSim.Core.Abstractions;
|
|
using CRSim.ScreenSimulator.Converters;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
|
|
namespace CRSim.ScreenSimulator.Views
|
|
{
|
|
public partial class SimulatorWindow : Window
|
|
{
|
|
private readonly ITimeService _timeService;
|
|
|
|
public SimulatorWindow(Page page,ITimeService timeService)
|
|
{
|
|
InitializeComponent();
|
|
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
|
|
contentFrame.Content = page;
|
|
_timeService = timeService;
|
|
foreach (var resource in page.Resources.Values)
|
|
{
|
|
if (resource is IHasTimeService needsTime)
|
|
{
|
|
needsTime.TimeService = timeService;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (e.ChangedButton == MouseButton.Left) DragMove();
|
|
}
|
|
|
|
private void DecreaseSpeed(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (_timeService.Speed > 0.25 && _timeService.Speed <= 1024)
|
|
{
|
|
_timeService.Speed /= 2;
|
|
SpeedText.Text = _timeService.Speed.ToString() + "x";
|
|
}
|
|
else
|
|
{
|
|
if (_timeService.Speed == 0.25)
|
|
{
|
|
_timeService.Speed = -1;
|
|
SpeedText.Text = _timeService.Speed.ToString() + "x";
|
|
}
|
|
}
|
|
}
|
|
private void IncreaseSpeed(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (_timeService.Speed >= 0.25 && _timeService.Speed < 1024)
|
|
{
|
|
_timeService.Speed *= 2;
|
|
SpeedText.Text = _timeService.Speed.ToString() + "x";
|
|
}
|
|
if (_timeService.Speed == -1)
|
|
{
|
|
_timeService.Speed = 0.25;
|
|
SpeedText.Text = _timeService.Speed.ToString() + "x";
|
|
}
|
|
}
|
|
|
|
private void Close(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}
|