示例#1
0
        public void Earser(Point p0)
        {
            for (int i = lineHistory.Count - 1; i >= 0; i--)
            {
                HLine line = lineHistory[i];
                bool  flag = false;
                foreach (Point p1 in line.PointList)
                {
                    double distance = GetDistance(p0, p1);
                    if (Math.Abs(distance) < 6)
                    {
                        //需要删除
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    lineHistory.RemoveAt(i);
                }
            }
            //擦除矩形
            for (int i = rectHistory.Count - 1; i >= 0; i--)
            {
                HRectangle rect = rectHistory[i];

                if (p0.X > rect.Start.X && p0.X < rect.End.X && p0.Y > rect.Start.Y && p0.Y < rect.End.Y)
                {
                    rectHistory.RemoveAt(i);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 绘制矩形
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        private void DrawRectangle(Graphics g, HRectangle rect)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;
            using (Pen p = new Pen(rect.LineColor, rect.LineWidth))
            {
                //设置起止点线帽
                p.StartCap = LineCap.Round;
                p.EndCap   = LineCap.Round;

                //设置连续两段的联接样式
                p.LineJoin = LineJoin.Round;
                g.DrawRectangle(p, rect.Start.X, rect.Start.Y, rect.End.X - rect.Start.X, rect.End.Y - rect.Start.Y); //画平滑曲线
            }
        }