mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
GUI桌面环境
This commit is contained in:
88
Gui/Apps/Calendar.cs
Normal file
88
Gui/Apps/Calendar.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using CMLeonOS;
|
||||
using CMLeonOS.Gui.UILib;
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps
|
||||
{
|
||||
internal class Calendar : Process
|
||||
{
|
||||
internal Calendar() : base("Calendar", ProcessType.Application) { }
|
||||
|
||||
AppWindow window;
|
||||
|
||||
WindowManager wm = ProcessManager.GetProcess<WindowManager>();
|
||||
|
||||
UILib.Calendar cal;
|
||||
|
||||
Button nextButton;
|
||||
|
||||
Button prevButton;
|
||||
|
||||
private void PrevClicked(int x, int y)
|
||||
{
|
||||
if (cal.Month == 1)
|
||||
{
|
||||
cal.SetCalendar(cal.Year - 1, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
cal.SetCalendar(cal.Year, cal.Month - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void NextClicked(int x, int y)
|
||||
{
|
||||
if (cal.Month == 12)
|
||||
{
|
||||
|
||||
cal.SetCalendar(cal.Year + 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cal.SetCalendar(cal.Year, cal.Month + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void WindowResized()
|
||||
{
|
||||
cal.Resize(window.Width, window.Height);
|
||||
|
||||
cal.Render();
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
window = new AppWindow(this, 320, 256, 384, 288);
|
||||
wm.AddWindow(window);
|
||||
window.Title = "Calendar";
|
||||
window.Icon = AppManager.GetAppMetadata("Calendar").Icon;
|
||||
window.CanResize = true;
|
||||
window.UserResized = WindowResized;
|
||||
window.Closing = TryStop;
|
||||
|
||||
cal = new UILib.Calendar(window, 0, 0, window.Width, window.Height);
|
||||
wm.AddWindow(cal);
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
cal.Year = now.Year;
|
||||
cal.Month = now.Month;
|
||||
|
||||
prevButton = new Button(window, 8, 8, 24, 24);
|
||||
prevButton.Text = "<";
|
||||
prevButton.OnClick = PrevClicked;
|
||||
wm.AddWindow(prevButton);
|
||||
|
||||
nextButton = new Button(window, 40, 8, 24, 24);
|
||||
nextButton.Text = ">";
|
||||
nextButton.OnClick = NextClicked;
|
||||
wm.AddWindow(nextButton);
|
||||
|
||||
wm.Update(window);
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user