Ejemplo n.º 1
0
        public static RoadModel getRoadStub(string id)
        {
            String[] rolorArr = { ScreenManager.Model.Constant.Constants.RED_COLOR, ScreenManager.Model.Constant.Constants.GREEN_COLOR, ScreenManager.Model.Constant.Constants.YELLOW_COLOR };

            RoadModel roadModel = new RoadModel();
            roadModel.BaseColor = ScreenManager.Model.Constant.Constants.DEFAULT_COLOR;
            roadModel.RoadID = id;
            roadModel.RoadName = "RoadStub" + id;
            List<SegmentModel> sl = new List<SegmentModel>();

            int k = 0;

            for(int i=0;i<10;i++){
                SegmentModel sm = new SegmentModel();
                sm.SegmentColor = rolorArr[i%3];
                sm.Address.Start = k;
                sm.Address.End = k+15;
                sm.SegmentID = id + "-"+i;
                sm.SegmentName = id + "-" + i;
                k = k + 15;
                sl.Add(sm);
            }

            roadModel.SegmentList = sl;
            return roadModel;
        }
Ejemplo n.º 2
0
        public static List<RoadModel> getRoadInfoByDll()
        {
            int roadNum = 10;

            ROAD_INFO[] infos = new ROAD_INFO[roadNum];
            for (int i = 0; i < roadNum; i++)
            {
                infos[i] = new ROAD_INFO();
            }

            IntPtr[] ptArr = new IntPtr[1];
            ptArr[0] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ROAD_INFO)) * roadNum); //分配包含两个元素的数组
            IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ROAD_INFO)));
            Marshal.Copy(ptArr, 0, pt, 1); //拷贝指针数组

            getRoadInfo(pt, roadNum);

            List<RoadModel> roadList = new List<RoadModel>();
            for (int i = 0; i < roadNum; i++)
            {
                infos[i] = (ROAD_INFO)Marshal.PtrToStructure((IntPtr)(pt.ToInt32() + i * Marshal.SizeOf(typeof(ROAD_INFO))), typeof(ROAD_INFO));
                RoadModel road = new RoadModel();
                road.RoadID = infos[i].roadNum.ToString();
                road.RoadID = infos[i].roadName;
                roadList.Add(road);
            }

            return roadList;
        }
Ejemplo n.º 3
0
 public ScreenModel()
 {
     for (int i = 0; i < 10; i++)
     {
         RoadModel rm = new RoadModel();
         rm.RoadID = i.ToString();
         rm.BaseColor = Constant.Constants.DEFAULT_COLOR;
         rm.RoadLenght = this.basicInfo.ScreenLength;
         rm.RoadName = "";
         roadList.Add(rm);
     }
 }
Ejemplo n.º 4
0
 public void loadRoadModel(RoadModel rm)
 {
     this.RoadID = rm.RoadID;
     this.BaseColor = rm.BaseColor;
     this.RoadName = rm.RoadName;
     this.RoadLenght = rm.RoadLenght;
     SegmentList.Clear();
     for(int i=0;i< rm.SegmentList.Count;i++){
         SegmentModel segModel = new SegmentModel();
         segModel.SegmentID = rm.SegmentList[i].SegmentID;
         segModel.SegmentColor = rm.SegmentList[i].SegmentColor;
         segModel.Address = rm.SegmentList[i].Address;
         segModel.SegmentName = rm.SegmentList[i].SegmentName;
         SegmentList.Add(segModel);
     }
 }