当前位置:编程学习 > C#/ASP.NET >>

c#如何像win7一样框选桌面图标实现鼠标框选

c#如何像win7框选桌面图标一样,实现对控件的框选,框选的区域是一个有背景色而透明的距形,控件要透过这个距形,知道的朋友请贴上代码,谢谢啦. --------------------编程问答-------------------- 两种方式:
1)

private void HandleZoomDragEx(Graphics g)
            {
                if (Math.Abs(_dragStartPt.X - _dragEndPt.X) < 4 &&
                   Math.Abs(_dragEndPt.Y - _dragStartPt.Y) < 4)
                {
                    return;
                }

                using (Pen pen = new Pen(Color.Black, 1))
                {
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    pen.DashPattern = new float[2] { 3, 3 };
                    pen.DashOffset = 3;
                    int w, h;
                    w = Math.Abs(_dragStartPt.X - _dragEndPt.X);
                    h = Math.Abs(_dragStartPt.Y - _dragEndPt.Y);

                    Point? ptStart = null;


                    if (_dragStartPt.X < _dragEndPt.X && _dragStartPt.Y < _dragEndPt.Y)
                    {
                        ptStart = _dragStartPt;
                    }
                    else if (_dragStartPt.X > _dragEndPt.X && _dragStartPt.Y > _dragEndPt.Y)
                    {
                        ptStart = _dragEndPt;
                    }
                    else if (_dragStartPt.X > _dragEndPt.X && _dragStartPt.Y < _dragEndPt.Y)
                    {
                        ptStart = new Point(_dragEndPt.X, _dragStartPt.Y);
                    }
                    else
                    {
                        ptStart = new Point(_dragStartPt.X, _dragEndPt.Y);
                    }

                    g.DrawRectangle(pen, new Rectangle(ptStart.Value, new Size(w, h)));
                }
            }


2)
ControlPaint.DrawReversibleFrame(rect, BackColor, FrameStyle.Dashed); --------------------编程问答--------------------
引用楼主 anlylee 的回复:
c#如何像win7框选桌面图标一样,实现对控件的框选,框选的区域是一个有背景色而透明的距形,控件要透过这个距形,知道的朋友请贴上代码,谢谢啦.

怎么用呢
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,