private void EditDictionaryButton_Click(object sender, EventArgs e) { if (DictionaryView.CurrentCell == null) { MessageBox.Show("Please select a cell.", "Error"); return; } string guid = (string)DictionaryView.Rows[DictionaryView.CurrentCell.RowIndex].Cells[0].Value; bool found = false; foreach (Dictionary dictionary in Data.Dictionaries) { if (dictionary.GUID.ToUpper() == guid.ToUpper()) { DictionaryEditorWindow dictionaryEditor = new DictionaryEditorWindow(this, dictionary); dictionaryEditor.OnCompleteEvent += OnDictionaryEndEdit; DictionaryEditors.Add(dictionaryEditor); dictionaryEditor.Show(); found = true; break; } } if (!found) { MessageBox.Show("Could not find dictionary with GUID: \"" + guid.ToUpper() + "\".", "Error!"); } }
private void OnDictionaryEndEdit(object sender, DictionaryEditorWindowEndEditEvent e) { DictionaryEditorWindow _sender = (DictionaryEditorWindow)sender; DictionaryEditors.Remove(_sender); bool exists = false; if (Data.Dictionaries.Length > 0) { for (int i = 0; i < Data.Dictionaries.Length; i++) { if (Data.Dictionaries[i].GUID == e.Data.GUID) { exists = true; Data.Dictionaries[i] = e.Data; } } } if (!exists) { Array.Resize <Dictionary>(ref Data.Dictionaries, Data.Dictionaries.Length + 1); Data.Dictionaries[Data.Dictionaries.Length - 1] = e.Data; } UpdateDictionaries(); modified = true; }
public VocabularyEditorWindow(DictionaryEditorWindow parentWindow, Vocabulary existingData) { InitializeComponent(); Parent = parentWindow; Data = existingData; UpdateViews(); }
private void CreateDictionaryButton_Click(object sender, EventArgs e) { DictionaryEditorWindow dictionaryEditorWindow = new DictionaryEditorWindow(this); dictionaryEditorWindow.Show(); DictionaryEditors.Add(dictionaryEditorWindow); dictionaryEditorWindow.OnCompleteEvent += OnDictionaryEndEdit; }
public VocabularyEditorWindow(DictionaryEditorWindow parentWindow) { InitializeComponent(); Parent = parentWindow; Data = new Vocabulary(); Data.GUID = EditorUtils.ByteArrayToHexString(EditorUtils.GenerateNextGUID()); modified = true; UpdateViews(); }