/// <summary> /// Load a menu into memory by instantiating an instance of it's view /// and populating it with the data from the model passed in. /// </summary> /// <typeparam name="T">The type of menu to load.</typeparam> /// <param name="menu">The menu's model.</param> public void LoadMenu <T>(T menu) where T : class, IMenu { if (menuPresenter != null) { menuPresenter.Unload(); } MenuPresenterAttribute presenterAttribute = typeof(T).GetCustomAttribute <MenuPresenterAttribute>(); //Easy. We know what kind of presenter to use. if (presenterAttribute != null) { //Is the current one what we need? if ((menuPresenter?.GetType() ?? null) != presenterAttribute.Type) { menuPresenter = Activator.CreateInstance(presenterAttribute.Type, this, commandConsole, configContainer) as IMenuPresenter; } } else { throw new Exception(string.Format("No menu presenter attribute found on menu of type: {0}", typeof(T))); } menuPresenter.Load(menuContainer, menu); }
private void OpenMenu(IMenuPresenter menu) { if (CurrentMenu != null) { CurrentMenu.Close(); } menu.Open(); CurrentMenu = menu; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MenuActivityLayout); _presenter = new MenuPresenter(this); ContentFrameLayout = FindViewById <FrameLayout>(Resource.Id.ContentFrame); _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.OptionsDrawer); _leftDrawer = FindViewById <ListView>(Resource.Id.LeftListView); _leftAdapter = new ArrayAdapter(this, Resource.Layout.SideMenuItem, _presenter.GetMenuItems()); _leftDrawer.Adapter = _leftAdapter; _leftDrawer.ItemClick += LeftDrawerItemClicked; ActionBar.SetDisplayHomeAsUpEnabled(false); ActionBar.SetHomeButtonEnabled(true); }
/// <summary> /// Begins running the main menu application loop. /// </summary> public void Run() { // Set the culture (used by the Resource Manager to look up // culture-specific resources). System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; // Create the Unity container,... using (IUnityContainer container = new UnityContainer()) { // ...initialize it and let it create depending objects. ContainerBootstrapper.RegisterTypes(container); IMenuPresenter presenter = container.Resolve <IMenuPresenter>("MainMenu"); // Start the application loop - show the main menu, get the command and // act on it. ICommand command; while (!((command = presenter.GetCommand()) is ExitCommand)) { command.Execute(); } } }
/// <summary> /// 依赖注入构造器 /// </summary> public MenuController(IMenuPresenter menuPresenter, IInfoSystemPresenter infoSystemPresenter, IAuthorizationContract authorizationContract) { this._menuPresenter = menuPresenter; this._infoSystemPresenter = infoSystemPresenter; this._authorizationContract = authorizationContract; }
public DeleteListCommand(IMenuPresenter receiver) { _receiver = receiver; }
public void AddPresenter(IMenuPresenter menuPresenter) { this.menuPresenter = menuPresenter; }
public ViewListCommand(IMenuPresenter receiver) { _receiver = receiver; }
private void Menu_Load(object sender, EventArgs e) { menuPresenter = new MenuPresenter(this); menuPresenter.Init(); }
internal void AddMenuPresenter(IMenuPresenter menuPresenter) { this.AddPresenter(GlobalPresenter.MenuPresenterKey, menuPresenter); }