Esempio n. 1
0
        private void DispatcherTimer_ListUpdate(object sender, EventArgs e)
        {
            Description.Text = AppControler.ActualDescriptionSource;

            if (AppControler.ActualChosenTypeInMenu == AppControler.TaskType)
            {
                Model.Task task = DataBase.GetTask(AppControler.ActualChosenIdInMenu);
                if (task != null)
                {
                    TaskName.Content = task.Name;
                }
            }
            else if (AppControler.ActualChosenTypeInMenu == AppControler.PointType)
            {
                Model.Point point = DataBase.GetPoint(AppControler.ActualChosenIdInMenu);
                if (point != null)
                {
                    Model.Task task = DataBase.GetTask(point.TaskId);
                    if (task != null)
                    {
                        TaskName.Content = task.Name;
                    }
                }
            }
        }
        public static void Draw(SpriteBatch sb, GraphicCache cache, Vector2 cameraOffset, Entity entity, Vision vision)
        {
            bool drawIt = vision == null;
            if (!drawIt)
            {
                Model.Point thisPt = new Model.Point(entity.getPosition());
                //foreach (CQT.Model.Point p in vision.lightTriangles)
                for (int i = 0; i < vision.lightTriangles.Count - 1; i++)
                {
                    if (thisPt.InTriangle(vision.origin, vision.lightTriangles[i], vision.lightTriangles[i + 1]))
                    {
                        drawIt = true;
                        break;
                    }
                }
            }
            if (!drawIt)
                return;

            Vector2 position = entity.getPosition();
            Vector2 size = entity.getSize();
            Single rotation = entity.getRotation();
            Texture2D texture = cache.getTexture(entity.getTextureName());
            Vector2 spriteOrigin = new Vector2 (texture.Width / 2, texture.Height / 2);

            Rectangle bounds = new Rectangle((int)Math.Round(cameraOffset.X + position.X),
                (int)Math.Round(cameraOffset.Y + position.Y), (int)Math.Round(size.X), (int)Math.Round(size.Y));

            sb.Draw(texture, bounds, null, Color.White, rotation, spriteOrigin, SpriteEffects.None, 0);
        }
        private void btnChart_Click(object sender, EventArgs e)
        {
            Simulation s = controller.getSimulation();

            if (!s.isSimulating())
            {
                Chart chart = new Chart(TEMP_FUNC_SERIE, TEMP_FUNC_TITLE);

                List <double> costs = s.get_costs_function();//s.getAcceptedSolutions();
                double        x     = 1.0;
                Console.WriteLine("Se aceptaron: " + costs.Count + " funciones");
                foreach (double p in costs)
                {
                    SimulatedAnneling.Model.Point point = new Model.Point(x, p);
                    chart.addPoint(point);
                    x++;

                    //Console.WriteLine("{0:N9}",p);
                }

                /*
                 * chart.addPoint(new Model.Point(0.5, 1.358));
                 * chart.addPoint(new Model.Point(2, 0.23));*/
                chart.Show();
            }
        }
Esempio n. 4
0
        private void AddToDayliToDo_Click(object sender, RoutedEventArgs e)
        {
            Model.Point point = (Model.Point)ListView_PointsList.SelectedItem;
            if (point != null)
            {
                point.IsTaskForToday = !point.IsTaskForToday;

                DataBase.ChangePointProperties(point.Id, point);
                AppControler.UpDateListSource();
            }
        }
        /// <summary>
        /// Navigates directly to a particular stop.
        /// </summary>
        public async Task NavigateDirectlyToStop(double latitude, double longitude, string selectedStopId)
        {
            var center = new Model.Point(latitude, longitude);

            this.MapControlViewModel.MapView = new MapView(center, Constants.ZoomedInMapZoom, false);

            await this.MapControlViewModel.RefreshStopsForLocationAsync(MapView.Current);

            this.MapControlViewModel.SelectStop(selectedStopId);

            await this.RoutesAndStopsViewModel.PopulateStopAsync(selectedStopId);
        }
        public PointEditWindow(int point_Id)
        {
            InitializeComponent();
            this.point_Id = point_Id;

            Model.Point editPoint = DataBase.GetPoint(point_Id);

            NameTextBox.Text  = editPoint.Name;
            DayTextBox.Text   = editPoint.DeadLineDate.Value.Day.ToString();
            MonthTextBox.Text = editPoint.DeadLineDate.Value.Month.ToString();
            YearTextBox.Text  = (editPoint.DeadLineDate.Value.Year - 2000).ToString();
        }
Esempio n. 7
0
 private void ContextMenu_Opened(object sender, RoutedEventArgs e)
 {
     Model.Point point = (Model.Point)ListView_PointsList.SelectedItem;
     if (point != null)
     {
         if (point.IsTaskForToday == false)
         {
             AddToDayliToDo.Header = "Dodaj zadanie do dzisiejszego TO DO";
         }
         if (point.IsTaskForToday == true)
         {
             AddToDayliToDo.Header = "Usuń zadanie z dzisiejszego TO DO";
         }
     }
 }
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime newDate;
            DateTime actulaData = DateTime.Now;

            if (NameTextBox.Text == "") //Jeśli pole puste
            {
                InformationText.Text = "Proszę uzupełnij nazwę zbioru.";
            }
            else if (DayTextBox.Text == "" || DayTextBox.Text == "" || YearTextBox.Text == "") //Jeśli którekolwiek pole puste
            {
                InformationText.Text = "Proszę uzupełnij  datę.";
            }
            else
            {
                //Sprawdzenie poprawności wprowadzonej daty:
                try
                {
                    newDate = new DateTime(Convert.ToInt32(YearTextBox.Text) + 2000, Convert.ToInt32(MonthTextBox.Text), Convert.ToInt32(DayTextBox.Text));
                }
                catch (Exception)
                {
                    InformationText.Text = "Proszę popraw datę.";
                    return;
                }
                if (newDate < actulaData)
                {
                    InformationText.Text = "Chcesz się cofnąć w czasie?";
                }
                else
                {
                    //Jeśli wszystko poszło dobrze to wysyłamy
                    Model.Point editPoint = DataBase.GetPoint(point_Id);
                    ManagementApp.Model.Point newPoint = new ManagementApp.Model.Point()
                    {
                        TaskId          = editPoint.TaskId,
                        Name            = NameTextBox.Text,
                        DeadLineDate    = newDate,
                        ExecutionStatus = editPoint.ExecutionStatus,
                        IsTaskForToday  = editPoint.IsTaskForToday
                    };

                    DataBase.ChangePointProperties(point_Id, newPoint);
                    AppControler.UpDateAllSource();
                    this.Close();
                }
            }
        }
Esempio n. 9
0
 public static void ActualDescriptionSourceUpdate()
 {
     if (ActualChosenTypeInMenu == AppControler.TaskCollectionType)
     {
         TaskCollection taskCollection = DataBase.GetTaskCollection(AppControler.ActualChosenIdInMenu);
         ActualDescriptionSource = taskCollection.Description;
     }
     else if (AppControler.ActualChosenTypeInMenu == AppControler.TaskType)
     {
         Model.Task task = DataBase.GetTask(AppControler.ActualChosenIdInMenu);
         ActualDescriptionSource = task.Description;
     }
     else if (ActualChosenTypeInMenu == AppControler.PointType)
     {
         Model.Point temporaryPoint = DataBase.GetPoint(ActualChosenIdInMenu);
         Model.Task  task           = DataBase.GetTask(temporaryPoint.TaskId);
         ActualDescriptionSource = task.Description;
     }
 }
Esempio n. 10
0
        public static List <Model.Point> StringToList(string Data)
        {
            if (string.IsNullOrEmpty(Data))
            {
                return(null);
            }
            byte[]             bytes  = Convert.FromBase64String(Data);
            byte[]             vs     = Decompress(bytes);
            List <Model.Point> points = new List <Model.Point>();

            for (int i = 0; i < vs.Length / 4; i++)
            {
                Model.Point point = new Model.Point();
                point.x = Convert.ToInt16((vs[4 * i] << 8) | vs[4 * i + 1]);
                point.y = Convert.ToInt16((vs[4 * i + 2] << 8) | vs[4 * i + 3]);
                points.Add(point);
            }
            return(points);
        }
Esempio n. 11
0
        public static void PointListSourceUpdate()
        {
            if (ActualChosenTypeInMenu == AppControler.TaskType)
            {
                PointListSource.Clear();
                foreach (var item in DataBase.GetPointsList(ActualChosenIdInMenu))
                {
                    PointListSource.Add(item);
                }
            }
            else if (ActualChosenTypeInMenu == AppControler.PointType)
            {
                Model.Point temporaryPoint = DataBase.GetPoint(ActualChosenIdInMenu);

                PointListSource.Clear();
                foreach (var item in DataBase.GetPointsList(temporaryPoint.TaskId))
                {
                    PointListSource.Add(item);
                }
            }
        }
Esempio n. 12
0
        public void PointWithCorrectPropertis()
        {
            int?pointID          = null;
            int?taskID           = null;
            int?taskCollectionID = null;

            TaskCollection newTaskCollection = new TaskCollection("Name");

            taskCollectionID = DataBase.AddCollection(newTaskCollection);
            Model.Task newTask = new Model.Task("Name", (int)taskCollectionID, DateTime.Now);
            taskID = DataBase.AddTask(newTask);
            Model.Point newPoint = new Model.Point("Name", (int)taskID, DateTime.Now);
            pointID = DataBase.AddPoint(newPoint);

            Assert.IsNotNull(pointID); /*TEST 1*/

            Model.Point pointFromDataBase = DataBase.GetPoint((int)pointID);
            Assert.AreEqual(pointFromDataBase.Name, newPoint.Name); /*TEST 2*/
            Assert.AreEqual(pointFromDataBase.Id, newPoint.Id);     /*TEST 3*/

            DataBase.DeleteCollection((int)taskCollectionID);
        }
 // helper function to convert a Point
 private PointF Convert(Model.Point pt)
 {
     return(new PointF(pt.X, pt.Y));
 }
Esempio n. 14
0
        private void PaintParcourAndData(PaintEventArgs pe, bool rescale)
        {
            if (Image == null)
            {
                return;
            }



            #region parcour
            if (Parcour != null && c != null)
            {
                //PenFlight.Width = 7f;
                //PenIntersection.Width = (float)Properties.Settings.Default.IntersectionPenWidth;
                Pen.Width = (float)Parcour.PenWidthGates;

                lock (Parcour)
                {
                    ICollection <Line> lines = Parcour.Line;
                    List <Line>        linesClosedPolygon = new List <Line>();
                    switch (ParcourT)
                    {
                    case (int)ParcourType.PROHZONES:
                        linesClosedPolygon = lines.Where(p => (p.Type == (int)LineType.PENALTYZONE) || (p.Type >= (int)LineType.PROH_A && p.Type <= (int)LineType.PROH_D)).ToList();
                        PolygonFiller(linesClosedPolygon, Pen, Brush, pe);
                        break;

                    case (int)ParcourType.CHANNELS:
                        if (FillChannel)
                        {
                            linesClosedPolygon = lines.Where(p => p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_D).ToList();
                            PolygonFiller(linesClosedPolygon, Pen, Brush, pe);
                        }
                        break;

                    default:
                        break;
                    }
                    // Polygons filling:  PROH zone, channel-specific PROH zones
                    PolygonFiller(linesClosedPolygon, Pen, Brush, pe);


                    //List<Line> linesL = lines.Where(p => (p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_A) || (p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_A)).ToList();
                    //foreach (Line l in linesL)

                    #region Draw line objects: basically SP line, FP line, Channel borders
                    foreach (Line l in lines)
                    {
                        if (l.A != null && l.B != null & l.O != null)
                        {
                            int   startX         = c.getStartX(l);
                            int   startY         = c.getStartY(l);
                            float LongCorrFactor = (float)c.LongitudeCorrFactor(l);
                            int   endX           = c.getEndX(l);
                            int   endY           = c.getEndY(l);

                            Model.Point CenterPoint = new Model.Point();
                            CenterPoint.latitude  = (l.A.latitude + l.B.latitude) / 2.0;
                            CenterPoint.longitude = (l.A.longitude + l.B.longitude) / 2.0;

                            // create a dedicated point on the same latitude as the Center point
                            Model.Point RadiusPoint = c.PointForRadius(CenterPoint);


                            int midX = startX + (endX - startX) / 2;
                            int midY = startY + (endY - startY) / 2;
                            int radX = c.LongitudeToX(RadiusPoint.longitude);
                            int radY = c.LatitudeToY(RadiusPoint.latitude);

                            Vector start  = new Vector(startX, startY, 0);
                            Vector radv   = new Vector(radX, radY, 0);
                            float  radius = Math.Abs(midY - radY) / LongCorrFactor;

                            try
                            {
                                //int orientationYCorr = pdf == true ? midY + (int)(LongCorrFactor * (orientationY - midY)) : orientationY;

                                if (l.Type == (int)LineType.PENALTYZONE)
                                {
                                    // common penaltyzone is handled above
                                }
                                if (l.Type >= (int)LineType.PROH_A && l.Type <= (int)LineType.PROH_D)
                                {
                                    // channel-specific penaltyzones are handled above
                                }
                                if (l.Type == (int)LineType.TKOF)
                                {
                                    // TKOF line is not shown/ for purpose not implemented
                                }
                                if (l.Type == (int)LineType.NOBACKTRACKLINE)
                                {
                                    // NBL is deprecated
                                }

                                if (l.Type >= (int)LineType.CENTERLINE_A && l.Type <= (int)LineType.CENTERLINE_D)
                                {
                                    // Centerline is not yet implemented on Route import, and therefore not yet implemented here
                                }

                                if (l.Type >= (int)LineType.CHANNEL_A && l.Type <= (int)LineType.CHANNEL_D && ParcourT == (int)ParcourType.CHANNELS)
                                {
                                    pe.Graphics.DrawLine(PenChannel, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                    pe.Graphics.ResetTransform();
                                }

                                if (l.Type >= (int)LineType.START_A && l.Type <= (int)LineType.END_D)
                                {
                                    pe.Graphics.DrawLine(PenGates, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                    pe.Graphics.ResetTransform();


                                    if (HasCircleOnGates)
                                    {
                                        // draw ellipse
                                        pe.Graphics.TranslateTransform(midX - radius, midY - radius * LongCorrFactor);
                                        pe.Graphics.DrawEllipse(PenGates, 0, 0, radius * 2, radius * 2 * LongCorrFactor);
                                        pe.Graphics.ResetTransform();
                                        // draw orientation line
                                        // http://www.movable-type.co.uk/scripts/latlong.html?from=48.619,-120.412&to=48.59617,-120.4020

                                        Vector a        = new Vector(l.A.longitude, l.A.latitude, 0);
                                        Vector b        = new Vector(l.B.longitude, l.B.latitude, 0);
                                        Vector o        = Vector.ArrowPointFromGivenLine(a, b, GateOrientationArrowLength);
                                        int    HeadingX = c.LongitudeToX(o.X);
                                        int    HeadingY = c.LatitudeToY(o.Y);
                                        pe.Graphics.DrawLine(PenGates, new System.Drawing.Point(midX, midY), new System.Drawing.Point(HeadingX, HeadingY));
                                        //  pe.Graphics.DrawLine(PenGates, new System.Drawing.Point(midX, midY), new System.Drawing.Point(orientationX, orientationYCorr));
                                        pe.Graphics.ResetTransform();
                                    }

                                    #region Legacy behaviour

                                    if (!pdf)
                                    {
                                        // LEGACY behaviour - used when editing points
                                        if (selectedLine == l)
                                        {
                                            pe.Graphics.DrawLine(PenSelected, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                            //   pe.Graphics.DrawLine(PenSelected, new System.Drawing.Point(midX, midY), new System.Drawing.Point(oriX, oriY));
                                        }

                                        if (hoverLine == l)
                                        {
                                            pe.Graphics.DrawLine(PenHover, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                            //  pe.Graphics.DrawLine(PenHover, new System.Drawing.Point(midX, midY), new System.Drawing.Point(oriX, oriY));
                                        }
                                    }
                                    #endregion
                                }
                            }
                            catch
                            {
                                //TODO
                            }
                        }
                    }

                    #endregion
                }
            }
            #endregion

            if (flights != null)
            {
                //PenFlight.Width = 7f;
                //PenIntersection.Width = (float)Properties.Settings.Default.IntersectionPenWidth;
                int r = (int)(IntersectionCircleRadius * 150.0);  //45.0

                foreach (FlightSet flight in flights)
                {
                    List <System.Drawing.Point> points = new List <System.Drawing.Point>();
                    foreach (AirNavigationRaceLive.Model.Point gd in flight.Point)
                    {
                        int startXp = (int)c.LongitudeToX(gd.longitude);
                        int startYp = (int)c.LatitudeToY(gd.latitude);
                        points.Add(new System.Drawing.Point(startXp, startYp));
                    }
                    if (points.Count > 2)
                    {
                        pe.Graphics.DrawLines(PenFlight, points.ToArray());
                    }
                    if (flight.IntersectionPointSet != null && ShowIntersectionCircle)
                    {
                        foreach (IntersectionPoint gd in flight.IntersectionPointSet)
                        {
                            int         startXp = (int)c.LongitudeToX(gd.longitude);
                            int         startYp = (int)c.LatitudeToY(gd.latitude);
                            Model.Point p       = new Model.Point();
                            p.latitude = gd.latitude;
                            float corrFact = (float)c.LongitudeCorrFactor(p);
                            pe.Graphics.DrawEllipse(PenIntersection, startXp - r, startYp - r * corrFact, 2 * r, 2 * r * corrFact);
                        }
                    }
                }
            }
        }
        private void PaintParcourAndData(PaintEventArgs pe, bool rescale)
        {
            if (Parcour != null && c != null)
            {
                lock (Parcour)
                {
                    ICollection <Line> lines = Parcour.Line;

                    List <Line> linesClosedPolygon   = new List <Line>();
                    List <System.Drawing.Point> pts  = new List <System.Drawing.Point>();
                    List <System.Drawing.Point> ptsF = new List <System.Drawing.Point>();
                    bool isPolygonStart = true;

                    if (showProh)
                    {
                        #region Polygons filling:  PROH zone, channel-specific PROH zones (new code)

                        // new code:
                        // we may have aseveral polygons, but they are saved as small line pieces in the database
                        // how to distinct different polygons: a polygons end point is identical with the first point
                        // consider the common type PENALRTZONE but also channel-specific Penalty zones PROH_A yo PROH_D
                        linesClosedPolygon = lines.Where(p => (p.Type == (int)LineType.PENALTYZONE) || (p.Type >= (int)LineType.PROH_A && p.Type <= (int)LineType.PROH_D)).ToList();

                        foreach (Line l in linesClosedPolygon)
                        {
                            if (isPolygonStart)
                            {
                                //reset
                                pts            = new List <System.Drawing.Point>();
                                ptsF           = new List <System.Drawing.Point>();
                                isPolygonStart = false;
                            }
                            System.Drawing.Point startPt = new System.Drawing.Point();
                            System.Drawing.Point endPt   = new System.Drawing.Point();
                            startPt.X = c.getStartX(l);
                            startPt.Y = c.getStartY(l);
                            endPt.X   = c.getEndX(l);
                            endPt.Y   = c.getEndY(l);
                            pts.Add(startPt);
                            ptsF.Add(startPt);

                            if (endPt != pts[0]) // line' end point identical with first point?
                            {
                                pts.Add(endPt);
                                ptsF.Add(endPt);
                            }
                            else
                            {
                                // handle Graphics
                                pe.Graphics.FillPolygon(Brush, pts.ToArray <System.Drawing.Point>());
                                // draw border of polygon --NOT YET activated
                                //pe.Graphics.DrawPolygon(UserPenLine, ptsF.ToArray<System.Drawing.Point>());
                                // start a new polygon
                                isPolygonStart = true;
                            }
                        }

                        #endregion
                    }

                    if (fillChannel)
                    {
                        #region Polygons filling: channels

                        // new code:
                        // we may have several polygons, but they are saved as small line pieces in the database
                        // how to distinct different polygons: a polygons end point is identical with the first point
                        linesClosedPolygon = lines.Where(p => p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_D).ToList();
                        pts            = new List <System.Drawing.Point>();
                        ptsF           = new List <System.Drawing.Point>();
                        isPolygonStart = true;
                        foreach (Line l in linesClosedPolygon)
                        {
                            if (isPolygonStart)
                            {
                                //reset
                                pts            = new List <System.Drawing.Point>();
                                ptsF           = new List <System.Drawing.Point>();
                                isPolygonStart = false;
                            }
                            System.Drawing.Point startPt = new System.Drawing.Point();
                            System.Drawing.Point endPt   = new System.Drawing.Point();
                            startPt.X = c.getStartX(l);
                            startPt.Y = c.getStartY(l);
                            endPt.X   = c.getEndX(l);
                            endPt.Y   = c.getEndY(l);
                            pts.Add(startPt);
                            ptsF.Add(startPt);

                            if (endPt != pts[0]) // line' end point identical with first point?
                            {
                                pts.Add(endPt);
                                ptsF.Add(endPt);
                            }
                            else
                            {
                                // handle Graphics
                                pe.Graphics.FillPolygon(Brush, pts.ToArray <System.Drawing.Point>());
                                // draw border of polygon --NOT YET activated
                                //pe.Graphics.DrawPolygon(UserPenLine, ptsF.ToArray<System.Drawing.Point>());
                                // start a new polygon
                                isPolygonStart = true;
                            }
                        }

                        #endregion
                    }

                    //List<Line> linesL = lines.Where(p => (p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_A) || (p.Type >= (int)LineType.CHANNEL_A && p.Type <= (int)LineType.CHANNEL_A)).ToList();
                    //foreach (Line l in linesL)

                    #region Draw line objects: basically SP line, FP line, Channel borders
                    foreach (Line l in lines)
                    {
                        if (l.A != null && l.B != null & l.O != null)
                        {
                            int   startX         = c.getStartX(l);
                            int   startY         = c.getStartY(l);
                            float LongCorrFactor = (float)c.LongitudeCorrFactor(l);
                            int   endX           = c.getEndX(l);
                            int   endY           = c.getEndY(l);

                            Model.Point CenterPoint = new Model.Point();
                            CenterPoint.latitude  = (l.A.latitude + l.B.latitude) / 2.0;
                            CenterPoint.longitude = (l.A.longitude + l.B.longitude) / 2.0;
                            // create a dedicated point on the same latitude as the Center point
                            Model.Point RadiusPoint = c.PointForRadius(CenterPoint);

                            int    midX         = startX + (endX - startX) / 2;
                            int    midY         = startY + (endY - startY) / 2;
                            int    radX         = c.LongitudeToX(RadiusPoint.longitude);
                            int    radY         = c.LatitudeToY(RadiusPoint.latitude);
                            int    orientationX = c.getOrientationX(l);
                            int    orientationY = c.getOrientationY(l);
                            double tmp          = (double)midY + (orientationY - midY) * c.LongitudeCorrFactor(CenterPoint);
                            orientationY = (int)tmp;
                            Vector start = new Vector(startX, startY, 0);
                            Vector radv  = new Vector(radX, radY, 0);
                            //float radius = (float)Vector.Abs(midv - start)
                            float radius = Math.Abs(midY - radY) / LongCorrFactor;
                            try
                            {
                                int orientationYCorr = pdf == true ? midY + (int)(LongCorrFactor * (orientationY - midY)) : orientationY;

                                if (l.Type == (int)LineType.PENALTYZONE)
                                {
                                    // common penaltyzone is handled above
                                }
                                if (l.Type >= (int)LineType.PROH_A && l.Type <= (int)LineType.PROH_D)
                                {
                                    // channel-specific penaltyzones are handled above
                                }
                                if (l.Type == (int)LineType.TKOF)
                                {
                                    // TKOF line is not shown/ for purpose not implemented
                                }
                                if (l.Type == (int)LineType.NOBACKTRACKLINE)
                                {
                                    // NBL is deprecated
                                }

                                if (l.Type >= (int)LineType.CENTERLINE_A && l.Type <= (int)LineType.CENTERLINE_D)
                                {
                                    // Centerline is not yet implemented on Route import, and therefore not yet implemented here
                                }

                                if (l.Type >= (int)LineType.CHANNEL_A && l.Type <= (int)LineType.CHANNEL_D && showChannel)
                                {
                                    pe.Graphics.DrawLine(UserPenGates, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                    pe.Graphics.ResetTransform();
                                }

                                if (l.Type >= (int)LineType.START_A && l.Type <= (int)LineType.END_D)
                                {
                                    pe.Graphics.DrawLine(UserPenGates, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                    pe.Graphics.ResetTransform();

                                    if (HasCircleOnGates)
                                    { // draw ellipse
                                        // https://docs.microsoft.com/en-us/dotnet/api/system.drawing.graphics.translatetransform?view=netframework-4.7.2
                                        float theta = Convert.ToSingle(Math.Atan2(endY - startY, endX - startX) * 180.0 / Math.PI);
                                        pe.Graphics.DrawLine(UserPenGates, new System.Drawing.Point(midX, midY), new System.Drawing.Point(orientationX, orientationYCorr));
                                        pe.Graphics.TranslateTransform(midX - radius, midY - radius * LongCorrFactor);
                                        // pe.Graphics.RotateTransform(theta, System.Drawing.Drawing2D.MatrixOrder.Prepend);
                                        pe.Graphics.DrawEllipse(UserPenGates, 0, 0, radius * 2, radius * 2 * LongCorrFactor);
                                        pe.Graphics.ResetTransform();
                                        // draw orientation line
                                        //pe.Graphics.DrawLine(UserPenGates, new System.Drawing.Point(midX, midY), new System.Drawing.Point(orientationX, orientationYCorr));
                                        pe.Graphics.ResetTransform();
                                    }

                                    if (!pdf)
                                    {
                                        // LEGACY behaviour - used when editing points
                                        if (selectedLine == l)
                                        {
                                            pe.Graphics.DrawLine(PenSelected, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                            pe.Graphics.DrawLine(PenSelected, new System.Drawing.Point(midX, midY), new System.Drawing.Point(orientationX, orientationY));
                                        }

                                        if (hoverLine == l)
                                        {
                                            pe.Graphics.DrawLine(PenHover, new System.Drawing.Point(startX, startY), new System.Drawing.Point(endX, endY));
                                            pe.Graphics.DrawLine(PenHover, new System.Drawing.Point(midX, midY), new System.Drawing.Point(orientationX, orientationY));
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                //TODO
                            }
                        }
                    }

                    #endregion
                }
            }

            if (flights != null)
            {
                double factor = 1;
                //PenFlight.Width = 7f;
                //PenIntersection.Width = (float)Properties.Settings.Default.IntersectionPenWidth;
                float radiusIntersection = 20;

                foreach (FlightSet flight in flights)
                {
                    List <System.Drawing.Point> points = new List <System.Drawing.Point>();
                    foreach (AirNavigationRaceLive.Model.Point gd in flight.Point)
                    {
                        int startXp = (int)(c.LongitudeToX(gd.longitude) * factor);
                        int startYp = (int)(c.LatitudeToY(gd.latitude) * factor);
                        points.Add(new System.Drawing.Point(startXp, startYp));
                    }
                    if (points.Count > 2)
                    {
                        pe.Graphics.DrawLines(PenFlight, points.ToArray());
                    }

                    if (flight.IntersectionPointSet != null)
                    {
                        foreach (IntersectionPoint gd in flight.IntersectionPointSet)
                        {
                            int         startXp = (int)(c.LongitudeToX(gd.longitude) * factor);
                            int         startYp = (int)(c.LatitudeToY(gd.latitude) * factor);
                            Model.Point p       = new Model.Point();
                            p.latitude = gd.latitude;
                            float corrFact = (float)c.LongitudeCorrFactor(p);
                            int   r        = (int)radiusIntersection;
                            pe.Graphics.DrawEllipse(PenIntersection, startXp - r, startYp - r * corrFact, 2 * r, 2 * r * corrFact);
                        }
                    }
                }
            }
        }
 public void DrawLine(Model.Point pt1, Model.Point pt2, double lineWidth, Model.Color color)
 {
     Pen.Width = (float)lineWidth;
     Pen.Color = Convert(color);
     Gfx.DrawLine(Pen, Convert(pt1), Convert(pt2));
 }
        /// <summary>
        /// Navigates directly to a particular stop.
        /// </summary>
        public async Task NavigateDirectlyToStop(double latitude, double longitude, string selectedStopId)
        {
            var center = new Model.Point(latitude, longitude);
            this.MapControlViewModel.MapView = new MapView(center, ViewModelConstants.ZoomedInMapZoom, false);

            await this.MapControlViewModel.RefreshStopsForLocationAsync(MapView.Current);
            this.MapControlViewModel.SelectStop(selectedStopId);

            await this.RoutesAndStopsViewModel.PopulateStopAsync(selectedStopId);
        }