Esempio n. 1
0
        bool UpdateEntry(Entry entry, bool checkForTheSameEng = true)
        {
            if (checkForTheSameEng && m_previewNewEntry.HasEntryWithEnglishWord(textBoxEng.Text))
            {
                MessageBox.Show("The word \"" + textBoxEng.Text + "\" already used. To modify it you must edit other entry", "Same English word", MessageBoxButton.OK, MessageBoxImage.Stop);
                return false;
            }

            entry.Eng = textBoxEng.Text;

            //remove all old translation from entry
            while (entry.EntryTranslations.Count > 0)
            {
                DictionaryEntities.Singleton.EntryTranslations.DeleteObject(entry.EntryTranslations.Last());
            }
            //and populate with new translations
            foreach (var translation in m_translations)
            {
                if (translation.Text == null || translation.Text.Length == 0)
                    continue;

                EntryTranslation entryTranslation = new EntryTranslation();
                entryTranslation.Entry = entry;
                entryTranslation.Rus = translation.Text;

                entry.EntryTranslations.Add(entryTranslation);
            }

            return true;
        }
Esempio n. 2
0
        void Add()
        {
            bool needReset = true;

            if (m_entry == null)
            {
                needReset = CreateNewEntry();
            }
            else
            {
                if (m_entry.Eng != textBoxEng.Text)
                {
                    var window = new CreateNewOrEditOldEntryWindow();
                    window.ShowDialog();

                    switch (window.Result)
                    {
                        case CreateNewOrEditOldEntryWindow.EResult.Create: needReset = CreateNewEntry(); break;
                        case CreateNewOrEditOldEntryWindow.EResult.Overwrite: needReset = UpdateEntry(m_entry); break;
                        case CreateNewOrEditOldEntryWindow.EResult.Cancel: return;
                    }
                }
                else
                {
                    needReset = UpdateEntry(m_entry, false);
                }
            }

            if (needReset)
            {
                m_entry = null;
                textBoxEng.Text = "";
                textBoxEng.Focus();
                m_translations.Clear();
            }
        }
Esempio n. 3
0
        bool CreateNewEntry()
        {
            Entry entry = new Entry();

            if (!UpdateEntry(entry))
                return false;

            entry.Group = m_currentGroup;

            if (AddNewEntry != null)
                AddNewEntry(entry);

            return true;
        }
Esempio n. 4
0
        void OpenAddNewEntryWindow(Entry entry)
        {
            if (m_addNewEntryWindow != null)
            {
                if (entry != null)
                    m_addNewEntryWindow.Entry = entry;

                //restore window
                m_addNewEntryWindow.WindowState = WindowState.Normal;
                m_addNewEntryWindow.Activate();
                return;
            }

            //open window
            m_addNewEntryWindow = new AddNewEntryWindow(m_currentGroup, this);
            m_addNewEntryWindow.AddNewEntry += this.OnAddNewEntry;
            m_addNewEntryWindow.Closed += (unused1, unused2) =>
            {
                dataGridGroups.IsEnabled = true;
                dataGridGroups.SelectedItem = m_currentGroup;

                m_addNewEntryWindow = null;
            };
            if (entry != null)
                m_addNewEntryWindow.Entry = entry;
            m_addNewEntryWindow.Show();

            dataGridGroups.IsEnabled = false;
        }
Esempio n. 5
0
        void OnAddNewEntry(Entry entry)
        {
            DictionaryEntities.Singleton.Entries.AddObject(entry);

            EntryItem entryItem = new EntryItem();
            entryItem.Entry = entry;
            m_entryItems.Add(entryItem);
        }
Esempio n. 6
0
 /// <summary>
 /// Create a new Entry object.
 /// </summary>
 /// <param name="eng">Initial value of the Eng property.</param>
 /// <param name="groupId">Initial value of the GroupId property.</param>
 /// <param name="timeStamp">Initial value of the TimeStamp property.</param>
 /// <param name="id">Initial value of the Id property.</param>
 public static Entry CreateEntry(global::System.String eng, global::System.Guid groupId, global::System.DateTime timeStamp, global::System.Guid id)
 {
     Entry entry = new Entry();
     entry.Eng = eng;
     entry.GroupId = groupId;
     entry.TimeStamp = timeStamp;
     entry.Id = id;
     return entry;
 }
Esempio n. 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Entries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEntries(Entry entry)
 {
     base.AddObject("Entries", entry);
 }