public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Matches?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ SegmentsCompleted;
         hashCode = (hashCode * 397) ^ Segments;
         hashCode = (hashCode * 397) ^ IsSearching.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Filters the search page
        /// </summary>
        public void Filter()
        {
            try
            {
                //clear existing picked visual records
                _history.Items.Clear();

                //if filters aren't identifed as used...
                if (!IsSearching)
                {
                    // for each item in all visual records
                    foreach (var item in checktemp)
                    {
                        //add it
                        _history.Items.Add(item);
                    }
                }
                //if filters are identifed as used...
                else
                {
                    // if check in date is ticked but null or if checkout date is ticked but null, throw error
                    if ((cbCheckIn.IsChecked == true && dpCheckIn.SelectedDate == null) || (cbCheckIn.IsChecked == true && dpCheckOut.SelectedDate == null))
                    {
                        throw new ArgumentException("Please select a respective date(s).");
                    }

                    // for each item in "all visual records but if users contains user if user is ticked but if room is room if room is ticked but if type is type if type is checked but if check in date is check in date but if checkout date is checkout date if checkout is ticked but if teacher is teacher if teacher is ticked"...
                    // [literally 'for each instance returned by a global search in checktemp for "where users contains user if user is ticked and if room is room if room is ticked and if type is type if type is checked and if check in date is check in date and if checkout date is checkout date if checkout is ticked and if teacher is teacher if teacher is ticked"']
                    foreach (var item in
                             checktemp.FindAll(o =>
                                               (_ifsearchusers.IsChecked == false || _searchusers.Text.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList().Contains(o.User)) &&
                                               (cbRoom.IsChecked == false || _searchrooms.Text == o.Room) &&
                                               (cbType.IsChecked == false || txtType.Text == o.Type) &&
                                               (cbCheckIn.IsChecked == false || o.In == dpCheckIn.SelectedDate.Value.ToString("dd/MM/yyyy HH:mm")) &&
                                               (cbCheckOut.IsChecked == false || o.In == dpCheckOut.SelectedDate.Value.ToString("dd/MM/yyyy HH:mm")) &&
                                               (cbTeachers.IsChecked == false || txtTeachers.Text.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList().Contains(o.Teacher)))
                             )
                    {
                        //add it
                        _history.Items.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + $" ({ex.GetType()})", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            tbResults.Text    = _history.Items.Count.ToString() + " of " + checktemp.Count.ToString();
            tbSearching.Text  = IsSearching.ToString();
            status.FontWeight = IsSearching ? FontWeights.Bold : FontWeights.Normal;
        }