コード例 #1
0
        public void DrawSquare(int i, int j, Brush b)
        {
            VisualWitness  visual = new VisualWitness();
            DrawingContext dc = visual.RenderOpen();
            int            height = hei, width = wid;
            int            oriX = X + height, oriY = Y + height;
            Rect           r = new Rect(oriX + j * (height + width), oriY + i * (height + width), width, width);
            Pen            p = null;

            if (i == onClick_x && j == onClick_y && onClick == "Square")
            {
                p = new Pen(Brushes.Red, 2);
            }
            dc.DrawRectangle(b, p, r);
            if (SquareOct[i, j] != -1)
            {
                dc.DrawGeometry(GetBrushes(SquareOct[i, j]), null, GetOct(oriX + j * (height + width) + width / 2, oriY + i * (height + width) + width / 2, width / 4));
            }
            if (SquareSqu[i, j] != -1)
            {
                dc.DrawGeometry(GetBrushes(SquareSqu[i, j]), null, GetSqu(oriX + j * (height + width) + width / 2, oriY + i * (height + width) + width / 2, width / 4));
            }
            dc.Close();
            visual.type = "Square";
            visual.x    = i;
            visual.y    = j;
            this.AddVisual(visual);
        }
コード例 #2
0
        public void DrawPoint(int i, int j, Brush b)
        {
            VisualWitness  visual = new VisualWitness();
            DrawingContext dc = visual.RenderOpen();
            int            height = hei, width = wid;
            int            oriX = X, oriY = Y;
            int            x = oriX + j * (height + width), y = oriY + i * (height + width);
            Pen            p = null;

            if (i == onClick_x && j == onClick_y && onClick == "Point")
            {
                p = new Pen(Brushes.Orange, 5);
            }
            if (m.isStartPointSet() && i == m.GetStartPointX() && j == m.GetStartPointY())
            {
                dc.DrawEllipse(b, p, new Point(x + height / 2, y + height / 2), height, height);
            }
            else if (m.isEndPointSet() && i == m.GetEndPointX() && j == m.GetEndPointY())
            {
                Rect rec = new Rect(x, y, height, height);
                if (i == 0)
                {
                    rec = new Rect(x, y - height, height, height * 2);
                }
                if (i == m.row())
                {
                    rec = new Rect(x, y, height, height * 2);
                }
                if (j == 0)
                {
                    rec = new Rect(x - height, y, height * 2, height);
                }
                if (j == m.column())
                {
                    rec = new Rect(x, y, height * 2, height);
                }
                dc.DrawRoundedRectangle(b, p, rec, 5, 5);
            }
            else
            {
                Rect r = new Rect(x, y, height, height);
                dc.DrawRoundedRectangle(b, p, r, 5, 5);
            }
            dc.Close();
            visual.type = "Point";
            visual.x    = i;
            visual.y    = j;
            this.AddVisual(visual);
        }
コード例 #3
0
        public void DrawLineRight(int i, int j, Brush b)
        {
            VisualWitness  visual = new VisualWitness();
            DrawingContext dc = visual.RenderOpen();
            int            oriX = X, oriY = Y;
            int            height = hei, width = wid;
            int            round = 5, penWid = 4;
            Pen            p = new Pen(Brushes.Red, penWid);

            if (LineRight[i, j] == 1)
            {
                b = Brushes.White;
            }
            Rect r = new Rect(oriX + j * (height + width), oriY + i * (height + width), width + 2 * height, height);

            dc.DrawRoundedRectangle(b, null, r, round, round);
            if (i == onClick_x && j == onClick_y && onClick == "LineRight")
            {
                Rect rr = new Rect(oriX + j * (height + width) + height + penWid / 2, oriY + i * (height + width) + penWid / 2, width - penWid, height - penWid);
                dc.DrawRectangle(null, p, rr);
            }
            if (LineRight[i, j] == 2)
            {
                int standX = oriX + height + width / 2 + j * (height + width);
                int standY = oriY + height / 2 + i * (height + width);
                int radius = height / 2;

                StreamGeometry g = GetHex(standX, standY, radius);

                dc.DrawGeometry(Brushes.Gray, null, g);
            }
            dc.Close();
            visual.type = "LineRight";
            visual.x    = i;
            visual.y    = j;
            this.AddVisual(visual);
        }