Exemplo n.º 1
0
        protected override void SubPerform(IEntity mobilesInn)
        {
            this.DrawXnode(mobilesInn);

            var node = mobilesInn as XNode;

            MobilePainter.Paint(node.Mobiles, _graphic);
        }
Exemplo n.º 2
0
        //protected override void SubPerform(ITrafficEntity tVar)
        //{
        //	Graphics g = this.Canvas.CreateGraphics();
        //	var lane = tVar as Lane;
        //	if (lane == null)
        //	{
        //		throw new Exception(string.Format("TrafficEntity类型为{0},使用了错误的绘图服务",tVar.GetType().ToString()));
        //	}

        //	OxyzPointF spStart = lane.Shape.Start;
        //	OxyzPointF spEnd = lane.Shape.End;

        //	//获取单位平移向量(法向量)
        //	var vtUnit = VectorTool.GetNormal(lane.ToVector());
        //	//获取平移向量
        //	var vtMulti =VectorTool.GetMultiNormal(vtUnit,lane.Rank-1);

        //	var liUpper = new List<PointF>(lane.Shape.Count*2);
        //	var stDown = new Stack<PointF>(lane.Shape.Count);

        //	int iWidth = GraphicsSetter.iPixels;
        //	var UpRightVector = new OxyzPointF(1f,-1f,0f);//offset
        //	foreach (var pShape in lane.Shape) {

        //		var pUpper = Coordinates.Offset(pShape,vtMulti);
        //		//move down for one unit
        //		var pDown = Coordinates.Offset(pUpper,vtUnit);

        //		var spUpper = Coordinates.Project(pUpper, iWidth);
        //		spUpper =Coordinates.Offset(spUpper,iWidth/2,UpRightVector);//cell offset

        //		var spDown = Coordinates.Project(pDown, iWidth);
        //		spDown =Coordinates.Offset(spDown,iWidth/2,UpRightVector);

        //		liUpper.Add(spUpper.ToPointF());
        //		stDown.Push(spDown.ToPointF());
        //	}
        //	while (stDown.Count>0) {
        //		liUpper.Add(stDown.Pop());
        //	}

        //	PointF[]  p= liUpper.ToArray();
        //	g.FillClosedCurve(laneBrush, p);

        //	MobilePainter.Paint(lane.Mobiles,_graphic);//画车

        //	g.Dispose();
        //}


        protected override void SubPerform(IEntity la)
        {
            var lane = la as Lane;
            int x1 = 0, y1 = 0;     // previous point
            int x2, y2;             // current point

            Graphics g = this.Canvas.CreateGraphics();

            g.SmoothingMode = SmoothingMode.AntiAlias;

            int penWidth = GraphicsSetter.iPixels;
            Pen pen      = new Pen(GraphicsSetter.roadColor, penWidth);

            IEnumerator <OxyzPointF> enumerator = lane.Shape.GetEnumerator();
            Point temp;

            //OxyzPointF basePoint;

            if (enumerator.MoveNext())
            {
                //basePoint = Coordinates.Offset( enumerator.Current, GraphicsSetter.baseOffset);
                //temp = Coordinates.Project(basePoint, penWidth).ToPoint();
                temp = Coordinates.Project(enumerator.Current, penWidth).ToPoint();
                x1   = temp.X;
                y1   = temp.Y;
            }

            while (enumerator.MoveNext())
            {
                //basePoint = Coordinates.Offset(enumerator.Current, GraphicsSetter.baseOffset);
                //temp = Coordinates.Project(basePoint, penWidth).ToPoint();
                temp = Coordinates.Project(enumerator.Current, penWidth).ToPoint();
                x2   = temp.X;
                y2   = temp.Y;

                g.DrawLine(pen, x1, y1, x2, y2);

                x1 = x2;
                y1 = y2;
            }

            MobilePainter.Paint(lane.Mobiles, _graphic);//画车
            pen.Dispose();
            g.Dispose();
        }