コード例 #1
0
        private void btnAddParticipant_Click(object sender, RoutedEventArgs e)
        {
            Participant participant = new Participant();

            _dm.GetParticipants().Add(participant);

            ParticipantEdit item = _editParticipants.FirstOrDefault(p => p.Participant == participant);

            dgParticipants.SelectedItem = item;
        }
コード例 #2
0
        private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                if (_viewParticipantsFilterHandler != null)
                {
                    _viewParticipants.Filter -= _viewParticipantsFilterHandler;
                }

                string sFilter = txtSearch.Text;

                _viewParticipantsFilterHandler = null;
                if (!string.IsNullOrEmpty(sFilter))
                {
                    _viewParticipantsFilterHandler = new FilterEventHandler(delegate(object s, FilterEventArgs ea)
                    {
                        bool contains(string bigString, string part)
                        {
                            if (string.IsNullOrEmpty(bigString))
                            {
                                return(false);
                            }

                            return(System.Threading.Thread.CurrentThread.CurrentCulture.CompareInfo.IndexOf(bigString, part, CompareOptions.IgnoreCase) >= 0);
                        }

                        ParticipantEdit p = (ParticipantEdit)ea.Item;

                        ea.Accepted =
                            contains(p.Name, sFilter) ||
                            contains(p.Firstname, sFilter) ||
                            contains(p.Club, sFilter) ||
                            contains(p.Nation, sFilter) ||
                            contains(p.Year.ToString(), sFilter) ||
                            contains(p.Code, sFilter) ||
                            contains(p.SvId, sFilter) ||
                            contains(p.Class?.ToString(), sFilter) ||
                            contains(p.Group?.ToString(), sFilter);
                    });
                }
                if (_viewParticipantsFilterHandler != null)
                {
                    _viewParticipants.Filter += _viewParticipantsFilterHandler;
                }

                _viewParticipants.View.Refresh();
            });
        }
コード例 #3
0
 private void btnDeleteParticipant_Click(object sender, RoutedEventArgs e)
 {
     ParticipantEdit[] selectedItems = new ParticipantEdit[dgParticipants.SelectedItems.Count];
     dgParticipants.SelectedItems.CopyTo(selectedItems, 0);
     if (selectedItems.Length > 0)
     {
         string szQuestion = string.Format("Sollen die markierten {0} Teilnehmer gelöscht werden?", selectedItems.Length);
         if (MessageBox.Show(szQuestion, "Teilnehmer löschen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
         {
             foreach (var item in selectedItems)
             {
                 if (item is ParticipantEdit pe)
                 {
                     Participant participant = pe.Participant;
                     _dm.GetParticipants().Remove(participant);
                 }
             }
         }
     }
 }