Exemplo n.º 1
0
        /// <summary>
        /// Triggers when the vocabulary editing window is closed. It saves all the data back into the array.
        /// </summary>
        /// <remarks>
        /// If the Vocabulary entry exists, it overrides the previous one.
        /// Otherwise, it would add a new element to the array.
        /// </remarks>
        /// <param name="sender">The vocabulary editor window that just closed.</param>
        /// <param name="e">Event data (the new vocabulary data) to replace the current data.</param>
        private void OnEndEdit(object sender, OnVocabularyEndEdit e)
        {
            VocabularyEditorWindow _sender = (VocabularyEditorWindow)sender;

            Editors.Remove(_sender);

            bool exists = false;

            if (Data.Vocabulary.Length > 0)
            {
                for (int i = 0; i < Data.Vocabulary.Length; i++)
                {
                    if (Data.Vocabulary[i].GUID == e.Data.GUID)
                    {
                        exists             = true;
                        Data.Vocabulary[i] = e.Data;
                    }
                }
            }
            if (!exists)
            {
                Array.Resize <Vocabulary>(ref Data.Vocabulary, Data.Vocabulary.Length + 1);
                Data.Vocabulary[Data.Vocabulary.Length - 1] = e.Data;
            }

            UpdateViews();

            modified = true;
        }
Exemplo n.º 2
0
        private void VocabularyAddButton_Click(object sender, EventArgs e)
        {
            VocabularyEditorWindow vocabularyEditor = new VocabularyEditorWindow(this);

            vocabularyEditor.Show();
            Editors.Add(vocabularyEditor);
            vocabularyEditor.OnEndEdit += OnEndEdit;
        }
Exemplo n.º 3
0
        private void VocabularyEditButton_Click(object sender, EventArgs e)
        {
            string guid = (string)VocabularyView.Rows[VocabularyView.CurrentCell.RowIndex].Cells[0].Value;

            bool found = false;

            foreach (Vocabulary vocabulary in Data.Vocabulary)
            {
                if (vocabulary.GUID.ToUpper() == guid.ToUpper())
                {
                    VocabularyEditorWindow intentEditor = new VocabularyEditorWindow(this, vocabulary);
                    intentEditor.OnEndEdit += OnEndEdit;
                    Editors.Add(intentEditor);
                    intentEditor.Show();
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                MessageBox.Show("Could not find vocabulary with GUID: \"" + guid.ToUpper() + "\".", "Error!");
            }
        }