Skip to content

Commit 95a6a47

Browse files
committed
download material design icons.
1 parent ee90a8f commit 95a6a47

File tree

8 files changed

+123
-0
lines changed

8 files changed

+123
-0
lines changed

MaterialDesignThemes.Wpf/Icon.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
4+
namespace MaterialDesignThemes.Wpf
5+
{
6+
/// <summary>
7+
/// Displays an icon image/path, according to the specified <see cref="Type"/> name.
8+
/// </summary>
9+
/// <remarks>
10+
/// All icons sourced from Material Design Icons Font - <see cref="https://materialdesignicons.com/"/> - in accordance of
11+
/// <see cref="https://github.com/Templarian/MaterialDesign/blob/master/license.txt"/>.
12+
/// </remarks>
13+
public class Icon : Control
14+
{
15+
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
16+
"Type", typeof (IconType), typeof (Icon), new PropertyMetadata(default(IconType)));
17+
18+
/// <summary>
19+
/// Gets or sets the name of icon being displayed.
20+
/// </summary>
21+
public IconType Type
22+
{
23+
get { return (IconType) GetValue(TypeProperty); }
24+
set { SetValue(TypeProperty, value); }
25+
}
26+
}
27+
}

MaterialDesignThemes.Wpf/IconType.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace MaterialDesignThemes.Wpf
2+
{
3+
/// <summary>
4+
/// List of available icons for use with <see cref="Icon"/>.
5+
/// </summary>
6+
/// <remarks>
7+
/// All icons sourced from Material Design Icons Font - <see cref="https://materialdesignicons.com/"/> - in accordance of
8+
/// <see cref="https://github.com/Templarian/MaterialDesign/blob/master/license.txt"/>.
9+
/// </remarks>
10+
public enum IconType
11+
{
12+
AutoGeneratedDoNotAmend
13+
}
14+
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@
250250
<Compile Include="DpiHelper.cs" />
251251
<Compile Include="DrawerHost.cs" />
252252
<Compile Include="Extensions.cs" />
253+
<Compile Include="Icon.cs" />
254+
<Compile Include="IconType.cs" />
253255
<Compile Include="ListSortDirectionIndicator.cs" />
254256
<Compile Include="MaterialDataGridComboBoxColumn.cs" />
255257
<Compile Include="MaterialDataGridTextColumn.cs" />

mdresgen/IconThing.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Net;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using Humanizer;
9+
using Newtonsoft.Json.Linq;
10+
11+
namespace mdresgen
12+
{
13+
class IconThing
14+
{
15+
public void Run()
16+
{
17+
var nameDataPairs = GetNameDataPairs(GetSourceData()).ToList();
18+
19+
Console.WriteLine(nameDataPairs.Count);
20+
}
21+
22+
private static string GetSourceData()
23+
{
24+
Console.WriteLine("Downloading icon data...");
25+
26+
var webRequest = WebRequest.CreateDefault(
27+
new Uri("https://materialdesignicons.com/api/package/38EF63D0-4744-11E4-B3CF-842B2B6CFE1B"));
28+
webRequest.UseDefaultCredentials = true;
29+
using (var sr = new StreamReader(webRequest.GetResponse().GetResponseStream()))
30+
{
31+
var iconData = sr.ReadToEnd();
32+
33+
Console.WriteLine("Got.");
34+
35+
return iconData;
36+
}
37+
}
38+
39+
private static IEnumerable<Tuple<string, string>> GetNameDataPairs(string sourceData)
40+
{
41+
var jObject = JObject.Parse(sourceData);
42+
return jObject["icons"].Select(t => new Tuple<string, string>(
43+
t["name"].ToString().Underscore().Pascalize(),
44+
t["data"].ToString()));
45+
}
46+
47+
48+
49+
private void UpdateEnum()
50+
{
51+
//SyntaxNode
52+
}
53+
54+
}
55+
}

mdresgen/IconType.template.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace MaterialDesignThemes.Wpf
2+
{
3+
/// <summary>
4+
/// List of available icons for use with <see cref="Icon"/>.
5+
/// </summary>
6+
/// <remarks>
7+
/// All icons sourced from Material Design Icons Font - <see cref="https://materialdesignicons.com/"/> - in accordance of
8+
/// <see cref="https://github.com/Templarian/MaterialDesign/blob/master/license.txt"/>.
9+
/// </remarks>
10+
public enum IconType
11+
{
12+
AutoGeneratedDoNotAmend
13+
}
14+
}

mdresgen/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ static void Main(string[] args)
5151
GenerateOldXaml(xDocument, true);
5252
else if (args.Contains("old"))
5353
GenerateOldXaml(xDocument, false);
54+
else if (args.Contains("icons"))
55+
new IconThing().Run();
5456
else
5557
GenerateXaml(xDocument, false);
5658

mdresgen/mdresgen.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
<Prefer32Bit>true</Prefer32Bit>
4545
</PropertyGroup>
4646
<ItemGroup>
47+
<Reference Include="Humanizer, Version=1.37.7.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Humanizer.1.37.7\lib\portable-win+net40+sl50+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Humanizer.dll</HintPath>
49+
<Private>True</Private>
50+
</Reference>
4751
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4852
<SpecificVersion>False</SpecificVersion>
4953
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -58,6 +62,10 @@
5862
<Reference Include="System.Xml" />
5963
</ItemGroup>
6064
<ItemGroup>
65+
<Compile Include="IconThing.cs" />
66+
<None Include="IconType.template.cs">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
6169
<Compile Include="Program.cs" />
6270
<Compile Include="Properties\AssemblyInfo.cs" />
6371
</ItemGroup>

mdresgen/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="Humanizer" version="1.37.7" targetFramework="net45" />
34
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
45
</packages>

0 commit comments

Comments
 (0)