Пример #1
0
        /////////////////////////////////
        /////////////////////////////////
        private void MapForm_Paint(object sender, PaintEventArgs e)
        {
            //"kresli sipky"
            Pen      sipkaPen;
            Graphics g = e.Graphics;
            bool     doSearch;
            int      prevIndex;
            double   normalSize2 = 0, normalSize;

            for (int p = 1; p < MainForm.myProject.shipDataArray.Count; p++)
            {
                MainForm.myProject.MapToScreen(p, ClientSize.Width, ClientSize.Height, ref pointActual);
                doSearch  = true;
                prevIndex = p - 1;
                while (prevIndex >= 0 && doSearch == true)
                {
                    MainForm.myProject.MapToScreen(prevIndex, ClientSize.Width, ClientSize.Height, ref pointPrev);
                    pointDirectionX = pointActual.X - pointPrev.X;
                    pointDirectionY = pointActual.Y - pointPrev.Y;
                    normalSize2     = (pointDirectionX * pointDirectionX + pointDirectionY * pointDirectionY);
                    if (normalSize2 != 0)
                    {
                        doSearch = false;
                    }
                    prevIndex--;
                }
                if (normalSize2 == 0)
                {
                    normalSize2 = 1;
                }
                normalSize       = Math.Sqrt(normalSize2);
                pointDirectionX /= (int)normalSize;
                pointDirectionY /= (int)normalSize;
                int sipkaScale = (int)MyProject.LinearChangeDouble(0.0, MainForm.myProject.voltageAbs, 0.0, 10, Math.Abs(MainForm.myProject.shipDataArray[p].voltage));

                //MainForm.myProject.;
                pointA.X = (int)(pointActual.X - sipkaScale * pointDirectionX);
                pointA.Y = (int)(pointActual.Y - sipkaScale * pointDirectionY);

                pointB.X = (int)(pointActual.X + sipkaScale * pointDirectionX);
                pointB.Y = (int)(pointActual.Y + sipkaScale * pointDirectionY);

                sipkaPen = greenSipkaPen;
                if (MainForm.myProject.shipDataArray[p].voltage < 0.0)
                {
                    sipkaPen = redSipkaPen;
                }
                g.DrawLine(sipkaPen, pointA, pointB);
            }
        }
Пример #2
0
 /////////////////////////////////
 public void MapToScreen(int indexPoint, int width, int height, ref Point point)
 {
     point.X = (int)MyProject.LinearChangeDouble(lonMin, lonMax, 0.0, width, shipDataArray[indexPoint].gpsData.lon.gpsValue);
     point.Y = (int)MyProject.LinearChangeDouble(latMin, latMax, height, 0.0, shipDataArray[indexPoint].gpsData.lat.gpsValue);
 }