public RestaurantSide(DataModel dataModel) { InitializeComponent(); _dataModel = dataModel; _dataModel._orderListAdd += UpdateCategoryDelete; _restaurantSidePresentationModel = new RestaurantSidePresentationModel(_dataModel); _mealListBox.DataSource = _dataModel.MealsList; _mealCategoryComboBox.DataSource = _dataModel.CategoriesList; _mealCategoryComboBox.DisplayMember = Constant.CATEGORY_NAME; GetMealGroupBoxData(); _categoryListBox.DataSource = _dataModel.CategoriesList; _categoryListBox.DisplayMember = Constant.CATEGORY_NAME; GetCategoryGroupData(); _usingCategoryListBox.DataSource = _dataModel.CategoryUsingList; string projectPath = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())); _openFileDialog.InitialDirectory = projectPath; _openFileDialog.Multiselect = false; _openFileDialog.Filter = @"Image|*.png;*.jpg;*.jpeg"; _mealCategoryComboBox.SelectedIndex = _dataModel.GetComboBoxIndex(_mealListBox.SelectedIndex); _mealSaveButton.DataBindings.Add(Constant.ITEM_ENABLE, _restaurantSidePresentationModel, Constant.NOTIFY_SAVE_BUTTON_ENABLE); _categorySaveButton.DataBindings.Add(Constant.ITEM_ENABLE, _restaurantSidePresentationModel, Constant.NOTIFY_SAVE_CATEGORY); _mealSaveButton.DataBindings.Add(Constant.ITEM_TEXT, _restaurantSidePresentationModel, Constant.NOTIFY_MEAL_SAVE); _categorySaveButton.DataBindings.Add(Constant.ITEM_TEXT, _restaurantSidePresentationModel, Constant.NOTIFY_CATEGORY_SAVE); this._mealListBox.SelectedIndexChanged += new System.EventHandler(this.SelectChangedEventMealListBox); this._categoryListBox.SelectedIndexChanged += new EventHandler(this.SelectChangedEventCategory); this._mealNameTextBox.TextChanged += new EventHandler(this.ChangeMealManagerTextBoxText); this._mealPriceTextBox.TextChanged += new EventHandler(this.ChangeMealManagerTextBoxText); this._mealPathTextBox.TextChanged += new EventHandler(this.ChangeMealManagerTextBoxText); this._descriptionRichTextBox.TextChanged += new EventHandler(this.ChangeDescriptionText); this._categoryNameTextBox.TextChanged += new EventHandler(this.ChangeCategoryName); _deleteMealButton.Enabled = _dataModel.IsMealInOrderList(_mealListBox.SelectedIndex); }
public void TestInitialize() { dataModel = new Model.DataModel(); restaurantSidePresentationModel = new RestaurantSidePresentationModel(dataModel); restaurantSidePresentationModel.PropertyChanged += RestaurantSidePresentationModel_PropertyChanged; string categoryButton = restaurantSidePresentationModel.CategorySaveButtonText; string mealButton = restaurantSidePresentationModel.MealSaveButtonText; restaurantSidePresentationModel.MealSaveButtonText = Model.Constant.ADD; restaurantSidePresentationModel.CategorySaveButtonText = Model.Constant.ADD; }