-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
DocumentationLink.cs
92 lines (73 loc) · 3.05 KB
/
DocumentationLink.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Configuration;
using System.Windows.Controls;
using System.Windows.Input;
namespace MaterialDesignColors.WpfExample.Domain
{
public class DocumentationLink
{
public DocumentationLink(DocumentationLinkType type, string url) : this(type, url, null)
{
}
public DocumentationLink(DocumentationLinkType type, string url, string label)
{
Label = label ?? type.ToString();
Url = url;
Type = type;
Open = new AnotherCommandImplementation(Execute);
}
public static DocumentationLink WikiLink(string page, string label)
{
return new DocumentationLink(DocumentationLinkType.Wiki,
$"{ConfigurationManager.AppSettings["GitHub"]}/wiki/" + page, label);
}
public static DocumentationLink StyleLink(string nameChunk)
{
return new DocumentationLink(
DocumentationLinkType.StyleSource,
$"{ConfigurationManager.AppSettings["GitHub"]}/blob/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.{nameChunk}.xaml",
nameChunk);
}
public static DocumentationLink ApiLink<TClass>(string subNamespace)
{
var typeName = typeof(TClass).Name;
return new DocumentationLink(
DocumentationLinkType.ControlSource,
$"{ConfigurationManager.AppSettings["GitHub"]}/blob/master/MaterialDesignThemes.Wpf/{subNamespace}/{typeName}.cs",
typeName);
}
public static DocumentationLink ApiLink<TClass>()
{
var typeName = typeof(TClass).Name;
return new DocumentationLink(
DocumentationLinkType.ControlSource,
$"{ConfigurationManager.AppSettings["GitHub"]}/blob/master/MaterialDesignThemes.Wpf/{typeName}.cs",
typeName);
}
public static DocumentationLink DemoPageLink<TDemoPage>()
{
return DemoPageLink<TDemoPage>(null);
}
public static DocumentationLink DemoPageLink<TDemoPage>(string label)
{
return DemoPageLink<TDemoPage>(label, null);
}
public static DocumentationLink DemoPageLink<TDemoPage>(string label, string nameSpace)
{
var ext = typeof(UserControl).IsAssignableFrom(typeof(TDemoPage))
? "xaml"
: "cs";
return new DocumentationLink(
DocumentationLinkType.DemoPageSource,
$"{ConfigurationManager.AppSettings["GitHub"]}/blob/master/MainDemo.Wpf/{(string.IsNullOrWhiteSpace(nameSpace) ? "" : ("/" + nameSpace + "/" ))}{typeof(TDemoPage).Name}.{ext}",
label ?? typeof(TDemoPage).Name);
}
public string Label { get; }
public string Url { get; }
public DocumentationLinkType Type { get; }
public ICommand Open { get; }
private void Execute(object o)
{
System.Diagnostics.Process.Start(Url);
}
}
}