示例#1
0
        public static string GetIconImg(string type, string theme)
        {
            var iconImg = IconStore.GetIcon(type, theme);

            if (string.IsNullOrEmpty(iconImg))
            {
                return(null);
            }

            return(iconImg);
        }
        /// <inheritdoc/>
        protected override void AddAccessPointsInternal(AppEntry appEntry, Feed feed, IEnumerable <AccessPoint> accessPoints)
        {
            #region Sanity checks
            if (appEntry == null)
            {
                throw new ArgumentNullException(nameof(appEntry));
            }
            if (feed == null)
            {
                throw new ArgumentNullException(nameof(feed));
            }
            if (accessPoints == null)
            {
                throw new ArgumentNullException(nameof(accessPoints));
            }
            if (appEntry.AccessPoints != null && ReferenceEquals(appEntry.AccessPoints.Entries, accessPoints))
            {
                throw new ArgumentException("Must not be equal to appEntry.AccessPoints.Entries", nameof(accessPoints));
            }
            #endregion

            // Skip entries with mismatching hostname
            if (appEntry.Hostname != null && !Regex.IsMatch(Environment.MachineName, appEntry.Hostname))
            {
                return;
            }

            appEntry.AccessPoints ??= new AccessPointList();

            AppList.CheckForConflicts(accessPoints, appEntry);

            var iconStore = new IconStore(Config, Handler, GetDir(MachineWide, "icons"));

            accessPoints.ApplyWithRollback(
                accessPoint => accessPoint.Apply(appEntry, feed, iconStore, MachineWide),
                accessPoint =>
            {
                // Don't perform rollback if the access point was already applied previously and this was only a refresh
                if (!appEntry.AccessPoints.Entries.Contains(accessPoint))
                {
                    accessPoint.Unapply(appEntry, MachineWide);
                }
            });

            appEntry.AccessPoints.Entries.RemoveRange(accessPoints); // Replace pre-existing entries
            appEntry.AccessPoints.Entries.AddRange(accessPoints);
            appEntry.Timestamp = DateTime.UtcNow;
        }
示例#3
0
    /// <summary>
    /// Exports all specified icons.
    /// </summary>
    /// <param name="icons">The icons to export.</param>
    /// <param name="iconStore">The icon store to export the icons from.</param>
    /// <exception cref="OperationCanceledException">The user canceled the task.</exception>
    /// <exception cref="IOException">A problem occurred while reading or writing a file.</exception>
    /// <exception cref="UnauthorizedAccessException">Read or access to a file is not permitted.</exception>
    /// <exception cref="WebException">A problem occurred while downloading icons.</exception>
    public void ExportIcons(IEnumerable <Icon> icons, IIconStore iconStore)
    {
        #region Sanity checks
        if (icons == null)
        {
            throw new ArgumentNullException(nameof(icons));
        }
        if (iconStore == null)
        {
            throw new ArgumentNullException(nameof(iconStore));
        }
        #endregion

        foreach (var icon in icons)
        {
            File.Copy(
                iconStore.GetFresh(icon),
                Path.Combine(_contentDir, IconStore.GetFileName(icon)),
                overwrite: true);
        }
    }
示例#4
0
        public bool IconExists(string theme = "", string type = "")
        {
            var icon = IconStore.GetIcon(type, theme);

            return(!string.IsNullOrEmpty(icon));
        }
示例#5
0
 public IDictionary <string, string[]> GetAllIcons()
 {
     return(IconStore.GetAllIconNames());
 }