Example #1
0
        private void Btn_SelectEntity_Click(object sender, EventArgs e)
        {
            try
            {
                var sPoint = new Point3d();
                var ePoint = new Point3d();
                if (string.IsNullOrEmpty(txt_SymbolSetName.Text.Trim()))
                {
                    lal_tip.Text = "请输入模版名称!";
                    txt_SymbolSetName.Focus();
                    return;
                }
                //选中的实体
                var objIds = PublicMethod.Instance.SelectEntities(ref sPoint, ref ePoint);

                if (objIds != null)
                {
                    if (objIds.Count() <= 120)
                    {
                        if (ePoint.X == 0 && ePoint.Y == 0)
                        {
                            return;
                        }
                        //获取图片的保存路径
                        imgPath = GetImgPath();
                        //生成图片
                        SaveImage.WindowScreenShot(sPoint, ePoint, imgPath);
                        //显示图片
                        pictureBox1.Load(imgPath);
                        //高亮显示选择的实体对象
                        HighlightEntity(objIds);
                        //刷新屏幕
                        Application.UpdateScreen();
                        lal_EntityCount.ForeColor  = Color.Black;
                        lal_EntityCount.Text       = string.Format("已选择{0}个对象", objCollection.Count);
                        txt_SymbolSetName.ReadOnly = true;
                    }
                    else
                    {
                        MessageBox.Show("选择实体过多(不多于120个设备),请重新选择!");
                    }
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception exception)
            {
                PublicMethod.Instance.Editor.WriteMessage(exception.Message);
            }
        }