private void L_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox lb = sender as ListBox; if (lb.SelectedIndex < 0) { return; } fillColors(); if (!inclusive) { Nscbs.Clear(); } foreach (ListBoxItem item in e.AddedItems) { TextBlock tb = item.Content as TextBlock; if (tb != null) { if (tb.Text.Contains("全て")) { ClearList(); return; } foreach (ListBoxItem ritem in R.Items) { if (ritem == null) { continue; } UniformGrid ug = ritem.Content as UniformGrid; TextBlock yomi = ug.Children[1] as TextBlock; if (yomi.Text.StartsWith(tb.Text)) { NamedSolidColorBrush nscb = new NamedSolidColorBrush(ritem); if (!Nscbs.Contains(nscb)) { Nscbs.Add(nscb); } } } } } R.Items.Clear(); foreach (NamedSolidColorBrush nscb in Nscbs) { R.Items.Add(SetListBoxItem(nscb)); } updateTitle(); e.Handled = true; }
private void fillColors() { Cursor keep = this.Cursor; this.Cursor = Cursors.Wait; R.Items.Clear(); foreach (KeyValuePair <string, NamedSolidColorBrush> Core in Jc.Cores) { ListBoxItem item = new ListBoxItem(); item.HorizontalContentAlignment = HorizontalAlignment.Stretch; item.Content = plateOf(Core); item.ToolTip = swatchOf(Core); R.Items.Add(item); } updateTitle(); clea.IsEnabled = false; if (!inclusive) { Nscbs.Clear(); } this.Cursor = keep; }