public CategoryPresenter(ICategoryView categoryView, FoodTracker foodTracker)
        {
            CategoryView = categoryView;
            FoodTracker = foodTracker;
            _inEditMode = false;

            CategoryLookupPresenter = new CategoryLookupPresenter(CategoryView.CategoryLookupView, FoodTracker, true, false);
            AddCategoryPresenter = new AddCategoryPresenter(CategoryView.AddCategoryView, FoodTracker, CategoryLookupPresenter);
            CategoryItemPresenter = new CategoryItemPresenter(CategoryView.CategoryItemView);

            CategoryLookupPresenter.SelectedCategoryChanged += new EventHandler(OnSelectedCategoryChanged);
            CategoryView.EditButtonClick += new EventHandler(OnEditCategoryButtonClick);
            CategoryView.DeleteButtonClick += new EventHandler(OnDeleteCategoryButtonClick);
            CategoryView.MoveUpButtonClick += new EventHandler(OnCategoryMoveUpButtonClick);
            CategoryView.MoveDownButtonClick += new EventHandler(OnCategoryMoveDownButtonClick);

            bool enabled;

            if(CategoryLookupPresenter.SelectedCategory != null)
            {
                enabled = true;
                CategoryItemPresenter.Set(CategoryLookupPresenter.SelectedCategory);
            }
            else
            {
                enabled = false;
            }

            CategoryView.DeleteButtonEnabled = enabled;
            CategoryView.EditButtonEnabled = enabled;
            CategoryView.MoveUpButtonEnabled = enabled;
            CategoryView.MoveDownButtonEnabled = enabled;
        }
        public AddCategoryPresenter(IAddCategoryView addCategoryView, FoodTracker foodTracker, CategoryLookupPresenter categoryLookupPresenter)
        {
            AddCategoryView = addCategoryView;
            FoodTracker = foodTracker;
            CategoryLookupPresenter = categoryLookupPresenter;

            AddCategoryView.AddCategoryClicked += new EventHandler(OnAddCategoriesButtonClick);
        }
        public FoodItemPresenter(IFoodItemView foodItemView, FoodTracker foodTracker)
        {
            FoodItemView = foodItemView;
            FoodTracker = foodTracker;

            FoodItemView.Categories = FoodTracker.GetAllFoodCategories(false);
            FoodItemView.LeaveCategoryField += new EventHandler(CheckExistingCategory);
        }
        public MainPresenter(IMainView mainView, FoodTracker foodTracker)
        {
            MainView = mainView;
            FoodTracker = foodTracker;
            FoodPresenter = new FoodPresenter(MainView.FoodView, FoodTracker);
            CategoryPresenter = new CategoryPresenter(MainView.CategoryView, FoodTracker);

        }
        public CategoryLookupPresenter(ICategoryLookupView categoryLookupView, FoodTracker foodTracker, bool showEmptyCategories, bool showUncategorised)
        {
            CategoryLookupView = categoryLookupView;
            FoodTracker = foodTracker;
            ShowUncategorised = showUncategorised;
            ShowEmptyCategories = showEmptyCategories;

            UpdateCategories();
        }
        public AddFoodPresenter(IAddFoodView addFoodView, FoodTracker foodTracker)
        {
            AddFoodView = addFoodView;
            FoodTracker = foodTracker;
            FoodItemPresenter = new FoodItemPresenter(AddFoodView.FoodItemView, FoodTracker);

            AddFoodView.AddFoodClick += new EventHandler(OnAddFoodButtonClick);
            AddFoodView.CancelClick += new EventHandler(OnCancelButtonClick);
        }
        public FoodSearchPresenter(IFoodSearchView foodSearchView, FoodTracker foodTracker, FoodLookupPresenter foodLookupPresenter)
        {
            FoodSearchView = foodSearchView;
            FoodTracker = foodTracker;
            FoodLookupPresenter = foodLookupPresenter;

            FoodSearchView.SearchBarTextChanged += new EventHandler(ClearSearchResults);
            FoodSearchView.SearchEntered += new KeyPressEventHandler(SearchHandler);
        }
        public FoodLookupPresenter(IFoodLookupView foodLookupView, FoodTracker foodTracker)
        {
            FoodLookupView = foodLookupView;
            FoodTracker = foodTracker;
            CategoryLookupPresenter = new CategoryLookupPresenter(FoodLookupView.CategoryLookupView, FoodTracker, false, true);

            CategoryLookupPresenter.SelectedCategoryChanged += new EventHandler(OnCategoriesSelectedIndexChanged);

            SetFoodList();
        }
        public MainForm(FoodTracker FoodTracker)
        {
            InitializeComponent();
            FoodView = new FoodView();
            CategoryView = new CategoryView();
            LeftView = new LeftView(this);


            _CurrentView = FoodView;
            Controls.Add(_CurrentView);
            Controls.Add(LeftView);
        }
示例#10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Create Data Access Layer
            FoodContext context = new FoodContext();
            FoodRepository fRepository = new FoodRepository(context);
            FoodCategoryRepository fCatRepository = new FoodCategoryRepository(context);
            PresetMealRepository pMRepository = new PresetMealRepository(context);
            UnitOfWork UnitOfWork = new UnitOfWork(context, fRepository, fCatRepository,pMRepository);

            //Create Business Layer
            FoodTracker FoodTracker = new FoodTracker(UnitOfWork);

            //Create UI Layer
            MainForm MainForm = new MainForm(FoodTracker);
            MainPresenter MainPresenter = new MainPresenter(MainForm, FoodTracker);

            Application.Run(MainForm);
        }
        public FoodPresenter(IFoodView foodView, FoodTracker foodTracker)
        {
            FoodView = foodView;
            FoodTracker = foodTracker;

            FoodItemPresenter = new FoodItemPresenter(FoodView.FoodItemView, FoodTracker);
            FoodLookupPresenter = new FoodLookupPresenter(FoodView.FoodLookupView, FoodTracker);
            FoodSearchPresenter = new FoodSearchPresenter(FoodView.FoodSearchView, FoodTracker, FoodLookupPresenter);

            FoodView.AddFoodClick += new EventHandler(OnAddFoodButtonClick);
            FoodView.EditFoodClick += new EventHandler(OnEditFoodButtonClick);
            FoodView.DeleteFoodClick += new EventHandler(OnDeleteFoodButtonClick);
            FoodLookupPresenter.FoodSelectedChanged += new System.EventHandler(OnFoodListItemChanged);

            setFood();

            InEditMode = false;

            if (FoodTracker.GetAllFoodCategories(true).Count == 0)
            {
                FoodView.AddFoodButtonEnabled = false;
            }
        }