-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from ItsMeSousuke/master
add MetroUI support
- Loading branch information
Showing
514 changed files
with
1,574 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
GlyphCompletionProviders/MetroUIGlyphCompletionProvider.cs
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,38 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using Microsoft.CSS.Editor.Completion; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace Glyphfriend.GlyphCompletionProviders | ||
{ | ||
[Export(typeof(ICssCompletionEntryGlyphProvider))] | ||
[Name("MetroUI Font")] | ||
class MetroUIGlyphCompletionProvider : ICssCompletionEntryGlyphProvider | ||
{ | ||
// Define a Regular Expression check for matches from this library | ||
private static Regex _regex = new Regex(@"^metro-icons(\.min)?\.css$", RegexOptions.IgnoreCase | RegexOptions.Compiled); | ||
// Store the Glyph folder related to this library | ||
private static string _lib = "MetroUI"; | ||
|
||
public ImageSource GetCompletionGlyph(string entryName, Uri sourceUri, CssNameType nameType) | ||
{ | ||
// If the source Uri for the image is null, ignore it | ||
if (sourceUri == null) { return null; } | ||
// Get the file path of the source being used | ||
string filename = Path.GetFileName(sourceUri.ToString()).Trim(); | ||
// Determine if this matches our filename | ||
if (_regex.IsMatch(filename) && GlyphfriendPackage.Glyphs.ContainsKey(_lib)) | ||
{ | ||
if (GlyphfriendPackage.Glyphs[_lib].ContainsKey(entryName)) | ||
{ | ||
return GlyphfriendPackage.Glyphs[_lib][entryName]; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.