Beispiel #1
0
        /// <summary>
        /// 圖面點擊事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dxf_view_MouseClick(object sender, MouseEventArgs e)
        {
            DataGridViewRowCollection pdata = pointdata.Rows;                                                        //宣告右邊表格"行"控制項

            if (e.Button == MouseButtons.Right && !active_zeropoint && zero_exist && ruler_exist && !mouse_move_pic) //普通標點 條件:滑鼠右鍵,沒在標原點,原點存在,比例尺存在
            {
                count++;                                                                                             //計算標到第幾點
                pointarray[count] = new pointer(s.X + e.X, s.Y + e.Y, count);                                        //用dxf_view座標與滑鼠座標算出該像素在bitmap位置
                draw_dxf.SetPixel(s.X + e.X, s.Y + e.Y, Color.Red);                                                  //標的位置//如點到bitmap外會崩潰 FIX ME
                pointarray[count].x_to_zero = pointer_x_to_zero(pointarray[count]);                                  //與原點距離 單位:像素
                pointarray[count].y_to_zero = pointer_y_to_zero(pointarray[count]);

                if (mouselock)
                {
                    pointarray[count].ori_x = ori_lock_x;//存鎖點的資料
                    pointarray[count].ori_y = ori_lock_y;
                    if (zeropoint.ori_x >= 0 && zeropoint.ori_y >= 0)
                    {
                        pointarray[count].x_to_zero_dou = (pointarray[count].ori_x - zeropoint.ori_x) * pixellength;//有原始資料便用原始資料算距離
                        pointarray[count].y_to_zero_dou = (pointarray[count].ori_y - zeropoint.ori_y) * pixellength;
                    }
                    else
                    {
                        pointarray[count].x_to_zero_dou = pointarray[count].x_to_zero * pixellength;//用比例尺算與原點距離
                        pointarray[count].y_to_zero_dou = pointarray[count].y_to_zero * pixellength;
                    }
                }
                else
                {
                    pointarray[count].ori_x         = -1;                                        //沒鎖點便存-1
                    pointarray[count].ori_y         = -1;
                    pointarray[count].x_to_zero_dou = pointarray[count].x_to_zero * pixellength; //用比例尺算與原點距離
                    pointarray[count].y_to_zero_dou = pointarray[count].y_to_zero * pixellength;
                }

                pointarray[count].sizenum = sizenum;//標點時的縮放倍率
                dxf_view.Image            = cut(s, dxf_view.Width, dxf_view.Height);

                pdata.Add(new object[] { pointarray[count].number.ToString(), pointarray[count].x_to_zero_dou.ToString(), pointarray[count].y_to_zero_dou.ToString() });     //資料顯示在右邊表格

                label1.Text = label1.Text + "\n" + pointarray[count].x_to_zero_dou.ToString() + "\n" + pointarray[count].y_to_zero_dou.ToString() + "\n" + count.ToString(); //測試用 ***完成後應刪除
            }

            else if (active_zeropoint && ruler_exist && e.Button == MouseButtons.Right && !mouse_move_pic) //原點標點
            {
                if (zero_exist)                                                                            //如有上個原點 將其變回白色
                {
                    draw_dxf.SetPixel(zeropoint.drawpoint.X, zeropoint.drawpoint.Y, Color.White);
                }
                zeropoint = new originpoint(new Point(s.X + e.X, s.Y + e.Y));//用dxf_view座標和滑鼠座標算在bitmap位置
                draw_dxf.SetPixel(s.X + e.X, s.Y + e.Y, Color.Blue);
                dxf_view.Image = cut(s, dxf_view.Width, dxf_view.Height);
                if (mouselock)
                {
                    zeropoint.ori_x = ori_lock_x;//存鎖點的資料
                    zeropoint.ori_y = ori_lock_y;
                }
                else
                {
                    zeropoint.ori_x = -1;//沒鎖點便存-1
                    zeropoint.ori_y = -1;
                }
                active_zeropoint = false;
                zero_exist       = true;
                label1.Text      = label1.Text + "\n" + zeropoint.drawpoint.X.ToString() + "\n" + zeropoint.drawpoint.Y.ToString();//測試用 ***完成後應刪除
            }

            if (startrulerset && e.Button == MouseButtons.Right && !mouse_move_pic)//設比例尺 點圖面上兩點手動填入距離算比例尺
            {
                if (c == 1)
                {
                    rulers = new Point(s.X + e.X, s.Y + e.Y);        //第一點座標
                }
                if (c == 2)
                {
                    rulere = new Point(s.X + e.X, s.Y + e.Y);        //第二點座標
                }
                c++;
                if (c >= 3 && length_refer.Text != "" && length_refer.Text != "在此輸入長度")//三以上且有輸入距離會計算比例尺
                {
                    length_refer.Visible = false;
                    startrulerset        = false;
                    ruler_exist          = true;
                    rulersetter();//計算方法
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 工具列measure->set zero
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void setZeroToolStripMenuItem_Click(object sender, EventArgs e)
 {
     active_zeropoint = true;//開始標註原點
     zeropoint        = new originpoint();
 }