Exemplo n.º 1
0
        private void GenerateInputfileControl(Field field)
        {
            TextBox control = new TextBox();
            Button  btn     = new Button {
                Content = "Выбрать файл", Width = 100
            };

            btn.Click += (o, e) =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
                };
                bool?showDialog = openFileDialog.ShowDialog();
                if (showDialog == true)
                {
                    control.Text = openFileDialog.FileName.CheckCurrentPath();
                }
            };

            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            control.AddAnimation();
            MainGrid.Children.Add(control);

            Grid.SetColumn(btn, 2);
            Grid.SetRow(btn, field.Order - 1);
            btn.AddAnimation();
            MainGrid.Children.Add(btn);
        }
Exemplo n.º 2
0
        private void GenerateOutputFileControl(Field field)
        {
            TextBox control = new TextBox();
            Button  btn     = new Button {
                Content = "Выбрать файл", Width = 100
            };

            btn.Click += (o, e) =>
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog
                {
                    Title            = "Выберете файл для сохранения",
                    Filter           = "Все файлы|*.*",
                    OverwritePrompt  = false,
                    InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
                };
                bool?showDialog = saveFileDialog.ShowDialog();
                if (showDialog == true)
                {
                    control.Text = saveFileDialog.FileName.CheckCurrentPath();
                }
            };

            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            control.AddAnimation();
            MainGrid.Children.Add(control);

            Grid.SetColumn(btn, 2);
            Grid.SetRow(btn, field.Order - 1);
            btn.AddAnimation();
            MainGrid.Children.Add(btn);
        }
Exemplo n.º 3
0
        private void GenerateComboBoxcontrol(Field field)
        {
            TextBox control = new TextBox {
                Width = 0
            };
            ComboBox combobox = new ComboBox
            {
                SelectedValuePath = "Key",
                DisplayMemberPath = "Value",
                ItemsSource       = field.DropDownItems,
                SelectedIndex     = 0
            };

            combobox.SelectionChanged += (o, e) =>
            {
                control.Text = ((ComboBox)o).SelectedValue.ToString();
            };

            Grid.SetColumn(combobox, 1);
            Grid.SetRow(combobox, field.Order - 1);
            Grid.SetColumnSpan(combobox, 2);
            combobox.AddAnimation();
            MainGrid.Children.Add(combobox);

            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            control.AddAnimation();
            MainGrid.Children.Add(control);
        }
Exemplo n.º 4
0
        private void GenerateTextControl(Field field)
        {
            TextBox control = new TextBox();

            control.AddAnimation();
            Grid.SetColumnSpan(control, 2);
            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            MainGrid.Children.Add(control);
        }
Exemplo n.º 5
0
        private void GenerateNumberControl(Field field)
        {
            TextBox control = new TextBox();

            control.AddAnimation();
            control.TextChanged += (sender, e) =>
            {
                Regex reg = new Regex("[^0-9.,]");
                ((TextBox)sender).Text = reg.Replace(((TextBox)sender).Text, "");
            };
            Grid.SetColumnSpan(control, 2);
            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            MainGrid.Children.Add(control);
        }
Exemplo n.º 6
0
        private void GenerateMultipseSelectFileControl(Field field)
        {
            TextBox control = new TextBox {
                Width = 0
            };
            Button button = new Button {
                Content = "Выбрать файлы"
            };

            button.Click += (sender, e) =>
            {
                OpenFileDialog dialog = new OpenFileDialog
                {
                    Multiselect      = true,
                    InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
                };
                bool?showDialog = dialog.ShowDialog();
                if (showDialog != true)
                {
                    return;
                }
                control.Text             = string.Empty;
                ((Button)sender).ToolTip = string.Empty;
                dialog.FileNames.ToList().ForEach(a => control.Text += a.CheckCurrentPath() + "||y||");
                control.Text = control.Text.Remove(control.Text.Length - 4, 3) + "||n";
                dialog.SafeFileNames.ToList().ForEach(a => ((Button)sender).ToolTip += a + "\n");
            };

            Grid.SetRow(button, field.Order - 1);
            Grid.SetColumn(button, 1);
            Grid.SetColumnSpan(button, 2);
            button.AddAnimation();
            MainGrid.Children.Add(button);

            Grid.SetColumn(control, 1);
            Grid.SetRow(control, field.Order - 1);
            control.AddAnimation();
            MainGrid.Children.Add(control);
        }