//Initialize items before the form Loads or is visible private void FormGPS_Load(object sender, EventArgs e) { //tooltips of controls ToolTip ToolTip1 = new ToolTip(); ToolTip1.SetToolTip(btnABLine, "Set and configure\n an ABLine"); if (Settings.Default.setF_workingDirectory == "Default") { baseDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\AgOpenGPS\\"; } else { baseDirectory = Settings.Default.setF_workingDirectory + "\\AgOpenGPS\\"; } //get the fields directory, if not exist, create fieldsDirectory = baseDirectory + "Fields\\"; string dir = Path.GetDirectoryName(fieldsDirectory); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //get the fields directory, if not exist, create vehiclesDirectory = baseDirectory + "Vehicles\\"; dir = Path.GetDirectoryName(vehiclesDirectory); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //make sure current field directory exists, null if not currentFieldDirectory = Settings.Default.setF_CurrentDir; string curDir; if (currentFieldDirectory != "") { curDir = fieldsDirectory + currentFieldDirectory + "//"; dir = Path.GetDirectoryName(curDir); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { currentFieldDirectory = ""; Settings.Default.setF_CurrentDir = ""; Settings.Default.Save(); } } //grab the current vehicle filename - make sure it exists vehiclefileName = Vehicle.Default.setVehicle_Name; fixUpdateHz = Properties.Settings.Default.setPort_NMEAHz; fixUpdateTime = 1 / (double)fixUpdateHz; //get the abLines directory, if not exist, create ablinesDirectory = baseDirectory + "ABLines\\"; dir = Path.GetDirectoryName(fieldsDirectory); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //set baud and port from last time run baudRateGPS = Settings.Default.setPort_baudRate; portNameGPS = Settings.Default.setPort_portNameGPS; //try and open SerialPortOpenGPS(); //same for SectionRelay port portNameRelaySection = Settings.Default.setPort_portNameRateRelay; wasRateRelayConnectedLastRun = Settings.Default.setPort_wasRateRelayConnected; if (wasRateRelayConnectedLastRun) { SerialPortRateRelayOpen(); } //same for AutoSteer port portNameAutoSteer = Settings.Default.setPort_portNameAutoSteer; wasAutoSteerConnectedLastRun = Settings.Default.setPort_wasAutoSteerConnected; if (wasAutoSteerConnectedLastRun) { SerialPortAutoSteerOpen(); } //Set width of section and positions for each section SectionSetPosition(); //Calculate total width and each section width SectionCalcWidths(); //start udp server if required if (Properties.Settings.Default.setUDP_isOn) { StartUDPServer(); } //set the correct zoom and grid camera.camSetDistance = camera.zoomValue * camera.zoomValue * -1; SetZoom(); //which heading source is being used headingFromSource = Settings.Default.setGPS_headingFromWhichSource; //triangle resolution is how far to next triangle point trigger distance camera.triangleResolution = Settings.Default.setDisplay_triangleResolution; //remembered window position if (Settings.Default.setWindow_Maximized) { WindowState = FormWindowState.Maximized; Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } else if (Settings.Default.setWindow_Minimized) { //WindowState = FormWindowState.Minimized; Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } else { Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } //don't draw the back opengl to GDI - it still works tho //openGLControlBack.Visible = false; //clear the flags flagPts.Clear(); btnFlag.Enabled = false; //workswitch stuff mc.isWorkSwitchEnabled = Settings.Default.setF_IsWorkSwitchEnabled; mc.isWorkSwitchActiveLow = Settings.Default.setF_IsWorkSwitchActiveLow; minFixStepDist = Settings.Default.setF_minFixStep; totalUserSquareMeters = Settings.Default.setF_UserTotalArea; userSquareMetersAlarm = Settings.Default.setF_UserTripAlarm; //space between points while recording a boundary boundaryTriggerDistance = Settings.Default.setF_boundaryTriggerDistance; //load the last used auto turn shape string fileAndDir = @".\YouTurnShapes\" + Properties.Settings.Default.setAS_youTurnShape; yt.LoadYouTurnShapeFromFile(fileAndDir); //sim.latitude = Settings.Default.setSim_lastLat; //sim.longitude = Settings.Default.setSim_lastLong; //load th elightbar resolution lightbarCmPerPixel = Properties.Settings.Default.setDisplay_lightbarCmPerPixel; // load all the gui elements in gui.designer.cs LoadGUI(); }
//Initialize items before the form Loads or is visible private void FormGPS_Load(object sender, EventArgs e) { //tooltips of controls ToolTip ToolTip1 = new ToolTip(); ToolTip1.SetToolTip(btnABLine, "Set and configure\n an ABLine"); //get the working directory, if not exist, create workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\AgOpenGPS\\Fields\\"; string dir = Path.GetDirectoryName(workingDirectory); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //set baud and port from last time run baudRateGPS = Settings.Default.setPort_baudRate; portNameGPS = Settings.Default.setPort_portNameGPS; //try and open SerialPortOpenGPS(); //same for SectionRelay port portNameRelaySection = Settings.Default.setPort_portNameRateRelay; wasRateRelayConnectedLastRun = Settings.Default.setPort_wasRateRelayConnected; if (wasRateRelayConnectedLastRun) { SerialPortRateRelayOpen(); } //same for AutoSteer port portNameAutoSteer = Settings.Default.setPort_portNameAutoSteer; wasAutoSteerConnectedLastRun = Settings.Default.setPort_wasAutoSteerConnected; if (wasAutoSteerConnectedLastRun) { SerialPortAutoSteerOpen(); } //Set width of section and positions for each section SectionSetPosition(); //Calculate total width and each section width SectionCalcWidths(); isTCPServerOn = Settings.Default.setPort_isTCPOn; isUDPServerOn = Settings.Default.setPort_isUDPOn; //start servers or not if (isTCPServerOn) { StartTCPServer(); } if (isUDPServerOn) { StartUDPServer(); } //set the correct zoom and grid camera.camSetDistance = zoomValue * zoomValue * -1; SetZoom(); //which cam source is being used isAtanCam = Settings.Default.setCam_isAtanCam; //triangle resolution is how far to next triangle point trigger distance triangleResolution = Settings.Default.setDisplay_triangleResolution; //remembered window position if (Settings.Default.setWindow_Maximized) { WindowState = FormWindowState.Maximized; Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } else if (Settings.Default.setWindow_Minimized) { //WindowState = FormWindowState.Minimized; Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } else { Location = Settings.Default.setWindow_Location; Size = Settings.Default.setWindow_Size; } //don;t draw the back opengl to GDI - it still works tho openGLControlBack.Visible = false; //set previous job directory currentFieldDirectory = Settings.Default.setF_CurrentDir; vehiclefileName = Settings.Default.setVehicle_Name; //clear the flags flagPts.Clear(); btnFlag.Enabled = false; //workswitch stuff mc.isWorkSwitchEnabled = Settings.Default.setF_IsWorkSwitchEnabled; mc.isWorkSwitchActiveLow = Settings.Default.setF_IsWorkSwitchActiveLow; minFixStepDist = Settings.Default.setF_minFixStep; pitchZero = Settings.Default.setIMU_pitchZero; rollZero = Settings.Default.setIMU_rollZero; totalUserSquareMeters = Settings.Default.setF_UserTotalArea; userSquareMetersAlarm = Settings.Default.setF_UserTripAlarm; //space between points while recording a boundary boundaryTriggerDistance = Settings.Default.setF_boundaryTriggerDistance; //load the last used auto turn shape string fileAndDir = @".\YouTurnShapes\" + Properties.Settings.Default.setAS_youTurnShape; yt.LoadYouTurnShapeFromFile(fileAndDir); // load all the gui elements in gui.designer.cs LoadGUI(); }