Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build SDUI

on:
pull_request:

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Restore NuGet packages
uses: nuget/setup-nuget@v1
with:
nuget-version: "5.x"

- name: Restore solution
run: nuget restore SDUI.sln

- name: Build solution
run: msbuild SDUI.sln /p:Configuration=Release
115 changes: 0 additions & 115 deletions .github/workflows/dotnet-desktop.yml

This file was deleted.

46 changes: 28 additions & 18 deletions SDUI/AnimationEngine/AnimationManager.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System;
using System.Windows.Forms;
using SDUI.AnimationEngine;
using SDUI.Helpers;

namespace SDUI.Animation
{
/// <summary>
/// Modern, optimize edilmi� animation manager - ValueProvider tabanl�
/// Modern, optimize edilmiş animation manager - ValueProvider tabanlı
/// </summary>
public class AnimationEngine : IDisposable
{
private readonly ValueProvider<double> _valueProvider;
private Timer _timer; // Lazy initialization i�in readonly kald�r�ld�
private Timer _timer; // Lazy initialization için readonly kaldırıldı
private bool _isRunning;
private bool _disposed;
private System.Drawing.Point _animationSource;
Expand All @@ -35,28 +36,28 @@ public AnimationEngine(bool singular = true)
AnimationType = AnimationType.EaseInOut;

_valueProvider = new ValueProvider<double>(0, ValueFactories.DoubleFactory, EasingMethods.DefaultEase);
// Timer' lazy initialization ile olu�tur - handle sorununu ��zer

// Timer'ı lazy initialization ile oluştur - handle sorununu çözer
// _timer = new Timer { Interval = 16 }; // BU SATIR KALDIRILDI
// _timer.Tick += OnTick; // BU SATIR KALDIRILDI
}

public bool Running => _isRunning;
// Lazy initialization - Timer sadece gerekti�inde olu�turulur

// Lazy initialization - Timer sadece gerektiğinde oluturulur
private void EnsureTimer()
{
if (_timer != null) return;

try
{
_timer = new Timer { Interval = 16 }; // ~60 FPS
_timer.Tick += OnTick;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"AnimationManager: Timer olu�turulamad� - {ex.Message}");
// Timer olu�turulamazsa animasyon devre d��� b�rak�l�r
System.Diagnostics.Debug.WriteLine($"AnimationManager: Timer oluturulamad - {ex.Message}");
// Timer oluşturulamazsa animasyon devre dışı bırakılır
_timer = null;
}
}
Expand All @@ -78,6 +79,15 @@ public void StartNewAnimation(AnimationDirection direction, object[] data)

public void StartNewAnimation(AnimationDirection direction, System.Drawing.Point source, object[] data)
{
if (!SystemAnimations.AreAnimationsEnabled)
{
var instantTarget = direction == AnimationDirection.In || direction == AnimationDirection.InOutIn ? 1.0 : 0.0;
SetProgress(instantTarget);
OnAnimationProgress?.Invoke(this);
OnAnimationFinished?.Invoke(this);
return;
}

if (_isRunning && !InterruptAnimation)
return;

Expand All @@ -91,12 +101,12 @@ public void StartNewAnimation(AnimationDirection direction, System.Drawing.Point
double duration = Math.Abs(target - _valueProvider.CurrentValue) / currentIncrement * 16; // milliseconds

_valueProvider.StartTransition(_valueProvider.CurrentValue, target, TimeSpan.FromMilliseconds(Math.Max(16, duration)));

_isRunning = true;
// Timer' lazy initialization ile olu�tur

// Timer'ı lazy initialization ile oluştur
EnsureTimer();

if (_timer != null && !_timer.Enabled)
_timer.Start();
}
Expand Down Expand Up @@ -176,7 +186,7 @@ private void OnTick(object sender, EventArgs e)
_timer.Stop();
OnAnimationFinished?.Invoke(this);
}

OnAnimationProgress?.Invoke(this);
}

Expand All @@ -201,16 +211,16 @@ private void UpdateEasingMethod()
public void Dispose()
{
if (_disposed) return;

if (_timer != null)
{
_timer.Stop();
_timer.Tick -= OnTick; // Event handler'� kald�r
_timer.Tick -= OnTick; // Event handler'ı kaldır
_timer.Dispose();
_timer = null;
}

_disposed = true;
}
}
}
}
67 changes: 34 additions & 33 deletions SDUI/Controls/UIWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public enum TabDesingMode
/// </summary>
private bool _formMoveMouseDown;

/// <summary>
/// Determines whether the user is dragging the form
/// </summary>
private bool _isDragging;

/// <summary>
/// The starting point of the drag
/// </summary>
private Point _dragStartPoint;

/// <summary>
/// The position of the form when the left mouse button is pressed
/// </summary>
Expand Down Expand Up @@ -699,6 +709,9 @@ protected override void OnMouseClick(MouseEventArgs e)
if (!ShowTitle)
return;

if (_isDragging)
return;

if (_inCloseBox)
{
_inCloseBox = false;
Expand Down Expand Up @@ -760,9 +773,6 @@ protected override void OnMouseClick(MouseEventArgs e)
if (pageRect == null)
UpdateTabRects();

if (_formMoveMouseDown && !MousePosition.Equals(_mouseOffset))
return;

for (int i = 0; i < pageRect.Count; i++)
{
if (pageRect[i].Contains(e.Location))
Expand Down Expand Up @@ -793,6 +803,7 @@ protected override void OnMouseDown(MouseEventArgs e)
if (e.Button == MouseButtons.Left && Movable)
{
_formMoveMouseDown = true;
_dragStartPoint = e.Location;
_location = Location;
_mouseOffset = MousePosition;
}
Expand Down Expand Up @@ -852,46 +863,25 @@ protected override void OnMouseUp(MouseEventArgs e)
IsStayAtTopBorder = false;
Cursor.Clip = new Rectangle();
_formMoveMouseDown = false;
_isDragging = false;

animationSource = e.Location;
}

protected override void OnMouseMove(MouseEventArgs e)
{
if (_formMoveMouseDown && !MousePosition.Equals(_mouseOffset))
if (_formMoveMouseDown)
{
if (WindowState == FormWindowState.Maximized)
{
int maximizedWidth = Width;
int locationX = Left;
ShowMaximize();

float offsetXRatio = 1 - (float)Width / maximizedWidth;
_mouseOffset.X -= (int)((_mouseOffset.X - locationX) * offsetXRatio);
}

var offsetX = _mouseOffset.X - MousePosition.X;
var offsetY = _mouseOffset.Y - MousePosition.Y;
var _workingArea = Screen.GetWorkingArea(this);

// If the current mouse stays on the upper edge of the container, it will trigger an edge wait for MaximumBorderInterval(ms),
// If the movement ends at this time, the window will be automatically maximized, this function is provided for multiple monitors arranged up and down
// The advantage of setting the judgment to a specific value here is that it is difficult to trigger the stay event if the form is quickly moved across the monitor
if (MousePosition.Y - _workingArea.Top == 0)
if (!_isDragging)
{
if (!IsStayAtTopBorder)
var dragRect = new Rectangle(_dragStartPoint, Size.Empty);
dragRect.Inflate(SystemInformation.DragSize);
if (!dragRect.Contains(e.Location))
{
Cursor.Clip = _workingArea;
TopBorderStayTicks = DateTime.Now.Ticks;
IsStayAtTopBorder = true;
}
else if (DateTime.Now.Ticks - TopBorderStayTicks > _stickyBorderTime)
{
Cursor.Clip = new Rectangle();
_isDragging = true;
PostDragForm(Handle);
}
}

Location = new Point(_location.X - offsetX, _location.Y - offsetY);
}
else
{
Expand Down Expand Up @@ -985,6 +975,17 @@ protected override void OnMouseMove(MouseEventArgs e)
base.OnMouseMove(e);
}

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

if (m.Msg == NativeMethods.WM_EXITSIZEMOVE)
{
_formMoveMouseDown = false;
_isDragging = false;
}
}

protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
Expand Down Expand Up @@ -1401,7 +1402,7 @@ private void DrawControlBoxButtons(Graphics g, Color foreColor)
{
// Cache hover colors
var closeHoverColor = Color.FromArgb(222, 179, 30, 30);

if (_inCloseBox)
{
var alpha = (int)(closeBoxHoverAnimationManager.GetProgress() * closeHoverColor.A);
Expand Down
Loading