mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-21 19:24:00 +00:00
修复bug
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-03-23 22:09:30
|
2026-03-24 17:20:32
|
||||||
@@ -1 +1 @@
|
|||||||
9197dfb
|
78ebe0c
|
||||||
@@ -36,9 +36,7 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
private AppWindow window;
|
private AppWindow window;
|
||||||
private Window canvas;
|
private Window canvas;
|
||||||
private TextBox pathBox;
|
|
||||||
private Button openButton;
|
private Button openButton;
|
||||||
private Button loadButton;
|
|
||||||
private Button clearButton;
|
private Button clearButton;
|
||||||
|
|
||||||
private WindowManager wm = ProcessManager.GetProcess<WindowManager>();
|
private WindowManager wm = ProcessManager.GetProcess<WindowManager>();
|
||||||
@@ -63,12 +61,10 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
int y = padding;
|
int y = padding;
|
||||||
int buttonY = y;
|
int buttonY = y;
|
||||||
|
|
||||||
openButton.MoveAndResize(window.Width - (buttonWidth * 3 + padding * 3), buttonY, buttonWidth, toolbarHeight);
|
openButton.MoveAndResize(window.Width - (buttonWidth * 2 + padding * 2), buttonY, buttonWidth, toolbarHeight);
|
||||||
loadButton.MoveAndResize(window.Width - (buttonWidth * 2 + padding * 2), buttonY, buttonWidth, toolbarHeight);
|
|
||||||
clearButton.MoveAndResize(window.Width - (buttonWidth + padding), buttonY, buttonWidth, toolbarHeight);
|
clearButton.MoveAndResize(window.Width - (buttonWidth + padding), buttonY, buttonWidth, toolbarHeight);
|
||||||
|
openButton.Render();
|
||||||
int pathWidth = window.Width - (buttonWidth * 3 + padding * 5);
|
clearButton.Render();
|
||||||
pathBox.MoveAndResize(padding, y + 3, pathWidth, toolbarHeight - 6);
|
|
||||||
|
|
||||||
int canvasY = toolbarHeight + (padding * 2);
|
int canvasY = toolbarHeight + (padding * 2);
|
||||||
int canvasHeight = window.Height - canvasY - padding;
|
int canvasHeight = window.Height - canvasY - padding;
|
||||||
@@ -181,7 +177,6 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
byte[] bmpBytes = File.ReadAllBytes(sanitizedPath);
|
byte[] bmpBytes = File.ReadAllBytes(sanitizedPath);
|
||||||
currentBitmap = new Bitmap(bmpBytes);
|
currentBitmap = new Bitmap(bmpBytes);
|
||||||
currentPath = sanitizedPath;
|
currentPath = sanitizedPath;
|
||||||
pathBox.Text = sanitizedPath;
|
|
||||||
window.Title = $"Image Viewer - {Path.GetFileName(sanitizedPath)}";
|
window.Title = $"Image Viewer - {Path.GetFileName(sanitizedPath)}";
|
||||||
RenderCanvas();
|
RenderCanvas();
|
||||||
return true;
|
return true;
|
||||||
@@ -209,11 +204,6 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
fileBrowser.Show();
|
fileBrowser.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFromPath()
|
|
||||||
{
|
|
||||||
LoadImage(pathBox.Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClearImage()
|
private void ClearImage()
|
||||||
{
|
{
|
||||||
currentBitmap = null;
|
currentBitmap = null;
|
||||||
@@ -234,21 +224,11 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
window.Closing = TryStop;
|
window.Closing = TryStop;
|
||||||
wm.AddWindow(window);
|
wm.AddWindow(window);
|
||||||
|
|
||||||
pathBox = new TextBox(window, 0, 0, 1, 1);
|
|
||||||
pathBox.PlaceholderText = @"0:\path\image.bmp";
|
|
||||||
pathBox.Submitted = LoadFromPath;
|
|
||||||
wm.AddWindow(pathBox);
|
|
||||||
|
|
||||||
openButton = new Button(window, 0, 0, 1, 1);
|
openButton = new Button(window, 0, 0, 1, 1);
|
||||||
openButton.Text = "Open";
|
openButton.Text = "Open";
|
||||||
openButton.OnClick = (_, _) => OpenDialog();
|
openButton.OnClick = (_, _) => OpenDialog();
|
||||||
wm.AddWindow(openButton);
|
wm.AddWindow(openButton);
|
||||||
|
|
||||||
loadButton = new Button(window, 0, 0, 1, 1);
|
|
||||||
loadButton.Text = "Load";
|
|
||||||
loadButton.OnClick = (_, _) => LoadFromPath();
|
|
||||||
wm.AddWindow(loadButton);
|
|
||||||
|
|
||||||
clearButton = new Button(window, 0, 0, 1, 1);
|
clearButton = new Button(window, 0, 0, 1, 1);
|
||||||
clearButton.Text = "Clear";
|
clearButton.Text = "Clear";
|
||||||
clearButton.OnClick = (_, _) => ClearImage();
|
clearButton.OnClick = (_, _) => ClearImage();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using CMLeonOS.Gui;
|
using CMLeonOS.Gui;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace CMLeonOS.UILib.Animations
|
namespace CMLeonOS.UILib.Animations
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,7 @@ namespace CMLeonOS.UILib.Animations
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class Animation
|
internal abstract class Animation
|
||||||
{
|
{
|
||||||
|
internal Action Completed { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The easing type of the animation.
|
/// The easing type of the animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -80,6 +82,7 @@ namespace CMLeonOS.UILib.Animations
|
|||||||
if (Finished)
|
if (Finished)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
Completed?.Invoke();
|
||||||
}
|
}
|
||||||
}, (ulong)((1000d /* ms */ / 60d) * 1e+6d /* ms -> ns */ ), true));
|
}, (ulong)((1000d /* ms */ / 60d) * 1e+6d /* ms -> ns */ ), true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using Cosmos.System.Graphics;
|
|||||||
using CMLeonOS;
|
using CMLeonOS;
|
||||||
using CMLeonOS.Gui.ShellComponents.Dock;
|
using CMLeonOS.Gui.ShellComponents.Dock;
|
||||||
using CMLeonOS.Gui.SmoothMono;
|
using CMLeonOS.Gui.SmoothMono;
|
||||||
|
using CMLeonOS.UILib.Animations;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
Icon = defaultAppIconBitmap;
|
Icon = defaultAppIconBitmap;
|
||||||
|
|
||||||
RenderDecoration();
|
RenderDecoration();
|
||||||
|
StartOpenAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.Gui.Resources.Close.bmp")]
|
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.Gui.Resources.Close.bmp")]
|
||||||
@@ -147,18 +149,73 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
private WindowManager wm;
|
private WindowManager wm;
|
||||||
|
|
||||||
private bool maximised = false;
|
private bool maximised = false;
|
||||||
|
private bool closeAnimationRunning = false;
|
||||||
private int originalX;
|
private int originalX;
|
||||||
private int originalY;
|
private int originalY;
|
||||||
private int originalWidth;
|
private int originalWidth;
|
||||||
private int originalHeight;
|
private int originalHeight;
|
||||||
|
|
||||||
|
private void StartOpenAnimation()
|
||||||
|
{
|
||||||
|
int targetY = Y;
|
||||||
|
int offsetY = Math.Min(18, Math.Max(8, Height / 12));
|
||||||
|
|
||||||
|
Move(X, targetY + offsetY, sendWMEvent: false);
|
||||||
|
|
||||||
|
MovementAnimation animation = new MovementAnimation(this)
|
||||||
|
{
|
||||||
|
From = new Rectangle(X, Y, Width, Height),
|
||||||
|
To = new Rectangle(X, targetY, Width, Height),
|
||||||
|
Duration = 12,
|
||||||
|
EasingType = EasingType.Sine,
|
||||||
|
EasingDirection = EasingDirection.Out
|
||||||
|
};
|
||||||
|
animation.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartCloseAnimation()
|
||||||
|
{
|
||||||
|
if (closeAnimationRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeAnimationRunning = true;
|
||||||
|
|
||||||
|
int offsetY = Math.Min(18, Math.Max(8, Height / 12));
|
||||||
|
int startX = X;
|
||||||
|
int startY = Y;
|
||||||
|
int startWidth = Width;
|
||||||
|
int startHeight = Height;
|
||||||
|
|
||||||
|
MovementAnimation animation = new MovementAnimation(this)
|
||||||
|
{
|
||||||
|
From = new Rectangle(startX, startY, startWidth, startHeight),
|
||||||
|
To = new Rectangle(startX, startY + offsetY, startWidth, startHeight),
|
||||||
|
Duration = 10,
|
||||||
|
EasingType = EasingType.Sine,
|
||||||
|
EasingDirection = EasingDirection.In
|
||||||
|
};
|
||||||
|
animation.Completed = () =>
|
||||||
|
{
|
||||||
|
Closing?.Invoke();
|
||||||
|
wm.RemoveWindow(this);
|
||||||
|
closeAnimationRunning = false;
|
||||||
|
};
|
||||||
|
animation.Start();
|
||||||
|
}
|
||||||
|
|
||||||
private void DecorationClicked(int x, int y)
|
private void DecorationClicked(int x, int y)
|
||||||
{
|
{
|
||||||
|
if (closeAnimationRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (x >= Width - titlebarHeight && _canClose)
|
if (x >= Width - titlebarHeight && _canClose)
|
||||||
{
|
{
|
||||||
// Close.
|
// Close.
|
||||||
Closing?.Invoke();
|
StartCloseAnimation();
|
||||||
wm.RemoveWindow(this);
|
|
||||||
}
|
}
|
||||||
else if (x >= Width - (titlebarHeight * (_canClose ? 2 : 1)) && _canResize)
|
else if (x >= Width - (titlebarHeight * (_canClose ? 2 : 1)) && _canResize)
|
||||||
{
|
{
|
||||||
@@ -218,6 +275,7 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
buttonSpace += titlebarHeight;
|
buttonSpace += titlebarHeight;
|
||||||
}
|
}
|
||||||
if (x >= Width - buttonSpace || maximised || !_canMove) return;
|
if (x >= Width - buttonSpace || maximised || !_canMove) return;
|
||||||
|
if (closeAnimationRunning) return;
|
||||||
|
|
||||||
uint startMouseX = MouseManager.X;
|
uint startMouseX = MouseManager.X;
|
||||||
uint startMouseY = MouseManager.Y;
|
uint startMouseY = MouseManager.Y;
|
||||||
|
|||||||
Reference in New Issue
Block a user