Subversion Repositories Projects

Rev

Rev 2347 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2347 Rev 2349
Line 353... Line 353...
353
            checkBoxAutoSetHP.IsChecked = _bAutoHome;
353
            checkBoxAutoSetHP.IsChecked = _bAutoHome;
354
            checkBoxFollowCopter.IsChecked = _bFollowCopter;
354
            checkBoxFollowCopter.IsChecked = _bFollowCopter;
355
            checkBoxGPXLog.IsChecked = _bGPXLog;
355
            checkBoxGPXLog.IsChecked = _bGPXLog;
356
            checkBoxShowWPRoute.IsChecked = _bShowWPRoute;
356
            checkBoxShowWPRoute.IsChecked = _bShowWPRoute;
Line -... Line 357...
-
 
357
 
357
 
358
            _initSerialCtrl();
358
        }
359
        }
359
        /// <summary>
360
        /// <summary>
360
        /// initialize the datatables
361
        /// initialize the datatables
361
        /// with columnnames etc
362
        /// with columnnames etc
Line 2671... Line 2672...
2671
                if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal);
2672
                if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal);
2672
                sVal = ini.IniReadValue("waypoints", "routecolor");
2673
                sVal = ini.IniReadValue("waypoints", "routecolor");
2673
                if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal);
2674
                if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal);
2674
                sVal = ini.IniReadValue("waypoints", "showWPRoute");
2675
                sVal = ini.IniReadValue("waypoints", "showWPRoute");
2675
                if(sVal != "") _bShowWPRoute = Convert.ToBoolean(sVal);
2676
                if(sVal != "") _bShowWPRoute = Convert.ToBoolean(sVal);
-
 
2677
 
-
 
2678
                for (int i = 0; i < 12; i++)
-
 
2679
                {
-
 
2680
                    sVal = ini.IniReadValue("serial", "ch" + i.ToString() + "Val");
-
 
2681
                    if (sVal != "")
-
 
2682
                        serChan[i] = Convert.ToInt16(sVal);
-
 
2683
                    sVal = ini.IniReadValue("serial", "ch" + i.ToString() + "Title");
-
 
2684
                    if (sVal != "")
-
 
2685
                        serChanTitle[i] = sVal;
-
 
2686
                    for (int y = 0; i < 4 && y < 3; y++)
-
 
2687
                    {
-
 
2688
                        sVal = ini.IniReadValue("serial", "ch" + i.ToString() + "ValSub" + y.ToString());
-
 
2689
                        if (sVal != "")
-
 
2690
                            serChan_sub[(i * 3) + y] = Convert.ToInt16(sVal);
-
 
2691
                    }
-
 
2692
                }
-
 
2693
 
2676
            }
2694
            }
2677
            catch (Exception e)
2695
            catch (Exception e)
2678
            {
2696
            {
Line 2679... Line 2697...
2679
 
2697
 
Line 2757... Line 2775...
2757
                ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString());
2775
                ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString());
2758
                ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString());
2776
                ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString());
2759
                ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString());
2777
                ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString());
2760
                ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString());
2778
                ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString());
2761
                ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString());
2779
                ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString());
-
 
2780
 
-
 
2781
                for (int i = 0; i < 12; i++)
-
 
2782
                {
-
 
2783
                    ini.IniWriteValue("serial", "ch" + i.ToString() + "Val", serChan[i].ToString());
-
 
2784
                    ini.IniWriteValue("serial", "ch" + i.ToString() + "Title", serChanTitle[i]);
-
 
2785
                    for (int y = 0; i < 4 && y < 3; y++)
-
 
2786
                    {
-
 
2787
                        ini.IniWriteValue("serial", "ch" + i.ToString() + "ValSub" + y.ToString(), serChan_sub[(i * 3) + y].ToString());
-
 
2788
                    }
-
 
2789
                }
-
 
2790
 
2762
            }
2791
            }
2763
            catch (Exception e)
2792
            catch (Exception e)
2764
            {
2793
            {
Line 2765... Line 2794...
2765
 
2794
 
2766
                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);
2767
            }
2796
            }
-
 
2797
        }
-
 
2798
        #region serial channels
-
 
2799
        /// <summary>
-
 
2800
        /// Sending the serial channel values
-
 
2801
        /// </summary>
-
 
2802
        void _sendSerialData()
-
 
2803
        {
-
 
2804
            byte[] serData = new byte[12];
-
 
2805
            for (int i = 0; i < 12; i++)
-
 
2806
            {
-
 
2807
                serData[i] = unchecked((byte)(serChan[i] - 127));
-
 
2808
            }
-
 
2809
            _sendControllerMessage('y', 1, serData);
-
 
2810
        }
-
 
2811
        /// <summary>
-
 
2812
        /// init the controls for displaying
-
 
2813
        /// and setting serial control channels
-
 
2814
        /// </summary>
-
 
2815
        void _initSerialCtrl()
-
 
2816
        {
-
 
2817
            SerChan1ScaleSlider.Value = serChan[0];
-
 
2818
            textBoxSerial1.Text = serChanTitle[0];
-
 
2819
            SerChan2ScaleSlider.Value = serChan[1];
-
 
2820
            textBoxSerial2.Text = serChanTitle[1];
-
 
2821
            //SerChan3ScaleSlider.Value = serChan[2];
-
 
2822
            //textBoxSerial3.Text = serChanTitle[2];
-
 
2823
            //SerChan4ScaleSlider.Value = serChan[3];
-
 
2824
            //textBoxSerial4.Text = serChanTitle[3];
-
 
2825
            //trckbarSerial5.Value = serChan[4];
-
 
2826
            //textBoxSerial5.Text = serChanTitle[4];
-
 
2827
            //trckbarSerial6.Value = serChan[5];
-
 
2828
            //textBoxSerial6.Text = serChanTitle[5];
-
 
2829
            //trckbarSerial7.Value = serChan[6];
-
 
2830
            //textBoxSerial7.Text = serChanTitle[6];
-
 
2831
            //trckbarSerial8.Value = serChan[7];
-
 
2832
            //textBoxSerial8.Text = serChanTitle[7];
-
 
2833
 
-
 
2834
            textBoxSerial1_val1.Text = serChan_sub[0].ToString();
-
 
2835
            textBoxSerial1_val2.Text = serChan_sub[1].ToString();
-
 
2836
            textBoxSerial1_val3.Text = serChan_sub[2].ToString();
-
 
2837
            textBoxSerial2_val1.Text = serChan_sub[3].ToString();
-
 
2838
            textBoxSerial2_val2.Text = serChan_sub[4].ToString();
-
 
2839
            textBoxSerial2_val3.Text = serChan_sub[5].ToString();
-
 
2840
            //textBoxSerial3_val1.Text = serChan_sub[6].ToString();
-
 
2841
            //textBoxSerial3_val2.Text = serChan_sub[7].ToString();
-
 
2842
            //textBoxSerial3_val3.Text = serChan_sub[8].ToString();
-
 
2843
            //textBoxSerial4_val1.Text = serChan_sub[9].ToString();
-
 
2844
            //textBoxSerial4_val2.Text = serChan_sub[10].ToString();
-
 
2845
            //textBoxSerial4_val3.Text = serChan_sub[11].ToString();
-
 
2846
        }
-
 
2847
        private void SerChan1ScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
-
 
2848
        {
-
 
2849
            if (!_init)
-
 
2850
            {
-
 
2851
                serChan[0] = (int)SerChan1ScaleSlider.Value;
-
 
2852
                _sendSerialData();
-
 
2853
            }
-
 
2854
        }
-
 
2855
        private void textBoxSerial1_TextChanged(object sender, TextChangedEventArgs e)
-
 
2856
        {
-
 
2857
            if (!_init)
-
 
2858
            {
-
 
2859
                serChanTitle[0] = textBoxSerial1.Text;
-
 
2860
            }
-
 
2861
        }
-
 
2862
        private void textBoxSerial1_val1_TextChanged(object sender, TextChangedEventArgs e)
-
 
2863
        {
-
 
2864
            if (textBoxSerial1_val1.Text.Length > 0 & !_init)
-
 
2865
            {
-
 
2866
                serChan_sub[0] = Convert.ToInt16(textBoxSerial1_val1.Text);
-
 
2867
            }
-
 
2868
        }
-
 
2869
        private void textBoxSerial1_val2_TextChanged(object sender, TextChangedEventArgs e)
-
 
2870
        {
-
 
2871
            if (textBoxSerial1_val2.Text.Length > 0 & !_init)
-
 
2872
            {
-
 
2873
                serChan_sub[1] = Convert.ToInt16(textBoxSerial1_val2.Text);
-
 
2874
            }
-
 
2875
        }
-
 
2876
        private void textBoxSerial1_val3_TextChanged(object sender, TextChangedEventArgs e)
-
 
2877
        {
-
 
2878
            if (textBoxSerial1_val3.Text.Length > 0 & !_init)
-
 
2879
            {
-
 
2880
                serChan_sub[2] = Convert.ToInt16(textBoxSerial1_val3.Text);
-
 
2881
            }
-
 
2882
        }
-
 
2883
        private void btnSer1_val1_Click(object sender, RoutedEventArgs e)
-
 
2884
        {
-
 
2885
            if (textBoxSerial1_val1.Text.Length > 0)
-
 
2886
            {
-
 
2887
                SerChan1ScaleSlider.Value = Convert.ToInt16(textBoxSerial1_val1.Text);
-
 
2888
            }
-
 
2889
        }
-
 
2890
        private void btnSer1_0_Click(object sender, RoutedEventArgs e)
-
 
2891
        {
-
 
2892
            SerChan1ScaleSlider.Value = 0;
-
 
2893
        }
-
 
2894
        private void btnSer1_127_Click(object sender, RoutedEventArgs e)
-
 
2895
        {
-
 
2896
            SerChan1ScaleSlider.Value = 127;
-
 
2897
        }
-
 
2898
        private void btnSer1_254_Click(object sender, RoutedEventArgs e)
-
 
2899
        {
-
 
2900
            SerChan1ScaleSlider.Value = 254;
-
 
2901
        }
-
 
2902
        private void btnSer1_val2_Click(object sender, RoutedEventArgs e)
-
 
2903
        {
-
 
2904
            if (textBoxSerial1_val2.Text.Length > 0)
-
 
2905
            {
-
 
2906
                SerChan1ScaleSlider.Value = Convert.ToInt16(textBoxSerial1_val2.Text);
-
 
2907
            }
-
 
2908
        }
-
 
2909
        private void btnSer1_val3_Click(object sender, RoutedEventArgs e)
-
 
2910
        {
-
 
2911
            if (textBoxSerial1_val3.Text.Length > 0)
-
 
2912
            {
-
 
2913
                SerChan1ScaleSlider.Value = Convert.ToInt16(textBoxSerial1_val3.Text);
-
 
2914
            }
-
 
2915
        }
-
 
2916
 
-
 
2917
        private void SerChan2ScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
-
 
2918
        {
-
 
2919
            if (!_init)
-
 
2920
            {
-
 
2921
                serChan[1] = (int)SerChan2ScaleSlider.Value;
-
 
2922
                _sendSerialData();
-
 
2923
            }
-
 
2924
        }
-
 
2925
        private void textBoxSerial2_TextChanged(object sender, TextChangedEventArgs e)
-
 
2926
        {
-
 
2927
            if (!_init)
-
 
2928
            {
-
 
2929
                serChanTitle[1] = textBoxSerial2.Text;
-
 
2930
            }
-
 
2931
        }
-
 
2932
        private void textBoxSerial2_val1_TextChanged(object sender, TextChangedEventArgs e)
-
 
2933
        {
-
 
2934
            if (textBoxSerial2_val1.Text.Length > 0 & !_init)
-
 
2935
            {
-
 
2936
                serChan_sub[3] = Convert.ToInt16(textBoxSerial2_val1.Text);
-
 
2937
            }
-
 
2938
        }
-
 
2939
        private void textBoxSerial2_val2_TextChanged(object sender, TextChangedEventArgs e)
-
 
2940
        {
-
 
2941
            if (textBoxSerial2_val2.Text.Length > 0 & !_init)
-
 
2942
            {
-
 
2943
                serChan_sub[4] = Convert.ToInt16(textBoxSerial2_val2.Text);
-
 
2944
            }
-
 
2945
        }
-
 
2946
        private void textBoxSerial2_val3_TextChanged(object sender, TextChangedEventArgs e)
-
 
2947
        {
-
 
2948
            if (textBoxSerial2_val3.Text.Length > 0 & !_init)
-
 
2949
            {
-
 
2950
                serChan_sub[5] = Convert.ToInt16(textBoxSerial2_val3.Text);
-
 
2951
            }
-
 
2952
        }
-
 
2953
        private void btnSer2_0_Click(object sender, RoutedEventArgs e)
-
 
2954
        {
-
 
2955
            SerChan2ScaleSlider.Value = 0;
-
 
2956
        }
-
 
2957
        private void btnSer2_127_Click(object sender, RoutedEventArgs e)
-
 
2958
        {
-
 
2959
            SerChan2ScaleSlider.Value = 127;
-
 
2960
        }
-
 
2961
        private void btnSer2_254_Click(object sender, RoutedEventArgs e)
-
 
2962
        {
-
 
2963
            SerChan2ScaleSlider.Value = 254;
-
 
2964
        }
-
 
2965
        private void btnSer2_val1_Click(object sender, RoutedEventArgs e)
-
 
2966
        {
-
 
2967
            if (textBoxSerial2_val1.Text.Length > 0)
-
 
2968
            {
-
 
2969
                SerChan2ScaleSlider.Value = Convert.ToInt16(textBoxSerial2_val1.Text);
-
 
2970
            }
-
 
2971
        }
-
 
2972
        private void btnSer2_val2_Click(object sender, RoutedEventArgs e)
-
 
2973
        {
-
 
2974
            if (textBoxSerial2_val2.Text.Length > 0)
-
 
2975
            {
-
 
2976
                SerChan2ScaleSlider.Value = Convert.ToInt16(textBoxSerial2_val2.Text);
-
 
2977
            }
-
 
2978
        }
-
 
2979
        private void btnSer2_val3_Click(object sender, RoutedEventArgs e)
-
 
2980
        {
-
 
2981
            if (textBoxSerial2_val3.Text.Length > 0)
-
 
2982
            {
-
 
2983
                SerChan2ScaleSlider.Value = Convert.ToInt16(textBoxSerial2_val3.Text);
-
 
2984
            }
-
 
2985
        }
-
 
2986
        /// <summary>
-
 
2987
        /// checks the input of a textbox
-
 
2988
        /// for valid data
-
 
2989
        /// in this case values 0-254
-
 
2990
        /// </summary>
-
 
2991
        /// <param name="sender"></param>
-
 
2992
        /// <param name="e"></param>
-
 
2993
        private void textBox_serial_KeyPress(object sender, KeyEventArgs e)
-
 
2994
        {
-
 
2995
            if ("1234567890,\b".IndexOf(e.Key.ToString()) < 0) //general check for valid chars(0-9) and backspace (\b)
-
 
2996
                e.Handled = true;
-
 
2997
            else
-
 
2998
            if ("\b".IndexOf(e.Key.ToString()) < 0)
-
 
2999
                if (Convert.ToInt16(((TextBox)sender).Text + e.Key) > 254) //if valid and not backspace, check for upper limit of the resulting number
-
 
3000
                    e.Handled = true;
-
 
3001
                else
-
 
3002
                {
-
 
3003
                    int i = -1;
-
 
3004
                    switch (((TextBox)sender).Name)
-
 
3005
                    {
-
 
3006
                        case "textBoxSerial1_val1":
-
 
3007
                            i = 0;
-
 
3008
                            break;
-
 
3009
                        case "textBoxSerial1_val2":
-
 
3010
                            i = 1;
-
 
3011
                            break;
-
 
3012
                        case "textBoxSerial1_val3":
-
 
3013
                            i = 2;
-
 
3014
                            break;
-
 
3015
                        case "textBoxSerial2_val1":
-
 
3016
                            i = 3;
-
 
3017
                            break;
-
 
3018
                        case "textBoxSerial2_val2":
-
 
3019
                            i = 4;
-
 
3020
                            break;
-
 
3021
                        case "textBoxSerial2_val3":
-
 
3022
                            i = 5;
-
 
3023
                            break;
-
 
3024
                        case "textBoxSerial3_val1":
-
 
3025
                            i = 6;
-
 
3026
                            break;
-
 
3027
                        case "textBoxSerial3_val2":
-
 
3028
                            i = 7;
-
 
3029
                            break;
-
 
3030
                        case "textBoxSerial3_val3":
-
 
3031
                            i = 8;
-
 
3032
                            break;
-
 
3033
                        case "textBoxSerial4_val1":
-
 
3034
                            i = 9;
-
 
3035
                            break;
-
 
3036
                        case "textBoxSerial4_val2":
-
 
3037
                            i = 10;
-
 
3038
                            break;
-
 
3039
                        case "textBoxSerial4_val3":
-
 
3040
                            i = 11;
-
 
3041
                            break;
-
 
3042
                    }
-
 
3043
                    if (i > -1)
-
 
3044
                        serChan_sub[i] = Convert.ToInt16(((TextBox)sender).Text + e.Key.ToString());
-
 
3045
                }
Line -... Line 3046...
-
 
3046
        }
2768
        }
3047
 
2769
 
3048
        #endregion serial channels
2770
        #region WP
3049
        #region WP
2771
        void _readWPLFile()
3050
        void _readWPLFile()
2772
        {
3051
        {