Beispiel #1
0
 // 提示鼠标双击下被点击的实体
 private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
 {
     //"lType 是事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击.lRet 返回非0,消息将不在往下传递"
     //选择后
     if (e.lType == 5)
     {
         // 构建选择集,找到鼠标左建双击下的实体。
         MxDrawSelectionSet ssGet = new MxDrawSelectionSet();
         //构造选择集
         ssGet.Select(MCAD_McSelect.mcSelectionSetUserSelect, null, null);//MCAD_McSelect构造选择集方式
         if (ssGet.Count > 0)
         {
             //contextMenuStrip1.Show(Control.MousePosition.X, Control.MousePosition.Y);
             DataGridBindDataTable(this.dataGridViewX1, RetTable());
             DataGridBindDataTable(this.dataGridViewX2, RetDetailTable());
             MessageBox.Show(ssGet.Count + "个图块被选择");
             axMxDrawX1.Focus();
         }
     }
     else if (e.lType == 6)
     {
         //控件中的选择集构造管理器,用图面上的实体搜索,与用户交互选择等操作
         MxDrawSelectionSet ssGet = new MxDrawSelectionSet();
         //构造选择集
         ssGet.Select(MCAD_McSelect.mcSelectionSetUserSelect, null, null);//MCAD_McSelect构造选择集方式
         if (ssGet.Count > 0)
         {
             //contextMenuStrip1.Show(Control.MousePosition.X, Control.MousePosition.Y);
             axMxDrawX1.Focus();
         }
     }
 }
Beispiel #2
0
        //鼠标点击事件
        private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
        {
            /*
             * 事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击
             * 5是鼠标左键释放 6是鼠标右键释放 7是鼠标中键按下 8是鼠标中键释放
             * 9是鼠标中键双击 10是鼠标中键滚动
             */

            switch (e.lType)
            {
            case 4:    //左键选择元素图层--所有元素
                //if(bar_state.state==true&& bar_state.id == 1001)
            {
                MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet();
                MxDrawResbuf       filter          = new MxDrawResbuf();
                MxDrawPoint        point           = new MxDrawPoint();
                point.x = e.dX; point.y = e.dY;
                mxDrawSelection.SelectAtPoint(point, filter);
                if (mxDrawSelection.Count > 0)
                {
                    MxDrawEntity entity = mxDrawSelection.Item(1);
                    //MxDrawLayerTable layer = (axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
                    //MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer);
                    if (entity.ObjectName == "McDbLine")
                    {
                        MessageBox.Show(JsonConvert.SerializeObject(new
                            {
                                handle = entity.handle,
                                ID     = entity.ObjectID,
                                Line   = entity.ObjectName,
                                B      = entity.LineType,
                                pt1    = ((MxDrawLine)entity).GetStartPoint(),
                                pt2    = ((MxDrawLine)entity).GetEndPoint(),
                                //color=dd.Color.colorIndex
                            }));
                    }
                    else
                    {
                        MessageBox.Show(JsonConvert.SerializeObject(new
                            {
                                handle = entity.handle,
                                ID     = entity.ObjectID,
                                Line   = entity.ObjectName,
                                B      = entity.LineType,
                                rotate = ((MxDrawText)entity).Rotation
                                         //pt1 = ((MxDrawLine)entity).GetStartPoint(),
                                         //pt2 = ((MxDrawLine)entity).GetEndPoint(),
                                         //color=dd.Color.colorIndex
                            }));
                    }
                    //double c=Models.MathSience.DistanceForPointToABLine(121324.953422, 33700.002475, ((MxDrawLine)entity).GetStartPoint(),((MxDrawLine)entity).GetEndPoint());
                    //double c1 = Algorithm.MathSience.GetAngle(new MxDrawPoint { x = 121324.95342187915, y = 54350.00279569807 }, ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    double c1 = Algorithm.MathSience.GetLineK(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    MessageBox.Show(c1.ToString());
                    //double c = Algorithm.MathSience.GetAngle2(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    //MxDrawLine line = axMxDrawX1.HandleToObject("61FCB") as MxDrawLine;
                    //PointF point1 = Algorithm.MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                }
            }
            break;
            }
        }