home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / form1.cs < prev    next >
Encoding:
Text File  |  2004-07-15  |  20.7 KB  |  654 lines

  1. //******************************************************************'
  2. //*                                                                *'
  3. //*                      TurboCAD for Windows                      *'
  4. //*                   Copyright (c) 1993 - 2004                    *'
  5. //*             International Microcomputer Software, Inc.         *'
  6. //*                            (IMSI)                              *'
  7. //*                      All rights reserved.                      *'
  8. //*                                                                *'
  9. //******************************************************************'
  10.  
  11. using System;
  12. using System.Drawing;
  13. using System.Collections;
  14. using System.ComponentModel;
  15. using System.Windows.Forms;
  16. using System.Data;
  17. enum ActiveTool
  18. {
  19.     iSelectTool = 0,
  20.     iAddLineSingleTool = 1,
  21.     iAddCircleCenterAndPoint = 2
  22. }
  23. namespace TCGeometry
  24. {
  25.     /// <summary>
  26.     /// Summary description for Form1.
  27.     /// </summary>
  28.     public class Form1 : System.Windows.Forms.Form
  29.     {
  30.         int firstPointX;
  31.         int firstPointY;
  32.         int previousMoveX;
  33.         int previousMoveY;
  34.         const string    sTitle = "TCGeometry sample application !";
  35.         private System.Windows.Forms.PictureBox picView;
  36.         private System.Windows.Forms.GroupBox groupBox1;
  37.         private System.Windows.Forms.Button cmCreateTCApp;
  38.         private System.Windows.Forms.GroupBox groupBox2;
  39.         private System.Windows.Forms.Button cmNewDrawing;
  40.         private System.Windows.Forms.Button cmCloseDrawing;
  41.         private System.Windows.Forms.Button cmZoomIn;
  42.         private System.Windows.Forms.Button cmZoomOut;
  43.         private System.Windows.Forms.Button cmZoomExtents;
  44.         private System.Windows.Forms.Button cmCreateLine;
  45.         private System.Windows.Forms.Button cmCreateCircle;
  46.         private System.Windows.Forms.Button cmSelect;
  47.         private System.Windows.Forms.StatusBar statusBar1;
  48.         private System.Drawing.Drawing2D.GraphicsPath mousePath;
  49.         private System.Drawing.Graphics pGraphics;
  50.         private System.Drawing.Pen pPen;
  51.         private System.Drawing.Pen pPenBackground;
  52.         /// <summary>
  53.         /// Required designer variable.
  54.         /// </summary>
  55.         private System.ComponentModel.Container components = null;
  56.         private System.Windows.Forms.TreeView propsPalette;
  57.         private System.Windows.Forms.Label label1;
  58.         private System.Windows.Forms.Label label2;
  59.         private System.Windows.Forms.Label label3;
  60.         private TCengine tcApp;
  61.         private bool m_bDrag;
  62.         private ActiveTool m_iActiveTool;
  63.         private System.Drawing.Color m_BackgroundColor;
  64.         public Form1()
  65.         {
  66.             //
  67.             // Required for Windows Form Designer support
  68.             //
  69.             InitializeComponent();
  70.             picView.MouseMove += new System.Windows.Forms.MouseEventHandler(picView_MouseMove);
  71.             picView.MouseDown += new System.Windows.Forms.MouseEventHandler(picView_MouseDown);
  72.             mousePath = new System.Drawing.Drawing2D.GraphicsPath();
  73.             pGraphics = picView.CreateGraphics ();
  74.             pGraphics.CompositingQuality  = System.Drawing.Drawing2D.CompositingQuality.HighQuality  ;
  75.             //pGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
  76.             pPen = new Pen(System.Drawing.Color.Blue ,1);
  77.             //pPenBackground = new Pen (picView.BackColor  ,1);
  78.             EnableButtons(false);
  79.             tcApp = new TCengine ();
  80.             firstPointX = firstPointY = -1;
  81.             previousMoveX = previousMoveY = -1;
  82.             m_bDrag = false;
  83.             m_iActiveTool = ActiveTool.iSelectTool;
  84.             //
  85.             // TODO: Add any constructor code after InitializeComponent call
  86.             //
  87.         }
  88.  
  89.         /// <summary>
  90.         /// Clean up any resources being used.
  91.         /// </summary>
  92.         protected override void Dispose( bool disposing )
  93.         {
  94.             if( disposing )
  95.             {
  96.                 if (components != null) 
  97.                 {
  98.                     components.Dispose();
  99.                 }
  100.             }
  101.             if (tcApp.m_gxApp != null)
  102.             {
  103.                 tcApp.m_gxApp.Quit ();
  104.  
  105.             }
  106.             base.Dispose( disposing );
  107.         }
  108.  
  109.         #region Windows Form Designer generated code
  110.         /// <summary>
  111.         /// Required method for Designer support - do not modify
  112.         /// the contents of this method with the code editor.
  113.         /// </summary>
  114.         private void InitializeComponent()
  115.         {
  116.             this.picView = new System.Windows.Forms.PictureBox();
  117.             this.cmCreateTCApp = new System.Windows.Forms.Button();
  118.             this.groupBox1 = new System.Windows.Forms.GroupBox();
  119.             this.groupBox2 = new System.Windows.Forms.GroupBox();
  120.             this.cmNewDrawing = new System.Windows.Forms.Button();
  121.             this.cmCloseDrawing = new System.Windows.Forms.Button();
  122.             this.propsPalette = new System.Windows.Forms.TreeView();
  123.             this.cmZoomIn = new System.Windows.Forms.Button();
  124.             this.cmZoomOut = new System.Windows.Forms.Button();
  125.             this.cmZoomExtents = new System.Windows.Forms.Button();
  126.             this.cmCreateLine = new System.Windows.Forms.Button();
  127.             this.cmCreateCircle = new System.Windows.Forms.Button();
  128.             this.cmSelect = new System.Windows.Forms.Button();
  129.             this.statusBar1 = new System.Windows.Forms.StatusBar();
  130.             this.label1 = new System.Windows.Forms.Label();
  131.             this.label2 = new System.Windows.Forms.Label();
  132.             this.label3 = new System.Windows.Forms.Label();
  133.             this.groupBox2.SuspendLayout();
  134.             this.SuspendLayout();
  135.             // 
  136.             // picView
  137.             // 
  138.             this.picView.BackColor = System.Drawing.SystemColors.ControlLight;
  139.             this.picView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  140.             this.picView.Location = new System.Drawing.Point(24, 152);
  141.             this.picView.Name = "picView";
  142.             this.picView.Size = new System.Drawing.Size(528, 360);
  143.             this.picView.TabIndex = 0;
  144.             this.picView.TabStop = false;
  145.             // 
  146.             // cmCreateTCApp
  147.             // 
  148.             this.cmCreateTCApp.Location = new System.Drawing.Point(32, 32);
  149.             this.cmCreateTCApp.Name = "cmCreateTCApp";
  150.             this.cmCreateTCApp.Size = new System.Drawing.Size(64, 24);
  151.             this.cmCreateTCApp.TabIndex = 1;
  152.             this.cmCreateTCApp.Text = "Create";
  153.             this.cmCreateTCApp.Click += new System.EventHandler(this.cmCreateTCApp_Click);
  154.             // 
  155.             // groupBox1
  156.             // 
  157.             this.groupBox1.Location = new System.Drawing.Point(24, 8);
  158.             this.groupBox1.Name = "groupBox1";
  159.             this.groupBox1.Size = new System.Drawing.Size(216, 56);
  160.             this.groupBox1.TabIndex = 2;
  161.             this.groupBox1.TabStop = false;
  162.             this.groupBox1.Text = "Application";
  163.             // 
  164.             // groupBox2
  165.             // 
  166.             this.groupBox2.Controls.Add(this.cmNewDrawing);
  167.             this.groupBox2.Controls.Add(this.cmCloseDrawing);
  168.             this.groupBox2.Location = new System.Drawing.Point(264, 8);
  169.             this.groupBox2.Name = "groupBox2";
  170.             this.groupBox2.Size = new System.Drawing.Size(264, 56);
  171.             this.groupBox2.TabIndex = 2;
  172.             this.groupBox2.TabStop = false;
  173.             this.groupBox2.Text = "Drawing";
  174.             // 
  175.             // cmNewDrawing
  176.             // 
  177.             this.cmNewDrawing.Location = new System.Drawing.Point(8, 24);
  178.             this.cmNewDrawing.Name = "cmNewDrawing";
  179.             this.cmNewDrawing.Size = new System.Drawing.Size(64, 24);
  180.             this.cmNewDrawing.TabIndex = 1;
  181.             this.cmNewDrawing.Text = "New";
  182.             this.cmNewDrawing.Click += new System.EventHandler(this.cmNewDrawing_Click);
  183.             // 
  184.             // cmCloseDrawing
  185.             // 
  186.             this.cmCloseDrawing.Location = new System.Drawing.Point(88, 24);
  187.             this.cmCloseDrawing.Name = "cmCloseDrawing";
  188.             this.cmCloseDrawing.Size = new System.Drawing.Size(64, 24);
  189.             this.cmCloseDrawing.TabIndex = 1;
  190.             this.cmCloseDrawing.Text = "Close";
  191.             this.cmCloseDrawing.Click += new System.EventHandler(this.cmCloseDrawing_Click);
  192.             // 
  193.             // propsPalette
  194.             // 
  195.             this.propsPalette.ImageIndex = -1;
  196.             this.propsPalette.Location = new System.Drawing.Point(576, 152);
  197.             this.propsPalette.Name = "propsPalette";
  198.             this.propsPalette.SelectedImageIndex = -1;
  199.             this.propsPalette.Size = new System.Drawing.Size(240, 376);
  200.             this.propsPalette.TabIndex = 3;
  201.             // 
  202.             // cmZoomIn
  203.             // 
  204.             this.cmZoomIn.Location = new System.Drawing.Point(32, 80);
  205.             this.cmZoomIn.Name = "cmZoomIn";
  206.             this.cmZoomIn.Size = new System.Drawing.Size(64, 24);
  207.             this.cmZoomIn.TabIndex = 1;
  208.             this.cmZoomIn.Text = "Zoom In";
  209.             this.cmZoomIn.Click += new System.EventHandler(this.cmZoomIn_Click);
  210.             // 
  211.             // cmZoomOut
  212.             // 
  213.             this.cmZoomOut.Location = new System.Drawing.Point(112, 80);
  214.             this.cmZoomOut.Name = "cmZoomOut";
  215.             this.cmZoomOut.Size = new System.Drawing.Size(64, 24);
  216.             this.cmZoomOut.TabIndex = 1;
  217.             this.cmZoomOut.Text = "Zoom Out";
  218.             this.cmZoomOut.Click += new System.EventHandler(this.cmZoomOut_Click);
  219.             // 
  220.             // cmZoomExtents
  221.             // 
  222.             this.cmZoomExtents.Location = new System.Drawing.Point(200, 80);
  223.             this.cmZoomExtents.Name = "cmZoomExtents";
  224.             this.cmZoomExtents.Size = new System.Drawing.Size(88, 24);
  225.             this.cmZoomExtents.TabIndex = 1;
  226.             this.cmZoomExtents.Text = "Zoom Extents";
  227.             this.cmZoomExtents.Click += new System.EventHandler(this.cmZoomExtents_Click);
  228.             // 
  229.             // cmCreateLine
  230.             // 
  231.             this.cmCreateLine.Location = new System.Drawing.Point(304, 80);
  232.             this.cmCreateLine.Name = "cmCreateLine";
  233.             this.cmCreateLine.Size = new System.Drawing.Size(64, 24);
  234.             this.cmCreateLine.TabIndex = 1;
  235.             this.cmCreateLine.Text = "Add Line";
  236.             this.cmCreateLine.Click += new System.EventHandler(this.cmCreateLine_Click);
  237.             // 
  238.             // cmCreateCircle
  239.             // 
  240.             this.cmCreateCircle.Location = new System.Drawing.Point(384, 80);
  241.             this.cmCreateCircle.Name = "cmCreateCircle";
  242.             this.cmCreateCircle.Size = new System.Drawing.Size(64, 24);
  243.             this.cmCreateCircle.TabIndex = 1;
  244.             this.cmCreateCircle.Text = "Add Circle";
  245.             this.cmCreateCircle.Click += new System.EventHandler(this.cmCreateCircle_Click);
  246.             // 
  247.             // cmSelect
  248.             // 
  249.             this.cmSelect.Location = new System.Drawing.Point(464, 80);
  250.             this.cmSelect.Name = "cmSelect";
  251.             this.cmSelect.Size = new System.Drawing.Size(64, 24);
  252.             this.cmSelect.TabIndex = 1;
  253.             this.cmSelect.Text = "Select";
  254.             this.cmSelect.Click += new System.EventHandler(this.cmSelect_Click);
  255.             // 
  256.             // statusBar1
  257.             // 
  258.             this.statusBar1.Location = new System.Drawing.Point(0, 519);
  259.             this.statusBar1.Name = "statusBar1";
  260.             this.statusBar1.Size = new System.Drawing.Size(824, 22);
  261.             this.statusBar1.TabIndex = 4;
  262.             // 
  263.             // label1
  264.             // 
  265.             this.label1.Location = new System.Drawing.Point(576, 120);
  266.             this.label1.Name = "label1";
  267.             this.label1.Size = new System.Drawing.Size(144, 24);
  268.             this.label1.TabIndex = 5;
  269.             this.label1.Text = "Properties:";
  270.             // 
  271.             // label2
  272.             // 
  273.             this.label2.Location = new System.Drawing.Point(24, 120);
  274.             this.label2.Name = "label2";
  275.             this.label2.TabIndex = 6;
  276.             this.label2.Text = "Active Tool :";
  277.             // 
  278.             // label3
  279.             // 
  280.             this.label3.Location = new System.Drawing.Point(144, 120);
  281.             this.label3.Name = "label3";
  282.             this.label3.Size = new System.Drawing.Size(208, 23);
  283.             this.label3.TabIndex = 7;
  284.             // 
  285.             // Form1
  286.             // 
  287.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  288.             this.CausesValidation = false;
  289.             this.ClientSize = new System.Drawing.Size(824, 541);
  290.             this.Controls.Add(this.label3);
  291.             this.Controls.Add(this.label2);
  292.             this.Controls.Add(this.label1);
  293.             this.Controls.Add(this.statusBar1);
  294.             this.Controls.Add(this.propsPalette);
  295.             this.Controls.Add(this.cmCreateTCApp);
  296.             this.Controls.Add(this.picView);
  297.             this.Controls.Add(this.groupBox1);
  298.             this.Controls.Add(this.groupBox2);
  299.             this.Controls.Add(this.cmZoomIn);
  300.             this.Controls.Add(this.cmZoomOut);
  301.             this.Controls.Add(this.cmZoomExtents);
  302.             this.Controls.Add(this.cmCreateLine);
  303.             this.Controls.Add(this.cmCreateCircle);
  304.             this.Controls.Add(this.cmSelect);
  305.             this.MaximizeBox = false;
  306.             this.Name = "Form1";
  307.             this.groupBox2.ResumeLayout(false);
  308.             this.ResumeLayout(false);
  309.  
  310.         }
  311.         #endregion
  312.  
  313.         /// <summary>
  314.         /// The main entry point for the application.
  315.         /// </summary>
  316.         [STAThread]
  317.         static void Main() 
  318.         {
  319.             Application.Run(new Form1());
  320.         }
  321.  
  322.         private void cmCreateTCApp_Click(object sender, System.EventArgs e)
  323.         {
  324.             tcApp.CreategxApp ();
  325.         }
  326.  
  327.         private void cmNewDrawing_Click(object sender, System.EventArgs e)
  328.         {
  329.             tcApp.CreateNewDrawing();
  330.             IMSIGX.Property pProp;
  331.             object varVal = "PaperColor";
  332.             int lcolor;
  333.             pProp = tcApp.m_gxApp.Properties.get_Item(ref varVal);
  334.             lcolor =(int) pProp.get_Value( 0);
  335.             m_BackgroundColor = picView.BackColor;
  336.             picView.BackColor = System.Drawing.ColorTranslator.FromWin32 (lcolor);
  337.             pPenBackground = new Pen (picView.BackColor  ,1);
  338.             tcApp.CreategxView ((int)picView.Handle);
  339.             tcApp.m_gxView.ZoomToExtents ();
  340.             EnableButtons(true);
  341.             this.Text = sTitle + " ------ "+ tcApp.m_gxDrawing.Name ;
  342.         }
  343.  
  344.         private void cmCreateLine_Click(object sender, System.EventArgs e)
  345.         {
  346.             tcApp.m_gxDrawing.Graphics.Unselect ();
  347.             tcApp.m_gxView.Refresh ();
  348.             m_iActiveTool = ActiveTool.iAddLineSingleTool;
  349.             UpdatePrompt();
  350.         }
  351.         void EnableButtons(bool bVal)
  352.         {
  353.             cmCloseDrawing.Enabled = bVal;
  354.             cmZoomIn.Enabled = bVal;
  355.             cmZoomOut.Enabled = bVal;
  356.             cmZoomExtents.Enabled = bVal;
  357.             cmCreateLine.Enabled = bVal;
  358.             cmCreateCircle.Enabled = bVal;
  359.             cmSelect.Enabled = bVal;
  360.             m_iActiveTool = ActiveTool.iSelectTool;
  361.             UpdatePrompt();
  362.         }
  363.  
  364.         private void cmCloseDrawing_Click(object sender, System.EventArgs e)
  365.         {
  366.             object missing = null;
  367.             m_bDrag = false;
  368.             pPenBackground.Dispose ();
  369.             tcApp.m_gxDrawing.Close (ref missing, ref missing, ref missing);
  370.             tcApp.m_gxDrawing = null;
  371.             tcApp.m_gxView = null;
  372.             EnableButtons(false);
  373.             Form1.ActiveForm.Text = sTitle;
  374.             picView.BackColor = m_BackgroundColor;
  375.             picView.Refresh ();
  376.             statusBar1.Text = "";
  377.         }
  378.  
  379.         private void picView_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
  380.         {
  381.             // Update the mouse path that is drawn onto the Panel.
  382.             UpdatePrompt();
  383.             if (!m_bDrag)
  384.                 return;
  385.  
  386.             int mouseX = e.X;
  387.             int mouseY = e.Y;
  388.             float r = 0;
  389.  
  390.             switch (m_iActiveTool)
  391.             {
  392.                 case ActiveTool.iAddLineSingleTool:
  393.                 {
  394.                     if (m_bDrag == true)
  395.                     {
  396.                         // draw previous state of line with background color to hide it
  397.                         pGraphics.DrawLine (pPenBackground,firstPointX,firstPointY,previousMoveX, previousMoveY);
  398.                         // draw current staet of line
  399.                         pGraphics.DrawLine (pPen,firstPointX,firstPointY,mouseX, mouseY);
  400.                     }
  401.                 }
  402.                     break;
  403.                 case ActiveTool.iAddCircleCenterAndPoint:
  404.                 {
  405.                     // calculate radius for previous state of the circle
  406.                     r = (float)System.Math.Sqrt ((firstPointX - previousMoveX)*(firstPointX - previousMoveX) + (firstPointY - previousMoveY) * (firstPointY - previousMoveY));
  407.                     if (r != 0)
  408.                     {
  409.                         // hide previous state of circle by draw it with background color
  410.                         pGraphics.DrawArc (pPenBackground, firstPointX - r, firstPointY - r , 2*r, 2*r, 0, 360);
  411.                     }
  412.                     // calculate radius of circle for current state
  413.                     r = (float)System.Math.Sqrt ((firstPointX - mouseX)*(firstPointX - mouseX) + (firstPointY - mouseY) * (firstPointY - mouseY));
  414.                     if (r != 0)
  415.                     {
  416.                         // draw current state of the circle
  417.                         pGraphics.DrawArc (pPen, firstPointX - r, firstPointY - r , 2*r, 2*r, 0, 360);
  418.                     }
  419.                 }
  420.                     break;
  421.             }
  422.             previousMoveX = mouseX;
  423.             previousMoveY = mouseY;
  424.  
  425.             if (tcApp.m_gxView !=null)
  426.             {
  427.                 tcApp.m_gxView.Refresh ();
  428.             }
  429.             return;
  430.             
  431.         }
  432.         private void picView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  433.         {
  434.             // Update the mouse path that is drawn onto the Panel.
  435.             IMSIGX.IGraphic gxGraphic;
  436.             int mouseX = e.X;
  437.             int mouseY = e.Y;
  438.             if (tcApp.m_gxView == null)
  439.                 return;
  440.             if (e.Button == MouseButtons.Left)
  441.             {
  442.                 if (m_iActiveTool != ActiveTool.iSelectTool )
  443.                 {
  444.                     // if firstPointX nad firstPointY equal -1 it means that tool just started and 
  445.                     // is in first click mode
  446.                     if (firstPointY == -1 && firstPointX == -1)
  447.                     {
  448.                         // store coordinates of first click
  449.                         firstPointX = mouseX;
  450.                         firstPointY = mouseY;
  451.                         // switch to second click mode
  452.                         m_bDrag = true;
  453.                         UpdatePrompt();
  454.                         return;
  455.                     }
  456.                 }
  457.  
  458.                 switch (m_iActiveTool)
  459.                 {
  460.                     case ActiveTool.iSelectTool :
  461.                     {
  462.                         tcApp.m_gxDrawing.Graphics.Unselect ();
  463.                         IMSIGX.IGraphic gxSelectedGraphic = tcApp.SelectGraphic(mouseX, mouseY);
  464.                         FillPropertiesPalette(gxSelectedGraphic);
  465.                         tcApp.m_gxView.Refresh ();
  466.                     }
  467.                     break;
  468.  
  469.                     case ActiveTool.iAddLineSingleTool  :
  470.                     {
  471.                         gxGraphic = tcApp.AddLineSingle (firstPointX,firstPointY, mouseX, mouseY);
  472.                         m_bDrag = false;
  473.                         firstPointX = -1;
  474.                         firstPointY = -1;
  475.                         previousMoveX = -1;
  476.                         previousMoveY = -1;
  477.                     }
  478.                     break;
  479.  
  480.                     case ActiveTool.iAddCircleCenterAndPoint :
  481.                     {
  482.                         gxGraphic = tcApp.AddCircleCenterAndPoint (firstPointX,firstPointY, mouseX, mouseY);
  483.                         m_bDrag = false;
  484.                         firstPointX = -1;
  485.                         firstPointY = -1;
  486.                         previousMoveX = -1;
  487.                         previousMoveY = -1;
  488.                     }    
  489.                     break;
  490.  
  491.                 
  492.                 
  493.                 }
  494.                 picView.Refresh ();
  495.                 tcApp.m_gxView.Refresh ();
  496.                 UpdatePrompt();
  497.                 return;
  498.             }
  499.         }
  500.         private void cmZoomExtents_Click(object sender, System.EventArgs e)
  501.         {
  502.             if (tcApp.m_gxView != null)
  503.             {
  504.                 picView.Refresh ();
  505.                 tcApp.m_gxView.ZoomToExtents ();
  506.             }
  507.         }
  508.  
  509.         private void cmSelect_Click(object sender, System.EventArgs e)
  510.         {
  511.             statusBar1.Text = "Select object";
  512.             m_iActiveTool = ActiveTool.iSelectTool ;
  513.             UpdatePrompt();
  514.             FillPropertiesPalette(null);
  515.         }
  516.  
  517.         private void cmCreateCircle_Click(object sender, System.EventArgs e)
  518.         {
  519.             tcApp.m_gxDrawing.Graphics.Unselect ();
  520.             tcApp.m_gxView.Refresh ();
  521.             m_iActiveTool = ActiveTool.iAddCircleCenterAndPoint;
  522.             UpdatePrompt();
  523.         }
  524.         private void UpdatePrompt()
  525.         {
  526.             statusBar1.Text = "";
  527.             switch (m_iActiveTool)
  528.             {
  529.                 case ActiveTool.iSelectTool :
  530.                 {
  531.                     statusBar1.Text = "Select Object";
  532.                     label3.Text = "Select Tool";
  533.                 }
  534.                 break;
  535.                 case ActiveTool.iAddLineSingleTool:
  536.                 {
  537.                     if (m_bDrag == false)
  538.                     {
  539.                         statusBar1.Text = "Define the start point of the line";
  540.                         label3.Text = "Add Single Line";
  541.                     }
  542.                     else
  543.                     {
  544.                         statusBar1.Text = "Define the end point of the line";
  545.                         label3.Text = "Add Single Line";
  546.                     }
  547.                 }
  548.                 break;
  549.                 case ActiveTool.iAddCircleCenterAndPoint:
  550.                 {
  551.                     if (m_bDrag == false)
  552.                     {
  553.                         statusBar1.Text = "Define the center point of the circle";
  554.                         label3.Text = "Add Circle Center and Point";
  555.                     }
  556.                     else
  557.                     {
  558.                         statusBar1.Text = "Define a second point of the circle's circumferences";
  559.                         label3.Text = "Add Circle Center and Point";
  560.                     }
  561.                 
  562.                 }
  563.                     break;
  564.  
  565.             }
  566.         }
  567.  
  568.         private void FillPropertiesPalette(IMSIGX.IGraphic gxGraphic)
  569.         {
  570.             //propsPalette.TopNode.Collapse();
  571.             ClearPropertiesPalette();
  572.             if (gxGraphic == null)
  573.                 return;
  574.             // fill common info
  575.             TreeNode pRootNode, pchildNode;
  576.             IMSIGX.Vertices  gxVertices;
  577.             IMSIGX.IVertex    gxVertex;
  578.             object var;
  579.             double vardblVal;
  580.             double radius;
  581.             double xCenter, yCenter, X,Y,Z;
  582.             vardblVal = 0;
  583.             pRootNode = propsPalette.Nodes.Add ("General");
  584.             pRootNode.Nodes.Add ("GraphicID = " + gxGraphic.ID );
  585.             pRootNode.Nodes.Add ("Type = " + gxGraphic.Type );
  586.             pRootNode = propsPalette.Nodes.Add ("Geometry Information");
  587.             gxVertices = gxGraphic.Vertices;
  588.             if (gxGraphic.TypeByValue == IMSIGX.ImsiGraphicType.imsiArc )
  589.             {
  590.  
  591.                 pchildNode = pRootNode.Nodes.Add ("Center");
  592.                 var = 0;
  593.                 gxVertex = gxVertices.get_Item(ref var);
  594.                 xCenter = gxVertex.X;
  595.                 yCenter = gxVertex.Y;
  596.                 vardblVal = gxVertex.X ;
  597.                 pchildNode.Nodes.Add ("X = " + vardblVal.ToString ());
  598.                 vardblVal = gxVertex.Y;
  599.                 pchildNode.Nodes.Add ("Y = " + vardblVal.ToString ());
  600.                 pchildNode.Nodes.Add ("Z = 0");
  601.                 
  602.                 var = 1;
  603.                 gxVertex = gxVertices.get_Item(ref var);
  604.                 X = gxVertex.X;
  605.                 Y = gxVertex.Y;
  606.                 radius = (float)System.Math.Sqrt ((xCenter - X)*(xCenter - X) + (yCenter - Y) * (yCenter - Y));
  607.                 pchildNode = pRootNode.Nodes.Add ("Radius " + radius.ToString ());
  608.             }
  609.             else if (gxGraphic.TypeByValue == IMSIGX.ImsiGraphicType.imsiPolyline )
  610.             {
  611.                 int n, i;
  612.                 n = gxVertices.Count;
  613.                 pRootNode = pRootNode.Nodes.Add ("Vertices");
  614.                 for (i = 0; i < n; i++)
  615.                 {
  616.                     var = i;
  617.                     gxVertex = gxVertices.get_Item(ref var);
  618.                     pchildNode = pRootNode.Nodes.Add ("V " + var.ToString ());
  619.                     X = gxVertex.X;
  620.                     Y = gxVertex.Y;
  621.                     Z = gxVertex.Z;
  622.                     pchildNode.Nodes.Add ("X = " + X.ToString ());
  623.                     pchildNode.Nodes.Add ("Y = " + Y.ToString ());
  624.                     pchildNode.Nodes.Add ("Z = " + Z.ToString ());
  625.                 }
  626.  
  627.             }
  628.             gxGraphic.Drawing.Graphics.Unselect ();
  629.             gxGraphic.Selected = true;
  630.             tcApp.m_gxView.Refresh ();
  631.             propsPalette.ExpandAll ();                        
  632.         }
  633.         private void ClearPropertiesPalette()
  634.         {
  635.             propsPalette.Nodes.Clear ();
  636.             
  637.         }
  638.  
  639.         private void cmZoomIn_Click(object sender, System.EventArgs e)
  640.         {
  641.             tcApp.Zoom (0.8);
  642.             picView.Refresh ();
  643.             tcApp.m_gxView.Refresh ();
  644.         }
  645.  
  646.         private void cmZoomOut_Click(object sender, System.EventArgs e)
  647.         {
  648.             tcApp.Zoom (1.2);
  649.             picView.Refresh ();
  650.             tcApp.m_gxView.Refresh ();
  651.         }
  652.     }
  653. }
  654.