private void AllCheckClick() { IsDefaultSelectAll = true; foreach (var item in ItemsSource) { ISelected selectedModel = item as ISelected; if (selectedModel == null) { continue; } if (AllChecked == true) { if (!selectedModel.IsSelected) { selectedModel.IsSelected = true; } } else { if (selectedModel.IsSelected) { selectedModel.IsSelected = false; } } } if (CheckedSelectedChanged != null) { CheckedSelectedChanged(null, new CheckSelectedEventArgs(true)); } IsDefaultSelectAll = false; }
private void GroupCheck(object obj) { if (obj is Group group) { IsDefaultSelectAll = true; if (group.Children != null) { foreach (var item in group.Children) { ISelected selectedModel = item as ISelected; if (selectedModel == null) { continue; } if (group.IsSelected == true) { if (!selectedModel.IsSelected) { selectedModel.IsSelected = true; } } else { if (selectedModel.IsSelected) { selectedModel.IsSelected = false; } } } } IsDefaultSelectAll = false; } }
public void SelectFigure() { Shape mShape; temp = null; foreach (SaveData save in saveList) { temp = CountValue(save); ISelected itemp = temp; if (itemp.isSelected(CurPointForSelect, save)) { curSelectFig = save; SetClear(false); mShape = CountValue(curSelectFig); mShape.getAtributs(Color.Blue, 4); mShape.Draw(Bmp, curSelectFig.one, curSelectFig.two); if (curSelectFig != null) { foreach (SaveData svd in saveList) { RedrawCanvas(svd); } } break; } } temp = null; }
public void z1_send_and_select_many_items_from_queued_channel() { Benchmark.Go("select on buffer of 1", (int runs) => { var data = new Channel <int>(10); ThreadPool.QueueUserWorkItem((state) => { for (int i = 0; i < runs; i++) { data.Send(i); } }); using (var select = new Channels(Op.Recv(data))) { for (int i = 0; i < runs; i++) { ISelected got = select.Select(); if (got.Index != 0) { Assert.AreEqual(0, got.Index); } var gotInt = (ISelected <int>)got; if (gotInt.Value.Value != i) { Assert.AreEqual(Maybe <int> .Some(i), got.Value); } } } }); }
public void UpdatePlayersInView(ISelected player) { if (playersInView.Contains(player) && !player.selectedObject.transform.IsInView()) { playersInView.Remove(player); } if (!playersInView.Contains(player) && player.selectedObject.transform.IsInView()) { playersInView.Add(player); } }
public void ToggleSelector(ISelected selectedPlayer) { if (selectedPlayers.Contains(selectedPlayer)) { selectedPlayers.Remove(selectedPlayer); selectedPlayer.UnSelect(); } else { selectedPlayers.Add(selectedPlayer); selectedPlayer.Select(highlightingPrefab); } SkillUIManager.Instance.UpdateSkillUI(); }
public void Add(ISelected visual) { if (null == visual) { return; } //没按control键 if (Keyboard.Modifiers != ModifierKeys.Control) { if (items.Count == 1 && items.FirstOrDefault() == visual) { return; } else { if (items.Contains(visual) && visual.IsSelected == true) { items.Remove(visual); Clear(); items.Add(visual); } else { Clear(); items.Add(visual); visual.IsSelected = true; OnCollectionChanged(NotifyCollectionChangedAction.Add, visual); } } } else { if (items.Contains(visual)) { visual.IsSelected = false; items.Remove(visual); OnCollectionChanged(NotifyCollectionChangedAction.Remove, visual); } else { visual.IsSelected = true; items.Add(visual); OnCollectionChanged(NotifyCollectionChangedAction.Add, visual); } } }
public ErrorDisplayVm( ISelected parent, IObservable <IConfigurationState> state) { DisplayedObject = parent; _state = state .ToGuiProperty(this, nameof(State), ConfigurationState.Success, deferSubscription: true); ErrorVM = new ErrorVM("Error", backAction: () => { DisplayedObject = parent; }); GoToErrorCommand = NoggogCommand.CreateFromObject( objectSource: state.Select(x => x.RunnableState), canExecute: x => x.Failed, execute: x => DisplayedObject = ErrorVM, disposable: this); parent.WhenAnyValue(x => x.IsSelected) .DistinctUntilChanged() .Where(x => x) .Subscribe(_ => { DisplayedObject = parent; }) .DisposeWith(this); state.Select(x => x.RunnableState) .Subscribe(state => { if (state.Failed) { ErrorVM.String = state.Reason; } else { ErrorVM.String = null; } }) .DisposeWith(this); }
protected override void OnSelectionChanged(SelectionChangedEventArgs e) { base.OnSelectionChanged(e); if (this.CurrentCell.Column == null) { return; } if (this.CurrentCell.Column.Header is CheckBox) { if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { foreach (var item in this.SelectedItems) { ISelected selectedModel = item as ISelected; CheckBox cb = (Mouse.DirectlyOver as UIElement) as CheckBox; if (cb == null || cb.DataContext != selectedModel) { selectedModel.IsSelected = true; } } } } }
private void SelectedModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "IsSelected") { return; } if (IsGroup) { IGroupItem selectedModel = sender as IGroupItem; if (selectedModel.IsSelected) { selectedModel.ParentGroup.IsSelected = true; if (!IsDefaultSelectAll) { foreach (var item in selectedModel.ParentGroup.Children) { IGroupItem model = item as IGroupItem; if (model == null) { continue; } if (!model.IsSelected) { model.ParentGroup.IsSelected = null; break; } } } } else { selectedModel.ParentGroup.IsSelected = false; foreach (var item in selectedModel.ParentGroup.Children) { IGroupItem model = item as IGroupItem; if (model == null) { continue; } if (model.IsSelected) { model.ParentGroup.IsSelected = null; break; } } } } else { CheckNumber = 0; foreach (var item in this.Items) { if (item is ISelected selected && selected.IsSelected) { CheckNumber++; } } ISelected selectedModel = sender as ISelected; if (selectedModel.IsSelected) { AllChecked = true; if (!IsDefaultSelectAll) { foreach (var item in ItemsSource) { ISelected model = item as ISelected; if (model == null) { continue; } if (!model.IsSelected) { AllChecked = null; break; } } } } else { AllChecked = false; foreach (var item in ItemsSource) { ISelected model = item as ISelected; if (model == null) { continue; } if (model.IsSelected) { AllChecked = null; break; } } } } }
private void OnCollectionChanged(NotifyCollectionChangedAction action, ISelected item) { var e = new NotifyCollectionChangedEventArgs(action, item); this.OnCollectionChanged(e); }
private void SelectedModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "IsSelected") { return; } if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { return; } ISelected selectedModel = sender as ISelected; if (selectedModel.IsSelected) { AllChecked = true; if (!IsDefaultSelectAll) { foreach (var item in ItemsSource) { ISelected model = item as ISelected; if (model == null) { continue; } if (!model.IsSelected) { AllChecked = null; break; } } if (CheckedSelectedChanged != null) { if (this.SelectedItem != null) { CheckedSelectedChanged(this.SelectedItem, new CheckSelectedEventArgs(IsDefaultSelectAll)); } else { CheckedSelectedChanged(sender, new CheckSelectedEventArgs(IsDefaultSelectAll)); } } } } else { AllChecked = false; foreach (var item in ItemsSource) { ISelected model = item as ISelected; if (model == null) { continue; } if (model.IsSelected) { AllChecked = null; break; } } if (!IsDefaultSelectAll) { if (CheckedSelectedChanged != null) { if (this.SelectedItem != null) { CheckedSelectedChanged(this.SelectedItem, new CheckSelectedEventArgs(IsDefaultSelectAll)); } else { CheckedSelectedChanged(sender, new CheckSelectedEventArgs(IsDefaultSelectAll)); } } } } }
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) { base.OnItemsChanged(e); if (this.Columns.Count > 0) { CheckBox cbAllCheck = null; if (this.Columns[0].Header is CheckBox) { cbAllCheck = this.Columns[0].Header as CheckBox; } else if (this.Columns[1].Header is CheckBox) { cbAllCheck = this.Columns[1].Header as CheckBox; } if (cbAllCheck != null) { BindingOperations.SetBinding(cbAllCheck, CheckBox.IsCheckedProperty, new Binding() { Path = new PropertyPath("AllChecked"), Source = this, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); cbAllCheck.Click -= CbAllCheck_Click; cbAllCheck.Click += CbAllCheck_Click; if (this.Items.Count > 0) { //AllChecked = true; bool isExistSelect = false; bool isExistNoSelect = false; foreach (var item in ItemsSource) { ISelected selectedModel = item as ISelected; if (selectedModel == null) { return; } selectedModel.PropertyChanged -= SelectedModel_PropertyChanged; selectedModel.PropertyChanged += SelectedModel_PropertyChanged; if (selectedModel.IsSelected) { isExistSelect = true; } if (!selectedModel.IsSelected) { isExistNoSelect = true; } //if (!selectedModel.IsSelected && AllChecked) //{ // AllChecked = false; //} } if (isExistSelect && !isExistNoSelect) { AllChecked = true; } else if (!isExistSelect && isExistNoSelect) { AllChecked = false; } else if (isExistSelect && isExistNoSelect) { AllChecked = null; } } else { AllChecked = false; } } } }
void filter_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "FilterChanged") { ColumnFilterControl cf = sender as ColumnFilterControl; Predicate <object> predicate = null; foreach (var filter in Filters) { if (filter.HasPredicate) { if (predicate == null) { predicate = filter.GeneratePredicate(); } else { predicate = predicate.And(filter.GeneratePredicate()); } } if (cf.FilterText == null) { if (predicate == null) { predicate = filter.GeneratePredicate(); } else { predicate = predicate.And(filter.GeneratePredicate() == null ? predicate : filter.GeneratePredicate()); } } } //bool canContinue = true; //var args = new CancelableFilterChangedEventArgs(predicate); //if (BeforeFilterChanged != null && !IsResetting) //{ // BeforeFilterChanged(this, args); // canContinue = !args.Cancel; //} //if (canContinue) //{ ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView; if (view != null && view.IsEditingItem) { view.CommitEdit(); } if (view != null && view.IsAddingNew) { view.CommitNew(); } if (CollectionView != null) { try { CollectionView.Filter = predicate; } catch { } //int count = 1; ObservableCollection <ISelected> list = new ObservableCollection <ISelected>(); foreach (var item in CollectionView) { ISelected selectedModel = item as ISelected; //selectedModel.Num= count++; list.Add(selectedModel); } //foreach (var item in list) //{ // if (item == null) // continue; // item.Num = count++; //} if (list != null && list.Count > 0) { //FilterFinshItemsSource = list; //if (AfterFilterChanged != null) // AfterFilterChanged(this, new FilterChangedEventArgs(predicate)); } } //} //else //{ // IsResetting = true; // var ctrl = sender as ColumnFilterControl; // ctrl.ResetControl(); // IsResetting = false; //} } }