Rev 2349 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2349 | Rev 2350 | ||
---|---|---|---|
Line 2793... | Line 2793... | ||
2793 | { |
2793 | { |
Line 2794... | Line 2794... | ||
2794 | 2794 | ||
2795 | MessageBox.Show("Error writing ini-file!" + Environment.NewLine + "Please make sure that the programm is in a location where it is allowed to write" + Environment.NewLine + e.Message, "Write ini-file", MessageBoxButton.OK, MessageBoxImage.Error); |
2795 | MessageBox.Show("Error writing ini-file!" + Environment.NewLine + "Please make sure that the programm is in a location where it is allowed to write" + Environment.NewLine + e.Message, "Write ini-file", MessageBoxButton.OK, MessageBoxImage.Error); |
2796 | } |
2796 | } |
- | 2797 | } |
|
2797 | } |
2798 | |
2798 | #region serial channels |
2799 | #region serial channels |
2799 | /// <summary> |
2800 | /// <summary> |
2800 | /// Sending the serial channel values |
2801 | /// Sending the serial channel values |
2801 | /// </summary> |
2802 | /// </summary> |
Line 2816... | Line 2817... | ||
2816 | { |
2817 | { |
2817 | SerChan1ScaleSlider.Value = serChan[0]; |
2818 | SerChan1ScaleSlider.Value = serChan[0]; |
2818 | textBoxSerial1.Text = serChanTitle[0]; |
2819 | textBoxSerial1.Text = serChanTitle[0]; |
2819 | SerChan2ScaleSlider.Value = serChan[1]; |
2820 | SerChan2ScaleSlider.Value = serChan[1]; |
2820 | textBoxSerial2.Text = serChanTitle[1]; |
2821 | textBoxSerial2.Text = serChanTitle[1]; |
2821 | //SerChan3ScaleSlider.Value = serChan[2]; |
2822 | SerChan3ScaleSlider.Value = serChan[2]; |
2822 | //textBoxSerial3.Text = serChanTitle[2]; |
2823 | textBoxSerial3.Text = serChanTitle[2]; |
2823 | //SerChan4ScaleSlider.Value = serChan[3]; |
2824 | //SerChan4ScaleSlider.Value = serChan[3]; |
2824 | //textBoxSerial4.Text = serChanTitle[3]; |
2825 | //textBoxSerial4.Text = serChanTitle[3]; |
2825 | //trckbarSerial5.Value = serChan[4]; |
2826 | //trckbarSerial5.Value = serChan[4]; |
2826 | //textBoxSerial5.Text = serChanTitle[4]; |
2827 | //textBoxSerial5.Text = serChanTitle[4]; |
2827 | //trckbarSerial6.Value = serChan[5]; |
2828 | //trckbarSerial6.Value = serChan[5]; |
Line 2835... | Line 2836... | ||
2835 | textBoxSerial1_val2.Text = serChan_sub[1].ToString(); |
2836 | textBoxSerial1_val2.Text = serChan_sub[1].ToString(); |
2836 | textBoxSerial1_val3.Text = serChan_sub[2].ToString(); |
2837 | textBoxSerial1_val3.Text = serChan_sub[2].ToString(); |
2837 | textBoxSerial2_val1.Text = serChan_sub[3].ToString(); |
2838 | textBoxSerial2_val1.Text = serChan_sub[3].ToString(); |
2838 | textBoxSerial2_val2.Text = serChan_sub[4].ToString(); |
2839 | textBoxSerial2_val2.Text = serChan_sub[4].ToString(); |
2839 | textBoxSerial2_val3.Text = serChan_sub[5].ToString(); |
2840 | textBoxSerial2_val3.Text = serChan_sub[5].ToString(); |
2840 | //textBoxSerial3_val1.Text = serChan_sub[6].ToString(); |
2841 | textBoxSerial3_val1.Text = serChan_sub[6].ToString(); |
2841 | //textBoxSerial3_val2.Text = serChan_sub[7].ToString(); |
2842 | textBoxSerial3_val2.Text = serChan_sub[7].ToString(); |
2842 | //textBoxSerial3_val3.Text = serChan_sub[8].ToString(); |
2843 | textBoxSerial3_val3.Text = serChan_sub[8].ToString(); |
2843 | //textBoxSerial4_val1.Text = serChan_sub[9].ToString(); |
2844 | //textBoxSerial4_val1.Text = serChan_sub[9].ToString(); |
2844 | //textBoxSerial4_val2.Text = serChan_sub[10].ToString(); |
2845 | //textBoxSerial4_val2.Text = serChan_sub[10].ToString(); |
2845 | //textBoxSerial4_val3.Text = serChan_sub[11].ToString(); |
2846 | //textBoxSerial4_val3.Text = serChan_sub[11].ToString(); |
2846 | } |
2847 | } |
2847 | private void SerChan1ScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
2848 | private void SerChan1ScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
Line 2981... | Line 2982... | ||
2981 | if (textBoxSerial2_val3.Text.Length > 0) |
2982 | if (textBoxSerial2_val3.Text.Length > 0) |
2982 | { |
2983 | { |
2983 | SerChan2ScaleSlider.Value = Convert.ToInt16(textBoxSerial2_val3.Text); |
2984 | SerChan2ScaleSlider.Value = Convert.ToInt16(textBoxSerial2_val3.Text); |
2984 | } |
2985 | } |
2985 | } |
2986 | } |
- | 2987 | ||
- | 2988 | private void SerChan3ScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
|
- | 2989 | { |
|
- | 2990 | if (!_init) |
|
- | 2991 | { |
|
- | 2992 | serChan[2] = (int)SerChan3ScaleSlider.Value; |
|
- | 2993 | _sendSerialData(); |
|
- | 2994 | } |
|
- | 2995 | } |
|
- | 2996 | private void textBoxSerial3_TextChanged(object sender, TextChangedEventArgs e) |
|
- | 2997 | { |
|
- | 2998 | if (!_init) |
|
- | 2999 | { |
|
- | 3000 | serChanTitle[2] = textBoxSerial3.Text; |
|
- | 3001 | } |
|
- | 3002 | } |
|
- | 3003 | private void textBoxSerial3_val1_TextChanged(object sender, TextChangedEventArgs e) |
|
- | 3004 | { |
|
- | 3005 | if (textBoxSerial3_val1.Text.Length > 0 & !_init) |
|
- | 3006 | { |
|
- | 3007 | serChan_sub[6] = Convert.ToInt16(textBoxSerial3_val1.Text); |
|
- | 3008 | } |
|
- | 3009 | } |
|
- | 3010 | private void textBoxSerial3_val2_TextChanged(object sender, TextChangedEventArgs e) |
|
- | 3011 | { |
|
- | 3012 | if (textBoxSerial3_val2.Text.Length > 0 & !_init) |
|
- | 3013 | { |
|
- | 3014 | serChan_sub[7] = Convert.ToInt16(textBoxSerial3_val2.Text); |
|
- | 3015 | } |
|
- | 3016 | } |
|
- | 3017 | private void textBoxSerial3_val3_TextChanged(object sender, TextChangedEventArgs e) |
|
- | 3018 | { |
|
- | 3019 | if (textBoxSerial3_val3.Text.Length > 0 & !_init) |
|
- | 3020 | { |
|
- | 3021 | serChan_sub[8] = Convert.ToInt16(textBoxSerial3_val3.Text); |
|
- | 3022 | } |
|
- | 3023 | } |
|
- | 3024 | private void btnSer3_0_Click(object sender, RoutedEventArgs e) |
|
- | 3025 | { |
|
- | 3026 | SerChan3ScaleSlider.Value = 0; |
|
- | 3027 | } |
|
- | 3028 | private void btnSer3_127_Click(object sender, RoutedEventArgs e) |
|
- | 3029 | { |
|
- | 3030 | SerChan3ScaleSlider.Value = 127; |
|
- | 3031 | } |
|
- | 3032 | private void btnSer3_254_Click(object sender, RoutedEventArgs e) |
|
- | 3033 | { |
|
- | 3034 | SerChan3ScaleSlider.Value = 254; |
|
- | 3035 | } |
|
- | 3036 | private void btnSer3_val1_Click(object sender, RoutedEventArgs e) |
|
- | 3037 | { |
|
- | 3038 | if (textBoxSerial3_val1.Text.Length > 0) |
|
- | 3039 | { |
|
- | 3040 | SerChan3ScaleSlider.Value = Convert.ToInt16(textBoxSerial3_val1.Text); |
|
- | 3041 | } |
|
- | 3042 | } |
|
- | 3043 | private void btnSer3_val2_Click(object sender, RoutedEventArgs e) |
|
- | 3044 | { |
|
- | 3045 | if (textBoxSerial3_val2.Text.Length > 0) |
|
- | 3046 | { |
|
- | 3047 | SerChan3ScaleSlider.Value = Convert.ToInt16(textBoxSerial3_val2.Text); |
|
- | 3048 | } |
|
- | 3049 | } |
|
- | 3050 | private void btnSer3_val3_Click(object sender, RoutedEventArgs e) |
|
- | 3051 | { |
|
- | 3052 | if (textBoxSerial3_val3.Text.Length > 0) |
|
- | 3053 | { |
|
- | 3054 | SerChan3ScaleSlider.Value = Convert.ToInt16(textBoxSerial3_val3.Text); |
|
- | 3055 | } |
|
- | 3056 | } |
|
2986 | /// <summary> |
3057 | /// <summary> |
2987 | /// checks the input of a textbox |
3058 | /// checks the input of a textbox |
2988 | /// for valid data |
3059 | /// for valid data |
2989 | /// in this case values 0-254 |
3060 | /// in this case values 0-254 |
2990 | /// </summary> |
3061 | /// </summary> |
Line 3109... | Line 3180... | ||
3109 | if (sVal != "") |
3180 | if (sVal != "") |
3110 | o[i] = Convert.ToInt16(sVal) - 1; |
3181 | o[i] = Convert.ToInt16(sVal) - 1; |
3111 | i++; |
3182 | i++; |
3112 | sVal = ini.IniReadValue(wp, "Prefix"); |
3183 | sVal = ini.IniReadValue(wp, "Prefix"); |
3113 | if (sVal != "") |
3184 | if (sVal != "") |
- | 3185 | o[i] = sVal + k.ToString(); |
|
3114 | o[i] = sVal == "0" ? "P" + k.ToString() : sVal + k.ToString(); |
3186 | // o[i] = sVal == "0" ? "!" + k.ToString() : sVal + k.ToString(); |
3115 | i++; |
3187 | i++; |
3116 | sVal = ini.IniReadValue(wp, "Latitude"); |
3188 | sVal = ini.IniReadValue(wp, "Latitude"); |
3117 | if (sVal != "") |
3189 | if (sVal != "") |
3118 | o[i] = Convert.ToDouble(sVal, nfi); |
3190 | o[i] = Convert.ToDouble(sVal, nfi); |
3119 | i++; |
3191 | i++; |
Line 3205... | Line 3277... | ||
3205 | MessageBox.Show("Error parsing wpl-file!" + Environment.NewLine + e.Message, "Read wpl-file", MessageBoxButton.OK, MessageBoxImage.Error); |
3277 | MessageBox.Show("Error parsing wpl-file!" + Environment.NewLine + e.Message, "Read wpl-file", MessageBoxButton.OK, MessageBoxImage.Error); |
3206 | } |
3278 | } |
Line 3207... | Line 3279... | ||
3207 | 3279 | ||
3208 | } |
3280 | } |
- | 3281 | } |
|
- | 3282 | void _saveWPLFile() |
|
- | 3283 | { |
|
- | 3284 | if (dtWaypoints.Rows.Count > 0) |
|
- | 3285 | { |
|
- | 3286 | Microsoft.Win32.SaveFileDialog fd = new Microsoft.Win32.SaveFileDialog(); |
|
- | 3287 | fd.Filter = "Waypointlists | *.wpl"; |
|
- | 3288 | fd.AddExtension = true; |
|
- | 3289 | if (fd.ShowDialog().Value) |
|
- | 3290 | { |
|
- | 3291 | string file = fd.SafeFileName; |
|
- | 3292 | IniFile ini = new IniFile(fd.SafeFileName); |
|
- | 3293 | ini.path = fd.FileName; |
|
- | 3294 | NumberFormatInfo nfi = new NumberFormatInfo(); |
|
- | 3295 | nfi.NumberDecimalSeparator = "."; |
|
- | 3296 | ||
- | 3297 | try |
|
- | 3298 | { |
|
- | 3299 | ini.IniWriteValue("General", "FileVersion", "3"); |
|
- | 3300 | ini.IniWriteValue("General", "NumberOfWaypoints", dtWaypoints.Rows.Count.ToString()); |
|
- | 3301 | ini.IniWriteValue("General", "Mapfile", ""); |
|
- | 3302 | for(int i = 1; i<=dtWaypoints.Rows.Count; i++) |
|
- | 3303 | { |
|
- | 3304 | ini.IniWriteValue("Point" + i.ToString(), "Latitude", ((double)(dtWaypoints.Rows[i-1][3])).ToString(nfi)); |
|
- | 3305 | ini.IniWriteValue("Point" + i.ToString(), "Longitude", ((double)(dtWaypoints.Rows[i - 1][4])).ToString(nfi)); |
|
- | 3306 | ini.IniWriteValue("Point" + i.ToString(), "Radius", dtWaypoints.Rows[i - 1][9].ToString()); |
|
- | 3307 | ini.IniWriteValue("Point" + i.ToString(), "Altitude", dtWaypoints.Rows[i - 1][5].ToString()); |
|
- | 3308 | ini.IniWriteValue("Point" + i.ToString(), "ClimbRate", dtWaypoints.Rows[i - 1][8].ToString()); |
|
- | 3309 | ini.IniWriteValue("Point" + i.ToString(), "DelayTime", dtWaypoints.Rows[i - 1][10].ToString()); |
|
- | 3310 | ini.IniWriteValue("Point" + i.ToString(), "WP_Event_Channel_Value", dtWaypoints.Rows[i - 1][14].ToString()); |
|
- | 3311 | ini.IniWriteValue("Point" + i.ToString(), "Heading", dtWaypoints.Rows[i - 1][6].ToString()); |
|
- | 3312 | ini.IniWriteValue("Point" + i.ToString(), "Speed", dtWaypoints.Rows[i - 1][7].ToString()); |
|
- | 3313 | ini.IniWriteValue("Point" + i.ToString(), "CAM-Nick", dtWaypoints.Rows[i - 1][12].ToString()); |
|
- | 3314 | ini.IniWriteValue("Point" + i.ToString(), "Type", ((int)dtWaypoints.Rows[i - 1][1]+1).ToString()); |
|
- | 3315 | ini.IniWriteValue("Point" + i.ToString(), "Prefix", dtWaypoints.Rows[i - 1][2].ToString().Substring(0, 1)); // == "!" ? "0" : dtWaypoints.Rows[i - 1][2].ToString().Substring(0, 1)); |
|
- | 3316 | ini.IniWriteValue("Point" + i.ToString(), "AutoTrigger", dtWaypoints.Rows[i - 1][11].ToString()); |
|
- | 3317 | } |
|
- | 3318 | MessageBox.Show(dtWaypoints.Rows.Count.ToString() + " points saved to " + file, "Waypointlist saved", MessageBoxButton.OK, MessageBoxImage.Information); |
|
- | 3319 | } |
|
- | 3320 | catch { } |
|
- | 3321 | } |
|
- | 3322 | } |
|
- | 3323 | else |
|
- | 3324 | MessageBox.Show("Nothing to save..."); |
|
- | 3325 | } |
|
- | 3326 | private void btnSaveWPLFile_Click(object sender, RoutedEventArgs e) |
|
- | 3327 | { |
|
- | 3328 | _saveWPLFile(); |
|
- | 3329 | } |
|
- | 3330 | /// <summary> |
|
- | 3331 | /// set the selected color for the route |
|
- | 3332 | /// </summary> |
|
- | 3333 | /// <param name="color"></param> |
|
3209 | } |
3334 | /// <returns></returns> |
3210 | Brush _getBrush(string color) |
3335 | Brush _getBrush(string color) |
3211 | { |
3336 | { |
3212 | switch (color) |
3337 | switch (color) |
3213 | { |
3338 | { |
Line 3403... | Line 3528... | ||
3403 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex],1); |
3528 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex],1); |
3404 | } |
3529 | } |
3405 | } |
3530 | } |
Line 3406... | Line 3531... | ||
3406 | 3531 | ||
3407 | #endregion WP |
- | |
3408 | 3532 | #endregion WP |
|
3409 | #region GPX |
3533 | #region GPX |
3410 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
3534 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
3411 | { |
3535 | { |
3412 | _bGPXLog = (bool)checkBoxGPXLog.IsChecked; |
3536 | _bGPXLog = (bool)checkBoxGPXLog.IsChecked; |
Line 3472... | Line 3596... | ||
3472 | { |
3596 | { |
3473 | myXmlTextWriter.Close(); |
3597 | myXmlTextWriter.Close(); |
3474 | } |
3598 | } |
3475 | } |
3599 | } |
3476 | } |
3600 | } |
3477 | - | ||
3478 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
3601 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
3479 | { |
3602 | { |
3480 | _loadGPXLog(); |
3603 | _loadGPXLog(); |
3481 | } |
3604 | } |
3482 | - | ||
3483 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |
3605 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |
3484 | { |
3606 | { |
3485 | _clearMapMarkers(typeof(GMapRoute)); |
3607 | _clearMapMarkers(typeof(GMapRoute)); |
3486 | } |
3608 | } |
3487 | - | ||
3488 | - | ||
3489 | void _loadGPXLog() |
3609 | void _loadGPXLog() |
3490 | { |
3610 | { |
Line 3491... | Line 3611... | ||
3491 | 3611 | ||
3492 | Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog(); |
3612 | Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog(); |