Esempio n. 1
0
        public RemoveBooksDialog(params Account[] accounts)
        {
            _libraryBooks = DbContexts.GetLibrary_Flat_NoTracking();
            _accounts     = accounts;

            InitializeComponent();

            this.Load        += (_, _) => this.RestoreSizeAndLocation(Configuration.Instance);
            this.FormClosing += (_, _) => this.SaveSizeAndLocation(Configuration.Instance);

            _labelFormat = label1.Text;

            _dataGridView.CellContentClick      += (_, _) => _dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
            _dataGridView.CellValueChanged      += (_, _) => UpdateSelection();
            _dataGridView.BindingContextChanged += _dataGridView_BindingContextChanged;

            var orderedGridEntries = _libraryBooks
                                     .Select(lb => new RemovableGridEntry(lb))
                                     .OrderByDescending(ge => (DateTime)ge.GetMemberValue(nameof(ge.PurchaseDate)))
                                     .ToList();

            _removableGridEntries             = new SortableBindingList <RemovableGridEntry>(orderedGridEntries);
            gridEntryBindingSource.DataSource = _removableGridEntries;

            _dataGridView.Enabled = false;
        }
        protected static async Task RunAsync(Processable Processable)
        {
            foreach (var libraryBook in Processable.GetValidLibraryBooks(DbContexts.GetLibrary_Flat_NoTracking()))
            {
                await ProcessOneAsync(Processable, libraryBook, false);
            }

            var done = "Done. All books have been processed";

            Console.WriteLine(done);
            Serilog.Log.Logger.Information(done);
        }
Esempio n. 3
0
        public void Display()
        {
            if (hasBeenDisplayed)
            {
                return;
            }
            hasBeenDisplayed = true;

            //
            // transform into sorted GridEntry.s BEFORE binding
            //
            var lib = DbContexts.GetLibrary_Flat_NoTracking();

            // if no data. hide all columns. return
            if (!lib.Any())
            {
                for (var i = _dataGridView.ColumnCount - 1; i >= 0; i--)
                {
                    _dataGridView.Columns.RemoveAt(i);
                }
                return;
            }

            var orderedGridEntries = lib
                                     .Select(lb =>
            {
                var entry        = new GridEntry(lb);
                entry.Committed += (_, __) => Filter();
                return(entry);
            }).ToList()
                                     // default load order
                                     .OrderByDescending(ge => (DateTime)ge.GetMemberValue(nameof(ge.PurchaseDate)))
                                     //// more advanced example: sort by author, then series, then title
                                     //.OrderBy(ge => ge.Authors)
                                     //    .ThenBy(ge => ge.Series)
                                     //    .ThenBy(ge => ge.Title)
                                     .ToList();

            // BIND
            gridEntryBindingSource.DataSource = new SortableBindingList <GridEntry>(orderedGridEntries);

            // FILTER
            Filter();
        }