2025-01-19 12:55:39 +03:00
|
|
|
using System;
|
2025-01-16 21:07:50 +03:00
|
|
|
using Avalonia.Controls;
|
2025-01-19 12:55:39 +03:00
|
|
|
using Avalonia.Threading;
|
2025-01-16 21:07:50 +03:00
|
|
|
using Nebula.Launcher.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace Nebula.Launcher.Views;
|
|
|
|
|
|
|
|
|
|
public partial class ServerEntryView : UserControl
|
|
|
|
|
{
|
2025-01-19 22:52:29 +03:00
|
|
|
private readonly TimeSpan _interval = TimeSpan.FromMilliseconds(25);
|
|
|
|
|
private readonly DispatcherTimer _scrollTimer;
|
|
|
|
|
private TimeSpan _currTime = TimeSpan.Zero;
|
2025-01-19 12:55:39 +03:00
|
|
|
|
2025-01-16 21:07:50 +03:00
|
|
|
public ServerEntryView()
|
|
|
|
|
{
|
2025-01-19 22:52:29 +03:00
|
|
|
_scrollTimer = new DispatcherTimer
|
|
|
|
|
{
|
|
|
|
|
Interval = _interval
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-16 21:07:50 +03:00
|
|
|
InitializeComponent();
|
2025-01-19 12:55:39 +03:00
|
|
|
StartAutoScrolling();
|
2025-01-16 21:07:50 +03:00
|
|
|
}
|
|
|
|
|
|
2025-07-02 21:32:51 +03:00
|
|
|
|
2025-01-19 12:55:39 +03:00
|
|
|
|
|
|
|
|
private void StartAutoScrolling()
|
|
|
|
|
{
|
|
|
|
|
_scrollTimer.Tick += AutoScroll;
|
|
|
|
|
_scrollTimer.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AutoScroll(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var maxOffset = AutoScrollViewer.Extent.Width - AutoScrollViewer.Viewport.Width;
|
2025-01-19 22:52:29 +03:00
|
|
|
var value = (Math.Sin(_currTime.TotalSeconds / 2) + 1) * (maxOffset / 2) ;
|
|
|
|
|
|
|
|
|
|
AutoScrollViewer.Offset = new Avalonia.Vector(value, AutoScrollViewer.Offset.Y);
|
|
|
|
|
_currTime += _interval;
|
|
|
|
|
if (_currTime > TimeSpan.FromSeconds(10000)) _currTime = TimeSpan.Zero;
|
2025-01-19 12:55:39 +03:00
|
|
|
}
|
2025-01-16 21:07:50 +03:00
|
|
|
}
|