Exemple #1
0
        private void DoEdit(MemoryEntry memoryEntry, bool isNew)
        {
            var dialog = new DialogEntryInfo(memoryEntry, _groups);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (isNew)
                {
                    _entries.Add(memoryEntry);
                    _entries.Sort((e1, e2) => e1.Frequency.CompareTo(e2.Frequency));
                }
                _settingsPersister.PersistStoredFrequencies(_entries);
                if (!_groups.Contains(memoryEntry.GroupName))
                {
                    _groups.Add(memoryEntry.GroupName);
                    ProcessGroups(memoryEntry.GroupName);
                }
                else
                {
                    if ((string)comboGroups.SelectedItem == AllGroups || (string)comboGroups.SelectedItem == memoryEntry.GroupName ||
                        ((string)comboGroups.SelectedItem == FavouriteGroup && memoryEntry.IsFavourite))
                    {
                        if (isNew)
                        {
                            _displayedEntries.Add(memoryEntry);
                        }
                    }
                    else
                    {
                        comboGroups.SelectedItem = memoryEntry.GroupName;
                    }
                }
            }
        }
 private void DoEdit(MemoryEntry memoryEntry, bool isNew)
 {
     var dialog = new DialogEntryInfo(memoryEntry, _groups);
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         if (isNew)
         {
             _entries.Add(memoryEntry);
             _entries.Sort((e1, e2) => e1.Frequency.CompareTo(e2.Frequency));
         }
         _settingsPersister.PersistStoredFrequencies(_entries);
         if (!_groups.Contains(memoryEntry.GroupName))
         {
             _groups.Add(memoryEntry.GroupName);
             ProcessGroups(memoryEntry.GroupName);
         }
         else
         {
             if ((string)comboGroups.SelectedItem == AllGroups || (string)comboGroups.SelectedItem == memoryEntry.GroupName ||
                 ((string)comboGroups.SelectedItem == FavouriteGroup && memoryEntry.IsFavourite))
             {
                 if (isNew)
                     _displayedEntries.Add(memoryEntry);
             }
             else
                 comboGroups.SelectedItem = memoryEntry.GroupName;
         }
     }
 }