Exemple #1
0
        public void MenuExec(MenuPage.BFkt fkt)
        {
            button1_disableTimer();         //could otherwise false trigger (if button looses focus before MouseUp)
            /*if (!mPage.mBAr[(int)fkt].enabled)
            {
                MessageBeep(BeepType.IconHand);
                return;
            }*/
            if (!Utils.backlightState)
                Utils.SwitchBacklight(true);

            switch (fkt)
            {
                case MenuPage.BFkt.main:
                    buttonMain_Click(false); break;
                case MenuPage.BFkt.start:
                    buttonStart_Click(); goto case MenuPage.BFkt.main;
                case MenuPage.BFkt.stop:
                    buttonStop_Click(true);
                    buttonMain_Click(checkShowExit.Checked);
                    break;
                case MenuPage.BFkt.map:
                    buttonMap_Click(null, null); break;
                case MenuPage.BFkt.pause:
                    buttonPause_Click();
                    break;
                case MenuPage.BFkt.waypoint:
                    AddWaypoint();
                    goto case MenuPage.BFkt.main;
                case MenuPage.BFkt.options:
                    buttonOptions_Click(null, null); break;
                case MenuPage.BFkt.graph_alt:
                    buttonGraph_Click(Graph.SourceY.Alt); break;
                case MenuPage.BFkt.graph_speed:
                    buttonGraph_Click(Graph.SourceY.Speed); break;
                case MenuPage.BFkt.graph_heartRate:
                    buttonGraph_Click(Graph.SourceY.Heart); break;

                case MenuPage.BFkt.load_gcc:
                    buttonLoad_Click(null, null); break;
                case MenuPage.BFkt.load_2follow:
                    t2fAppendMode = false;
                    buttonLoadTrack2Follow_Click(null, null); break;
                case MenuPage.BFkt.restore_clear2f:
                    if (mPage.buttonIsClear2F)
                    {
                        buttonClearT2F_Click();
                    }
                    else
                    {
                        LoadState(true);        //restore
                        mPage.ChangeRestore2Clear();
                        MenuExec(MenuPage.BFkt.map);
                    }
                    break;

                case MenuPage.BFkt.clearTrack:
                    buttonClearTrack_Click(); break;

                case MenuPage.BFkt.exit:
                    BufferDrawMode = BufferDrawModeMain;    //to avoid exception in mPage OnMouseUp()
                    this.Close();
                    //Application.Exit();   Form1.Close is enough - Exit would exit in any case (also if Close was interrupted)
                    break;
                case MenuPage.BFkt.navigate:
                    BufferDrawMode = BufferDrawModeNavigate;
                    showButton(button1, MenuPage.BFkt.main);
                    showButton(button2, MenuPage.BFkt.map);
                    showButton(button3, MenuPage.BFkt.mPage);
                    NoBkPanel.BringToFront();
                    NoBkPanel.Invalidate();
                    mapUtil.nav.voicePlayed_toRoute = false;
                    mapUtil.nav.voicePlayed_dest = false;
                    mapUtil.corner.voicePlayed = false;
                    break;
                case MenuPage.BFkt.continu:
                    buttonContinue_Click(); break;
                case MenuPage.BFkt.lap:
                    BufferDrawMode = BufferDrawModeLap;
                    ShowOptionPageNumber(6);
                    showButton(button2, MenuPage.BFkt.options_prev);
                    showButton(button3, MenuPage.BFkt.options_next);
                    break;

                case MenuPage.BFkt.recall1:
                    RecallSettings(mPage.mBAr[(int)MenuPage.BFkt.recall1].text); break;
                case MenuPage.BFkt.recall2:
                    RecallSettings(mPage.mBAr[(int)MenuPage.BFkt.recall2].text); break;
                case MenuPage.BFkt.recall3:
                    RecallSettings(mPage.mBAr[(int)MenuPage.BFkt.recall3].text); break;

                case MenuPage.BFkt.backlight_off:
                    Utils.SwitchBacklight(false);
                    buttonMain_Click(false);
                    break;
                case MenuPage.BFkt.inputLatLon:
                    string LatLon = Lat2String(CurrentLat, false) + "; " + Lat2String(CurrentLong, true);
                    retry:
                    if (Utils.InputBox("Input", "Lat; Lon [; waypoint name]", ref LatLon) == DialogResult.OK)
                    {
                        int i=0;
                        double Lat, Lon;
                        bool showCurrent = false;
                        if (LatString2Double(LatLon, ref i, out Lat) && LatString2Double(LatLon, ref i, out Lon))
                        {
                            // ask, if the user wants to replace the loaded track to follow or add the point. 'Cancel' sets the current position
                            if (Plot2ndCount > 0)
                            {
                                DialogResult dr = MessageBox.Show("YES: REPLACE loaded Track2Follow with the new Lat/Long values\nNO: ADD point to t2f\nCANCEL: set 'Current Position' instead",
                                                  "Overwrite Track2Follow", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2);
                                if (dr == DialogResult.Cancel)
                                {
                                    // The current Lat/Long values will only be usefull, if GPS is switched off.
                                    // If GPS is on, the values are directly overwritten, and will distort an active log
                                    if (state != State.logging)
                                    {
                                        CurrentLat = Lat;
                                        CurrentLong = Lon;
                                        showCurrent = true;
                                    }
                                    goto createWaypoint;
                                }
                                if (dr == DialogResult.Yes)
                                    Plot2ndCount = 0;
                            }
                            // Replace the existing track2follow with the new coordinates
                            if (Plot2ndCount == 0)
                            {
                                T2fSummary.Clear();
                                T2fSummary.desc = "Created by Input LatLon";
                            }
                            AddThisLatLonToT2F((float)Lat, (float)Lon);
                            
                        createWaypoint:      //create waypoint if there is an additional name
                            if (LatLon.Length > i)
                            {
                                string waypointname;
                                int idx = LatLon.IndexOf(';', i);
                                if (idx != -1)
                                {
                                    waypointname = LatLon.Substring(idx + 1).Trim();
                                    if (WayPointsT2F.Count < WayPointsT2F.DataSize)
                                    {
                                        WayPointsT2F.name[WayPointsT2F.Count] = waypointname;
                                        WayPointsT2F.lon[WayPointsT2F.Count] = (float)Lon;
                                        WayPointsT2F.lat[WayPointsT2F.Count] = (float)Lat;
                                        WayPointsT2F.Count++;
                                    }
                                    else
                                        MessageBox.Show("Max number of waypoints reached", "Error");
                                }
                            }
                            mPage.ChangeRestore2Clear();
                            // Jump in the Map screen directly to the track to follow new position
                            ResetMapPosition();
                            if (showCurrent)
                                mapUtil.ShowTrackToFollowMode = MapUtil.ShowTrackToFollow.T2FCurrent;
                            else
                                mapUtil.ShowTrackToFollowMode = MapUtil.ShowTrackToFollow.T2FEnd;
                            // Jump Directly to the Map view
                            buttonMap_Click(null, null);
                        }
                        else goto retry;

                    }
                    break;

                case MenuPage.BFkt.help:
                    buttonHelp_Click(null, null); break;
                case MenuPage.BFkt.about:
                    ShowOptionPageNumber(7);
                    break;


                case MenuPage.BFkt.gps_toggle:
                    buttonGPS_Click(null, null); break;

                case MenuPage.BFkt.options_next:
                    buttonOptionsNext_Click(null, null); break;
                case MenuPage.BFkt.options_prev:
                    buttonOptionsPrev_Click(null, null); break;
                case MenuPage.BFkt.map_zoomIn:
                    if (BufferDrawMode == BufferDrawModeMaps)
                    {
                        mapUtil.ZoomIn();
                        NoBkPanel.Invalidate();
                    }
                    else if (BufferDrawMode == BufferDrawModeGraph)
                        graph.GraphZoomIn();
                    break;
                case MenuPage.BFkt.map_zoomOut:
                    if (BufferDrawMode == BufferDrawModeMaps)
                    {
                        mapUtil.ZoomOut();
                        NoBkPanel.Invalidate();
                    }
                    else if (BufferDrawMode == BufferDrawModeGraph)
                        graph.GraphZoomOut();
                    break;
                case MenuPage.BFkt.dialog_open:
                    buttonDialogOpen_Click(null, null); break;
                case MenuPage.BFkt.dialog_cancel:
                    buttonDialogCancel_Click(null, null); break;
                case MenuPage.BFkt.dialog_up:
                    buttonDialogUp_Click(null, null); break;
                case MenuPage.BFkt.dialog_down:
                    buttonDialogDown_Click(null, null); break;
                case MenuPage.BFkt.dialog_nextFileType:
                    buttonNextFileType_Click(null,null); break;
                case MenuPage.BFkt.dialog_prevFileType:
                    buttonPrevFileType_Click(null, null); break;
                case MenuPage.BFkt.dialog_saveKml:
                    buttonSaveKML_Click(null, null); break;
                case MenuPage.BFkt.dialog_saveGpx:
                    buttonSaveGPX_Click(null, null); break;



                case MenuPage.BFkt.mPage:
                    mPage.ResetScroll();
                    mPage.ShowMenu();
                    break;
                case MenuPage.BFkt.mPageUp:
                    mPage.MenuUp();
                    mPage.ShowMenu();
                    break;
                case MenuPage.BFkt.mPageDown:
                    mPage.MenuDown();
                    mPage.ShowMenu();
                    break;
                case MenuPage.BFkt.waypoint2:
                    AddWaypoint2(false);
                    break;

                case MenuPage.BFkt.nothing:
                    break;

                default:
                    MessageBox.Show(fkt.ToString());
                    break;
            }
        }
Exemple #2
0
        // c-tor. Create classes used, init some components
        public Form1()      //first executed, then Form1_Load()
        {
            //this.Menu = null;
            //this.ControlBox = false;
            
            // Required for Windows Form Designer support
            InitializeComponent();      //3162ms
            
            CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            if (CurrentDirectory != "\\") { CurrentDirectory += "\\"; }

            mPage = new MenuPage();
            Controls.Add(mPage);
            mapUtil = new MapUtil();
            mapUtil.parent = this;
            graph = new Graph();
            graph.parent = this;

            // set defaults (shall load from file later)
            comboGpsPoll.SelectedIndex = 0;
            comboDropFirst.SelectedIndex = 0;
            comboUnits.SelectedIndex = 1;
            comboBoxKmlOptColor.SelectedIndex = 0;
            comboBoxKmlOptWidth.SelectedIndex = 1;
            comboBoxLine2OptColor.SelectedIndex = 1;
            comboBoxLine2OptWidth.SelectedIndex = 1;
            comboBoxUseGccDllRate.SelectedIndex = 0;
            comboBoxUseGccDllCom.SelectedIndex = 4;
            checkBoxUseGccDll.Checked = true;
            //checkPlotLine2AsDots.Checked = true;
            comboMultiMaps.SelectedIndex = 1;
            //comboMapDownload.SelectedIndex = 0; initializes at runtime
            comboBoxCwLogMode.SelectedIndex = 0;
            comboLapOptions.SelectedIndex = 0;
            comboArraySize.SelectedIndex = 0;
            comboNavCmd.SelectedIndex = 0;      //0=off; 1=voice on; 2=voice only important; 3=beep on; 4=beep only important

            Revision = Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "."
                     + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString()
#if BETA
                     + "beta" + Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()
#endif
#if SERVICEPACK
                     + "SP" + Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()
#endif
                     ;
            labelRevision.Text = "programming/idea : AndyZap\ncontributors: expo7, AngelGR, Blaustein\n\nversion " + Revision;

            
            CreateCustomControls();         //3350ms
            
                                            //8s until here
            LockResize = false;

            cMenu1.Popup += new EventHandler(cMenu1_Popup);
            this.NoBkPanel.ContextMenu = cMenu1;
            mPage.ContextMenu = cMenu1;
            listBoxFiles.ContextMenu = cMenu1;
            //tabOpenFile.ContextMenu = cMenu1;         //don't work on WinCE  - listBoxFiles has no MouseDown
            //tabOpenFile.MouseDown += new MouseEventHandler(Form1_MouseDownCE);
            mPage.form1ref = this;
            Utils.form1ref = this;

            //for WinCE     -> for WM it is not necessary - does it really not harm on WM?
            contextMenuTimerCE.Tick += new EventHandler(contextMenuTimer_Tick);
            //this.MouseDown += new MouseEventHandler(Form1_MouseDownCE);   //is called in tabGraph_MouseDown
            mPage.MouseDown += new MouseEventHandler(Form1_MouseDownCE);
            mPage.MouseUp += new MouseEventHandler(Form1_MouseUpCE);
            timerButtonHide.Tick += new EventHandler(timerButtonHide_Tick);
        }
Exemple #3
0
 public void showButton(PictureButton b, MenuPage.BFkt fkt)
 {
     b.BackgroundImage = mPage.mBAr[(int)fkt].icon;
     b.PressedImage = mPage.mBAr[(int)fkt].icon_p;
     b.Tag = fkt;
     b.BringToFront();
     b.Invalidate();
 }