/// <summary>
        /// Метод, заполняющий таблицу в соответствии с имеющимся
        /// порядком критериев
        /// </summary>
        /// <param name="rowToSelectIndex">Индекс строки, которую нужно выделить
        /// (подсветить) в таблице. Если не надо подсвечивать, то -1</param>
        private void FillDataTable(int rowToSelectIndex)
        {
            this.dgvData.SuspendLayout();

            this.dgvData.Rows.Clear();

            int critCount = this._criteriaPriorities.GetLength(0);

            for (int row = 0; row < critCount; row++)
            {
                this.dgvData.Rows.Add();
                this.dgvData.Rows[row].Cells[0].Value = (row + 1).ToString();
                this.dgvData.Rows[row].Cells[1].Value =
                    this._model.Criteria[this._criteriaPriorities[row]].Name;
                this.dgvData.Rows[row].Cells[2].Value =
                    CriterionTypeManager.GetCriterionTypeName(
                        this._model.Criteria[this._criteriaPriorities[row]].Type
                        );
            }

            this.dgvData.ClearSelection();

            if (rowToSelectIndex != -1 && rowToSelectIndex > -1 && rowToSelectIndex < critCount)
            {
                this.dgvData.Rows[rowToSelectIndex].Selected = true;
            }

            this.dgvData.ResumeLayout();
        }
        private void btnCriterionInfo_Click(object sender, EventArgs e)
        {
            string message = "Имя критерия: " +
                             this._modelCriteria[this._currentCriterionId].Name +
                             "\nИдентификатор переменной: " +
                             this._modelCriteria[this._currentCriterionId].VariableIdentifier +
                             "\nТип критерия: " +
                             CriterionTypeManager.GetCriterionTypeName(
                this._modelCriteria[this._currentCriterionId].Type) +
                             "\nВесовой коэффициент: " +
                             this._modelCriteria[this._currentCriterionId].Weight.ToString();

            MessageBoxHelper.ShowInformation(message);
        }
Esempio n. 3
0
        /// <summary>
        /// Writes model information (parameters, criteria, functional constraints)
        /// </summary>
        /// <param name="model"><see cref="Model"/> instance to be exported</param>
        /// <param name="outputFileWriter"><see cref="StreamWriter"/> to be used for the output</param>
        private void WriteModelDetails(Model model, StreamWriter outputFileWriter)
        {
            outputFileWriter.WriteLine(NamesAndFormats.Parameters);
            foreach (Parameter parameter in model.Parameters.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(parameter.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, parameter.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.ParameterFormat,
                                               parameter.Name,
                                               variableIdentifier,
                                               parameter.MinValue.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat),
                                               parameter.MaxValue.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat)));
            }

            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine(NamesAndFormats.Criteria);
            foreach (Criterion criterion in model.Criteria.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(criterion.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, criterion.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.CriterionFormat,
                                               criterion.Name,
                                               variableIdentifier,
                                               CriterionTypeManager.GetCriterionTypeName(criterion.Type)));
            }

            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine(NamesAndFormats.Constraints);
            foreach (Constraint constraint in model.FunctionalConstraints.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(constraint.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, constraint.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.ConstraintFormat,
                                               constraint.Name,
                                               variableIdentifier,
                                               RelationManager.GetRelationName(constraint.ConstraintRelation),
                                               constraint.Value.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat)));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Метод для заполнения таблицы данными о критериях
        /// </summary>
        private void UpdateCriteriaDataGrid()
        {
            this.dgvCriteria.SuspendLayout();

            this.dgvCriteria.Rows.Clear();
            foreach (KeyValuePair <TId, Criterion> criterion in this._model.Criteria)
            {
                int ind = this.dgvCriteria.Rows.Add();
                this.dgvCriteria[0, ind].Value = criterion.Value.Id;
                this.dgvCriteria[1, ind].Value = criterion.Value.Name;
                this.dgvCriteria[2, ind].Value = criterion.Value.VariableIdentifier;
                this.dgvCriteria[3, ind].Value = CriterionTypeManager.GetCriterionTypeName(criterion.Value.Type);
#if !DUMMY
                // НЕ РАБОТАЕТ В РЕЖИМЕ ДЛЯ ДУРАЧКОВ
                this.dgvCriteria[4, ind].Value = criterion.Value.Expression;
#endif
            }

            this.dgvCriteria.ResumeLayout();
        }
Esempio n. 5
0
        public CriterionForm(
            Model model,
            TId criterionId)
        {
            InitializeComponent();
            this._model       = model;
            this._criterionId = criterionId;
            this.Text         = "Редактировать критерий оптимальности";
            this.FillCriterionTypesList();
#if DUMMY
            this.DummyMode();
#endif

            // Заполним поля информацией
            Criterion criterion = this._model.Criteria[this._criterionId];
            this.txtCriterionName.Text = criterion.Name;
            this.txtCriterionVariableIdentifier.Text = criterion.VariableIdentifier;
            this.cmbCriterionType.SelectedItem       =
                CriterionTypeManager.GetCriterionTypeName(criterion.Type);
            this.txtCriterionExpression.Text = criterion.Expression;
        }