Пример #1
0
 public void removePattern(Pattern pattern)
 {
     patterns.Remove(pattern);
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtName.Text != "")
            {
                if (txtProblem.Text != "")
                {
                    if (lbParrentPurpose.SelectedIndex != -1 && lbParrentScope.SelectedIndex != -1)
                    {
                        Pattern patternId = new Pattern();
                        Pattern pattern = new Pattern();
                        if (editScreen)
                        {
                            foreach (Scope scope in editPattern.getScopeList())
                            {
                                ComponentModel patternForRemove;
                                patternForRemove = scope.GetSubComponentById(editPattern.getId());
                                scope.RemoveSubComponent(patternForRemove);
                            }
                            foreach (Purpose purpose in editPattern.getPurposeList())
                            {
                                ComponentModel patternForRemove;
                                patternForRemove = purpose.GetSubComponentById(editPattern.getId());
                                purpose.RemoveSubComponent(patternForRemove);
                            }

                            editPattern.cleanPurpose();
                            editPattern.cleanScope();
                            pattern = editPattern;
                        }
                        else
                        {
                            pattern.setId(Program.database.getId());
                            Program.database.addPattern(pattern);
                        }

                        pattern.setName(txtName.Text);
                        pattern.setDescription(txtDescription.Text);
                        pattern.setProblem(txtProblem.Text);
                        pattern.setConsequence(txtConsequence.Text);
                        pattern.setSolution(txtSolution.Text);
                        patternId.setId(pattern.getId());
                        pattern.setImage(pbImage.Image);

                        foreach (KeyValue parentItemPurpose in lbParrentPurpose.SelectedItems)
                        {
                            Purpose parentPurpose = Program.database.getPurposeById(Convert.ToInt32(parentItemPurpose.key));
                            pattern.addPurpose(parentPurpose);
                            if (parentPurpose != null)
                                parentPurpose.AddSubComponent(patternId);
                        }

                        foreach (KeyValue parentItemScope in lbParrentScope.SelectedItems)
                        {
                            Scope parentScope = Program.database.getScopeById(Convert.ToInt32(parentItemScope.key));
                            pattern.addScope(parentScope);
                            if (parentScope != null)
                                parentScope.AddSubComponent(patternId);
                        }

                        this.receiver.Updater();
                        exitform = true;
                        this.Close();
                    }
                    else
                    {
                        string message = "Je moet mininaal 1 Parent Purpose en Parent Scope kiezen!";
                        MessageBox.Show(message, "Foutmelding", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    string message = "Het probleemveld mag niet leeg zijn!";
                    MessageBox.Show(message, "Foutmelding", MessageBoxButtons.OK);

                }
            }
            else
            {
                string message = "Het naamveld mag niet leeg zijn!";
                MessageBox.Show(message, "Foutmelding", MessageBoxButtons.OK);
            }
        }
Пример #3
0
 public void addPattern(Pattern pattern)
 {
     patterns.Add(pattern);
 }