/// <summary>
 /// Adds the variable.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public void AddVariable(FuzzyVariableModel variable)
 {
     if (!this.FuzzyVariables.Contains(variable))
     {
         this.FuzzyVariables.Add(variable);
     }
 }
 /// <summary>
 /// Called when [variable removed]. Removes from rules variable.
 /// </summary>
 /// <param name="fuzzyVariable">The fuzzy variable.</param>
 private void RemoveVariableFromRules(FuzzyVariableModel fuzzyVariable)
 {
     foreach (var rule in this.RuleBlocks.Select(rb => rb.Rules.Rules))
     {
         rule.Remove(fuzzyVariable.Name);
     }
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FuzzyVariableWizard"/> class.
        /// </summary>
        /// <param name="fuzzyVariable">The fuzzy variable.</param>
        public FuzzyVariableWizardDialog(FuzzyVariableModel fuzzyVariable)
        {
            InitializeComponent();

            // copy variable
            this.oldFuzzyVariable = fuzzyVariable;
            this.newFuzzyVariable = new FuzzyVariableModel(
                this.oldFuzzyVariable.Name,
                this.oldFuzzyVariable.Type,
                this.oldFuzzyVariable.Terms.ToList(),
                this.oldFuzzyVariable.Comment);

            // Update all fields in dialog according to old Fuzzy Variable.
            this.UpdateListBox();
            foreach (var term in this.newFuzzyVariable.Terms)
            {
                this.UpdateChart(term);
            }

            this.textBoxVariableName.Text    = this.newFuzzyVariable.Name;
            this.textBoxVariableComment.Text = this.newFuzzyVariable.Comment;

            if (this.newFuzzyVariable.Type == VariableType.Input)
            {
                this.radioButtonInputType.Checked = true;
            }
            else if (this.newFuzzyVariable.Type == VariableType.Intermediate)
            {
                this.radioButtonIntermediateType.Checked = true;
            }
            else if (this.newFuzzyVariable.Type == VariableType.Output)
            {
                this.radioButtonOutputType.Checked = true;
            }
        }
        /// <summary>
        /// Opens the fuzzy variable wizard dialog.
        /// </summary>
        /// <param name="variable">The variable that need to update.</param>
        private void OpenFuzzyVariableWizardDialog(FuzzyVariableModel variable = null)
        {
            FuzzyVariableWizardDialog variableDialog = null;

            if (variable == null)   // open to create
            {
                variableDialog = new FuzzyVariableWizardDialog();
            }
            else // open to edit
            {
                variableDialog = new FuzzyVariableWizardDialog(variable);
            }
            variableDialog.Owner = this;
            variableDialog.ShowDialog();
        }
        /// <summary>
        /// Sets the updated variable to collection.
        /// </summary>
        /// <param name="variable">The variable to update.</param>
        /// <param name="oldName">Old name of the variable</param>
        /// <param name="oldType">Type old variable.</param>
        public void SetVariable(FuzzyVariableModel variable, string oldName, VariableType oldType)
        {
            if (this.FuzzyVariables.Contains(variable))
            {
                var index = this.FuzzyVariables.IndexOf(variable);
                this.FuzzyVariables[index] = variable;

                // TODO: move this block to changed_collection event
                var labelToUpdate = this.Labels.Where(lbl => (lbl as Label).Text.Equals(oldName)).FirstOrDefault();
                labelToUpdate.Text = variable.Name;

                this.RemoveOldVariableFromTreeView(oldType, oldName);
                this.AddNewVariableToTreeView(variable);
            }
        }
Exemple #6
0
        private void OnFuzzyVariableAdd(FuzzyVariableModel newFuzzyVariable)
        {
            if (FuzzyVariables == null)
            {
                FuzzyVariables = new ObservableCollection <FuzzyVariableModel>();
            }

            if (!FuzzyVariables.Contains(newFuzzyVariable))
            {
                FuzzyVariables.Add(newFuzzyVariable);
                Console.WriteLine("added");
            }

            foreach (var item in _fuzzyVariables)
            {
                Console.WriteLine(item.Name);
            }
            Console.WriteLine();
        }
 /// <summary>
 /// Add node with variable to tree view.
 /// </summary>
 /// <param name="type">The type of variable and node name.</param>
 /// <param name="name">The name of variable.</param>
 private void AddNewVariableToTreeView(FuzzyVariableModel variable)
 {
     this.treeView1.Nodes["Variables"].Nodes[variable.Type.ToString()].Nodes.Add(variable.Name);
 }
 /// <summary>
 /// Moves the fuzzy variable between two collections.
 /// </summary>
 /// <param name="variable">The variable to move.</param>
 /// <param name="collectionFrom">The collection from which move.</param>
 /// <param name="collectionTo">The collection to which move.</param>
 private void MoveFuzzyVariableBetweenCollections(FuzzyVariableModel variable, ObservableCollection <FuzzyVariableModel> collectionFrom,
                                                  ObservableCollection <FuzzyVariableModel> collectionTo)
 {
     collectionFrom.Remove(variable);
     collectionTo.Add(variable);
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FuzzyVariableWizard"/> class.
 /// </summary>
 public FuzzyVariableWizardDialog()
 {
     InitializeComponent();
     this.chartTerms.Series.Clear(); this.newFuzzyVariable = new FuzzyVariableModel();
 }