This repository was archived by the owner on Nov 13, 2018. It is now read-only.
forked from ArthurHub/HTML-Renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevForm.cs
More file actions
executable file
·116 lines (91 loc) · 3.28 KB
/
Copy pathDevForm.cs
File metadata and controls
executable file
·116 lines (91 loc) · 3.28 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace LayoutFarm.Demo
{
public partial class DevForm : Form
{
PixelFarm.Drawing.GraphicsPlatform graphicsPlatform;
public DevForm(PixelFarm.Drawing.GraphicsPlatform graphicsPlatform)
{
this.graphicsPlatform = graphicsPlatform;
InitializeComponent();
this.lstDemoList.DoubleClick += new EventHandler(lstDemoList_DoubleClick);
LoadDemoList();
}
void lstDemoList_DoubleClick(object sender, EventArgs e)
{
var demoInfo = lstDemoList.SelectedItem as DemoInfo;
if (demoInfo != null)
{
DemoBase demoInstance = (DemoBase)Activator.CreateInstance(demoInfo.DemoType);
if (demoInstance != null)
{
DemoForm demoForm = new DemoForm(this.graphicsPlatform);
demoForm.Show();
demoForm.Activate();
demoForm.LoadDemo(demoInstance);
}
}
}
void LoadDemoList()
{
this.lstDemoList.Items.Clear();
var demoBaseType = typeof(DemoBase);
var thisAssem = System.Reflection.Assembly.GetAssembly(this.GetType());
List<DemoInfo> demoInfoList = new List<DemoInfo>();
foreach (var t in thisAssem.GetTypes())
{
if (demoBaseType.IsAssignableFrom(t) && t != demoBaseType)
{
string demoTypeName = t.Name;
object[] notes = t.GetCustomAttributes(typeof(DemoNoteAttribute), false);
string noteMsg = null;
if (notes != null && notes.Length > 0)
{
//get one only
DemoNoteAttribute note = notes[0] as DemoNoteAttribute;
if (note != null)
{
noteMsg = note.Message;
}
}
demoInfoList.Add(new DemoInfo(t, noteMsg));
}
}
demoInfoList.Sort((d1, d2) =>
d1.DemoType.Name.CompareTo(d2.DemoType.Name));
foreach (var demo in demoInfoList)
{
this.lstDemoList.Items.Add(demo);
}
}
private void button1_Click(object sender, EventArgs e)
{
DemoForm demoForm = new DemoForm(this.graphicsPlatform);
demoForm.PrepareSamples();
demoForm.Show();
demoForm.Activate();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; ++i)
{
DemoForm demoForm = new DemoForm(this.graphicsPlatform);
demoForm.StartAtSampleIndex = 2;
demoForm.PrepareSamples();
demoForm.Show();
demoForm.Activate();
System.Threading.Thread.Sleep(10);
demoForm.Close();
}
}
}
}