Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commands.WinForms: Added feed-specific branding to progress dialog
- Loading branch information
1 parent
e672e6c
commit 14df6dc
Showing
3 changed files
with
62 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright Bastian Eicher et al. | ||
// Licensed under the GNU Lesser Public License | ||
|
||
using System.Windows.Forms; | ||
using NanoByte.Common; | ||
using NanoByte.Common.Storage; | ||
using NanoByte.Common.Tasks; | ||
using ZeroInstall.Commands.Properties; | ||
using ZeroInstall.DesktopIntegration; | ||
using ZeroInstall.Model; | ||
using ZeroInstall.Store.Configuration; | ||
using ZeroInstall.Store.Feeds; | ||
using ZeroInstall.Store.Icons; | ||
using ZeroInstall.Store.Trust; | ||
|
||
namespace ZeroInstall.Commands.WinForms | ||
{ | ||
/// <summary> | ||
/// Feed-specific visual branding information. | ||
/// </summary> | ||
public class FeedBranding | ||
{ | ||
/// <summary> | ||
/// The title of the window. | ||
/// </summary> | ||
public string Title { get; } | ||
|
||
/// <summary> | ||
/// The title of the window. | ||
/// </summary> | ||
public System.Drawing.Icon Icon { get; } | ||
|
||
/// <summary> | ||
/// Loads visual branding information for a specific <paramref name="feedUri"/> or falls back to defaults. | ||
/// </summary> | ||
public FeedBranding(FeedUri? feedUri) | ||
{ | ||
var feed = feedUri?.To(FeedCaches.Default(OpenPgp.Verifying()).GetFeed); | ||
|
||
Icon = feed | ||
?.Icons.GetIcon(ZeroInstall.Model.Icon.MimeTypeIco) | ||
?.To(IconStores.DesktopIntegration(Config.LoadSafe(), new SilentTaskHandler(), machineWide: false).GetCached) | ||
?.To(path => new System.Drawing.Icon(path)) | ||
?? System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath)!; | ||
|
||
Title = feed?.To(x => $"{x.Name} (Zero Install)") | ||
?? "Zero Install"; | ||
if (Locations.IsPortable) Title += @" - " + Resources.PortableMode; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters