예제 #1
0
        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!");
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
        public VocabularyEditorWindow(DictionaryEditorWindow parentWindow, Vocabulary existingData)
        {
            InitializeComponent();
            Parent = parentWindow;
            Data   = existingData;

            UpdateViews();
        }
예제 #4
0
        private void CreateDictionaryButton_Click(object sender, EventArgs e)
        {
            DictionaryEditorWindow dictionaryEditorWindow = new DictionaryEditorWindow(this);

            dictionaryEditorWindow.Show();
            DictionaryEditors.Add(dictionaryEditorWindow);
            dictionaryEditorWindow.OnCompleteEvent += OnDictionaryEndEdit;
        }
예제 #5
0
        public VocabularyEditorWindow(DictionaryEditorWindow parentWindow)
        {
            InitializeComponent();
            Parent    = parentWindow;
            Data      = new Vocabulary();
            Data.GUID = EditorUtils.ByteArrayToHexString(EditorUtils.GenerateNextGUID());
            modified  = true;

            UpdateViews();
        }