static IControl CreateIconForStatus(SoftwareStatus software, IReport report) { var iconPath = "Outracks.Fuse.Icons."; var unknown = Layout.Layer(); var error = ImageFromResource(iconPath + "Plugin_Error.png"); var success = ImageFromResource(iconPath + "Plugin_Success.png"); var warning = ImageFromResource(iconPath + "Plugin_Warning.png"); return(software.Status .Select(s => { switch (s) { case InstallStatus.Unknown: return unknown; case InstallStatus.NotInstalled: return error; case InstallStatus.Installed: return success; case InstallStatus.Installing: case InstallStatus.UpdateAvailable: return warning; default: report.Error("Unknown InstallStatus " + s, ReportTo.Headquarters); return error; } }) .StartWith(unknown) .Switch()); }
static IControl CreateInstallButton(SoftwareStatus software) { return(software.Status .StartWith(InstallStatus.Unknown) .Select(s => { switch (s) { case InstallStatus.NotInstalled: return Buttons.DefaultButton("Install", cmd: Command.Enabled(software.Install)).WithWidth(100); case InstallStatus.UpdateAvailable: return Buttons.DefaultButton("Update", cmd: Command.Enabled(software.Install)).WithWidth(100); case InstallStatus.Installing: return Label.Create("Installing...", color: Theme.DefaultText, font: Theme.DefaultFont) .WithHeight(Buttons.DefaultButtonHeight); default: return Control.Empty .WithHeight(Buttons.DefaultButtonHeight); } }) .Switch()); }
static IControl CreatePluginLine(SoftwareStatus software, IReport report) { return(Layout.Dock() .Left(CreateIconForStatus(software, report) .WithWidth(25).WithHeight(25) .CenterVertically()) .Left(Spacer.Medium) .Left(Label.Create(software.Name, color: Theme.DefaultText, font: Theme.DefaultFont) .CenterVertically()) .Right(CreateInstallButton(software) .CenterVertically()) .Fill() .WithMediumPadding()); }
public SoftwareCollectionStatus(IFuse fuse) { SublimeApp = new SublimeAppStatus(fuse.Report); SublimePlugin = new SublimePluginStatus(fuse); }