Example #1
0
 /// <summary>
 /// 绘制该控制点
 /// </summary>
 /// <param name="g"></param>
 public void Draw(Graphics g)
 {
     DrawBorderHandler(g, PositionRect, backColor);
     if (selected)
     {
         //选中时边框变粗
         CustomRectangle rect = new CustomRectangle(x - 4, y - 4, 8, 8);
         g.DrawRectangle(new Pen(Color.Black), rect.ToRectangle());
     }
 }
Example #2
0
        public static CustomRectangle ToCustomRectangle(RectangleF re)
        {
            CustomRectangle cus = new CustomRectangle();

            cus.X      = re.X;
            cus.Y      = re.Y;
            cus.Width  = re.Width;
            cus.Height = re.Height;
            return(cus);
        }
Example #3
0
        void VistaCalendar_Resize(object sender, EventArgs e)
        {
            if (positionRect == null)
            {
                positionRect = new CustomRectangle();
            }
            positionRect.Width  = (int)ImageBg.Width;
            positionRect.Height = (int)ImageBg.Height;
            positionRect.Top    = (int)(this.ClientSize.Height < ImageBg.Height ? 0 : (this.ClientSize.Height - ImageBg.Height) / 2f);
            positionRect.Left   = (int)(this.ClientSize.Width < ImageBg.Width ? 0 : (this.ClientSize.Width - ImageBg.Width) / 2f);

            this.Invalidate();
        }
Example #4
0
        /// <summary>
        /// 鼠标点击测试,看是否在点附近点击
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public bool MouseHitTest(PointF pt)
        {
            CustomRectangle rect = new CustomRectangle(x - 5, y - 5, 10, 10);   //判断选中时加点误差,使选中更加顺利

            return(rect.IsPointFInRectangle(pt.X, pt.Y));
        }
Example #5
0
 /// <summary>
 /// 绘制边框句柄
 /// </summary>
 /// <param name="g"></param>
 /// <param name="rect"></param>
 private void DrawBorderHandler(Graphics g, CustomRectangle rect, Color clr)
 {
     g.FillRectangle(new SolidBrush(clr), rect.ToRectangleF());
     g.DrawRectangle(new Pen(Color.Black), rect.ToRectangle());
 }