Ejemplo n.º 1
0
        private void CreateConfigurationParametersGrid()
        {
            ProblemConfigurationParametersCollectionViewModel contraintsCollection = ProblemConfigurationParametersDataProvider.GetConfigurationParameters();
            int column = -3;
            int row    = 0;

            foreach (ProblemConfigurationParameterViewModel constraint in contraintsCollection)
            {
                if (row % 4 == 0)
                {
                    row     = 0;
                    column += 3;
                }

                Label contraintLabel = new Label();
                contraintLabel.Content = constraint.Name;
                Grid.SetRow(contraintLabel, row);
                Grid.SetColumn(contraintLabel, column);
                ConfigurationParametersGrid.Children.Add(contraintLabel);

                CheckBox contraintCheckBox = new CheckBox();
                contraintCheckBox.VerticalAlignment   = VerticalAlignment.Center;
                contraintCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
                Binding binding = new Binding("BoolValue");
                binding.Source = constraint;
                contraintCheckBox.SetBinding(CheckBox.IsCheckedProperty, binding);
                Grid.SetRow(contraintCheckBox, row);
                Grid.SetColumn(contraintCheckBox, column + 1);
                ConfigurationParametersGrid.Children.Add(contraintCheckBox);
                row++;
            }
        }
Ejemplo n.º 2
0
        public static ProblemConfigurationParametersCollectionViewModel GetConfigurationParameters()
        {
            ProblemConfigurationParametersCollectionViewModel UIObjects = new ProblemConfigurationParametersCollectionViewModel();

            List <ProblemConfigurationParameter> dataObjects = ProblemConfigurationParametersDataAccess.GetObjects(2);

            foreach (ProblemConfigurationParameter dataObject in dataObjects)
            {
                UIObjects.Add(new ProblemConfigurationParameterViewModel(dataObject));
            }

            return(UIObjects);
        }
Ejemplo n.º 3
0
        private void CreateConstraintsGrid()
        {
            ProblemConfigurationParametersCollectionViewModel contraintsCollection = ProblemConfigurationParametersDataProvider.GetConstraints();
            int  column   = -2;
            int  row      = 0;
            bool addedRow = true;

            foreach (ProblemConfigurationParameterViewModel constraint in contraintsCollection)
            {
                if (row % 6 == 0 && addedRow)
                {
                    row     = 0;
                    column += 2;
                }

                Label contraintLabel = new Label();
                contraintLabel.Content = constraint.Name;

                Binding binding;
                if (constraint.DBName.Equals("DEMANDA") || constraint.DBName.Equals("FCVARIABLE") || constraint.DBName.Equals("FTVARIABLE"))
                {
                    addedRow = false;
                    int      tmpRow             = 0;
                    ComboBox constraintComboBox = new ComboBox();
                    binding        = new Binding("Value");
                    binding.Source = constraint;
                    constraintComboBox.SetBinding(ComboBox.SelectedValueProperty, binding);

                    switch (constraint.DBName)
                    {
                    case "DEMANDA":
                        tmpRow         = 0;
                        binding        = new Binding("LoadTypes");
                        binding.Source = contraintsCollection;
                        constraintComboBox.SetBinding(ComboBox.ItemsSourceProperty, binding);
                        constraintComboBox.ToolTip = MessageUtil.FormatMessage("TOOLTIP.LoadRestrictionTypes");
                        break;

                    case "FCVARIABLE":
                        tmpRow         = 1;
                        binding        = new Binding("ConversionFactorTypes");
                        binding.Source = contraintsCollection;
                        constraintComboBox.SetBinding(ComboBox.ItemsSourceProperty, binding);
                        constraintComboBox.ToolTip = MessageUtil.FormatMessage("TOOLTIP.ConversionFactorRestrictionTypes");
                        break;

                    case "FTVARIABLE":
                        tmpRow         = 2;
                        binding        = new Binding("ConsumptionFactorTypes");
                        binding.Source = contraintsCollection;
                        constraintComboBox.SetBinding(ComboBox.ItemsSourceProperty, binding);
                        constraintComboBox.ToolTip = MessageUtil.FormatMessage("TOOLTIP.ConsumptionFactorRestrictionTypes");
                        break;
                    }

                    Grid.SetRow(contraintLabel, tmpRow);
                    Grid.SetColumn(contraintLabel, 4);
                    ConstraintsGrid.Children.Add(contraintLabel);

                    Grid.SetRow(constraintComboBox, tmpRow);
                    Grid.SetColumn(constraintComboBox, 5);
                    ConstraintsGrid.Children.Add(constraintComboBox);
                }
                else
                {
                    addedRow = true;

                    if (((row == 0) || (row == 1) || (row == 2)) & ((column == 4) || (column == 5)))
                    {
                        row = row + 3; column = column = column + 2;
                    }

                    if (column >= 6)
                    {
                        column = 4;
                    }

                    Grid.SetRow(contraintLabel, row);
                    Grid.SetColumn(contraintLabel, column);
                    ConstraintsGrid.Children.Add(contraintLabel);

                    CheckBox contraintCheckBox = new CheckBox();
                    contraintCheckBox.VerticalAlignment   = VerticalAlignment.Center;
                    contraintCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
                    binding        = new Binding("BoolValue");
                    binding.Source = constraint;
                    contraintCheckBox.SetBinding(CheckBox.IsCheckedProperty, binding);
                    Grid.SetRow(contraintCheckBox, row);
                    Grid.SetColumn(contraintCheckBox, column + 1);
                    ConstraintsGrid.Children.Add(contraintCheckBox);
                    row++;
                }
            }
        }