forked from weiyu666/RevitExportGltf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectData.cs
231 lines (209 loc) · 6.43 KB
/
ObjectData.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RevitExportGltf
{
class ObjectData : INotifyPropertyChanged
{
/// <summary>
/// 子项
/// </summary>
private ObservableCollection<ObjectData> _children = new ObservableCollection<ObjectData>();
public ObservableCollection<ObjectData> Children
{
get { return _children; }
set
{
_children = value;
}
}
public ObjectData()
{
_children = new ObservableCollection<ObjectData>();
_isExpanded = false;
_isChecked = true;
_isEnabled = true;
}
public string ElementName { set; get; }
public string ElementId { set; get; }
public string SimilarObjectID { set; get; }
public List<string> ElementLocation { set; get; }
public string ElementVertices { set; get; }
public string ElementNormal { set; get; }
public string ElementArea { set; get; }
public string ElementVolum { set; get; }
public string VertexIndices { set; get; }
public string SimilarToJson()
{
string s = string.Format
("\n \"ElementLocation\":{0},"
+ "\n \"ElementNormal\":{1}",
"\"" + ElementLocation + "\"",
"\"" + ElementNormal + "\"");
return "\n{" + s + "\n}" + ",";
}
public string CurrentToJson()
{
string s = string.Format
("\n \"ElementName\":{0},"
+ "\n \"ElementId\":{1},"
+ "\n \"ElementLocation\":{2},"
+ "\n \"ElementVertices\":{3},"
+ "\n \"VertexIndices\":{4},"
+ "\n \"ElementNormal\":{5},"
+ "\n \"ElementArea\":{6},"
+ "\n \"ElementVolum\":{7},"
+ "\n \"SimilarObject\":{8}",
"\"" + ElementName + "\"",
"\"" + ElementId + "\"",
"\"" + ElementLocation + "\"",
"\"" + ElementVertices + "\"",
"\"" + VertexIndices + "\"",
"\"" + ElementNormal + "\"",
"\"" + ElementArea + "\"",
"\"" + ElementVolum + "\"",
SimilarEleJson());
return "\n{" + s + "\n}" + ",";
}
public string SimilarEleJson()
{
string s = null;
foreach (ObjectData child in Children)
{
s += child.SimilarToJson();
}
return "[" + s + "\n]";
}
public string ToJson()
{
//string s = string.Format
// ("\n \"Name\":{0},"
// + "\n \"Children\":{1}",
// "\"" + ElementName + "\"",
// ChildrenToJson2());
//return "\n{" + s + "\n}"+",";
string s = null;
s += CurrentToJson();
return s;
}
/// <summary>
/// 选中状态
/// </summary>
public bool _isChecked;
public bool IsChecked
{
get
{
return _isChecked;
}
set
{
if (value != _isChecked)
{
_isChecked = value;
NotifyPropertyChanged("IsChecked");
if (_isChecked)
{
foreach (ObjectData child in Children)
{
child.IsEnabled = true;
}
}
else
{
foreach (ObjectData child in Children)
{
child.IsEnabled = false;
}
}
}
}
}
/// <summary>
/// 可见行
/// </summary>
private bool _isEnabled;
public bool IsEnabled
{
get { return _isEnabled; }
set
{
if (value != _isEnabled)
{
_isEnabled = value;
NotifyPropertyChanged("IsEnabled");
if (_isEnabled)
{
foreach (ObjectData child in Children)
{
child.IsEnabled = true;
}
}
else
{
foreach (ObjectData child in Children)
{
child.IsEnabled = false;
}
}
}
}
}
/// <summary>
/// 折叠状态
/// </summary>
private bool _isExpanded;
public bool IsExpanded
{
get { return _isExpanded; }
set
{
if (value != _isExpanded)
{
//折叠状态改变
_isExpanded = value;
NotifyPropertyChanged("IsExpanded");
}
}
}
/// <summary>
/// 设置所有子项的选中状态
/// </summary>
/// <param name="isChecked"></param>
public void SetChildrenChecked(bool isChecked)
{
foreach (ObjectData child in Children)
{
child.IsChecked = IsChecked;
child.SetChildrenChecked(IsChecked);
}
}
/// <summary>
/// 设置所有子项展开状态
/// </summary>
/// <param name="isExpanded"></param>
public void SetChildrenExpanded(bool isExpanded)
{
foreach (ObjectData child in Children)
{
child.IsExpanded = isExpanded;
child.SetChildrenExpanded(isExpanded);
}
}
/// <summary>
/// 属性改变事件
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
}