private void tabGraph_MainConfig() { if (MouseClientX < MGridX[2] && MouseClientY < MGridY[1]) //Time { checkExStopTime.Checked = !checkExStopTime.Checked; } else if (MouseClientX > MGridX[2] && MouseClientY < MGridY[1]) //Clock { dayScheme = !dayScheme; ApplyCustomBackground(); } else if (MouseClientX < MGridX[1]) { if (MouseClientY < MGridY[3]) //Speed { if (oHeartBeat != null) if (MainConfigSpeedSource < 3) MainConfigSpeedSource = 3; else MainConfigSpeedSource = 0; } else if (MouseClientY < MGridY[5]) //Distance { if (MainConfigDistance == eConfigDistance.eDistanceTrip) MainConfigDistance = eConfigDistance.eDistance2Destination; else if (MainConfigDistance == eConfigDistance.eDistance2Destination) MainConfigDistance = eConfigDistance.eDistanceOdo; else MainConfigDistance = eConfigDistance.eDistanceTrip; if (Plot2ndCount == 0 && MainConfigDistance == eConfigDistance.eDistance2Destination) MainConfigDistance = eConfigDistance.eDistanceOdo; } else //Info { } } else { if (MouseClientY < MGridY[3]) { } else if (MouseClientY < MGridY[4]) //Altitude { MainConfigRelativeAlt = !MainConfigRelativeAlt; } else if (MouseClientY < MGridY[5]) //Alt2 { if (MainConfigAlt2display <= 4) if (++MainConfigAlt2display > 4) MainConfigAlt2display = 0; } else //GPS { if (Plot2ndCount > 0) MainConfigNav = !MainConfigNav; } } }
void cMenuItem_Click(object sender, EventArgs e) { switch (((MenuItem)sender).Text) { // main page Time case "inc stop": checkExStopTime.Checked = false; break; case "ex stop": checkExStopTime.Checked = true; break; case "beep on start/stop": beepOnStartStop = !beepOnStartStop; break; case "don't log passive time": configNoLogPassiveTime = !configNoLogPassiveTime; break; // main page Clock case "App full screen": AppFullScreen = !AppFullScreen; FormFullScreen(AppFullScreen); //DoOrientationSwitch(); break; case "night scheme": dayScheme = false; ApplyCustomBackground(); break; case "day scheme": dayScheme = true; ApplyCustomBackground(); break; case "sync with GPS": configSyncSystemTime = !configSyncSystemTime; break; // main page Speed case "from gps": MainConfigSpeedSource = 0; break; case "from position": MainConfigSpeedSource = 1; break; case "both": MainConfigSpeedSource = 2; break; case "speed + heart rate": MainConfigSpeedSource = 3; break; case "speed + hr + signal": MainConfigSpeedSource = 4; break; // main page Distance case "since start of trip": MainConfigDistance = eConfigDistance.eDistanceTrip; break; case "to destination": MainConfigDistance = eConfigDistance.eDistance2Destination; break; case "to t2f start (bee line)": MainConfigDistance = eConfigDistance.eDistanceTrack2FollowStart; break; case "to t2f end (bee line)": MainConfigDistance = eConfigDistance.eDistanceTrack2FollowEnd; break; case "ODO": MainConfigDistance = eConfigDistance.eDistanceOdo; break; // main page Altitude case "absolute": MainConfigRelativeAlt = false; break; case "relative": MainConfigRelativeAlt = true; break; // main page Altitude2 case "gain": MainConfigAlt2display = 0; break; case "loss": MainConfigAlt2display = 1; break; case "max": MainConfigAlt2display = 2; break; case "min": MainConfigAlt2display = 3; break; case "slope": MainConfigAlt2display = 4; break; case "<sequential>": MainConfigAlt2display = 256; break; // main page GPS case "beep on gps fix": checkBeepOnFix.Checked = !checkBeepOnFix.Checked; break; case "show navigation here": MainConfigNav = !MainConfigNav; break; case "compass shows north": compass_north = !compass_north; break; case "compass style [0]": case "compass style [1]": compass_style++; break; case "compass style [2]": compass_style = 0; break; case "log raw nmea": logRawNmea = !logRawNmea; break; case "LatLon dd.dddddd�": MainConfigLatFormat = 0; break; case "LatLon Ndd癿m.mmmm'": MainConfigLatFormat = 1; break; case "LatLon Ndd癿m'ss.ss\"": MainConfigLatFormat = 2; break; //***** menu page ******************************************************* case "show summary": if (mPage.lastSelectedBFkt == MenuPage.BFkt.load_2follow) ShowTrackSummary(T2fSummary); else ShowTrackSummary(TSummary); break; case "enter name": if (mPage.lastSelectedBFkt == MenuPage.BFkt.load_2follow) Utils.InputBox("Track 2 Follow", "Name of the track", ref T2fSummary.name); else { string str; if (TSummary.name.Length == 0) str = TSummary.StartTime.ToString(); else str = TSummary.name; if (Utils.InputBox("Main Track", "Name of the track", ref str) == DialogResult.OK) { TSummary.name = str; WriteStringRecord(32, str); } } break; case "enter description": if (mPage.lastSelectedBFkt == MenuPage.BFkt.load_2follow) Utils.InputBox("Track 2 Follow", "Description of the track", ref T2fSummary.desc); else { string str; if (TSummary.desc.Length == 0) str = CreateTrackDescription(); else str = TSummary.desc; if (Utils.InputBox("Main Track", "Description of the track", ref str) == DialogResult.OK) { TSummary.desc = str; WriteStringRecord(33, str); } } break; case "save as GPX": SaveT2F(true); break; case "save as KML": SaveT2F(false); break; case "append T2F...": t2fAppendMode = true; buttonLoadTrack2Follow_Click(null, null); break; case "save settings": // On the HTC TouchDiamond 2 Device / Windows Mobile 6.5, the returned Mouse Position is the Mouse Position of the // PopUp selection and not of the Button itself. The result will be, it磗 not possible to // change the name, or safe the data. // Bugfix: Store the the position of the button before opening the popup menu. SaveSettings(CurrentDirectory + mPage.mBAr[(int)mPage.lastSelectedBFkt].text + ".dat"); LoadedSettingsName = mPage.mBAr[(int)mPage.lastSelectedBFkt].text; break; case "change name": Utils.InputBox("Rename", "input name", ref mPage.mBAr[(int)mPage.lastSelectedBFkt].text); break; //***** graph page ******************************************************** case "autoscale": graph.scaleCmd = Graph.ScaleCmd.DoAutoscale; break; case "autoscale Y only": graph.scaleCmd = Graph.ScaleCmd.DoYAutoscale; break; case "undo autoscale": graph.UndoAutoscale(); break; case "align t2f": graph.alignT2f = !graph.alignT2f; graph.scaleCmd = Graph.ScaleCmd.DoRedraw; break; case "hide track": graph.hideTrack = !graph.hideTrack; graph.scaleCmd = Graph.ScaleCmd.DoRedraw; break; case "hide t2f": graph.hideT2f = !graph.hideT2f; graph.scaleCmd = Graph.ScaleCmd.DoRedraw; break; case "Altitude": graph.SetSource(Graph.SourceY.Alt, Graph.SourceX.Old); break; case "Speed": graph.SetSource(Graph.SourceY.Speed, Graph.SourceX.Old); break; case "Heart Rate": graph.SetSource(Graph.SourceY.Heart, Graph.SourceX.Old); break; case "over time": graph.SetSource(Graph.SourceY.Old, Graph.SourceX.Time); break; case "over distance": graph.SetSource(Graph.SourceY.Old, Graph.SourceX.Distance); break; case "auto hide buttons": graph.autoHideButtons ^= true; graph.scaleCmd = Graph.ScaleCmd.DoRedraw; break; case "help": buttonHelp_Click(null, null); break; //***** map page ************************************************************ case "reset map (GPS/last)": ResetMapPosition(); break; case "undo reset map": mapUtil.LongShift = LongShiftUndo; mapUtil.LatShift = LatShiftUndo; mapUtil.ZoomValue = ZoomUndo; ZoomUndo = 0.0; break; case "show track2follow - end": if (Plot2ndCount > 0) { ResetMapPosition(); mapUtil.ShowTrackToFollowMode = MapUtil.ShowTrackToFollow.T2FEnd; NoBkPanel.Invalidate(); // Update Screen } break; case "show track2follow - start": if (Plot2ndCount > 0) { ResetMapPosition(); mapUtil.ShowTrackToFollowMode = MapUtil.ShowTrackToFollow.T2FStart; NoBkPanel.Invalidate(); // Update Screen } break; case "edit t2f (add points)": if (trackEditMode != TrackEditMode.T2f) trackEditMode = TrackEditMode.T2f; else trackEditMode = TrackEditMode.Off; MenuExec(MenuPage.BFkt.map); //show the appropriate buttons break; case "remove last point of t2f": Plot2ndCount--; updateNavData(); if (Plot2ndCount > 0) T2fSummary.Distance = Plot2ndD[Plot2ndCount - 1]; else MenuExec(MenuPage.BFkt.map); //show the appropriate buttons (remove waypoint2) break; case "undo remove point": Plot2ndCount++; T2fSummary.Distance = Plot2ndD[Plot2ndCount-1]; MenuExec(MenuPage.BFkt.map); //show the appropriate buttons break; case "add waypoint to track": AddWaypoint(); break; case "add waypoint to t2f": AddWaypoint2(true); break; case "remove last waypoint (t2f)": WayPointsT2F.Count--; break; case "reload map tiles": mapUtil.reDownloadMaps = true; break; //***** navigation page ********************************************************* case "navigate backward": mapUtil.clearNav(!mapUtil.nav.backward); updateNavData(); break; case "calc min dist. to t2f": mapUtil.clearNav(mapUtil.nav.backward); mapUtil.nav.ShortSearch = 0; break; case "show nav button": mapUtil.show_nav_button = !mapUtil.show_nav_button; break; case "play voice test": mapUtil.playVoiceTest(); break; case "rename": string old_name = listBoxFiles.SelectedItem.ToString(); old_name = old_name.Replace("*", ""); old_name = old_name.Replace("+", ""); string new_name = old_name; if (Utils.InputBox("File", "Rename", ref new_name) == DialogResult.OK) { if (IoFilesDirectory != "\\") { old_name = "\\" + old_name; new_name = "\\" + new_name; } old_name = IoFilesDirectory + old_name; new_name = IoFilesDirectory + new_name; try { File.Move(old_name, new_name); } catch { MessageBox.Show(null, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } refillListBox(); } break; case "delete": string file_name = listBoxFiles.SelectedItem.ToString(); file_name = file_name.Replace("*", ""); file_name = file_name.Replace("+", ""); if (DialogResult.OK == MessageBox.Show("Delete File?", file_name, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)) { if (IoFilesDirectory != "\\") { file_name = "\\" + file_name; } file_name = IoFilesDirectory + file_name; try { File.Delete(file_name); } catch { MessageBox.Show(null, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } refillListBox(); } break; default: MessageBox.Show("no method for menu: " + ((MenuItem)sender).Text); break; } if (BufferDrawMode == BufferDrawModeMenu) mPage.deselectButton(); }
private void LoadSettings(string file_name) { FileStream fs = null; BinaryReader wr = null; try { fs = new FileStream(file_name, FileMode.Open, FileAccess.Read); wr = new BinaryReader(fs, Encoding.UTF8); comboGpsPoll.SelectedIndex = wr.ReadInt32(); comboUnits.SelectedIndex = wr.ReadInt32(); beepOnStartStop = 1 == wr.ReadInt32(); // reused checkExStopTime.Checked = 1 == wr.ReadInt32(); checkStopOnLow.Checked = 1 == wr.ReadInt32(); checkGpxRte.Checked = 1 == wr.ReadInt32(); numericGeoID.Value = wr.ReadInt32(); // load IoFilesDirectory int str_len = 0; string saved_name = ""; str_len = wr.ReadInt32(); for (int i = 0; i < str_len; i++) { saved_name += (char)(wr.ReadInt32()); } if (saved_name != "") { IoFilesDirectory = saved_name; } // more options checkKmlAlt.Checked = 1 == wr.ReadInt32(); checkEditFileName.Checked = 1 == wr.ReadInt32(); // kml line comboBoxKmlOptColor.SelectedIndex = wr.ReadInt32(); comboBoxKmlOptWidth.SelectedIndex = wr.ReadInt32(); // GCC DLL checkBoxUseGccDll.Checked = 1 == wr.ReadInt32(); comboBoxUseGccDllRate.SelectedIndex = wr.ReadInt32(); comboBoxUseGccDllCom.SelectedIndex = wr.ReadInt32(); // and more ... checkConfirmStop.Checked = 1 == wr.ReadInt32(); //was previous checkShowBkOff.Checked - reused MainConfigRelativeAlt = 1 == wr.ReadInt32(); int tmp = wr.ReadInt32(); if (tmp > 3) tmp = 1; //to avoid Exception, because index shortened - remove in future releases? comboMultiMaps.SelectedIndex = tmp; // load MapsFilesDirectory str_len = 0; saved_name = ""; str_len = wr.ReadInt32(); for (int i = 0; i < str_len; i++) { saved_name += (char)(wr.ReadInt32()); } if (saved_name != "") MapsFilesDirectory = saved_name; // ---------- Crossingways option ---------------- // load CW username str_len = 0; saved_name = ""; str_len = wr.ReadInt32(); for (int i = 0; i < str_len; i++) { saved_name += (char)(wr.ReadInt32()); } if (saved_name != "") { textBoxCw1.Text = saved_name; } // load CW hashed password str_len = 0; saved_name = ""; str_len = wr.ReadInt32(); for (int i = 0; i < str_len; i++) { saved_name += (char)(wr.ReadInt32()); } if (saved_name != "") { CwHashPassword = saved_name; textBoxCw2.Text = "******"; } else { CwHashPassword = ""; textBoxCw2.Text = ""; } // Live logging option comboBoxCwLogMode.SelectedIndex = wr.ReadInt32(); // 2nd line and "dots" options comboBoxLine2OptWidth.SelectedIndex = wr.ReadInt32(); comboBoxLine2OptColor.SelectedIndex = wr.ReadInt32(); checkPlotTrackAsDots.Checked = 1 == wr.ReadInt32(); checkPlotLine2AsDots.Checked = 1 == wr.ReadInt32(); // pages to show checkOptAbout.Checked = 1 == wr.ReadInt32(); checkOptLiveLog.Checked = 1 == wr.ReadInt32(); checkOptMaps.Checked = 1 == wr.ReadInt32(); checkOptGps.Checked = 1 == wr.ReadInt32(); checkOptKmlGpx.Checked = 1 == wr.ReadInt32(); // GPX, Map Bkgrd and Last ext to open, etc numericGpxTimeShift.Value = wr.ReadInt32(); checkMapsWhiteBk.Checked = 1 == wr.ReadInt32(); FileExtentionToOpen = (byte)wr.ReadInt32(); checkOptLaps.Checked = 1 == wr.ReadInt32(); wr.ReadInt32(); //no more used: comboMapDownload.SelectedIndex = wr.ReadInt32(); mapUtil.OsmTilesWebDownload = comboMapDownload.SelectedIndex; checkOptMain.Checked = 1 == wr.ReadInt32(); checkUploadGpx.Checked = 1 == wr.ReadInt32(); comboDropFirst.SelectedIndex = wr.ReadInt32(); checkGpxSpeedMs.Checked = 1 == wr.ReadInt32(); CurrentLat = wr.ReadDouble(); CurrentLong = wr.ReadDouble(); checkBeepOnFix.Checked = 1 == wr.ReadInt32(); numericAvg.Value = wr.ReadInt32(); checkkeepAliveReg.Checked = 1 == wr.ReadInt32(); textBoxCwUrl.Text = wr.ReadString(); checkWgs84Alt.Checked = 1 == wr.ReadInt32(); comboLapOptions.SelectedIndex = wr.ReadInt32(); checkLapBeep.Checked = 1 == wr.ReadInt32(); graph.sourceX = (Graph.SourceX)wr.ReadInt32(); //graph.GraphOverDistance = 1 == wr.ReadInt32(); importantNewsId = wr.ReadInt32(); MainConfigSpeedSource = wr.ReadInt32(); MainConfigAlt2display = wr.ReadInt32(); dayScheme = 1 == wr.ReadInt32(); mapUtil.DefaultZoomRadius = wr.ReadInt32(); numericZoomRadius.Value = mapUtil.DefaultZoomRadius; mPage.mBAr[(int)MenuPage.BFkt.recall1].text = wr.ReadString(); mPage.mBAr[(int)MenuPage.BFkt.recall2].text = wr.ReadString(); mPage.mBAr[(int)MenuPage.BFkt.recall3].text = wr.ReadString(); // additional Energy Safe options added checkGPSOffOnPowerOff.Checked = 1 == wr.ReadInt32(); checkKeepBackLightOn.Checked = 1 == wr.ReadInt32(); showWayPoints = wr.ReadInt32(); MainConfigDistance = (eConfigDistance) wr.ReadInt32(); MainConfigLatFormat = wr.ReadInt32(); LoadedSettingsName = wr.ReadString(); compass_north = 1 == wr.ReadInt32(); mapUtil.show_nav_button = 1 == wr.ReadInt32(); comboNavCmd.SelectedIndex = wr.ReadInt32(); checkGPXtrkseg.Checked = 1 == wr.ReadInt32(); compass_style = wr.ReadInt32(); LanguageDirectory = wr.ReadString(); bkColor_day = Color.FromArgb(wr.ReadInt32()); foColor_day = Color.FromArgb(wr.ReadInt32()); bkColor_night = Color.FromArgb(wr.ReadInt32()); foColor_night = Color.FromArgb(wr.ReadInt32()); configSyncSystemTime = 1 == wr.ReadInt32(); configNoLogPassiveTime = 1 == wr.ReadInt32(); mapLabelColor = Color.FromArgb(wr.ReadInt32()); checkTouchOn.Checked = 1 == wr.ReadInt32(); comboArraySize.SelectedIndex = wr.ReadInt32(); mapUtil.drawWhileShift = 1 == wr.ReadInt32(); checkShowExit.Checked = 1 == wr.ReadInt32(); checkChangeMenuOptBKL.Checked = 1 == wr.ReadInt32(); graph.alignT2f = 1 == wr.ReadInt32(); AppFullScreen = 1 == wr.ReadInt32(); //FormFullScreen(AppFullScreen); //here it is not executed, if file not exists (or far too short) MainConfigNav = 1 == wr.ReadInt32(); checkMainConfigSingleTap.Checked = 1 == wr.ReadInt32(); for (int i = 0; i < 3; i++) mapValuesConf[i] = (MapValue)wr.ReadInt32(); mapValuesShowName = 1 == wr.ReadInt32(); mapValuesCleanBack = 1 == wr.ReadInt32(); mapUtil.showMapLabel = 1 == wr.ReadInt32(); mapUtil.showNav = 1 == wr.ReadInt32(); mapUtil.autoHideButtons = 1 == wr.ReadInt32(); graph.autoHideButtons = 1 == wr.ReadInt32(); numericTrackTolerance.Value = wr.ReadInt32(); } catch (FileNotFoundException) { FormFullScreen(AppFullScreen); MessageBox.Show("Configuration file not found: " + file_name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } catch (EndOfStreamException) { FormFullScreen(AppFullScreen); MessageBox.Show("Unexpected EOF while reading " + file_name + " (Position " + fs.Position + ").\nUsing current (or default) Options for remainder.\n\nThis is ok if you have just updated to a newer version.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } catch (Exception ee) { FormFullScreen(AppFullScreen); Utils.log.Error(" LoadSettings ", ee); } finally { if (wr != null) wr.Close(); if (fs != null) fs.Close(); } //process the new settings FormFullScreen(AppFullScreen); //here it works if file not exists, but it doesn't work on EndOfStream (open file and MsgBox?) -> also before MsgBox CheckIoDirectoryExists(); CheckMapsDirectoryExists(); mapUtil.LoadMaps(MapsFilesDirectory); CheckLanguageDirectoryExists(); }