-
Notifications
You must be signed in to change notification settings - Fork 1
/
cCheckbox.cs
103 lines (102 loc) · 4.88 KB
/
cCheckbox.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
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
//**************************************************************************************
namespace Convert_to_WPF
{
public class cCheckbox : cBase
{
//**********************************************************************************
// Events and properties specific to this control
//**********************************************************************************
public string checkEvent = String.Empty;
public bool IsChecked = false;
public bool IsThreeState = false;
//**********************************************************************************
public static bool findControl(string line)
{
//******************************************************************************
// Does this string contain a definition for this control.
//******************************************************************************
if (line.Contains("new System.Windows.Forms.CheckBox();")) return true;
//******************************************************************************
return false;
}
//**********************************************************************************
public override string type
{
get { return "Checkbox"; }
}
//**********************************************************************************
public cCheckbox(string line, string filename) : base(line, filename)
{
}
//**********************************************************************************
public override void Settings(string t)
{
//******************************************************************************
// Parse our base settings
//******************************************************************************
base.Settings(t);
//******************************************************************************
// Parse settings specific to this control
//******************************************************************************
int index;
string search_text;
//******************************************************************************
search_text = "this." + name + ".Checked = ";
index = t.IndexOf(search_text);
if (index != -1)
{
index = index + search_text.Length;
int len = t.IndexOf(';', index) - index;
string vText = t.Substring(index, len);
IsChecked = Convert.ToBoolean(vText);
}
//******************************************************************************
search_text = "this." + name + ".ThreeState = ";
index = t.IndexOf(search_text);
if (index != -1)
{
index = index + search_text.Length;
int len = t.IndexOf(';', index) - index;
string vText = t.Substring(index, len);
IsThreeState = Convert.ToBoolean(vText);
}
//******************************************************************************
checkEvent = base.parseEvent(name, "CheckedChanged", t);
}
//**********************************************************************************
public override void xaml(StreamWriter w, Size pSize)
{
string o = "\t\t<CheckBox ";
//******************************************************************************
// Write base XAML attributes and margins...
//******************************************************************************
o += xamlAttributes();
o += margins(pSize);
//******************************************************************************
// Write specific control settings...
//******************************************************************************
if (IsChecked)
o += "IsChecked=\"True\" ";
if (IsThreeState)
o += "IsThreeState=\"True\" ";
if (checkEvent != String.Empty)
o += "Checked=\"" + checkEvent + "\" ";
o += ">";
//******************************************************************************
// Add any text
//******************************************************************************
o += XAML.encodeText(text);
//******************************************************************************
// Close out control and write the line...
//******************************************************************************
o += "</CheckBox>";
w.WriteLine(o);
}
}
}