private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Add: foreach (var newItem in args.NewItems) { Selectables.Add(CreateSelectable(newItem)); } break; case NotifyCollectionChangedAction.Remove: foreach (var newItem in args.NewItems) { Selectables.Remove(e => e.Item.Equals(newItem)); } break; case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Reset: Selectables.Clear(); break; default: throw new ArgumentOutOfRangeException(); } }
protected override Optional <TValue> ParseValue(SocketMessage message) { var result = Selectables.First(x => x.Key.Contains(message.Content)); return(result.Equals(Selectables.Last()) ? Optional <TValue> .Unspecified : result.Value); }
public void OnBeginDrag(PointerEventData eventData) { Debug.Log("Start dragging"); if (!Input.GetKey(KeyCode.RightControl) && !Input.GetKey(KeyCode.LeftControl)) { Selectables.DeselectAll(new BaseEventData(EventSystem.current)); } _DragSelectionBox.gameObject.SetActive(true); selectorStartPoint = eventData.position; rect = new Rect(); }
public override BaseReactionSelection <TValue> Build() { if (Selectables == null) { throw new ArgumentException(nameof(Selectables)); } if (Selectables.Count == 0) { throw new InvalidOperationException("You need at least one selectable"); } if (AllowCancel && Selectables.Keys.Contains(CancelEmote)) { throw new InvalidOperationException("Found duplicate emotes! (Cancel Emote)"); } if (Selectables.Distinct().Count() != Selectables.Count) { throw new InvalidOperationException("Found duplicate emotes!"); } if (AllowCancel && CancelEmote == null) { throw new ArgumentNullException(nameof(CancelEmote)); } if (EnableDefaultSelectionDescription) { var builder = new StringBuilder(); foreach (var selectable in Selectables) { string option = StringConverter.Invoke(selectable.Value); builder.AppendLine($"{selectable.Key} - {option}"); } SelectionPage.AddField(Title, builder.ToString()); } return(new ReactionSelection <TValue>( Selectables.AsReadOnly(), Users?.AsReadOnly() ?? throw new ArgumentException(nameof(Users)), SelectionPage?.Build() ?? throw new ArgumentNullException(nameof(SelectionPage)), CancelledPage?.Build(), TimeoutedPage?.Build(), AllowCancel, CancelEmote, Deletion )); }
private bool TryReselect(LeanSelectable selectable) { switch (reselect) { case ReselectType.KeepSelected: { if (Selectables.Contains(selectable) == false) // NOTE: Property { return(true); } } break; case ReselectType.Deselect: { if (Selectables.Contains(selectable) == false) // NOTE: Property { return(true); } else { Deselect(selectable); } } break; case ReselectType.DeselectAndSelect: { if (Selectables.Contains(selectable) == true) // NOTE: Property { Deselect(selectable); } } return(true); case ReselectType.SelectAgain: { } return(true); } return(false); }
/// <inheritdoc /> protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue) { base.OnItemsSourceChanged(oldValue, newValue); Selectables = AsyncObservableCollection <SelectableItem> .Create(); foreach (var newItem in newValue) { Selectables.Add(CreateSelectable(newItem)); } if (newValue is INotifyCollectionChanged notify) { notify.CollectionChanged += OnCollectionChanged; } if (oldValue is INotifyCollectionChanged oldNotify) { oldNotify.CollectionChanged -= OnCollectionChanged; } }
protected bool TrySelect(LeanSelectable selectable) { if (selectable != null && selectable.isActiveAndEnabled == true) { if (TryReselect(selectable) == true) { if (Selectables.Contains(selectable) == false) // NOTE: Property { switch (limit) { case LimitType.Unlimited: { } break; case LimitType.StopAtMax: { if (selectables.Count >= maxSelectables) { return(false); } } break; case LimitType.DeselectFirst: { if (selectables.Count > 0 && selectables.Count >= maxSelectables) { TryDeselect(selectables[0]); } } break; } } selectables.Add(selectable); if (onSelected != null) { onSelected.Invoke(selectable); } if (OnAnySelected != null) { OnAnySelected.Invoke(this, selectable); } selectable.InvokeOnSelected(this); return(true); } } // Nothing was selected? else { if (onNothing != null) { onNothing.Invoke(); } if (deselectWithNothing == true) { DeselectAll(); } } return(false); }
public void Read(string path) { FileEntity f = new FileEntity(path, "UTF-8"); f.Read(); foreach (string l in f.Get) { if (0 > l.IndexOf("\t")) { continue; } string left = l.Split("\t".ToCharArray())[0]; string right = l.Split("\t".ToCharArray())[1]; switch (left) { case DEFINE_FUNCTION: Functions.Add(right); break; case DEFINE_PACKAGEBODY: PackageBodies.Add(right); break; case DEFINE_PACKAGE: Packages.Add(right); break; case DEFINE_PROCEDURE: Procedures.Add(right); break; case DEFINE_TABLE: Tables.Add(right); break; case DEFINE_TRIGGER: Triggers.Add(right); break; case DEFINE_VIEW: Views.Add(right); break; default: break; } } foreach (string item in Functions) { Executables.Add(item); } foreach (string item in PackageBodies) { Executables.Add(item); } foreach (string item in Packages) { Executables.Add(item); } foreach (string item in Procedures) { Executables.Add(item); } foreach (string item in Tables) { Selectables.Add(item); } foreach (string item in Views) { Selectables.Add(item); } }
protected override bool ShouldProcess(SocketMessage message) => message.Source == MessageSource.User && Selectables.Any(x => x.Key.Contains(message.Content));
protected override bool ShouldProcess(SocketReaction reaction) => (AllowCancel && reaction.Emote.Equals(CancelEmote)) || Selectables.ContainsKey(reaction.Emote);