Beispiel #1
0
        internal Route GetItem(MyPoint point1, MyPoint point2)
        {
            var listNew = (from item in list
                           where (point1 == item.MyPoint1 || point1 == item.MyPoint2) && (point2 == item.MyPoint1 || point2 == item.MyPoint2)
                           select item).ToList();

            return (point1 == listNew.First().MyPoint1) ? listNew.First() : new Route(listNew.First().MyPoint2, listNew.First().MyPoint1, listNew.First().Distance.ToString());
        }
Beispiel #2
0
        public Route(MyPoint myPoint1, MyPoint myPoint2, string distance)
        {
            MyPoint1 = myPoint1;
            MyPoint2 = myPoint2;

            int distanceInt;
            int.TryParse(distance, out distanceInt);
            Distance = distanceInt;
        }
Beispiel #3
0
 private void openAddEdit(MyPoint myPoint)
 {
     MyPoint_AddEdit myPointAE = new MyPoint_AddEdit(myPoint);
     if (myPointAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         loadData();
 }
Beispiel #4
0
        internal object[] getRow(MyPoint myPoint1)
        {
            MyPoint myPoint = (MyPoint1.ID == myPoint1.ID) ? MyPoint2 : MyPoint1;

            return(new object[] { ID, myPoint.Name, Distance });
        }
Beispiel #5
0
 public Route(MyPoint myPoint1)
 {
     MyPoint1 = myPoint1;
     Distance = 0;
 }
Beispiel #6
0
        internal Route GetRandomItem(Random random, MyPoint mainPoint)
        {
            var listNew = (from item in list
                           where mainPoint == item.MyPoint1 || mainPoint == item.MyPoint2
                           select item).ToList();

            if (listNew.Count == 0)
                throw new NullReferenceException("Отсутствуют маршруты для данного города");

            int rand = random.Next(0, listNew.Count - 1);

            return (mainPoint == listNew[rand].MyPoint1) ? new Route(listNew[rand].MyPoint1, listNew[rand].MyPoint2, listNew[rand].Distance.ToString()) : new Route(listNew[rand].MyPoint2, listNew[rand].MyPoint1, listNew[rand].Distance.ToString());
        }
Beispiel #7
0
        public DataTable ToDataTable(MyPoint myPoint1)
        {
            var listNew = list.Where(item => (item.MyPoint1 == myPoint1) || (item.MyPoint2 == myPoint1)).ToList();

            return CreateTable(listNew, myPoint1);
        }
Beispiel #8
0
 public bool Exists(MyPoint myPoint)
 {
     return list.Exists(item => myPoint == item.MyPoint1 || myPoint == item.MyPoint2);
 }
Beispiel #9
0
 public bool Exists(MyPoint myPoint1, MyPoint myPoint2)
 {
     return list.Exists(item => ((item.MyPoint1 == myPoint1 && myPoint2 == item.MyPoint2)) || ((item.MyPoint2 == myPoint1 && myPoint2 == item.MyPoint1)));
 }
Beispiel #10
0
        private DataTable CreateTable(List<Route> routes, MyPoint myPoint1)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("id");
            dt.Columns.Add("Пункт назначения");
            dt.Columns.Add("Дистанция");

            foreach (Route route in routes)
                dt.Rows.Add(route.getRow(myPoint1));

            return dt;
        }
Beispiel #11
0
        internal Route GetRandomItem(Random random, MyPoint mainPoint, MyPoint toPoint)
        {
            var listNew = (from item in list
                           where (toPoint == item.MyPoint1 || toPoint == item.MyPoint2) && mainPoint != item.MyPoint1 && mainPoint != item.MyPoint2
                           select item).ToList();

            int rand = random.Next(0, listNew.Count - 1);

            return (toPoint == listNew[rand].MyPoint1) ? new Route(listNew[rand].MyPoint1, listNew[rand].MyPoint2, listNew[rand].Distance.ToString()) : new Route(listNew[rand].MyPoint2, listNew[rand].MyPoint1, listNew[rand].Distance.ToString());
        }
Beispiel #12
0
        internal object[] getRow(MyPoint myPoint1)
        {
            MyPoint myPoint = (MyPoint1.ID == myPoint1.ID) ? MyPoint2 : MyPoint1;

            return new object[] { ID, myPoint.Name, Distance };
        }
Beispiel #13
0
 public Route(MyPoint myPoint1)
 {
     MyPoint1 = myPoint1;
     Distance = 0;
 }