Пример #1
0
 public static IIconCache GetInstance()
 {
     // Share one instance globally to prevent race-conditions
     // Thread-safe singleton with double-check
     if (_iconCache == null)
     {
         lock (_lock)
         {
             if (_iconCache == null)
                 _iconCache = new DiskIconCache(Locations.GetCacheDirPath("0install.net", false, "interface_icons"));
         }
     }
     return _iconCache;
 }
Пример #2
0
        /// <summary>
        /// Creates a new tile manager.
        /// </summary>
        /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param>
        /// <param name="catalogManager">Provides access to remote and local <see cref="Catalog"/>s. Handles downloading, signature verification and caching.</param>
        /// <param name="iconCache">The icon cache used by newly created <see cref="IAppTile"/>s to retrieve application icons.</param>
        /// <param name="tileListMyApps">The <see cref="IAppTileList"/> used to represent the "my apps" <see cref="AppList"/>.</param>
        /// <param name="tileListCatalog">The <see cref="IAppTileList"/> used to represent the merged <see cref="Catalog"/>.</param>
        /// <param name="machineWide">Apply operations machine-wide instead of just for the current user.</param>
        public AppTileManagement([NotNull] IFeedManager feedManager, [NotNull] ICatalogManager catalogManager, [NotNull] IIconCache iconCache, [NotNull] IAppTileList tileListMyApps, [NotNull] IAppTileList tileListCatalog, bool machineWide)
        {
            #region Sanity checks
            if (feedManager == null) throw new ArgumentNullException(nameof(feedManager));
            if (catalogManager == null) throw new ArgumentNullException(nameof(catalogManager));
            if (iconCache == null) throw new ArgumentNullException(nameof(iconCache));
            if (tileListMyApps == null) throw new ArgumentNullException(nameof(tileListMyApps));
            if (tileListCatalog == null) throw new ArgumentNullException(nameof(tileListCatalog));
            #endregion

            _feedManager = feedManager;
            _catalogManager = catalogManager;
            _iconCache = iconCache;

            _tileListMyApps = tileListMyApps;
            _tileListCatalog = tileListCatalog;
            _machineWide = machineWide;
        }
Пример #3
0
        /// <inheritdoc/>
        public IAppTile QueueNewTile(FeedUri interfaceUri, string appName, AppStatus status, IIconCache iconCache = null, bool machineWide = false)
        {
            #region Sanity checks
            if (interfaceUri == null) throw new ArgumentNullException(nameof(interfaceUri));
            if (appName == null) throw new ArgumentNullException(nameof(appName));
            if (_tileDictionary.ContainsKey(interfaceUri)) throw new InvalidOperationException("Duplicate interface URI");
            #endregion

            var tile = new AppTile(interfaceUri, appName, status, iconCache, machineWide) {Width = _flowLayout.Width};

            if (appName.ContainsIgnoreCase(TextSearch.Text))
            {
                _appTileQueueHeight += tile.Height;

                // Alternate between light and dark tiles
                tile.BackColor = _lastTileLight ? TileColorDark : TileColorLight;
                _lastTileLight = !_lastTileLight;
            }
            else tile.Visible = false;

            _appTileQueue.Add(tile);
            _tileDictionary.Add(interfaceUri, tile);
            return tile;
        }
Пример #4
0
        /// <summary>
        /// Creates a new application tile.
        /// </summary>
        /// <param name="interfaceUri">The interface URI of the application this tile represents.</param>
        /// <param name="appName">The name of the application this tile represents.</param>
        /// <param name="status">Describes whether the application is listed in the <see cref="AppList"/> and if so whether it is integrated.</param>
        /// <param name="iconCache">The icon cache used to retrieve icons specified in <see cref="Feed"/>; can be <see langword="null"/>.</param>
        /// <param name="machineWide">Apply operations machine-wide instead of just for the current user.</param>
        public AppTile([NotNull] FeedUri interfaceUri, [NotNull] string appName, AppStatus status, [CanBeNull] IIconCache iconCache = null, bool machineWide = false)
        {
            #region Sanity checks
            if (interfaceUri == null) throw new ArgumentNullException("interfaceUri");
            if (appName == null) throw new ArgumentNullException("appName");
            #endregion

            _machineWide = machineWide;

            InitializeComponent();
            buttonRun.Text = _runButtonText;
            buttonAdd.Image = _addButton;
            buttonRemove.Image = _removeButton;
            buttonIntegrate.Image = _setupButton;
            toolTip.SetToolTip(buttonAdd, _addButtonTooltip);
            toolTip.SetToolTip(buttonRemove, _removeButtonTooltip);
            buttonSelectCommand.Text = _selectCommandButton;
            buttonSelectVersion.Text = _selectVersionButton;
            buttonUpdate.Text = _updateButtonText;

            InterfaceUri = interfaceUri;
            labelName.Text = appName;
            labelSummary.Text = "";
            Status = status;

            _iconCache = iconCache;

            CreateHandle();
        }