Пример #1
0
        private void RadioButton_Checked_14(object sender, RoutedEventArgs e)
        {
            ErrorLabel.Content = "";
            while (true)
            {
                if (TypeOfEnter == 3)
                {
                    try
                    {
                        Long = Convert.ToDouble(TextBoxLeftUp1.Text);
                        Lat  = Convert.ToDouble(TextBoxLeftDown1.Text);
                    }
                    catch (FormatException)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                        ErrorLabel.Content = rb.Message1;
                        break;
                    }
                    try
                    {
                        MinLong = Convert.ToDouble(TextBoxLeftUp2.Text);
                        MinLat  = Convert.ToDouble(TextBoxLeftDown2.Text);
                    }
                    catch (Exception)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                        ErrorLabel.Content = rb.Message1;
                        break;
                    }

                    GeoCalculator.ClassGeoCalculator.f_GM_GMS((int)Long, MinLong, ref IntLong2, ref IntMinLong2, ref SekLong);
                    GeoCalculator.ClassGeoCalculator.f_GM_GMS((int)Lat, MinLat, ref IntLat2, ref IntMinLat2, ref SekLat);

                    TextBoxLeftUp1.Text   = Convert.ToString(IntLong2);
                    TextBoxLeftDown1.Text = Convert.ToString(IntLat2);

                    TextBoxLeftUp2.Text   = Convert.ToString(IntMinLong2);
                    TextBoxLeftDown2.Text = Convert.ToString(IntMinLat2);
                    TextBoxLeftUp3.Text   = Convert.ToString(Math.Round(SekLong, 4));
                    TextBoxLeftDown3.Text = Convert.ToString(Math.Round(SekLat, 4));
                }
                else if (TypeOfEnter == 2)
                {
                    try
                    {
                        Long = Convert.ToDouble(TextBoxLeftUp1.Text);
                        Lat  = Convert.ToDouble(TextBoxLeftDown1.Text);
                    }
                    catch (FormatException)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                        ErrorLabel.Content = rb.Message1;
                        break;
                    }
                    GeoCalculator.ClassGeoCalculator.f_Grad_GMS(Long, ref IntLong2, ref IntMinLong2, ref SekLong);
                    GeoCalculator.ClassGeoCalculator.f_Grad_GMS(Lat, ref IntLat2, ref IntMinLat2, ref SekLat);

                    TextBoxLeftUp1.Text   = Convert.ToString(IntLong2);
                    TextBoxLeftDown1.Text = Convert.ToString(IntLat2);

                    TextBoxLeftUp2.Text   = Convert.ToString(IntMinLong2);
                    TextBoxLeftDown2.Text = Convert.ToString(IntMinLat2);
                    TextBoxLeftUp3.Text   = Convert.ToString(Math.Round(SekLong, 4));
                    TextBoxLeftDown3.Text = Convert.ToString(Math.Round(SekLat, 4));
                }
                break;
            }

            TypeOfEnter = 4;
            TextBoxLeftUp2.IsReadOnly   = false;
            TextBoxLeftUp3.IsReadOnly   = false;
            TextBoxLeftDown2.IsReadOnly = false;
            TextBoxLeftDown3.IsReadOnly = false;

            TextBoxLeftUp2.Visibility   = Visibility.Visible;
            TextBoxLeftUp3.Visibility   = Visibility.Visible;
            TextBoxLeftDown2.Visibility = Visibility.Visible;
            TextBoxLeftDown3.Visibility = Visibility.Visible;

            Label11.Visibility = Visibility.Visible;
            Label12.Visibility = Visibility.Visible;
            Label21.Visibility = Visibility.Visible;
            Label22.Visibility = Visibility.Visible;

            if ((bool)CB2.IsChecked)
            {
                string copyText = string.Empty;
                copyText = TextBoxLeftUp1.Text + "°" + TextBoxLeftUp2.Text + "'" + TextBoxLeftUp3 + "\"" + ", " + Environment.NewLine + TextBoxLeftDown1.Text + "°" + TextBoxLeftDown2.Text + "'" + TextBoxLeftUp3 + "\"  ";
                Clipboard.SetDataObject(copyText);
            }
        }
Пример #2
0
        private void Button_Click_Translate(object sender, RoutedEventArgs e)
        {
            ErrorLabel.Content = "";
            StructerOfData SOD = new StructerOfData();

            Counter++; SOD.Num = Counter;

            // Lat = Long = 0;
            try
            {
                Long     = Convert.ToDouble(TextBoxLeftUp1.Text);
                Lat      = Convert.ToDouble(TextBoxLeftDown1.Text);
                SOD.Lat  = TextBoxLeftUp1.Text + "°";
                SOD.Long = TextBoxLeftDown1.Text + "°";
            }
            catch (FormatException)
            {
                ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                ErrorLabel.Content = rb.Message1;
                return;
            }

            try { MinLong = Convert.ToDouble(TextBoxLeftUp2.Text); }
            catch (Exception) { MinLong = 0; }
            try { MinLat = Convert.ToDouble(TextBoxLeftDown2.Text); }
            catch (Exception) { MinLat = 0; }
            try { SekLong = Convert.ToDouble(TextBoxLeftUp3.Text); }
            catch (Exception) { SekLong = 0; }
            try { SekLat = Convert.ToDouble(TextBoxLeftDown3.Text); }
            catch (Exception) { SekLat = 0; }

            if (SystemOfCoordinate1 != 3)
            {
                switch (TypeOfEnter)
                {
                case 2: break;

                case 3:
                    SOD.Lat  = TextBoxLeftUp1.Text + "°" + TextBoxLeftUp2.Text + "'";
                    SOD.Long = TextBoxLeftDown1.Text + "°" + TextBoxLeftDown2.Text + "'";
                    GeoCalculator.ClassGeoCalculator.f_GM_Grad((int)Long, MinLong, ref Long);
                    GeoCalculator.ClassGeoCalculator.f_GM_Grad((int)Lat, MinLat, ref Lat);
                    break;

                case 4:
                    SOD.Lat  = TextBoxLeftUp1.Text + "°" + TextBoxLeftUp2.Text + "'" + TextBoxLeftUp3.Text + "\"";
                    SOD.Long = TextBoxLeftDown1.Text + "°" + TextBoxLeftDown2.Text + "'" + TextBoxLeftDown3.Text + "\"";
                    GeoCalculator.ClassGeoCalculator.f_GMS_Grad((int)Long, (int)MinLong, SekLong, ref Long);
                    GeoCalculator.ClassGeoCalculator.f_GMS_Grad((int)Lat, (int)MinLat, SekLat, ref Lat);
                    break;

                default: return;
                }
            }
            else
            {
                switch (TypeOfEnter)
                {
                case 2:
                    SOD.Lat  = TextBoxLeftUp1.Text + "м.";
                    SOD.Long = TextBoxLeftDown1.Text + "м.";
                    break;

                case 3:
                    SOD.Lat  = TextBoxLeftUp1.Text + "км.";
                    SOD.Long = TextBoxLeftDown1.Text + "км.";
                    Lat      = Lat * 1000;
                    Long     = Long * 1000;
                    break;

                default: return;
                }
            }

            if ((bool)CB1.IsChecked)
            {
                dx = 25;
                dy = -141;
                dz = -80;
            }
            try
            {
                dx = Convert.ToDouble(TextBoxDX.Text);
                dy = Convert.ToDouble(TextBoxDY.Text);
                dz = Convert.ToDouble(TextBoxDZ.Text);
            }
            catch (System.FormatException err) { ErrorLabel.Content = err.Message; }

            try
            {
                switch (SystemOfCoordinate1)
                {
                case 1:
                    switch (SystemOfCoordinate2)
                    {
                    case 2:
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        GeoCalculator.ClassGeoCalculator.f_WGS84_SK42_BL(Lat, Long, dx, dy, dz, ref Lat, ref Long);
                        break;

                    case 3:
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        GeoCalculator.ClassGeoCalculator.f_WGS84_Mercator(Lat, Long, ref Lat, ref Long);
                        break;

                    default: throw new OneTypeExeption("", SystemOfCoordinate1, SystemOfCoordinate2);
                    }
                    break;

                case 2:
                    switch (SystemOfCoordinate2)
                    {
                    case 1:
                        GeoCalculator.ClassGeoCalculator.f_SK42_WGS84_BL(Lat, Long, dx, dy, dz, ref Lat, ref Long);
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        break;

                    case 3:
                        GeoCalculator.ClassGeoCalculator.f_SK42_WGS84_BL(Lat, Long, dx, dy, dz, ref Lat, ref Long);
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        GeoCalculator.ClassGeoCalculator.f_WGS84_Mercator(Lat, Long, ref Lat, ref Long);
                        break;

                    default: throw new OneTypeExeption("", SystemOfCoordinate1, SystemOfCoordinate2);
                    }
                    break;

                case 3:
                    switch (SystemOfCoordinate2)
                    {
                    case 1:
                        GeoCalculator.ClassGeoCalculator.f_Mercator_WGS84(Lat, Long, ref Lat, ref Long);
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        break;

                    case 2:
                        GeoCalculator.ClassGeoCalculator.f_Mercator_WGS84(Lat, Long, ref Lat, ref Long);
                        SOD.MGRS = TextBoxRightDown_Copy.Text = GeoCalculator.ClassGeoCalculator.f_WGS84_MGRS(Lat, Long);
                        GeoCalculator.ClassGeoCalculator.f_WGS84_SK42_BL(Lat, Long, dx, dy, dz, ref Lat, ref Long);
                        break;

                    default: throw new OneTypeExeption("", SystemOfCoordinate1, SystemOfCoordinate2);
                    }
                    break;

                default: throw new TraslationExeption("This Translation is not possible. \n", SystemOfCoordinate1, SystemOfCoordinate2);
                }
            }
            catch (TraslationExeption error)
            {
                ErrorLabel.Content = error.Message1;
                return;
            }
            catch (OneTypeExeption error)
            {
                ErrorLabel.Content = error.Message1;
                return;
            }

            if (SystemOfCoordinate2 != 3)
            {
                switch (TypeOfDisplay)
                {
                case 2:
                    SOD.NewLong = TextBoxRightUp.Text = Convert.ToString(Long);
                    SOD.NewLat  = TextBoxRightDown.Text = Convert.ToString(Lat);
                    break;

                case 3:
                    GeoCalculator.ClassGeoCalculator.f_Grad_GM(Long, ref IntLong2, ref MinLong);
                    GeoCalculator.ClassGeoCalculator.f_Grad_GM(Lat, ref IntLat2, ref MinLat);
                    SOD.NewLong = TextBoxRightUp.Text = Convert.ToString(IntLong2) + "°" + Convert.ToString(MinLong) + "'";
                    SOD.NewLat  = TextBoxRightDown.Text = Convert.ToString(IntLat2) + "°" + Convert.ToString(MinLat) + "'";
                    break;

                case 4:
                    GeoCalculator.ClassGeoCalculator.f_Grad_GMS(Long, ref IntLong2, ref IntMinLong2, ref SekLong);
                    GeoCalculator.ClassGeoCalculator.f_Grad_GMS(Lat, ref IntLat2, ref IntMinLat2, ref SekLat);
                    SOD.NewLong = TextBoxRightUp.Text = Convert.ToString(IntLong2) + "°" + Convert.ToString(IntMinLong2) + "'" + Convert.ToString(SekLong) + "\"";
                    SOD.NewLat  = TextBoxRightDown.Text = Convert.ToString(IntLat2) + "°" + Convert.ToString(IntMinLat2) + "'" + Convert.ToString(SekLong) + "\"";
                    break;

                default:
                    return;
                }
            }
            else
            {
                switch (TypeOfDisplay)
                {
                case 2:
                    SOD.NewLong = TextBoxRightUp.Text = Convert.ToString(Long) + " м.";
                    SOD.NewLat  = TextBoxRightDown.Text = Convert.ToString(Lat) + " м.";
                    break;

                case 3:
                    Long        = Long * 0.001;
                    Lat         = Lat * 0.001;
                    SOD.NewLong = TextBoxRightUp.Text = Convert.ToString(Long) + " км.";
                    SOD.NewLat  = TextBoxRightDown.Text = Convert.ToString(Lat) + " км.";
                    break;

                case 4:
                    break;
                }
            }


            SOD.Info  = TraslationExeption.CreateMessage(SystemOfCoordinate1, SystemOfCoordinate2);
            SOD.datum = "dx=" + Convert.ToString(dx) + ", dy=" + Convert.ToString(dy) + ", dz=" + Convert.ToString(dz);
            list2.Add(SOD);
            ListV.ItemsSource = list2;

            if ((bool)CB2.IsChecked)
            {
                string copyText = string.Empty;
                copyText = TextBoxRightUp.Text + Environment.NewLine + TextBoxRightDown.Text + Environment.NewLine + TextBoxRightDown_Copy.Text;
                Clipboard.SetDataObject(copyText);
            }
            else
            {
                TextBoxRightUp.SelectionStart  = 0;
                TextBoxRightUp.SelectionLength = TextBoxRightUp.Text.Length;
                TextBoxRightUp.Focus();
            }
        }
Пример #3
0
        private void RadioButton_Checked_12(object sender, RoutedEventArgs e)
        {
            ErrorLabel.Content = "";
            while (true)
            {
                if (TypeOfEnter == 3)
                {
                    if (SystemOfCoordinate1 == 3)
                    {
                        try
                        {
                            Long = Convert.ToDouble(TextBoxLeftUp1.Text);
                            Lat  = Convert.ToDouble(TextBoxLeftDown1.Text);
                        }
                        catch (FormatException)
                        {
                            ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                            ErrorLabel.Content = rb.Message1; break;
                        }
                        Long = Long * 1000;
                        Lat  = Lat * 1000;
                        TextBoxLeftUp1.Text   = Convert.ToString(Long);
                        TextBoxLeftDown1.Text = Convert.ToString(Lat);
                    }
                    else
                    {
                        try
                        {
                            Long = Convert.ToDouble(TextBoxLeftUp1.Text);
                            Lat  = Convert.ToDouble(TextBoxLeftDown1.Text);
                        }
                        catch (FormatException)
                        {
                            ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                            ErrorLabel.Content = rb.Message1; break;
                        }
                        try
                        {
                            MinLong = Convert.ToDouble(TextBoxLeftUp2.Text);
                            MinLat  = Convert.ToDouble(TextBoxLeftDown2.Text);
                        }
                        catch (Exception)
                        {
                            ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                            ErrorLabel.Content = rb.Message1; break;
                        }

                        GeoCalculator.ClassGeoCalculator.f_GM_Grad((int)Long, MinLong, ref Long);
                        GeoCalculator.ClassGeoCalculator.f_GM_Grad((int)Lat, MinLat, ref Lat);
                        TextBoxLeftUp1.Text   = Convert.ToString(Long);
                        TextBoxLeftDown1.Text = Convert.ToString(Lat);
                    }
                }
                else if (TypeOfEnter == 4)
                {
                    try
                    {
                        Long = Convert.ToDouble(TextBoxLeftUp1.Text);
                        Lat  = Convert.ToDouble(TextBoxLeftDown1.Text);
                    }
                    catch (FormatException)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp1.Text, TextBoxLeftDown1.Text);
                        ErrorLabel.Content = rb.Message1; break;
                    }
                    try
                    {
                        MinLong = Convert.ToDouble(TextBoxLeftUp2.Text);
                        MinLat  = Convert.ToDouble(TextBoxLeftDown2.Text);
                    }
                    catch (Exception)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp2.Text, TextBoxLeftDown2.Text);
                        ErrorLabel.Content = rb.Message1; break;
                    }
                    try
                    {
                        SekLong = Convert.ToDouble(TextBoxLeftUp3.Text);
                        SekLat  = Convert.ToDouble(TextBoxLeftDown3.Text);
                    }
                    catch (Exception)
                    {
                        ExeptionRB rb = new ExeptionRB(TextBoxLeftUp3.Text, TextBoxLeftDown3.Text);
                        ErrorLabel.Content = rb.Message1; break;
                    }

                    GeoCalculator.ClassGeoCalculator.f_GMS_Grad((int)Long, (int)MinLong, SekLong, ref Long);
                    GeoCalculator.ClassGeoCalculator.f_GMS_Grad((int)Lat, (int)MinLat, SekLat, ref Lat);

                    TextBoxLeftUp1.Text   = Convert.ToString(Long);
                    TextBoxLeftDown1.Text = Convert.ToString(Lat);
                }
                break;
            }

            TypeOfEnter           = 2;
            TextBoxLeftUp2.Text   = "";
            TextBoxLeftUp3.Text   = "";
            TextBoxLeftDown2.Text = "";
            TextBoxLeftDown3.Text = "";

            TextBoxLeftUp2.IsReadOnly   = true;
            TextBoxLeftUp3.IsReadOnly   = true;
            TextBoxLeftDown2.IsReadOnly = true;
            TextBoxLeftDown3.IsReadOnly = true;

            TextBoxLeftUp2.Visibility   = Visibility.Collapsed;
            TextBoxLeftUp3.Visibility   = Visibility.Collapsed;
            TextBoxLeftDown2.Visibility = Visibility.Collapsed;
            TextBoxLeftDown3.Visibility = Visibility.Collapsed;

            Label11.Visibility = Visibility.Collapsed;
            Label12.Visibility = Visibility.Collapsed;
            Label21.Visibility = Visibility.Collapsed;
            Label22.Visibility = Visibility.Collapsed;

            if (SystemOfCoordinate1 == 3)
            {
                Label1.Content = "м.";
                Label2.Content = "м.";
            }

            if ((bool)CB2.IsChecked)
            {
                string copyText = string.Empty;
                copyText = TextBoxLeftUp1.Text + "°" + ", " + Environment.NewLine + TextBoxLeftDown1.Text + "°   ";
                Clipboard.SetDataObject(copyText);
            }
        }