Ejemplo n.º 1
0
 public void ParseRects(List <List <string> > data)
 {
     Rects.Clear();
     foreach (var rect in data)
     {
         Rects.Add(new DrawRects(rect));
     }
 }
Ejemplo n.º 2
0
        public ViewModel()
        {
            _nodes = new ObservableCollection <Node>();
            _rects = new ObservableCollection <Rect>();
            GenerateNode(2, 6);
            Rect inlet = new Rect();

            inlet.X          = Nodes[0].X - RowPitch + 5;
            inlet.Y          = Nodes[0].Y;
            inlet.RectHeight = 170;
            Rects.Add(inlet);
            Rect outlet = new Rect();

            outlet.X          = Nodes[1].X + RowPitch + 5;
            outlet.Y          = Nodes[0].Y - TubePitch / 2;
            outlet.RectHeight = inlet.RectHeight;
            Rects.Add(outlet);
        }
Ejemplo n.º 3
0
        public Args(Engine engine, string args)
        {
            this.engine = engine;
            var items  = args.Split(new[] { ' ' });
            var others = new List <string>();

            foreach (var item in items)
            {
                if (engine.Markers.ContainsKey(item))
                {
                    Markers.Add(engine.Markers[item]);
                }
                else if (engine.Rects.ContainsKey(item))
                {
                    Rects.Add(engine.Rects[item]);
                }
                else if (engine.Strings.ContainsKey(item))
                {
                    Strings.Add(engine.Strings[item]);
                }
                else if (engine.Floats.ContainsKey(item))
                {
                    Floats.Add(engine.Floats[item]);
                }
                else if (float.TryParse(item, out float f))
                {
                    Floats.Add(f);
                }
                else
                {
                    others.Add(item);
                }
            }
            if (others.Count > 0)
            {
                Text = string.Join(" ", others);
            }
        }
Ejemplo n.º 4
0
        public void draw_stage_one()
        {
            int    half_blank          = (this.splitContainer1.Panel1.Width - _width) / 2;
            Random rd                  = new Random();
            int    bricksNumberPerLine = 10;

            for (int i = 66, j = 0; i < _height - 18 * 3; i += 18, j += 20, bricksNumberPerLine--)
            {
                int bricksNumberCurrentLine = bricksNumberPerLine;
                for (int x = j; x < _width; x += 40)
                {
                    if (bricksNumberCurrentLine-- > 0)
                    {
                        Rectangle  Rect       = new Rectangle(half_blank + x, i, 40, 18);
                        Brick_Type temp_brick = new Brick_Type();
                        temp_brick.rectangle  = Rect;
                        temp_brick.type       = rd.Next() % 3;
                        temp_brick.pictureBox = new PictureBox();
                        Rects.Add(temp_brick);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void draw_stage_two()
        {
            int    half_blank = (this.splitContainer1.Panel1.Width - _width) / 2;
            Random rd         = new Random();

            for (int i = 66; i < _height - 18 * 3; i += 18)   //_width: 400 、  _height: 300 、 每个砖块的高度18
            {
                for (int j = 0; j < _width; j += 40)
                {
                    int x = j / 40;
                    int y = (i - 66) / 18;
                    if (x + y == 9 || x == y || y == 5 || y == 0 || y == 9 || x == 0 || x == 9)
                    {
                        Rectangle  Rect       = new Rectangle(half_blank + j, i, 40, 18);
                        Brick_Type temp_brick = new Brick_Type();
                        temp_brick.rectangle  = Rect;
                        temp_brick.type       = rd.Next() % 3;
                        temp_brick.pictureBox = new PictureBox();
                        Rects.Add(temp_brick);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public void RectInvalidated(Rect rc)
 {
     Rects.Add(rc);
 }
Ejemplo n.º 7
0
 public static void FullRedraw()
 {
     Clear();
     FrameBuffer.Instance.Clear();
     Rects.Add(new Rect(0, 0, FrameBuffer.Instance.Width, FrameBuffer.Instance.Height));
 }
Ejemplo n.º 8
0
 //Add a rectangle to the list
 public void AddRect(Rect rect)
 {
     Rects.Add(rect);
 }
Ejemplo n.º 9
0
 public void Execute()
 {
     rects.Add(rect);
     rects.OnChanged();
 }
Ejemplo n.º 10
0
        public Path RenderPath(PathPaintingRenderInfo renderInfo)
        {
            //var p = typeof(PathPaintingRenderInfo).GetField("gs", BindingFlags.NonPublic | BindingFlags.Instance);
            //var gs = (GraphicsState)(p.GetValue(renderInfo));
            //Debug.WriteLine(gs.StrokeColor?.RGB.ToString() ?? "empty");
            // detect gs.StrokeColor != null

            if (renderInfo.Operation != 0)
            {
                Tuple <int, Vector> cur = null;
                Vector from             = null;
                Vector to = null;
                while (movements.Count > 0 && (cur = movements.Dequeue()) != null)
                {
                    if (cur.Item1 == 1)
                    {
                        from = cur.Item2.Cross(renderInfo.Ctm);
                    }
                    else
                    {
                        if (from == null)
                        {
                            continue;
                        }

                        to = cur.Item2.Cross(renderInfo.Ctm);

                        if (from[0] == to[0] && from[1] < to[1] ||
                            from[1] == to[1] && from[0] < to[0])
                        {
                            Lines.Add(new LineSegment(new Vector(FixAxis(from[0]), FixAxis(from[1]), 1)
                                                      , new Vector(FixAxis(to[0]), FixAxis(to[1]), 1)));
                        }
                        else if (from[0] == to[0] && from[1] > to[1] ||
                                 from[1] == to[1] && from[0] > to[0])
                        {
                            Lines.Add(new LineSegment(new Vector(FixAxis(to[0]), FixAxis(to[1]), 1)
                                                      , new Vector(FixAxis(from[0]), FixAxis(from[1]), 1)));
                        }
                        else
                        {
                            //throw new Exception("oblique line");
                        }

                        //Debug.WriteLine("x:{0},y:{1}", Lines[Lines.Count - 1].GetStartPoint()[0], Lines[Lines.Count - 1].GetStartPoint()[1]);
                        from = null;
                        to   = null;
                    }
                }

                if (rData != null)
                {
                    var    r   = rData;
                    Vector vxy = new Vector(r[0], r[1], 1).Cross(renderInfo.Ctm);
                    Vector vwh = new Vector(r[2], r[3], 1).Cross(renderInfo.Ctm);
                    var    x   = vxy[0];
                    var    y   = vxy[1];
                    if (vwh[0] < 0)
                    {
                        x = vxy[0] + vwh[0];
                    }
                    if (vwh[1] < 0)
                    {
                        y = vxy[1] - vwh[1];
                    }
                    vxy = new Vector(x, y, 1);
                    vwh = new Vector(Math.Abs(r[2]), Math.Abs(r[3]), 1).Cross(renderInfo.Ctm);
                    if (TreatSmallRectAsLine && vwh[0] < Variance)
                    {
                        //Lines.Add(new LineSegment(new Vector(FixAxis(x), FixAxis(y - vwh[1]), 1)
                        //       , new Vector(FixAxis(x), FixAxis(y), 1)));
                        Lines.Add(new LineSegment(new Vector(FixAxis(x), FixAxis(y), 1)
                                                  , new Vector(FixAxis(x), FixAxis(y + vwh[1]), 1)));
                    }
                    else if (TreatSmallRectAsLine && vwh[1] < Variance)
                    {
                        Lines.Add(new LineSegment(new Vector(FixAxis(x), FixAxis(y), 1)
                                                  , new Vector(FixAxis(x + vwh[0]), FixAxis(y), 1)));
                    }
                    else
                    {
                        Rects.Add(new Rect(vxy[0], vxy[1], vwh[0], vwh[1]));
                    }
                    rData = null;
                }
            }

            return(null);
        }