public MainWindow(IRepositoryFactory repositoryFactory)
            : base(Gtk.WindowType.Toplevel)
        {
            Resizable = true;

            this.rekeningRepository = repositoryFactory.CreateRepository<IRekeningRepository>();
            this.consumptieRepository = repositoryFactory.CreateRepository<IConsumptieRepository>();

            this.DeleteEvent += OnDeleteEvent;

            windowPaned = new VPaned();
            Add(windowPaned);

            initializeRekeningen(rekeningRepository);
            initializeConsumpties(consumptieRepository);

            ShowAll();
        }
        public MainWindow(HttpAgent httpAgent, IRepositoryFactory repositoryFactory)
            : base(Gtk.WindowType.Toplevel)
        {
            this.httpAgent = httpAgent;

            WindowPosition = WindowPosition.Center;

            rekeningRepository = repositoryFactory.CreateRepository<IRekeningRepository>();
            consumptieRepository = repositoryFactory.CreateRepository<IConsumptieRepository>();

            // Rekeningen overzicht
            rekeningOverzichtWidget = new RekeningOverzichtWidget();
            rekeningOverzichtWidget.Refresh(rekeningRepository.GetAll());
            rekeningOverzichtWidget.RekeningClicked += handleRekeningClicked;

            // Afrekenen button
            Pango.FontDescription fontDescription = Pango.FontDescription.FromString("Arial");
            fontDescription.Size = 13000;
            fontDescription.Weight = Pango.Weight.Bold;
            Label afrekenenLabel = new Label("Afrekenen");
            afrekenenLabel.ModifyFont(fontDescription);
            afrekenenButton = new Button();
            afrekenenButton.Add(afrekenenLabel);
            afrekenenButton.Clicked += handleAfrekenenButtonClicked;

            // Rechter panel (bestellingen)
            bestellingenOverzichtWidget = new BestellingenOverzichtWidget();

            box = new HBox(false, 3);
            box.PackStart(rekeningOverzichtWidget);
            box.PackStart(bestellingenOverzichtWidget);

            // Main box
            vbox = new VBox(false, 0);
            vbox.PackStart(box);
            vbox.PackEnd(afrekenenButton);
            Add(vbox);

            ShowAll();

            this.DeleteEvent += OnDeleteEvent;
        }
        void initializeConsumpties(IConsumptieRepository consumptieRepository)
        {
            consumptiesTable = new Table(2, 1, false);
            windowPaned.Add2(consumptiesTable);

            consumptiesManager = new ObjectManagerWidget<Consumptie>(typeof(ConsumptieEditorWindow));
            consumptiesManager.GetObjectsFunc = delegate {
                return consumptieRepository.GetAll();
            };
            consumptiesManager.GetObjectTitleFunc = delegate(Consumptie consumptie) {
                return consumptie.Naam;
            };
            consumptiesManager.DeleteObjectFunc = delegate(Consumptie consumptie) {
                try
                {
                    consumptieRepository.Delete(consumptie);
                }
                catch(Exception ex)
                {
                    log.Error(ex);
                    UIHelper.ShowErrorDialog(this, "Kan consumptie '{0}' niet verwijderen: " + ex.Message, consumptie.Naam);
                }
                OnRefreshConsumpties();
            };
            consumptiesManager.UpdateObjectFunc = delegate(Consumptie consumptie) {
                try
                {
                    consumptieRepository.Update(consumptie);
                }
                catch(Exception ex)
                {
                    log.Error(ex);
                    UIHelper.ShowErrorDialog(this, "Kan consumptie '{0}' niet wijzigen: " + ex.Message, consumptie.Naam);
                }
                OnRefreshConsumpties();
            };
            consumptiesManager.AddObjectFunc = delegate(Consumptie consumptie) {
                try
                {
                    consumptieRepository.Create(consumptie);
                }
                catch(Exception ex)
                {
                    log.Error(ex);
                    UIHelper.ShowErrorDialog(this, "Kan consumptie '{0}' niet toevoegen: " + ex.Message, consumptie.Naam);
                }
                OnRefreshConsumpties();
            };
            consumptiesTable.Attach(consumptiesManager, 0, 1, 0, 1);

            consumptiesOverzicht = new OverzichtWidget<Consumptie>(new OverzichtWidgetColumn("Naam", 0, "{0}:"), new OverzichtWidgetColumn("Prijs", 1, "{0:C}"));
            consumptiesTable.Attach(consumptiesOverzicht, 0, 1, 1, 2);

            OnRefreshConsumpties();
            consumptiesManager.Refresh();
        }