Beispiel #1
0
 private void BindEvents()
 {
     // Trigger search patient every after 3 seconds from text change.
     OnSearchTextChanged.Sample(TimeSpan.FromSeconds(3))
     .ObserveOn(SynchronizationContext.Current)
     .Subscribe(x => SearchPatient());
 }
Beispiel #2
0
 private void richTextBox1_TextChanged(object sender, EventArgs e)
 {
     if (!isSearchEmpty)
     {
         OnSearchTextChanged?.Invoke(richTextBox1.Text);
     }
 }
        public EditPartyViewModel(Unit[] units, UserParty party = null)
        {
            m_UnitsCollection      = new ObservableCollection <Unit>(units);
            UnitList               = m_UnitsCollection.ToReadOnlyReactiveCollection(x => new UnitViewModel(x));
            m_PartyUnitsCollection = new ObservableCollection <UserUnit>();
            PartyUnits             = m_PartyUnitsCollection.ToReadOnlyReactiveCollection(x => new UserUnitViewModel(x, () => UnselectUserUnit(x)));

            OnCancel.Subscribe(x => CloseWindow((Window)x));
            OnSubmit.Subscribe(x => SaveParty((Window)x));

            OnSearchTextChanged.Subscribe(() => { SearchUnit(SearchText.Value); });

            ShowUnitType.Subscribe(OnChangeShowUnitType);
            OnChangeSelected.Subscribe(OnChangeSelectedUnit);

            OnAddTag.Subscribe(() =>
            {
                var window = new AddTagWindow(tag =>
                {
                    Tags.Add(new TagViewModel(tag, OnRemoveTag));
                });
                window.ShowDialog();
            });

            if (party != null)
            {
                m_Party     = party;
                m_PartUnits = party.UserUnits.ToList();
                foreach (var unitViewModel in UnitList)
                {
                    if (m_PartUnits.Any(x => x.UnitId == unitViewModel.Unit.Id))
                    {
                        unitViewModel.SetSelect(true);
                    }
                }
                m_PartyUnitsCollection.Clear();
                foreach (var unit in m_PartUnits)
                {
                    m_PartyUnitsCollection.Add(unit);
                }

                IsFullParty.Value       = true;
                IsVisibleSelected.Value = Visibility.Visible;
                PartyComment.Value      = party.Comment;
                EstimateDamage.Value    = party.EstimateDamage;

                Tags.Clear();
                if (party.Tags?.Length > 0)
                {
                    var vms = party.Tags
                              .Select(x => Database.I.Tags.SingleOrDefault(db => db.Id == x))
                              .Select(x => new TagViewModel(x, OnRemoveTag));
                    Tags.AddRange(vms);
                }
            }
        }
        private IEnumerable <SelectedItem> GetData()
        {
            var data = Items;

            if (ShowSearch && !string.IsNullOrEmpty(SearchText) && OnSearchTextChanged != null)
            {
                data = OnSearchTextChanged.Invoke(SearchText);
            }
            return(data);
        }
Beispiel #5
0
        private IEnumerable <SelectedItem> GetData()
        {
            var data = Items;

            if (ShowSearch && !string.IsNullOrEmpty(SearchText))
            {
                data = OnSearchTextChanged?.Invoke(SearchText);
            }
            return(data ?? Enumerable.Empty <SelectedItem>());
        }
    public async Task ConfirmSelectedItem(int index)
    {
        var ds = string.IsNullOrEmpty(SearchText)
            ? DataSource
            : OnSearchTextChanged.Invoke(SearchText);
        var item = ds.ElementAt(index);

        await OnItemClick(item);

        StateHasChanged();
    }
Beispiel #7
0
 private void SearchTextField_TextChanged(object sender, TextChangedEventArgs e) => OnSearchTextChanged?.Invoke(SearchTextField.Text);
Beispiel #8
0
 private void OnWidgetSearchBarTextChanged(object sender, TextChangedEventArgs e) => OnSearchTextChanged?.Invoke(e.NewTextValue);
 /// <summary>
 /// 获取显示的候选项集合
 /// </summary>
 /// <returns></returns>
 private IEnumerable <SelectedItem> GetShownItems() => string.IsNullOrEmpty(SearchText)
     ? DataSource
     : OnSearchTextChanged.Invoke(SearchText);