示例#1
0
        /// <summary>
        /// Event delegate method fired when the <see cref="FilterTimer"/> timer's elapses.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void FilterTimer_Tick(object sender, EventArgs e)
        {
            bool filter = FilterTimer.Enabled;

            FilterTimer.Stop();
            if (filter)
            {
                RefreshConnectionsList(false);
            }
        }
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (localCollection != null)
                        localCollection.Clear();
                }

                if (setFilterTimer != null)
                {
                    setFilterTimer.Dispose();
                    setFilterTimer = null;
                }

                disposedValue = true;
            }
        }
        public AccountImportQueueRecordsEditViewModel()
        {
            encodings = new ObservableCollection<Encoding>(new[] { Encoding.UTF8, Encoding.ASCII, Encoding.GetEncoding(1252), Encoding.Unicode });
            Encodings = CollectionViewSource.GetDefaultView(encodings);
            Encodings.SortDescriptions.Add(new SortDescription(nameof(Encoding.WebName), ListSortDirection.Ascending));
            SelectedEncoding = encodings.FirstOrDefault();

            loadTypes = new ObservableCollection<LoadType>(new[] { new LoadType("Для анализа", true), new LoadType("Обычная загрузка", false) });
            LoadTypes = CollectionViewSource.GetDefaultView(loadTypes);
            SelectedLoadType = loadTypes.FirstOrDefault();

            localCollection = new ObservableCollectionWatcher<ImportQueueRecord>((x, y) => x.Id == y.Id);
            ImportQueueRecords = CollectionViewSource.GetDefaultView(localCollection);
            //ImportQueueRecords.CollectionChanged += ImportQueueRecords_CollectionChanged;
            ImportQueueRecords.SortDescriptions.Add(new SortDescription(nameof(ImportQueueRecord.CreatedDate), ListSortDirection.Descending));
            setFilterTimer = new FilterTimer<DateTimeFilter>(TimeSpan.FromMilliseconds(500), (filter) =>
            {
                RunUnderDispatcher(() =>
                {
                    if (this.AccountsImportQueueRecordsComponent != null)
                    {
                        localCollection.Clear();
                        AccountsImportQueueRecordsComponent.From = filter.From;
                        AccountsImportQueueRecordsComponent.To = filter.To;
                    }
                });
            });
            InsertCommand = new DelegateCommand((o) => InsertNew());
            DeleteCommand = new DelegateCommand((o) => DeleteFromCollection(o as ImportQueueRecord));
        }
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }

                if (setFilterTimer != null)
                {
                    setFilterTimer.Dispose();
                    setFilterTimer = null;
                }

                disposedValue = true;
            }
        }
 public AccountPhoneMarksEditViewModel()
 {
     localCollection = new ObservableCollectionWatcher<AccountPhoneMark>((x, y) => x.Id == y.Id);
     AccountPhoneMarks = CollectionViewSource.GetDefaultView(localCollection);
     AccountPhoneMarks.CollectionChanged += AccountPhoneMarks_CollectionChanged;
     RowEditEndingCommand = new DelegateCommand(o => RowEditEnding(o as System.Windows.Controls.DataGridRowEditEndingEventArgs));
     setFilterTimer = new FilterTimer<string>(TimeSpan.FromMilliseconds(200), (filter) =>
     {
         RunUnderDispatcher(() =>
         {
             if (this.AccountsPhoneMarksComponent != null)
             {
                 localCollection.Clear();
                 AccountsPhoneMarksComponent.Filter = filter;
             }
         });
     });
 }
示例#6
0
 /// <summary>
 /// Event delegate method fired when the <see cref="FilterTextBox"/> textbox's text changes.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void FilterTextBox_TextChanged(object sender, EventArgs e)
 {
     FilterTimer.Stop();
     FilterTimer.Start();
 }