Example #1
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();
        }
Example #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;
        }
Example #3
0
        public IconManager(HttpClient httpClient, IIconCache cache, IconOptions options)
        {
            options.ThrowIfNull();

            _httpClient = httpClient;
            _cache      = cache;
            _options    = options;
        }
 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;
 }
Example #5
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);
 }
        /// <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;
        }
Example #7
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;
        }
Example #8
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();
        }
Example #9
0
        public ExhibitCard(string name)
        {
            _iconCache = DependencyService.Get <IIconCache>();

            _mainLayout = new Grid
            {
                RowSpacing = 4,
                Padding    = new Thickness(16, 8),

                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(5, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                },
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = 44
                    }
                },

                BackgroundColor = Color.Transparent
            };

            _name = new Label
            {
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Start,
                VerticalTextAlignment   = Xamarin.Forms.TextAlignment.Center,
                FontSize       = 18,
                TextColor      = Colors.NearWhite,
                FontAttributes = FontAttributes.Bold,
                LineBreakMode  = LineBreakMode.NoWrap,
                Text           = name
            };

            _percentCompleteChart = new DonutChart
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                ProgressColor           = Colors.NearWhite,
                ProgressBackgroundColor = Colors.LightBlue,
                StartingDegree          = 0d,
                EndingDegree            = 0d,
                RingThickness           = 8d,
                Opacity = 0d
            };

            _percentComplete = new Label
            {
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                VerticalTextAlignment   = Xamarin.Forms.TextAlignment.Center,
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Center,
                FontSize     = 12d,
                TextColor    = Colors.NearWhite,
                Opacity      = 0,
                TranslationX = 2
            };

            _syncStatusIcon = new Image
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Source            = _iconCache.FileImageSourceFromSvg("ok.svg", 42d, colorOverride: Colors.NearWhite).AsAsyncFileImageSource()
            };

            _mainLayout.Children.Add(_name, 0, 0);
            _mainLayout.Children.Add(_percentCompleteChart, 2, 0);
            _mainLayout.Children.Add(_percentComplete, 2, 0);
            _mainLayout.Children.Add(_syncStatusIcon, 2, 0);

            _cardViewLayout = new CardViewLayout
            {
                Margin          = new Thickness(8, 0d),
                CornerRadius    = 18d,
                BackgroundColor = Colors.Blue,
                Content         = _mainLayout
            };

            Content = _cardViewLayout;

            _cardViewLayout.GestureRecognizers.Add(TapGestureRecognizer);

            ClearDonut();
            AnimateDonut();
        }
Example #10
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);
        }
Example #11
0
 public static bool Layout(IIconCache icon, float iconSize, Color failColor, char failLetter = ' ', string tooltip = "")
 {
     return(Layout(icon.Texture, iconSize, failColor, failLetter, tooltip));
 }
Example #12
0
 public static bool Layout(IIconCache icon, float iconSize, char failLetter = ' ', string tooltip = "")
 {
     return(Layout(icon, iconSize, DEFAULT_FAIL_COLOR, failLetter, tooltip));
 }
Example #13
0
 public static bool Layout(IIconCache icon, char failLetter = ' ', string tooltip = "")
 {
     return(Layout(icon, EditorGUIUtility.singleLineHeight, DEFAULT_FAIL_COLOR, failLetter, tooltip));
 }