71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Eto.Drawing;
|
|
using Eto.Forms;
|
|
using UpToolLib.DataStructures;
|
|
using UpToolLib.v1.Tool;
|
|
using UpToolLib.v2;
|
|
using UpToolLib.v2.TaskQueue;
|
|
|
|
namespace UpToolEto.Controls
|
|
{
|
|
public class AppPanel : Panel
|
|
{
|
|
private readonly Button _appNameLabel;
|
|
private readonly Label _appDescriptionLabel;
|
|
private readonly AppControls _appControls;
|
|
private App _app;
|
|
public AppPanel(TaskFactory factory, AppExtras extras, IList<AppTask> tasks, IExternalFunctionality platform, Action updateAppList)
|
|
{
|
|
_appDescriptionLabel = new Label();
|
|
_appNameLabel = new Button((_, _) =>
|
|
{
|
|
try
|
|
{
|
|
extras.RunApp(_app);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
platform.OkDialog("Failed to start\r\n" + e);
|
|
}
|
|
});
|
|
_appNameLabel.Font = new Font(_appNameLabel.Font.Family, _appNameLabel.Font.Size * 2);
|
|
_appControls = new AppControls(factory, tasks, platform, () =>
|
|
{
|
|
updateAppList();
|
|
SetApp(_app);
|
|
});
|
|
Content = new StackLayout
|
|
{
|
|
Items =
|
|
{
|
|
new StackLayoutItem(_appNameLabel, HorizontalAlignment.Center),
|
|
new StackLayoutItem(_appDescriptionLabel, HorizontalAlignment.Center, true),
|
|
new StackLayoutItem(_appControls, HorizontalAlignment.Stretch)
|
|
},
|
|
Orientation = Orientation.Vertical
|
|
};
|
|
if (Main.DebugColors)
|
|
BackgroundColor = Colors.Red;
|
|
Clear();
|
|
}
|
|
|
|
public void SetApp(App app)
|
|
{
|
|
_app = app;
|
|
_appNameLabel.Text = app.Name;
|
|
_appNameLabel.Enabled = app.Status.Contains(Status.Installed) && app.Runnable;
|
|
_appDescriptionLabel.Text = app.Description;
|
|
_appControls.SetApp(app);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
_appNameLabel.Text = "Welcome to UpTool2";
|
|
_appNameLabel.Enabled = false;
|
|
_appDescriptionLabel.Text = "Select an app to get started";
|
|
_appControls.Clear();
|
|
}
|
|
}
|
|
}
|