コード例 #1
0
        public void DrawRectPlace(RectangleInfo RectInfo, Color textColor)
        {
            Font       f     = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
            SolidBrush brush = new SolidBrush(textColor);
            Pen        pen   = new Pen(textColor, 1);

            SizeF  stringSize = gSurface.MeasureString(RectInfo.Info.Tag.ToString(), f);
            PointF point      = new PointF(RectInfo.Rect.Left + (RectInfo.Rect.Width - stringSize.Width) / 2, RectInfo.Rect.Top + 10);

            gSurface.DrawString(RectInfo.Info.Tag.ToString(), f, brush, point);
        }
コード例 #2
0
        public void DrawRectangleInfo(RectangleInfo RectInfo, Color lineColor, Color fillColor)
        {
            Font       f     = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
            SolidBrush brush = new SolidBrush(lineColor);
            Pen        pen   = new Pen(lineColor, 1);

            SizeF      stringSize = gSurface.MeasureString(RectInfo.Info.Text, f);
            PointF     point      = new PointF(RectInfo.Rect.Left + (RectInfo.Rect.Width - stringSize.Width) / 2, RectInfo.Rect.Top - 30);
            RectangleF textRect   = new RectangleF(point.X, point.Y, stringSize.Width + 2, stringSize.Height);

            gSurface.FillRectangle(new SolidBrush(fillColor), textRect);
            gSurface.DrawRectangle(pen, textRect.X, textRect.Y, textRect.Width, textRect.Height);
            gSurface.DrawLine(pen, new PointF(RectInfo.Rect.Left + RectInfo.Rect.Width / 2, RectInfo.Rect.Top), new PointF(RectInfo.Rect.Left + RectInfo.Rect.Width / 2, textRect.Bottom));

            gSurface.DrawString(RectInfo.Info.Text, f, brush, point);
        }
コード例 #3
0
        public void SelectRectangle(int pointX, int pointY)
        {
            bool          selectionChanged = false, isSelected = false;
            RectangleInfo oldSelected = selected;

            for (int i = 0; i < rectSequence.Count; i++)
            {
                if (rectSequence[i].Rect.Contains(new Point(pointX, pointY)) == true)
                {
                    selected   = rectSequence[i];
                    isSelected = true;
                    if (selected != oldSelected)
                    {
                        selectionChanged = true;
                    }
                    break;
                }
            }

            if (isSelected == false)
            {
                selected         = null;
                selectionChanged = true;
            }

            if (selectionChanged == true)
            {
                if (oldSelected != null)
                {
                    DrawRectangleInfo(oldSelected, Color.White, Color.White); //clearing old rectinfo
                }
                DrawGrid();                                                   // repainting grid

                DrawSequence();                                               // repainting all rects

                if (selected != null)
                {
                    DrawRectangleInfo(selected, Color.Black, selColor); //painting new rectinfo
                }
            }
        }