Example #1
0
        public static bool SetGroupSetting(ReplaceGroupSetting group)
        {
            if (group != null)
            {
                ReplaceGroupSetting setting = GetReplaceGroupSetting(group.GroupName);
                if (setting != null)
                {
                    bool ok = ConfigSetting.GroupSettings.Remove(setting);
                    if (ok)
                    {
                        ConfigSetting.GroupSettings.Add(group);
                        return true;
                    }
                    return false;
                }
                else
                {
                    ConfigSetting.GroupSettings.Add(group);
                }
            }
            return false;

        }
Example #2
0
 private void btnRemoveGroup_Click(object sender, RoutedEventArgs e)
 {
     int count = this.listGroup.SelectedItems.Count;
     if (count > 0)
     {
         MessageBoxResult result = MessageBox.Show("是否要删除选中的项吗?", "警告", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             List<string> removeList = new List<string>();
             for (int i = 0; i < count; i++)
             {
                 var item = this.listGroup.SelectedItems[i].ToString();
                 //this.listGroup.Items.Remove(item.ToString());
                 removeList.Add(item.ToString());
                 ReplaceGroupSetting setting = new ReplaceGroupSetting();
                 var obj = ConfigHelper.ConfigSetting.GroupSettings.Where(p => p.GroupName == item.ToString()).FirstOrDefault();
                 if (obj != null)
                     ConfigHelper.ConfigSetting.GroupSettings.Remove(obj);
             }
             for (int i = 0; i < removeList.Count; i++)
             {
                 this.listGroup.Items.Remove(removeList[i]);
             }
         }
     }
 }