Example #1
0
        public static DrawingBrush GetDrawingForIcon(Octicon icon, Brush colorBrush, string theme = null)
        {
            string name = icon.ToString();

            if (theme != null)
            {
                name += "_" + theme;
            }
            if (drawingBrushes.ContainsKey(name))
            {
                return(drawingBrushes[name]);
            }

            var brush = new DrawingBrush()
            {
                Drawing = new GeometryDrawing()
                {
                    Brush    = colorBrush,
                    Geometry = OcticonPath.GetGeometryForIcon(icon).FreezeThis()
                }
                .FreezeThis(),
                Stretch = Stretch.Uniform
            }
            .FreezeThis();

            drawingBrushes.Add(name, brush);
            return(brush);
        }
Example #2
0
        static Geometry LoadGeometry(Octicon icon)
        {
            var name = Enum.GetName(typeof(Octicon), icon);

            if (name == "lock")
            {
                name = "_lock";
            }

            var pathData = OcticonPaths.ResourceManager.GetString(name);

            if (pathData == null)
            {
                throw new ArgumentException("Could not find octicon geometry for '" + name + "'");
            }

            var path = PathGeometry.CreateFromGeometry(Geometry.Parse(pathData));

            if (path.CanFreeze)
            {
                path.Freeze();
            }

            return(path);
        }
 /// <summary>
 /// Sets the <see cref="Icon"/> based on a private and fork state.
 /// </summary>
 /// <param name="isPrivate">Whether the repository is a private repository.</param>
 /// <param name="isFork">Whether the repository is a fork.</param>
 public void SetIcon(bool isPrivate, bool isFork)
 {
     Icon = isPrivate
         ? Octicon.@lock
         : isFork
             ? Octicon.repo_forked
             : Octicon.repo;
 }
Example #4
0
        public static DrawingBrush GetDrawingForIcon(Octicon icon, Color color, string theme = null)
        {
            var brush = new SolidColorBrush(color);

            brush.Freeze();

            return(GetDrawingForIcon(icon, brush, theme));
        }
        public static Geometry GetGeometryForIcon(Octicon icon)
        {
            var c = cache.Value;
            Lazy<Geometry> g;

            if (c.TryGetValue(icon, out g))
                return g.Value;

            throw new ArgumentException(
                String.Format(CultureInfo.InvariantCulture, "Unknown Octicon: {0}", icon), nameof(icon));
        }
Example #6
0
        public static Geometry GetGeometryForIcon(Octicon icon)
        {
            var             c = cache.Value;
            Lazy <Geometry> g;

            if (c.TryGetValue(icon, out g))
            {
                return(g.Value);
            }

            throw new ArgumentException(
                      String.Format(CultureInfo.InvariantCulture, "Unknown Octicon: {0}", icon), "icon");
        }
        public TeamExplorerNavigationItemBase(ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, Octicon octicon)
            : base(apiFactory, holder)
        {
            this.octicon = octicon;

            IsVisible = false;
            IsEnabled = true;

            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
            };

            holder.Subscribe(this, UpdateRepo);
        }
        public TeamExplorerNavigationItemBase(ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, Octicon octicon)
            : base(apiFactory, holder)
        {
            this.octicon = octicon;

            IsVisible = false;
            IsEnabled = true;

            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
            };

            holder.Subscribe(this, UpdateRepo);
        }
        public GiteaNavigationItem(Octicon icon, IGitService git, IShellService shell, IStorage storage, ITeamExplorerServices tes, IWebService web)
        {
            _git     = git;
            _shell   = shell;
            _storage = storage;
            _tes     = tes;
            _web     = web;
            octicon  = icon;
            var brush = new SolidColorBrush(Color.FromRgb(66, 66, 66));

            brush.Freeze();
            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
                Invalidate();
            };
        }
        public TeamExplorerNavigationItemBase(IGitHubServiceProvider serviceProvider,
                                              ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, Octicon octicon)
            : base(serviceProvider, apiFactory, holder)
        {
            this.octicon = octicon;

            IsVisible = false;
            IsEnabled = true;

            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
                Invalidate();
            };

            // Navigation items need to listen for repo change events before they're visible
            SubscribeToRepoChanges();
        }
        public GitLabNavigationItem(Octicon icon, IGitService git, IShellService shell, IStorage storage, ITeamExplorerServices tes, IWebService web)
        {
            _git     = git;
            _shell   = shell;
            _storage = storage;
            _tes     = tes;
            _web     = web;
            octicon  = icon;
            var brush = new SolidColorBrush(Color.FromRgb(66, 66, 66));

            brush.Freeze();
            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
                Invalidate();
            };
            var gitExt = ServiceProvider.GlobalProvider.GetService <Microsoft.VisualStudio.TeamFoundation.Git.Extensibility.IGitExt>();

            gitExt.PropertyChanged += GitExt_PropertyChanged;
        }
        static Geometry LoadGeometry(Octicon icon)
        {
            var name = Enum.GetName(typeof(Octicon), icon);

            if (name == "lock")
                name = "_lock";

            var pathData = OcticonPaths.ResourceManager.GetString(name);

            if (pathData == null)
            {
                throw new ArgumentException("Could not find octicon geometry for '" + name + "'");
            }

            var path = PathGeometry.CreateFromGeometry(Geometry.Parse(pathData));

            if (path.CanFreeze)
                path.Freeze();

            return path;
        }
        public TeamExplorerNavigationItemBase(IGitHubServiceProvider serviceProvider,
                                              ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, Octicon octicon)
            : base(serviceProvider, apiFactory, holder)
        {
            Guard.ArgumentNotNull(serviceProvider, nameof(serviceProvider));
            Guard.ArgumentNotNull(apiFactory, nameof(apiFactory));
            Guard.ArgumentNotNull(holder, nameof(holder));

            this.octicon = octicon;

            IsVisible = false;
            IsEnabled = true;

            OnThemeChanged();
            VSColorTheme.ThemeChanged += _ =>
            {
                OnThemeChanged();
                Invalidate();
            };

            holder.Subscribe(this, UpdateRepo);
        }
Example #14
0
        public static DrawingBrush GetDrawingForIcon(Octicon icon, Brush colorBrush, string theme = null)
        {
            string name = icon.ToString();
            if (theme != null)
                name += "_" + theme;
            if (drawingBrushes.ContainsKey(name))
                return drawingBrushes[name];

            var brush = new DrawingBrush()
            {
                Drawing = new GeometryDrawing()
                {
                    Brush = colorBrush,
                    Geometry = OcticonPath.GetGeometryForIcon(icon).FreezeThis()
                }
                .FreezeThis(),
                Stretch = Stretch.Uniform
            }
            .FreezeThis();
            drawingBrushes.Add(name, brush);
            return brush;
        }
Example #15
0
 public BigButtonElement(string name, Octicon img) : base(name, img.ToImage())
 {
 }
 /// <summary>
 /// Sets the <see cref="Icon"/> based on a private and fork state.
 /// </summary>
 /// <param name="isPrivate">Whether the repository is a private repository.</param>
 /// <param name="isFork">Whether the repository is a fork.</param>
 public void SetIcon(bool isPrivate, bool isFork)
 {
     Icon = isPrivate
         ? Octicon.@lock
         : isFork
             ? Octicon.repo_forked
             : Octicon.repo;
 }
 public static DrawingBrush GetDrawingForIcon(Octicon icon, Color color, string theme = null)
 {
     return GetDrawingForIcon(icon, new SolidColorBrush(color).FreezeThis(), theme);
 }
Example #18
0
 public static DrawingBrush GetDrawingForIcon(Octicon icon, Color color, string theme = null)
 {
     return(GetDrawingForIcon(icon, new SolidColorBrush(color).FreezeThis(), theme));
 }