2023-06-29 09:42:02 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2023-07-28 21:37:49 +02:00
|
|
|
using Quik.CommandMachine;
|
|
|
|
using Quik.Controls;
|
|
|
|
using Quik.Media;
|
|
|
|
using Quik.PAL;
|
2023-06-29 09:42:02 +02:00
|
|
|
|
|
|
|
namespace Quik
|
|
|
|
{
|
2023-07-28 21:37:49 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Main class for Quik applications.
|
|
|
|
/// </summary>
|
2023-06-29 09:42:02 +02:00
|
|
|
public class QuikApplication
|
|
|
|
{
|
2023-07-28 21:37:49 +02:00
|
|
|
/// <summary>
|
|
|
|
/// The application platform driver.
|
|
|
|
/// </summary>
|
|
|
|
public IQuikPlatform Platform { get; }
|
2023-06-29 09:42:02 +02:00
|
|
|
|
2023-07-28 21:37:49 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Title of the application.
|
|
|
|
/// </summary>
|
|
|
|
public string Title
|
|
|
|
{
|
|
|
|
get => Platform.Title;
|
|
|
|
set => Platform.Title = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Application icon.
|
|
|
|
/// </summary>
|
|
|
|
public QImage Icon
|
|
|
|
{
|
|
|
|
get => Platform.Icon;
|
|
|
|
set => Platform.Icon = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public View MainView { get; private set; } = null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// List of media loaders, drivers that load media such as images and fonts.
|
|
|
|
/// </summary>
|
|
|
|
public List<MediaLoader> MediaLoaders { get; } = new List<MediaLoader>();
|
|
|
|
|
|
|
|
public QuikApplication(IQuikPlatform platform)
|
|
|
|
{
|
|
|
|
Platform = platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Run(View mainView)
|
|
|
|
{
|
|
|
|
IQuikPort port = Platform.CreatePort();
|
2024-04-08 22:50:05 +02:00
|
|
|
CommandList cmd = new CommandList();
|
2023-07-28 21:37:49 +02:00
|
|
|
|
|
|
|
MainView = mainView;
|
|
|
|
|
|
|
|
port.EventRaised += (sender, ea) => mainView.NotifyEvent(sender, ea);
|
|
|
|
|
|
|
|
while (port.IsValid)
|
|
|
|
{
|
|
|
|
Platform.ProcessEvents(false);
|
|
|
|
if (port.IsValid)
|
|
|
|
{
|
2024-04-08 22:50:05 +02:00
|
|
|
cmd.Clear();
|
2023-07-28 21:37:49 +02:00
|
|
|
MainView.Paint(cmd);
|
|
|
|
port.Paint(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 09:42:02 +02:00
|
|
|
}
|
|
|
|
}
|