Exemplo n.º 1
0
        private time calcHikeTime(LocPoint start, LocPoint fin)
        {
            time hikeTime;

            hikeTime.hours   = 0;
            hikeTime.minutes = 0;
            hikeTime.seconds = 0;

            //figure out time hiked
            hikeTime.seconds = (fin.capTime.seconds - start.capTime.seconds);
            hikeTime.minutes = (fin.capTime.minutes - start.capTime.minutes);
            hikeTime.hours   = (fin.capTime.hours - start.capTime.hours);
            if (hikeTime.seconds < 0)
            {
                hikeTime.seconds = hikeTime.seconds + 60;
                hikeTime.minutes--;
            }
            if (hikeTime.minutes < 0)
            {
                hikeTime.minutes = hikeTime.minutes + 60;
                hikeTime.hours--;
            }

            return(hikeTime);
        }
Exemplo n.º 2
0
        private void RemovePoint_Click(object sender, EventArgs e)
        {
            if (lastSelected != -1)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove Point " + Convert.ToString(lastSelected + 1),
                                                            "Warning",
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Warning,
                                                            MessageBoxDefaultButton.Button2);
                if (dialogResult == DialogResult.Yes)
                {
                    //remove selected point
                    bool       pastPointBeingRemoved = false;
                    LocPoint[] newHike = new LocPoint[hike.Length - 1];
                    for (int i = 0; i < hike.Length; i++)
                    {
                        if ((i != (hike.Length - 1) - lastSelected) & (pastPointBeingRemoved == false))
                        {
                            newHike[i] = hike[i];
                        }
                        else if (i == (hike.Length - 1) - lastSelected)
                        {
                            pastPointBeingRemoved = true;
                        }
                        else
                        {
                            newHike[i - 1] = hike[i];
                        }
                    }

                    //switch hike to newHike
                    hike = newHike;
                    ClearMap();
                    AddPointsToMap();
                    MainMap.Refresh();
                }
            }
        }
Exemplo n.º 3
0
        private void MainMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //change curser back
                MainMap.Cursor = Cursors.Default;

                //get click location
                double lat = MainMap.FromLocalToLatLng(e.X, e.Y).Lat;
                double lng = MainMap.FromLocalToLatLng(e.X, e.Y).Lng;

                //delete MouseEventHandler
                //MouseEventHandler.Remove(MainMap_MouseClick, MainMap_MouseClick);
                MainMap.MouseClick -= new MouseEventHandler(MainMap_MouseClick);

                //add point to map
                LocPoint[] newHike;
                if (hike != null)
                {
                    newHike = new LocPoint[hike.Length + 1];
                }
                else
                {
                    newHike = new LocPoint[1];
                }

                int posToAdd = 0;
                if (lastSelected == -1)     //if nothing is selected
                {
                    /* if (hike != null)
                     *   posToAdd = hike.Length;
                     * else*/
                    posToAdd = 0;
                }
                else
                {
                    posToAdd = (hike.Length - 1) - lastSelected;
                }

                bool pastAddedPoint = false;
                for (int i = 0; i < newHike.Length; i++)
                {
                    if (((newHike.Length - 1) - i != posToAdd) && (!pastAddedPoint))
                    {
                        newHike[(newHike.Length - 1) - i] = hike[(hike.Length - 1) - i];
                    }
                    else
                    {
                        if (!pastAddedPoint)
                        {
                            //setup position in newHike
                            int pos = (newHike.Length - 1) - i;

                            //put location in newHike
                            newHike[pos].degreeNorthSouth = (int)lat;
                            newHike[pos].minuteNorthSouth = (float)((lat - newHike[pos].degreeNorthSouth) * 60);
                            newHike[pos].degreeEastWest   = (int)lng;
                            newHike[pos].minuteEastWest   = (float)((lng - newHike[pos].degreeEastWest) * 60);
                            newHike[pos].elevation        = -1;

                            //fix negitives if they exist
                            if (newHike[pos].degreeNorthSouth > 0)
                            {
                                newHike[pos].northSouth = 'N';
                            }
                            else
                            {
                                newHike[pos].northSouth        = 'S';
                                newHike[pos].degreeNorthSouth *= -1;
                                newHike[pos].minuteNorthSouth *= -1;
                            }

                            if (newHike[pos].degreeEastWest > 0)
                            {
                                newHike[pos].eastWest = 'E';
                            }
                            else
                            {
                                newHike[pos].eastWest        = 'W';
                                newHike[pos].degreeEastWest *= -1;
                                newHike[pos].minuteEastWest *= -1;
                            }

                            //set time equal to point before if possable
                            if (hike != null)
                            {
                                //if there is a point before this one
                                if (pos != newHike.Length)
                                {
                                    newHike[pos].capTime.hours   = newHike[pos + 1].capTime.hours;
                                    newHike[pos].capTime.minutes = newHike[pos + 1].capTime.minutes;
                                    newHike[pos].capTime.seconds = newHike[pos + 1].capTime.seconds;
                                }
                            }

                            //mark pastAddedPoint
                            pastAddedPoint = true;
                        }
                        else
                        {
                            newHike[(newHike.Length - 1) - i] = hike[hike.Length - i];
                        }
                    }
                }

                //switch hike to newHike
                hike = newHike;
                ClearMap();
                AddPointsToMap();
                MainMap.Refresh();

                //toggle buttons back
                ToggleButtons();
            }
        }
Exemplo n.º 4
0
        private void RemovePoint_Click(object sender, EventArgs e)
        {
            if(lastSelected != -1)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove Point " + Convert.ToString(lastSelected + 1),
                    "Warning",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2);
                if(dialogResult == DialogResult.Yes)
                {
                    //remove selected point
                    bool pastPointBeingRemoved = false;
                    LocPoint[] newHike = new LocPoint[hike.Length - 1];
                    for (int i = 0; i < hike.Length; i++)
                    {
                        if ( (i != (hike.Length - 1) - lastSelected) & (pastPointBeingRemoved == false) )
                        {
                            newHike[i] = hike[i];
                        }
                        else if (i == (hike.Length - 1) - lastSelected)
                        {
                            pastPointBeingRemoved = true;
                        }
                        else
                        {
                            newHike[i - 1] = hike[i];
                        }
                    }

                    //switch hike to newHike
                    hike = newHike;
                    ClearMap();
                    AddPointsToMap();
                    MainMap.Refresh();

                }
            }
        }
Exemplo n.º 5
0
        private void MainMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //change curser back
                MainMap.Cursor = Cursors.Default;

                //get click location
                double lat = MainMap.FromLocalToLatLng(e.X, e.Y).Lat;
                double lng = MainMap.FromLocalToLatLng(e.X, e.Y).Lng;

                //delete MouseEventHandler
                //MouseEventHandler.Remove(MainMap_MouseClick, MainMap_MouseClick);
                MainMap.MouseClick -= new MouseEventHandler(MainMap_MouseClick);

                //add point to map
                LocPoint[] newHike;
                if(hike != null)
                    newHike = new LocPoint[hike.Length + 1];
                else
                    newHike = new LocPoint[1];

                int posToAdd = 0;
                if (lastSelected == -1)     //if nothing is selected
                {
                   /* if (hike != null)
                        posToAdd = hike.Length;
                    else*/
                        posToAdd = 0;
                }
                else
                {
                    posToAdd = (hike.Length - 1) - lastSelected;
                }

                bool pastAddedPoint = false;
                for (int i = 0; i < newHike.Length; i++)
                {
                    if ( ((newHike.Length - 1) - i != posToAdd) && (!pastAddedPoint) )
                        newHike[(newHike.Length - 1) - i] = hike[(hike.Length - 1) - i];
                    else
                    {
                        if (!pastAddedPoint)
                        {
                            //setup position in newHike
                            int pos = (newHike.Length - 1) - i;

                            //put location in newHike
                            newHike[pos].degreeNorthSouth = (int)lat;
                            newHike[pos].minuteNorthSouth = (float)((lat - newHike[pos].degreeNorthSouth) * 60);
                            newHike[pos].degreeEastWest = (int)lng;
                            newHike[pos].minuteEastWest = (float)((lng - newHike[pos].degreeEastWest) * 60);
                            newHike[pos].elevation = -1;

                            //fix negitives if they exist
                            if (newHike[pos].degreeNorthSouth > 0)
                                newHike[pos].northSouth = 'N';
                            else
                            {
                                newHike[pos].northSouth = 'S';
                                newHike[pos].degreeNorthSouth *= -1;
                                newHike[pos].minuteNorthSouth *= -1;
                            }

                            if (newHike[pos].degreeEastWest > 0)
                                newHike[pos].eastWest = 'E';
                            else
                            {
                                newHike[pos].eastWest = 'W';
                                newHike[pos].degreeEastWest *= -1;
                                newHike[pos].minuteEastWest *= -1;
                            }

                            //set time equal to point before if possable
                            if(hike != null)
                            {
                                //if there is a point before this one
                                if(pos != newHike.Length)
                                {
                                    newHike[pos].capTime.hours = newHike[pos + 1].capTime.hours;
                                    newHike[pos].capTime.minutes = newHike[pos + 1].capTime.minutes;
                                    newHike[pos].capTime.seconds = newHike[pos + 1].capTime.seconds;
                                }
                            }

                            //mark pastAddedPoint
                            pastAddedPoint = true;
                        }
                        else
                        {
                            newHike[(newHike.Length - 1) - i] = hike[hike.Length - i];
                        }
                    }
                }

                //switch hike to newHike
                hike = newHike;
                ClearMap();
                AddPointsToMap();
                MainMap.Refresh();

                //toggle buttons back
                ToggleButtons();
            }
        }
Exemplo n.º 6
0
        private time calcHikeTime(LocPoint start, LocPoint fin)
        {
            time hikeTime;
            hikeTime.hours = 0;
            hikeTime.minutes = 0;
            hikeTime.seconds = 0;

            //figure out time hiked
            hikeTime.seconds = (fin.capTime.seconds - start.capTime.seconds);
            hikeTime.minutes = (fin.capTime.minutes - start.capTime.minutes);
            hikeTime.hours = (fin.capTime.hours - start.capTime.hours);
            if (hikeTime.seconds < 0)
            {
                hikeTime.seconds = hikeTime.seconds + 60;
                hikeTime.minutes--;
            }
            if (hikeTime.minutes < 0)
            {
                hikeTime.minutes = hikeTime.minutes + 60;
                hikeTime.hours--;
            }

            return hikeTime;
        }