Esempio n. 1
0
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string      patertn2 = @"\w,\w";
            string      patertn3 = @"[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*";
            string      patertn1 = @"\w+";
            XmlDocument doc      = new XmlDocument();

            doc.Load("data.xml");
            int i = ListBoxOpity.SelectedIndex;

            if (ListBoxOpity.SelectedIndex != -1)
            {
                ListBox_X.Items.Clear();
                ListBox_Y.Items.Clear();
                ListBox_dz.Items.Clear();
                ListBox_opori.Items.Clear();
                List_kars_x.Clear();
                List_kars_y.Clear();
                List_dz_foarm.Clear();


                foreach (Match match in Regex.Matches(doc.GetElementsByTagName("X")[i].InnerText, patertn2))
                {
                    ListBox_X.Items.Add(match);
                }
                foreach (Match match in Regex.Matches(doc.GetElementsByTagName("Y")[i].InnerText, patertn2))
                {
                    ListBox_Y.Items.Add(match);
                }

                foreach (Match match in Regex.Matches(doc.GetElementsByTagName("X_dz")[i].InnerText, patertn3))
                {
                    ListBox_dz.Items.Add(match);
                    List_dz_foarm.Add(double.Parse(match.Value, CultureInfo.InvariantCulture));
                }
                foreach (Match match in Regex.Matches(doc.GetElementsByTagName("Select")[i].InnerText, patertn2))
                {
                    ListBox_opori.Items.Add(match);
                }
                int s = 0;
                foreach (Match match2 in Regex.Matches(doc.GetElementsByTagName("Select")[i].InnerText, patertn1))
                {
                    s++;
                    if (s % 2 == 0)
                    {
                        List_kars_y.Add(double.Parse(match2.Value, CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        List_kars_x.Add(double.Parse(match2.Value, CultureInfo.InvariantCulture));
                    }
                }
            }
        }
Esempio n. 2
0
        public void ResOnClick(object sender, RoutedEventArgs e)
        {
            List_zakon1_L.Clear();
            Value_Centr.Clear();
            Value_Kars.Clear();


            if (CheckOpora.IsChecked == true)
            {
                for (int sw = 0; sw < Kars.MainWindow.List_kars_x.Count; sw++)
                {
                    ValuesE.Add(new ObservablePoint(Kars.MainWindow.List_kars_x[sw], Kars.MainWindow.List_kars_y[sw]));
                }
            }
            else
            {
                ValuesE.Clear();
            }



            Assembly a = Assembly.Load("dllcsharp");
            Object   o = a.CreateInstance("vscode");
            Type     t = a.GetType("vscode");

            Object[]   zakon   = new Object[1];
            MethodInfo mi      = t.GetMethod("zakon_1");
            double     zakon_1 = Convert.ToDouble(mi.Invoke(o, zakon));

            mi = t.GetMethod("zakon_2");
            double zakon_2 = Convert.ToDouble(mi.Invoke(o, zakon));

            mi = t.GetMethod("zakon_3");
            double zakon_3 = Convert.ToDouble(mi.Invoke(o, zakon));


            int i = ListViewZakon.SelectedIndex;

            if (i == 0)
            {
                Kars.Cor.Zakon = zakon_1;
                Val_Kars.MinPointShapeDiameter = zakon_1 * 40;
                Val_Kars.MaxPointShapeDiameter = zakon_1 * 40;
            }
            if (i == 1)
            {
                Val_Kars.MinPointShapeDiameter = zakon_2 * 40;
                Val_Kars.MaxPointShapeDiameter = zakon_2 * 40;

                Kars.Cor.Zakon = zakon_2;
            }
            if (i == 2)
            {
                Val_Kars.MinPointShapeDiameter = zakon_3 * 40;
                Val_Kars.MaxPointShapeDiameter = zakon_3 * 40;
                Kars.Cor.Zakon = zakon_3;
            }

            if (Kars.Cor.Zakon > 2)
            {
                for (int q = 0; List_XY.Count > q; q++)
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                    string wzx = List_XY[q];


                    string X_pas  = System.Text.RegularExpressions.Regex.Match(wzx, @"\w+").Groups[0].Value;
                    string Y_pas1 = System.Text.RegularExpressions.Regex.Match(wzx, @"[,]\w+").Groups[0].Value;
                    string Y_pas  = System.Text.RegularExpressions.Regex.Match(Y_pas1, @"\w+").Groups[0].Value;
                    double X      = Convert.ToDouble(X_pas);
                    double Y      = Convert.ToDouble(Y_pas);


                    List_kars_x.Add(X);
                    List_kars_y.Add(Y);


                    //
                    /////
                    /// ДОБАВЛЕНИЕ КРУГОВ ВОКРУГ ОПОРЫ

                    if (CheckOpora.IsChecked == true)
                    {
                        ValuesE.Add(new ObservablePoint(X, Y));
                    }
                    else
                    {
                        ValuesE.Clear();
                    }
                }
                int sd = Listbox_dz.Items.Count;


                for (int dx = 0; dx < sd; dx++)
                {
                    if (i == 0)
                    {
                        Object[] zakon_1_1 = new Object[1];
                        zakon_1_1[0] = Convert.ToDouble(Listbox_dz.Items[dx]);
                        MethodInfo mi2      = t.GetMethod("zakon_1_1");
                        double     radius_1 = Convert.ToDouble(mi2.Invoke(o, zakon_1_1));
                        List_zakon1_L.Add(radius_1);
                        //Передаем значения X
                    }
                    if (i == 1)
                    {
                        Object[] zakon_1_1 = new Object[1];
                        zakon_1_1[0] = Convert.ToDouble(Listbox_dz.Items[dx]);
                        MethodInfo mi2      = t.GetMethod("zakon_2_1");
                        double     radius_1 = Convert.ToDouble(mi2.Invoke(o, zakon_1_1));
                        List_zakon1_L.Add(radius_1);
                        //Передаем значения X
                    }
                    if (i == 2)
                    {
                        Object[] zakon_1_1 = new Object[1];
                        zakon_1_1[0] = Convert.ToDouble(Listbox_dz.Items[dx]);
                        MethodInfo mi2      = t.GetMethod("zakon_3_1");
                        double     radius_1 = Convert.ToDouble(mi2.Invoke(o, zakon_1_1));
                        List_zakon1_L.Add(radius_1);
                        //Передаем значения X
                    }
                }



                for (int xsd = 0; xsd < Listbox_dz_x.Items.Count; xsd++)
                {
                    List_lib_x.Add(Convert.ToDouble(Listbox_dz_x.Items[xsd]));
                    List_lib_y.Add(Convert.ToDouble(Listbox_dz_y.Items[xsd]));
                    List_lib_dz.Add(Convert.ToDouble(Listbox_dz.Items[xsd]));
                    Console.WriteLine(List_zakon1_L[xsd]);
                }

                Object[] centr_x_y = new Object[5];
                centr_x_y[0] = List_lib_x;
                centr_x_y[1] = List_lib_y;
                centr_x_y[2] = List_lib_dz;
                centr_x_y[3] = List_zakon1_L;
                centr_x_y[4] = i;

                MethodInfo mi1 = t.GetMethod("centr_x_y");


                string patertn = @"[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*";


                foreach (Match match in Regex.Matches(Convert.ToString(mi1.Invoke(o, centr_x_y)), patertn))
                {
                    final.Add(double.Parse(match.Value, CultureInfo.InvariantCulture));
                }
                Value_Kars.Add(new ObservablePoint(final[0], final[1]));
                Value_Centr.Add(new ObservablePoint(final[0], final[1]));


                List_kars_y.Clear();
                List_kars_x.Clear();
                List_lib_x.Clear();
                List_lib_y.Clear();
                List_lib_dz.Clear();
                List_zakon1_L.Clear();
                final.Clear();
            }
            else
            {
                MessageBox.Show("Нужно выбрать закон!");
            }
        }