예제 #1
0
        public MainWindow()
        {
            App.StartSSH();

            Logger.Log.ErrorToScreenEvent += ErrorEventHandler; // add  showmessage method to logger
            FilterList.AddFilter(CategoryFilterCollection.Instance);
            InitializeComponent();

            App.RegisterSession(new SessionMapLocation(wpfMapMain));
            App.RegisterSession(new SessionMapZoom(wpfMapMain));
            App.RegisterSession(new SessionFilterSingleDate(DatePickerSingle));
            App.RegisterSession(new SessionFilterDateRange(DatePickerFrom, DatePickerTo));
            App.RegisterSession(new SessionActiveDateFilter(SingleDate, DateRange));
            App.RegisterSession(new SessionFilterCategories());
            App.LoadSession();

            wpfMapMain.Background           = new SolidColorBrush(Color.FromRgb(172, 199, 242));
            wpfMapMain.ViewChangeOnFrame   += CheckZoomBoundaries;
            wpfMapMain.MouseLeftButtonDown += AddPin;

            FillCategoryFiltermenu();
            FillOffenceList(true);

            var aTimer = new Timer(5000);

            aTimer.Elapsed  += (sender, e) => Dispatcher.Invoke(() => CollectNewOffences());
            aTimer.AutoReset = true;
            aTimer.Enabled   = true;
        }
예제 #2
0
 /// <summary>
 /// Applies all filters contained in the FilterList to the offences.
 /// </summary>
 /// <returns></returns>
 public static List <Offence> FilterOffences(bool update = false)
 {
     if (update)
     {
         GetOffences();
     }
     return(FilterList.ApplyFilters(_offences));
 }
예제 #3
0
 /// <summary>
 /// On click button reset all filters
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void wpfBTNResetFilters_Click(object sender, RoutedEventArgs e)
 {
     ResetCategoryCheckbox();
     DatePickerSingle.SelectedDate = null;
     DatePickerFrom.SelectedDate   = null;
     DatePickerTo.SelectedDate     = null;
     FilterList.ClearFilters();
     FillOffenceList();
 }
예제 #4
0
 /// <summary>
 /// Adds single date filter to the filterlist using the date from the datepicker.
 /// </summary>
 /// <param name="datePicker">Datepicker containing the date.</param>
 /// <returns>Boolean based on whether the filter was added.</returns>
 private bool AddSingleDateFilter(DatePicker datePicker)
 {
     if (datePicker != null && datePicker.SelectedDate.HasValue)
     {
         FilterList.RemoveFilter($"{typeof(DateRangeFilter)}");
         DateTime   date   = new DateTime(datePicker.SelectedDate.Value.Year, datePicker.SelectedDate.Value.Month, datePicker.SelectedDate.Value.Day);
         DateFilter filter = new DateFilter(date);
         FilterList.AddFilter(filter);
         return(true);
     }
     return(false);
 }
예제 #5
0
 /// <summary>
 /// Adds a DateRangeFilter to the filterlist using the dates from two datepickers.
 /// </summary>
 /// <param name="DatePickerFrom">Datepicker containing the lower bound of the date range.</param>
 /// <param name="DatePickerTo">Datepicker containing the upper bound of the date range.</param>
 /// <returns>Boolean based on whether the filter was added.</returns>
 private bool AddDateRangeFilter(DatePicker DatePickerFrom, DatePicker DatePickerTo)
 {
     if (DatePickerFrom != null && DatePickerFrom.SelectedDate.HasValue && DatePickerTo != null && DatePickerTo.SelectedDate.HasValue)
     {
         FilterList.RemoveFilter($"{typeof(DateFilter)}");
         DateTime        DateFrom = new DateTime(DatePickerFrom.SelectedDate.Value.Year, DatePickerFrom.SelectedDate.Value.Month, DatePickerFrom.SelectedDate.Value.Day);
         DateTime        DateTo   = new DateTime(DatePickerTo.SelectedDate.Value.Year, DatePickerTo.SelectedDate.Value.Month, DatePickerTo.SelectedDate.Value.Day);
         DateRangeFilter filter   = new DateRangeFilter(DateFrom, DateTo);
         FilterList.AddFilter(filter);
         return(true);
     }
     return(false);
 }