Example #1
0
        void item_IsSelectedChanged(object sender, EventArgs e)
        {
            if (_IsSelfChanged)
            {
                return;
            }

            _IsSelfChanged = true;

            var item = sender as UISelectSettingItem;

            if (item.IsSelected && _IsMutiSelect == false)
            {
                foreach (var s in ListItems.Where(w => w.IsSelected && (w != item)))
                {
                    s.IsSelected = false;
                }
            }
            var texts = GetTextItems().ToList();

            if (item.IsSelected)
            {
                if (texts.FirstOrDefault(s => s.Equals(item.SettingItem.Name, StringComparison.OrdinalIgnoreCase)) == null)
                {
                    texts.Add(item.SettingItem.Name);
                }
            }
            else
            {
                var sitem = texts.FirstOrDefault(s => s.Equals(item.SettingItem.Name, StringComparison.OrdinalIgnoreCase));
                if (sitem != null)
                {
                    texts.Remove(sitem);
                }
            }
            StringBuilder sb = new StringBuilder();

            texts.ForEachWithFirst((s) =>
            {
                sb.Append(s);
            },
                                   (s) =>
            {
                sb.AppendFormat("{0}{1}", SplitSeperate, s);
            });
            comboBox.Text  = sb.ToString();
            _IsSelfChanged = false;
        }