0012042: Problem with standard Qt-based Import/Export sample application
[occt.git] / samples / CSharp / WinForms / Form1.cs
CommitLineData
d1a2fee8 1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7
8namespace IE_WinForms
9{
10 /// <summary>
11 /// Summary description for Form1.
12 /// </summary>
13 public class Form1 : System.Windows.Forms.Form
14 {
15 private System.Windows.Forms.MainMenu mainMenu1;
16 private System.Windows.Forms.MenuItem FileNew;
17 private System.Windows.Forms.MenuItem FileClose;
18 private System.Windows.Forms.MenuItem FileExport;
19 private System.Windows.Forms.MenuItem FileImport;
20 private System.Windows.Forms.MenuItem ImportBRep;
21 private System.Windows.Forms.MenuItem ExportImage;
22 private System.Windows.Forms.MenuItem File;
23 private System.Windows.Forms.MenuItem Window;
24 private System.Windows.Forms.ToolBarButton New;
25 private System.Windows.Forms.ImageList imageList1;
26 private System.Windows.Forms.ToolBarButton About;
27 private System.Windows.Forms.StatusBar myStatusBar;
28 private System.Windows.Forms.MenuItem ImportIges;
29 private System.Windows.Forms.MenuItem ImportStep;
30 private System.Windows.Forms.MenuItem ExportBRep;
31 private System.Windows.Forms.MenuItem ExportIges;
32 private System.Windows.Forms.MenuItem ExportStep;
33 private System.Windows.Forms.MenuItem ExportStl;
34 private System.Windows.Forms.MenuItem ExportVrml;
35 private System.ComponentModel.IContainer components;
36 private System.Windows.Forms.MenuItem menuItem1;
37 private System.Windows.Forms.MenuItem menuItem2;
38 private System.Windows.Forms.MenuItem menuItem3;
39 private System.Windows.Forms.MenuItem View;
40 private System.Windows.Forms.MenuItem Help;
41 private System.Windows.Forms.MenuItem HelpAbout;
42 private System.Windows.Forms.MenuItem ViewToolbar;
43 private System.Windows.Forms.MenuItem ViewStatusBar;
44 private System.Windows.Forms.MenuItem menuItem4;
45 private System.Windows.Forms.MenuItem WindowCascade;
46 private System.Windows.Forms.MenuItem WindowTile;
47
48 protected IE_WinForms.ModelFormat myModelFormat;
49 private System.Windows.Forms.ToolBarButton wireframe;
50 private System.Windows.Forms.ToolBarButton shading;
51 private System.Windows.Forms.ToolBarButton toolBarButton1;
52 private System.Windows.Forms.ToolBarButton color;
53 private System.Windows.Forms.ToolBarButton transparency;
54 private System.Windows.Forms.ToolBarButton delete;
55 private System.Windows.Forms.ToolBarButton material;
56 private System.Windows.Forms.ToolBarButton ZoomAll;
57 private System.Windows.Forms.ToolBarButton ZoomWin;
58 private System.Windows.Forms.ToolBarButton ZoomProg;
59 private System.Windows.Forms.ToolBarButton Pan;
60 private System.Windows.Forms.ToolBarButton PanGlo;
61 private System.Windows.Forms.ToolBarButton Front;
62 private System.Windows.Forms.ToolBarButton Back;
63 private System.Windows.Forms.ToolBarButton TOP;
64 private System.Windows.Forms.ToolBarButton BOTTOM;
65 private System.Windows.Forms.ToolBarButton RIGHT;
66 private System.Windows.Forms.ToolBarButton LEFT;
67 private System.Windows.Forms.ToolBarButton Axo;
68 private System.Windows.Forms.ToolBarButton Rot;
69 private System.Windows.Forms.ToolBarButton Reset;
70 private System.Windows.Forms.ToolBarButton HlrOn;
71 private System.Windows.Forms.ToolBarButton HlrOff;
72 private System.Windows.Forms.ToolBar toolBarTool;
73 private System.Windows.Forms.ToolBar toolBarView;
74 protected static int myNbOfChildren;
75
76 public Form1()
77 {
78 //
79 // Required for Windows Form Designer support
80 //
81 InitializeComponent();
82
83 //
84 IE_WinForms.Form1.myNbOfChildren = 0;
85 }
86
87 /// <summary>
88 /// Clean up any resources being used.
89 /// </summary>
90 protected override void Dispose(bool disposing)
91 {
92 if (disposing)
93 {
94 if (components != null)
95 {
96 components.Dispose();
97 }
98 }
99 base.Dispose(disposing);
100 }
101
102 #region Windows Form Designer generated code
103 /// <summary>
104 /// Required method for Designer support - do not modify
105 /// the contents of this method with the code editor.
106 /// </summary>
107 private void InitializeComponent()
108 {
109 this.components = new System.ComponentModel.Container();
110 System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
111 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
112 this.mainMenu1 = new System.Windows.Forms.MainMenu();
113 this.File = new System.Windows.Forms.MenuItem();
114 this.FileNew = new System.Windows.Forms.MenuItem();
115 this.FileExport = new System.Windows.Forms.MenuItem();
116 this.ImportBRep = new System.Windows.Forms.MenuItem();
117 this.ImportIges = new System.Windows.Forms.MenuItem();
118 this.ImportStep = new System.Windows.Forms.MenuItem();
119 this.FileImport = new System.Windows.Forms.MenuItem();
120 this.ExportBRep = new System.Windows.Forms.MenuItem();
121 this.ExportIges = new System.Windows.Forms.MenuItem();
122 this.ExportStep = new System.Windows.Forms.MenuItem();
123 this.ExportStl = new System.Windows.Forms.MenuItem();
124 this.ExportVrml = new System.Windows.Forms.MenuItem();
125 this.menuItem3 = new System.Windows.Forms.MenuItem();
126 this.ExportImage = new System.Windows.Forms.MenuItem();
127 this.FileClose = new System.Windows.Forms.MenuItem();
128 this.menuItem2 = new System.Windows.Forms.MenuItem();
129 this.menuItem1 = new System.Windows.Forms.MenuItem();
130 this.View = new System.Windows.Forms.MenuItem();
131 this.ViewToolbar = new System.Windows.Forms.MenuItem();
132 this.ViewStatusBar = new System.Windows.Forms.MenuItem();
133 this.Window = new System.Windows.Forms.MenuItem();
134 this.menuItem4 = new System.Windows.Forms.MenuItem();
135 this.WindowCascade = new System.Windows.Forms.MenuItem();
136 this.WindowTile = new System.Windows.Forms.MenuItem();
137 this.Help = new System.Windows.Forms.MenuItem();
138 this.HelpAbout = new System.Windows.Forms.MenuItem();
139 this.toolBarTool = new System.Windows.Forms.ToolBar();
140 this.New = new System.Windows.Forms.ToolBarButton();
141 this.About = new System.Windows.Forms.ToolBarButton();
142 this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
143 this.wireframe = new System.Windows.Forms.ToolBarButton();
144 this.shading = new System.Windows.Forms.ToolBarButton();
145 this.color = new System.Windows.Forms.ToolBarButton();
146 this.material = new System.Windows.Forms.ToolBarButton();
147 this.transparency = new System.Windows.Forms.ToolBarButton();
148 this.delete = new System.Windows.Forms.ToolBarButton();
149 this.imageList1 = new System.Windows.Forms.ImageList(this.components);
150 this.myStatusBar = new System.Windows.Forms.StatusBar();
151 this.toolBarView = new System.Windows.Forms.ToolBar();
152 this.ZoomAll = new System.Windows.Forms.ToolBarButton();
153 this.ZoomWin = new System.Windows.Forms.ToolBarButton();
154 this.ZoomProg = new System.Windows.Forms.ToolBarButton();
155 this.Pan = new System.Windows.Forms.ToolBarButton();
156 this.PanGlo = new System.Windows.Forms.ToolBarButton();
157 this.Front = new System.Windows.Forms.ToolBarButton();
158 this.Back = new System.Windows.Forms.ToolBarButton();
159 this.TOP = new System.Windows.Forms.ToolBarButton();
160 this.BOTTOM = new System.Windows.Forms.ToolBarButton();
161 this.LEFT = new System.Windows.Forms.ToolBarButton();
162 this.RIGHT = new System.Windows.Forms.ToolBarButton();
163 this.Axo = new System.Windows.Forms.ToolBarButton();
164 this.Rot = new System.Windows.Forms.ToolBarButton();
165 this.Reset = new System.Windows.Forms.ToolBarButton();
166 this.HlrOn = new System.Windows.Forms.ToolBarButton();
167 this.HlrOff = new System.Windows.Forms.ToolBarButton();
168 this.SuspendLayout();
169 //
170 // mainMenu1
171 //
172 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
173 this.File,
174 this.View,
175 this.Window,
176 this.Help});
177 //
178 // File
179 //
180 this.File.Index = 0;
181 this.File.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
182 this.FileNew,
183 this.FileExport,
184 this.FileImport,
185 this.FileClose,
186 this.menuItem2,
187 this.menuItem1});
188 this.File.Text = "&File";
189 this.File.Popup += new System.EventHandler(this.File_Popup);
190 //
191 // FileNew
192 //
193 this.FileNew.Index = 0;
194 this.FileNew.Text = "&New";
195 this.FileNew.Click += new System.EventHandler(this.menuItem2_Click);
196 //
197 // FileExport
198 //
199 this.FileExport.Index = 1;
200 this.FileExport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
201 this.ImportBRep,
202 this.ImportIges,
203 this.ImportStep});
204 this.FileExport.Text = "&Import";
205 this.FileExport.Visible = false;
206 //
207 // ImportBRep
208 //
209 this.ImportBRep.Index = 0;
210 this.ImportBRep.Text = "&BRep ...";
211 this.ImportBRep.Click += new System.EventHandler(this.ImportBRep_Click);
212 //
213 // ImportIges
214 //
215 this.ImportIges.Index = 1;
216 this.ImportIges.Text = "&Iges ...";
217 this.ImportIges.Click += new System.EventHandler(this.ImportIges_Click);
218 //
219 // ImportStep
220 //
221 this.ImportStep.Index = 2;
222 this.ImportStep.Text = "&Step ...";
223 this.ImportStep.Click += new System.EventHandler(this.ImportStep_Click);
224 //
225 // FileImport
226 //
227 this.FileImport.Index = 2;
228 this.FileImport.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
229 this.ExportBRep,
230 this.ExportIges,
231 this.ExportStep,
232 this.ExportStl,
233 this.ExportVrml,
234 this.menuItem3,
235 this.ExportImage});
236 this.FileImport.Text = "&Export";
237 this.FileImport.Visible = false;
238 this.FileImport.Popup += new System.EventHandler(this.FileImport_Popup);
239 //
240 // ExportBRep
241 //
242 this.ExportBRep.Enabled = false;
243 this.ExportBRep.Index = 0;
244 this.ExportBRep.Text = "&BRep ...";
245 this.ExportBRep.Click += new System.EventHandler(this.ExportBRep_Click);
246 //
247 // ExportIges
248 //
249 this.ExportIges.Enabled = false;
250 this.ExportIges.Index = 1;
251 this.ExportIges.Text = "&Iges ...";
252 this.ExportIges.Click += new System.EventHandler(this.ExportIges_Click);
253 //
254 // ExportStep
255 //
256 this.ExportStep.Enabled = false;
257 this.ExportStep.Index = 2;
258 this.ExportStep.Text = "&Step ...";
259 this.ExportStep.Click += new System.EventHandler(this.ExportStep_Click);
260 //
261 // ExportStl
262 //
263 this.ExportStl.Enabled = false;
264 this.ExportStl.Index = 3;
265 this.ExportStl.Text = "&Stl ...";
266 this.ExportStl.Click += new System.EventHandler(this.ExportStl_Click);
267 //
268 // ExportVrml
269 //
270 this.ExportVrml.Enabled = false;
271 this.ExportVrml.Index = 4;
272 this.ExportVrml.Text = "&Vrml ...";
273 this.ExportVrml.Click += new System.EventHandler(this.ExportVrml_Click);
274 //
275 // menuItem3
276 //
277 this.menuItem3.Index = 5;
278 this.menuItem3.Text = "-";
279 //
280 // ExportImage
281 //
282 this.ExportImage.Index = 6;
283 this.ExportImage.Text = "Image ...";
284 this.ExportImage.Click += new System.EventHandler(this.ExportImage_Click);
285 //
286 // FileClose
287 //
288 this.FileClose.Enabled = false;
289 this.FileClose.Index = 3;
290 this.FileClose.Text = "&Close";
291 this.FileClose.Click += new System.EventHandler(this.menuItem3_Click);
292 //
293 // menuItem2
294 //
295 this.menuItem2.Index = 4;
296 this.menuItem2.Text = "-";
297 //
298 // menuItem1
299 //
300 this.menuItem1.Index = 5;
301 this.menuItem1.Text = "&Quit";
302 this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
303 //
304 // View
305 //
306 this.View.Index = 1;
307 this.View.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
308 this.ViewToolbar,
309 this.ViewStatusBar});
310 this.View.Text = "&View";
311 //
312 // ViewToolbar
313 //
314 this.ViewToolbar.Checked = true;
315 this.ViewToolbar.Index = 0;
316 this.ViewToolbar.Text = "&Toolbar";
317 this.ViewToolbar.Click += new System.EventHandler(this.ViewToolbar_Click);
318 //
319 // ViewStatusBar
320 //
321 this.ViewStatusBar.Checked = true;
322 this.ViewStatusBar.Index = 1;
323 this.ViewStatusBar.Text = "&Statusbar";
324 this.ViewStatusBar.Click += new System.EventHandler(this.ViewStatusBar_Click);
325 //
326 // Window
327 //
328 this.Window.Index = 2;
329 this.Window.MdiList = true;
330 this.Window.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
331 this.menuItem4,
332 this.WindowCascade,
333 this.WindowTile});
334 this.Window.Text = "&Window";
335 this.Window.Visible = false;
336 //
337 // menuItem4
338 //
339 this.menuItem4.Index = 0;
340 this.menuItem4.Text = "&New 3d View";
341 this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
342 //
343 // WindowCascade
344 //
345 this.WindowCascade.Index = 1;
346 this.WindowCascade.Text = "&Cascade";
347 this.WindowCascade.Click += new System.EventHandler(this.WindowCascade_Click);
348 //
349 // WindowTile
350 //
351 this.WindowTile.Index = 2;
352 this.WindowTile.Text = "&Tile";
353 this.WindowTile.Click += new System.EventHandler(this.WindowTile_Click);
354 //
355 // Help
356 //
357 this.Help.Index = 3;
358 this.Help.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
359 this.HelpAbout});
360 this.Help.Text = "&Help";
361 //
362 // HelpAbout
363 //
364 this.HelpAbout.Index = 0;
365 this.HelpAbout.Shortcut = System.Windows.Forms.Shortcut.F1;
366 this.HelpAbout.Text = "&About";
367 this.HelpAbout.Click += new System.EventHandler(this.HelpAbout_Click);
368 //
369 // toolBarTool
370 //
371 this.toolBarTool.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar;
372 this.toolBarTool.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
373 this.New,
374 this.About,
375 this.toolBarButton1,
376 this.wireframe,
377 this.shading,
378 this.color,
379 this.material,
380 this.transparency,
381 this.delete});
382 this.toolBarTool.DropDownArrows = true;
383 this.toolBarTool.ImageList = this.imageList1;
384 this.toolBarTool.Location = new System.Drawing.Point(0, 0);
385 this.toolBarTool.Name = "toolBarTool";
386 this.toolBarTool.ShowToolTips = true;
387 this.toolBarTool.Size = new System.Drawing.Size(560, 28);
388 this.toolBarTool.TabIndex = 1;
389 this.toolBarTool.Enter += new System.EventHandler(this.menuItem3_Click);
390 this.toolBarTool.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
391 this.toolBarTool.MouseHover += new System.EventHandler(this.toolBar1_MouseHover);
392 this.toolBarTool.MouseLeave += new System.EventHandler(this.toolBar1_MouseLeave);
393 //
394 // New
395 //
396 this.New.ImageIndex = 0;
397 this.New.ToolTipText = "New";
398 this.New.Visible = ((bool)(configurationAppSettings.GetValue("New.Visible", typeof(bool))));
399 //
400 // About
401 //
402 this.About.ImageIndex = 1;
403 this.About.ToolTipText = "About(F1)";
404 this.About.Visible = ((bool)(configurationAppSettings.GetValue("About.Visible", typeof(bool))));
405 //
406 // toolBarButton1
407 //
408 this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
409 //
410 // wireframe
411 //
412 this.wireframe.Enabled = ((bool)(configurationAppSettings.GetValue("wireframe.Enabled", typeof(bool))));
413 this.wireframe.ImageIndex = 2;
414 this.wireframe.Pushed = ((bool)(configurationAppSettings.GetValue("wireframe.Pushed", typeof(bool))));
415 this.wireframe.ToolTipText = "Wireframe";
416 this.wireframe.Visible = ((bool)(configurationAppSettings.GetValue("wireframe.Visible", typeof(bool))));
417 //
418 // shading
419 //
420 this.shading.Enabled = ((bool)(configurationAppSettings.GetValue("shading.Enabled", typeof(bool))));
421 this.shading.ImageIndex = 3;
422 this.shading.Pushed = ((bool)(configurationAppSettings.GetValue("shading.Pushed", typeof(bool))));
423 this.shading.ToolTipText = "Shading";
424 this.shading.Visible = ((bool)(configurationAppSettings.GetValue("shading.Visible", typeof(bool))));
425 //
426 // color
427 //
428 this.color.Enabled = ((bool)(configurationAppSettings.GetValue("color.Enabled", typeof(bool))));
429 this.color.ImageIndex = 4;
430 this.color.ToolTipText = "Color";
431 this.color.Visible = ((bool)(configurationAppSettings.GetValue("color.Visible", typeof(bool))));
432 //
433 // material
434 //
435 this.material.Enabled = ((bool)(configurationAppSettings.GetValue("material.Enabled", typeof(bool))));
436 this.material.ImageIndex = 5;
437 this.material.ToolTipText = "Material";
438 this.material.Visible = ((bool)(configurationAppSettings.GetValue("material.Visible", typeof(bool))));
439 //
440 // transparency
441 //
442 this.transparency.Enabled = ((bool)(configurationAppSettings.GetValue("transparency.Enabled", typeof(bool))));
443 this.transparency.ImageIndex = 6;
444 this.transparency.ToolTipText = "Transparency";
445 this.transparency.Visible = ((bool)(configurationAppSettings.GetValue("transparency.Visible", typeof(bool))));
446 //
447 // delete
448 //
449 this.delete.Enabled = ((bool)(configurationAppSettings.GetValue("delete.Enabled", typeof(bool))));
450 this.delete.ImageIndex = 7;
451 this.delete.ToolTipText = "Delete";
452 this.delete.Visible = ((bool)(configurationAppSettings.GetValue("delete.Visible", typeof(bool))));
453 //
454 // imageList1
455 //
456 this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
457 this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
458 this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
459 //
460 // myStatusBar
461 //
462 this.myStatusBar.AccessibleRole = System.Windows.Forms.AccessibleRole.StatusBar;
463 this.myStatusBar.Location = new System.Drawing.Point(0, 363);
464 this.myStatusBar.Name = "myStatusBar";
465 this.myStatusBar.Size = new System.Drawing.Size(560, 22);
466 this.myStatusBar.TabIndex = 3;
467 //
468 // toolBarView
469 //
470 this.toolBarView.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar;
471 this.toolBarView.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
472 this.ZoomAll,
473 this.ZoomWin,
474 this.ZoomProg,
475 this.Pan,
476 this.PanGlo,
477 this.Front,
478 this.Back,
479 this.TOP,
480 this.BOTTOM,
481 this.LEFT,
482 this.RIGHT,
483 this.Axo,
484 this.Rot,
485 this.Reset,
486 this.HlrOn,
487 this.HlrOff});
488 this.toolBarView.DropDownArrows = true;
489 this.toolBarView.ImageList = this.imageList1;
490 this.toolBarView.Location = new System.Drawing.Point(0, 28);
491 this.toolBarView.Name = "toolBarView";
492 this.toolBarView.ShowToolTips = true;
493 this.toolBarView.Size = new System.Drawing.Size(560, 28);
494 this.toolBarView.TabIndex = 5;
495 this.toolBarView.Visible = false;
496 this.toolBarView.Wrappable = false;
497 this.toolBarView.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBarView_ButtonClick);
498 this.toolBarView.MouseHover += new System.EventHandler(this.toolBarView_MouseHover);
499 this.toolBarView.MouseLeave += new System.EventHandler(this.toolBarView_MouseLeave);
500 //
501 // ZoomAll
502 //
503 this.ZoomAll.ImageIndex = 8;
504 this.ZoomAll.ToolTipText = "FitAll";
505 //
506 // ZoomWin
507 //
508 this.ZoomWin.ImageIndex = 9;
509 this.ZoomWin.ToolTipText = "Zoom Window";
510 //
511 // ZoomProg
512 //
513 this.ZoomProg.ImageIndex = 10;
514 this.ZoomProg.ToolTipText = "Dynamic Zooming";
515 //
516 // Pan
517 //
518 this.Pan.ImageIndex = 11;
519 this.Pan.ToolTipText = "Dynamic Panning";
520 //
521 // PanGlo
522 //
523 this.PanGlo.ImageIndex = 12;
524 this.PanGlo.ToolTipText = "GlobalPanning";
525 //
526 // Front
527 //
528 this.Front.ImageIndex = 13;
529 this.Front.ToolTipText = "Front";
530 //
531 // Back
532 //
533 this.Back.ImageIndex = 14;
534 this.Back.ToolTipText = "Back";
535 //
536 // TOP
537 //
538 this.TOP.ImageIndex = 15;
539 this.TOP.ToolTipText = "Top";
540 //
541 // BOTTOM
542 //
543 this.BOTTOM.ImageIndex = 16;
544 this.BOTTOM.ToolTipText = "Bottom";
545 //
546 // LEFT
547 //
548 this.LEFT.ImageIndex = 17;
549 this.LEFT.ToolTipText = "Left";
550 //
551 // RIGHT
552 //
553 this.RIGHT.ImageIndex = 18;
554 this.RIGHT.ToolTipText = "Right";
555 //
556 // Axo
557 //
558 this.Axo.ImageIndex = 19;
559 this.Axo.ToolTipText = "Axo";
560 //
561 // Rot
562 //
563 this.Rot.ImageIndex = 20;
564 this.Rot.ToolTipText = "Dynamic Rotation";
565 //
566 // Reset
567 //
568 this.Reset.ImageIndex = 21;
569 this.Reset.ToolTipText = "Reset";
570 //
571 // HlrOn
572 //
573 this.HlrOn.ImageIndex = 22;
574 this.HlrOn.Pushed = true;
575 this.HlrOn.ToolTipText = "Hidden On";
576 //
577 // HlrOff
578 //
579 this.HlrOff.ImageIndex = 23;
580 this.HlrOff.ToolTipText = "Hidden Off";
581 //
582 // Form1
583 //
584 this.AccessibleRole = System.Windows.Forms.AccessibleRole.Application;
585 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
586 this.ClientSize = new System.Drawing.Size(560, 385);
587 this.Controls.Add(this.toolBarView);
588 this.Controls.Add(this.myStatusBar);
589 this.Controls.Add(this.toolBarTool);
590 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
591 this.IsMdiContainer = true;
592 this.Menu = this.mainMenu1;
593 this.Name = "Form1";
594 this.Text = "Sample Import / Export";
595 this.Activated += new System.EventHandler(this.Form1_Activated);
596 this.ResumeLayout(false);
597 }
598 #endregion
599
600 /// <summary>
601 /// The main entry point for the application.
602 /// </summary>
603 [STAThread]
604 static void Main()
605 {
606 Application.Run(new Form1());
607 }
608
609 private void menuItem2_Click(object sender, System.EventArgs e)
610 {
611
612 this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
613 this.OnNewFile();
614 }
615
616 private void menuItem3_Click(object sender, System.EventArgs e)
617 {
618 if (this.MdiChildren.Length > 0)
619 this.ActiveMdiChild.Close();
620
621 }
622
623 private void ImportBRep_Click(object sender, System.EventArgs e)
624 {
625 Form2 curForm = (Form2)this.ActiveMdiChild;
626 if (curForm == null)
627 return;
628 this.myModelFormat = ModelFormat.BREP;
629 curForm.ImportModel(this.myModelFormat);
630 }
631
632 private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
633 {
634 Form2 curForm = (Form2)this.ActiveMdiChild;
635 switch (toolBarTool.Buttons.IndexOf(e.Button))
636 {
637 case 0:
638 this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
639 this.OnNewFile();
640 break;
641 case 1:
642 AboutDialog myDlg = new AboutDialog();
643 myDlg.ShowDialog(this);
644 break;
645
646 case 2: //just separator
647 break;
648 case 3:
649 if (curForm == null)
650 return;
651 curForm.SetDisplayMode(0); //wireframe
652 this.wireframe.Enabled = false;
653 this.shading.Enabled = true;
654 this.transparency.Enabled = false;
655 break;
656 case 4:
657 if (curForm == null)
658 return;
659 curForm.SetDisplayMode(1); //shading
660 this.shading.Enabled = false;
661 this.wireframe.Enabled = true;
662 this.transparency.Enabled = true;
663 break;
664 case 5:
665 if (curForm == null)
666 return;
667 curForm.ChangeColor(true);
668 break;
669 case 6:
670 if (curForm == null)
671 return;
672 MaterialDialog m = new MaterialDialog();
673 m.View = curForm.View;
674 m.ShowDialog(curForm);
675 break;
676 case 7:
677 if (curForm == null)
678 return;
679 IE_WinForms.TransparencyDialog t = new TransparencyDialog();
680 t.View = curForm.View;
681 t.ShowDialog(curForm);
682 break;
683 case 8:
684 if (curForm == null)
685 return;
686 curForm.DeleteObjects();
687 break;
688 default:
689 break;
690 }
691 }
692
693 private void toolBar1_MouseHover(object sender, System.EventArgs e)
694 {
695 this.myStatusBar.Text = "Document toolbar";
696 }
697
698 private void toolBar1_MouseLeave(object sender, System.EventArgs e)
699 {
700 this.myStatusBar.Text = "";
701 }
702
d1a2fee8 703 private void ImportIges_Click(object sender, System.EventArgs e)
704 {
705 Form2 curForm = (Form2)this.ActiveMdiChild;
706 if (curForm == null)
707 return;
708 this.myModelFormat = IE_WinForms.ModelFormat.IGES;
709 curForm.ImportModel(this.myModelFormat);
710 }
711
712 private void ImportStep_Click(object sender, System.EventArgs e)
713 {
714 Form2 curForm = (Form2)this.ActiveMdiChild;
715 if (curForm == null)
716 return;
717 this.myModelFormat = IE_WinForms.ModelFormat.STEP;
718 curForm.ImportModel(this.myModelFormat);
719 }
720
721 private void ExportBRep_Click(object sender, System.EventArgs e)
722 {
723 Form2 curForm = (Form2)this.ActiveMdiChild;
724 if (curForm == null)
725 return;
726 this.myModelFormat = IE_WinForms.ModelFormat.BREP;
727 curForm.ExportModel(this.myModelFormat);
728 }
729
d1a2fee8 730 private void ExportIges_Click(object sender, System.EventArgs e)
731 {
732 Form2 curForm = (Form2)this.ActiveMdiChild;
733 if (curForm == null)
734 return;
735 this.myModelFormat = IE_WinForms.ModelFormat.IGES;
736 curForm.ExportModel(this.myModelFormat);
737 }
738
739 private void ExportStep_Click(object sender, System.EventArgs e)
740 {
741 Form2 curForm = (Form2)this.ActiveMdiChild;
742 if (curForm == null)
743 return;
744 this.myModelFormat = IE_WinForms.ModelFormat.STEP;
745 curForm.ExportModel(this.myModelFormat);
746 }
747
748 private void ExportStl_Click(object sender, System.EventArgs e)
749 {
750 Form2 curForm = (Form2)this.ActiveMdiChild;
751 if (curForm == null)
752 return;
753 this.myModelFormat = IE_WinForms.ModelFormat.STL;
754 curForm.ExportModel(this.myModelFormat);
755 }
756
757 private void ExportVrml_Click(object sender, System.EventArgs e)
758 {
759 Form2 curForm = (Form2)this.ActiveMdiChild;
760 if (curForm == null)
761 return;
762 this.myModelFormat = IE_WinForms.ModelFormat.VRML;
763 curForm.ExportModel(this.myModelFormat);
764 }
765
766 private void ExportImage_Click(object sender, System.EventArgs e)
767 {
768 Form2 curForm = (Form2)this.ActiveMdiChild;
769 if (curForm == null)
770 return;
771 this.myModelFormat = IE_WinForms.ModelFormat.IMAGE;
772 curForm.ExportModel(this.myModelFormat);
773 }
774
775 private void HelpAbout_Click(object sender, System.EventArgs e)
776 {
777 AboutDialog myDlg = new AboutDialog();
778 myDlg.ShowDialog(this);
779 }
780
781 private void ViewToolbar_Click(object sender, System.EventArgs e)
782 {
783
784 if (this.ViewToolbar.Checked)
785 {
786 if (this.MdiChildren.Length > 0)
787 {
788 this.New.Visible = false;
789 this.About.Visible = false;
790 }
791 else
792 this.toolBarTool.Hide();
793 this.ViewToolbar.Checked = false;
794 }
795 else
796 {
797 if (this.MdiChildren.Length > 0)
798 {
799 this.New.Visible = true;
800 this.About.Visible = true;
801 }
802 else
803 this.toolBarTool.Show();
804 this.ViewToolbar.Checked = true;
805 }
806
807 }
808
809 private void ViewStatusBar_Click(object sender, System.EventArgs e)
810 {
811 if (this.ViewStatusBar.Checked)
812 {
813 this.myStatusBar.Hide();
814 this.ViewStatusBar.Checked = false;
815 }
816 else
817 {
818 this.myStatusBar.Show();
819 this.ViewStatusBar.Checked = true;
820 }
821 }
822
823 public void OnNewFile()
824 {
825 Form2 newForm = new Form2();
826 newForm.MdiParent = this;
827 IE_WinForms.Form1.myNbOfChildren = IE_WinForms.Form1.myNbOfChildren + 1;
828 newForm.SetIndex (IE_WinForms.Form1.myNbOfChildren, 1);
829 newForm.Show();
830 newForm.InitView();
831 newForm.InitV3D();
832 this.FileExport.Visible = true;
833 this.FileImport.Visible = true;
834 this.Window.Visible = true;
835 this.wireframe.Visible = true;
836 this.shading.Visible = true;
837 this.color.Visible = true;
838 this.material.Visible = true;
839 this.transparency.Visible = true;
840 this.delete.Visible = true;
841 this.Cursor = System.Windows.Forms.Cursors.Default;
842 this.toolBarView.Visible = true;
843 }
844
845 private void FileImport_Popup(object sender, System.EventArgs e)
846 {
847 IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild;
848 if (curForm == null)
849 return;
850 if (curForm.View.IsObjectSelected())
851 {
852 this.ExportBRep.Enabled = true;
853 this.ExportIges.Enabled = true;
854 this.ExportStep.Enabled = true;
855 this.ExportVrml.Enabled = true;
856 this.ExportStl.Enabled = true;
857 }
858
859 }
860
861 private void menuItem1_Click(object sender, System.EventArgs e)
862 {
863 this.Close();
864 }
865
866 private void File_Popup(object sender, System.EventArgs e)
867 {
868 if (this.MdiChildren.Length > 0)
869 this.FileClose.Enabled = true;
870 else
871 {
872 this.FileClose.Enabled = false;
873 this.FileExport.Visible = false;
874 this.FileImport.Visible = false;
875 }
876 }
877
878 private void menuItem4_Click(object sender, System.EventArgs e)
879 {
880 IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild;
881 IE_WinForms.Form2 newView = new Form2();
882 newView.MdiParent = this;
883 newView.Show();
884 newView.InitView();
885 newView.SetContext(curForm.View);
886 newView.View.CreateNewView(newView.Handle);
887 newView.SetNextIndex(curForm);
888 }
889
890 private void WindowCascade_Click(object sender, System.EventArgs e)
891 {
892 this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);
893 }
894
895 private void WindowTile_Click(object sender, System.EventArgs e)
896 {
897 this.LayoutMdi(System.Windows.Forms.MdiLayout.TileVertical);
898 }
899
900 public void SelectionChanged()
901 {
902 if (this.MdiChildren.Length == 0)
903 return;
904 IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild;
905 if (curForm == null)
906 return;
907 switch (curForm.View.DisplayMode())
908 {
909 case -1:
910 this.shading.Enabled = false;
911 this.wireframe.Enabled = false;
912 break;
913 case 0:
914 this.wireframe.Enabled = false;
915 this.shading.Enabled = true;
916 this.transparency.Enabled = false;
917 break;
918 case 1:
919 this.wireframe.Enabled = true;
920 this.shading.Enabled = false;
921 this.transparency.Enabled = true;
922 break;
923 case 10:
924 this.wireframe.Enabled = true;
925 this.shading.Enabled = true;
926 this.transparency.Enabled = true;
927 break;
928 default:
929 break;
930 }
931 bool IsSelected = curForm.View.IsObjectSelected();
932 if (IsSelected)
933 {
934 this.color.Enabled = true;
935 this.material.Enabled = true;
936 this.delete.Enabled = true;
937 }
938 else
939 {
940 this.color.Enabled = false;
941 this.material.Enabled = false;
942 this.transparency.Enabled = false;
943 this.delete.Enabled = false;
944 }
945 if (curForm.DegenerateMode)
946 {
947 this.HlrOff.Pushed = false;
948 this.HlrOn.Pushed = true;
949 }
950 else
951 {
952 this.HlrOff.Pushed = true;
953 this.HlrOn.Pushed = false;
954 }
955 if (curForm.Mode == IE_WinForms.CurrentAction3d.CurAction3d_WindowZooming)
956 this.ZoomWin.Pushed = false;
957
958 }
959
960 public StatusBar StatusBar
961 {
962 get
963 {
964 return this.myStatusBar;
965 }
966 }
967
968 public void OnFileClose()
969 {
970 if (this.MdiChildren.Length <= 1)
971 {
972 this.FileClose.Enabled = false;
973 this.Window.Visible = false;
974 this.wireframe.Visible = false;
975 this.shading.Visible = false;
976 this.color.Visible = false;
977 this.material.Visible = false;
978 this.transparency.Visible = false;
979 this.delete.Visible = false;
980 this.toolBarView.Visible = false;
981 }
982 }
983
984 private void toolBarView_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
985 {
986 IE_WinForms.Form2 curForm = (IE_WinForms.Form2)this.ActiveMdiChild;
987 if (curForm == null)
988 return;
989 switch (toolBarView.Buttons.IndexOf(e.Button))
990 {
991 case 0:
992 curForm.View.ZoomAllView();
993 break;
994 case 1:
995 curForm.Mode = CurrentAction3d.CurAction3d_WindowZooming;
996 this.ZoomWin.Pushed = true;
997 break;
998 case 2:
999 curForm.Mode = CurrentAction3d.CurAction3d_DynamicZooming;
1000 break;
1001 case 3:
1002 curForm.Mode = CurrentAction3d.CurAction3d_DynamicPanning;
1003 break;
1004 case 4:
1005 curForm.Zoom = curForm.View.Scale();
1006 curForm.Mode = CurrentAction3d.CurAction3d_GlobalPanning;
1007 break;
1008 case 5:
1009 curForm.View.FrontView();
1010 break;
1011 case 6:
32757c6e 1012 curForm.View.BackView();
d1a2fee8 1013 break;
1014 case 7:
32757c6e 1015 curForm.View.TopView();
d1a2fee8 1016 break;
1017 case 8:
32757c6e 1018 curForm.View.BottomView();
d1a2fee8 1019 break;
1020 case 9:
32757c6e 1021 curForm.View.LeftView();
d1a2fee8 1022 break;
1023 case 10:
32757c6e 1024 curForm.View.RightView();
d1a2fee8 1025 break;
1026 case 11:
1027 curForm.View.AxoView();
1028 break;
1029 case 12:
1030 curForm.Mode = CurrentAction3d.CurAction3d_DynamicRotation;
1031 break;
1032 case 13:
1033 curForm.View.Reset();
1034 break;
1035 case 14:
1036 curForm.View.SetDegenerateModeOn();
1037 curForm.DegenerateMode = true;
1038 this.HlrOff.Pushed = false;
1039 this.HlrOn.Pushed = true;
1040 break;
1041 case 15:
1042 curForm.View.SetDegenerateModeOff();
1043 curForm.DegenerateMode = false;
1044 this.HlrOn.Pushed = false;
1045 this.HlrOff.Pushed = true;
1046 break;
1047 default:
1048 break;
1049 }
1050 }
1051
1052 private void Form1_Activated(object sender, System.EventArgs e)
1053 {
1054 if (this.toolBarView.Visible)
1055 this.SelectionChanged();
1056 }
1057
1058 private void toolBarView_MouseHover(object sender, System.EventArgs e)
1059 {
1060 this.myStatusBar.Text = "View toolbar";
1061 }
1062
1063 private void toolBarView_MouseLeave(object sender, System.EventArgs e)
1064 {
1065 this.myStatusBar.Text = "";
1066 }
1067
1068 }
1069
1070}