Exemple #1
0
        private void cmbMethodNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            stckControls.Children.Clear();
            stckLabel.Children.Clear();

            if (cmbMethodNames.SelectedIndex != 0)
            {
                ParameterInfo[] parameters = ReadWebService.GetWebServiceMethodsParameters(txtServer.Text, cmbMethodNames.SelectedItem.ToString());

                if (parameters.Length > 0)
                {
                    methodWithParameter = true;

                    for (int i = 0; i < parameters.Length; i++)
                    {
                        Label lbl = new Label();
                        lbl.Height  = 25;
                        lbl.Margin  = new Thickness(3);
                        lbl.Content = parameters[i].Name + ":";
                        string bas = lbl.Content.ToString().ToCharArray()[0].ToString().ToUpper();
                        for (int j = 1; j < lbl.Content.ToString().ToCharArray().Length; j++)
                        {
                            bas += lbl.Content.ToString().ToCharArray()[j].ToString();
                        }

                        lbl.Content = bas;

                        string type = parameters[i].ParameterType.ToString();

                        if (type == "System.Int32")
                        {
                            TextBox txt = new TextBox();
                            txt.Width             = 300;
                            txt.Height            = 25;
                            txt.Margin            = new Thickness(3);
                            txt.PreviewTextInput += NumberValidationTextBox;
                            txt.Tag = "Int";
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.Boolean")
                        {
                            ComboBox cmb = new ComboBox();
                            cmb.Items.Add("True");
                            cmb.Items.Add("False");
                            cmb.SelectedIndex = 0;
                            cmb.Tag           = "Bool";
                            cmb.Height        = 25;
                            cmb.Margin        = new Thickness(3);
                            stckControls.Children.Add(cmb);
                        }
                        else if (type == "System.String")
                        {
                            TextBox txt = new TextBox();
                            txt.Width  = 300;
                            txt.Tag    = "Text";
                            txt.Height = 25;
                            txt.Margin = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.Double")
                        {
                            TextBox txt = new TextBox();
                            txt.Width             = 300;
                            txt.PreviewTextInput += NumberValidationTextBox;
                            txt.Tag    = "Double";
                            txt.Height = 25;
                            txt.Margin = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.Int16")
                        {
                            TextBox txt = new TextBox();
                            txt.Width             = 300;
                            txt.PreviewTextInput += NumberValidationTextBox;
                            txt.Tag    = "Int16";
                            txt.Height = 25;
                            txt.Margin = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.Int64")
                        {
                            TextBox txt = new TextBox();
                            txt.Width             = 300;
                            txt.PreviewTextInput += NumberValidationTextBox;
                            txt.Tag    = "Int64";
                            txt.Height = 25;
                            txt.Margin = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.Decimal")
                        {
                            TextBox txt = new TextBox();
                            txt.Width             = 300;
                            txt.PreviewTextInput += NumberValidationTextBox;
                            txt.Tag    = "Decimal";
                            txt.Height = 25;
                            txt.Margin = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }
                        else if (type == "System.DateTime")
                        {
                            DatePicker dp = new DatePicker();

                            dp.Width  = 300;
                            dp.Tag    = "DateTime";
                            dp.Height = 25;
                            dp.Margin = new Thickness(3);
                            stckControls.Children.Add(dp);
                        }
                        else if (type == "System.Char")
                        {
                            TextBox txt = new TextBox();
                            txt.Width     = 300;
                            txt.MaxLength = 1;
                            txt.Tag       = "Char";
                            txt.Height    = 25;
                            txt.Margin    = new Thickness(3);
                            stckControls.Children.Add(txt);
                        }

                        stckLabel.Children.Add(lbl);
                    }
                }
            }
        }