Beispiel #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);
        }
Beispiel #2
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point         pointClicked = e.GetPosition(canvas);
            VisualWitness visual       = canvas.GetVisual(pointClicked);

            if (visual != null)
            {
                int oriX = canvas.X, oriY = canvas.Y;
                int height = canvas.hei, width = canvas.wid;
                canvas.onClick_x     = visual.x;
                canvas.onClick_y     = visual.y;
                canvas.onClick       = visual.type;
                label2_Copy1.Content = visual.x;
                label2_Copy2.Content = visual.y;
                if (canvas.onClick == "Square")
                {
                    comboBox.SelectedIndex  = canvas.m.GetSqu(canvas.onClick_x, canvas.onClick_y);
                    comboBox1.SelectedIndex = canvas.m.GetOct(canvas.onClick_x, canvas.onClick_y);
                }
            }
            else
            {
                canvas.onClick = "Nothing";
            }
            canvas.Clear();
            canvas.Draw();
        }
Beispiel #3
0
        public void RemoveVisual(VisualWitness visual)
        {
            visuals.Remove(visual);

            base.RemoveVisualChild(visual);
            base.RemoveLogicalChild(visual);
        }
Beispiel #4
0
        public void AddVisual(VisualWitness visual)
        {
            visuals.Add(visual);

            base.AddVisualChild(visual);
            base.AddLogicalChild(visual);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }