/
DimRecPMPage.cs
191 lines (152 loc) · 7.35 KB
/
DimRecPMPage.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
// (C) Jan Boettcher, <http://www.ib-boettcher.de>
// Licensed under the EUPL V.1.1
using System;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swpublished;
using SolidWorks.Interop.swconst;
using SolidWorksTools;
namespace DimensionRecorder
{
/// <summary>
/// Summary description for PMPage.
/// </summary>
public class DimRecPMPage
{
//Local Objects
IPropertyManagerPage2 swPropertyPage;
PMPHandler handler;
ISldWorks iSwApp;
DimensionRecorder userAddin;
#region Property Manager Page Controls
//Groups
IPropertyManagerPageGroup groupDimensions;
IPropertyManagerPageGroup groupObjects;
IPropertyManagerPageGroup groupEvents;
IPropertyManagerPageGroup groupOptions;
//Controls
internal IPropertyManagerPageCheckbox traceDialog = null;
internal IPropertyManagerPageCheckbox traceDrag = null;
internal IPropertyManagerPageCheckbox traceRegen = null;
internal IPropertyManagerPageCheckbox traceSketch = null;
internal IPropertyManagerPageCheckbox supprDouble = null;
internal IPropertyManagerPageSelectionbox selectionDimensions;
internal IPropertyManagerPageSelectionbox selectionObjects;
//Control IDs
public const int groupDimensionsID = 0;
public const int groupObjectsID = 1;
public const int groupEventsID = 2;
public const int groupOptionsID = 3;
//Selection IDs
public const int selectionDimensionsID = 10;
public const int selectionObjectsID = 11;
//OPtion IDs
public const int cb_idSketch = 20;
public const int cb_idDialog = 21;
public const int cb_idDrag = 22;
public const int optionDropDoubleID = 23;
public const int cb_idRegen = 24;
#endregion
public DimRecPMPage(DimensionRecorder addin)
{
userAddin = addin;
iSwApp = (ISldWorks)userAddin.GetSldWorks();
CreatePropertyManagerPage();
}
protected void CreatePropertyManagerPage()
{
int errors = -1;
int options = (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton |
(int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton;
handler = new PMPHandler(userAddin,this);
swPropertyPage = (IPropertyManagerPage2)iSwApp.CreatePropertyManagerPage(Lang.DIMENSION_SELECTION, options, handler, ref errors);
if (swPropertyPage != null && errors == (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay)
{
try
{
AddControls();
}
catch(Exception e)
{
iSwApp.SendMsgToUser2(e.Message,0,0);
}
}
}
//Controls are displayed on the page top to bottom in the order
//in which they are added to the object.
protected void AddControls()
{
short controlType = -1;
short align = -1;
int options = -1;
//Add the groups
options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
(int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;
groupDimensions = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupDimensionsID, Lang.DIMENSIONS, options);
groupObjects = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupObjectsID, Lang.POINTS, options);
groupEvents = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupEventsID, Lang.EVENTS, options);
groupOptions = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupOptionsID, Lang.OPTIONS, options);
//Selection of dimensions
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
selectionDimensions = (IPropertyManagerPageSelectionbox)groupDimensions.AddControl(selectionDimensionsID, controlType, Lang.RECORD_DIMENSIONS, align, options, Lang.RECORD_DIMENSIONS_HINT);
if (selectionDimensions != null)
{
selectionDimensions.Height = 40;
selectionDimensions.SetSelectionFilters(Target.dimensionFilters);
}
//Selection of objects
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
selectionObjects = (IPropertyManagerPageSelectionbox)groupObjects.AddControl(selectionObjectsID, controlType, Lang.RECORD_POSITIONS, align, options, Lang.RECORD_POSITIONS_HINT);
if (selectionObjects != null)
{
selectionObjects.Height = 40;
selectionObjects.SetSelectionFilters(Target.objectFilters);
}
//Trace options
traceDialog = null;
traceDrag = null;
traceSketch = null;
traceRegen = null;
// Trace drag events
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
traceDrag = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idDrag, controlType, Lang.DRAG, align, options, Lang.DRAG_HINT);
// Trace dimension change events
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
traceDialog = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idDialog, controlType, Lang.CHANGE_DIMENSION, align, options, Lang.CHANGE_DIMENSION_HINT);
// Trace Sketch change events
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
traceSketch = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idSketch, controlType, Lang.SKETCH_SOLVE, align, options, Lang.SKETCH_SOLVE_HINT);
// Regenerate events
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
traceRegen = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idRegen, controlType, Lang.MODEL_REGENERATION, align, options, Lang.MODEL_REGENERATION_HINT);
// Other Options
// do not record double
controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
options = (int)swAddControlOptions_e.swControlOptions_Enabled |
(int)swAddControlOptions_e.swControlOptions_Visible;
supprDouble = (IPropertyManagerPageCheckbox)groupOptions.AddControl(optionDropDoubleID, controlType, Lang.DROP_DOUBLE, align, options, Lang.DROP_DOUBLE_HINT);
}
public void Show()
{
swPropertyPage.Show();
}
}
}