/// <summary> /// Gets the presenter. /// </summary> /// <param name="view">The view.</param> /// <returns></returns> public IPresenterType GetPresenter <IPresenterType>(object view) { Check.Require(view != null, "view could not be null."); if (container.ServiceContainer.Kernel.HasComponent(typeof(IPresenterType))) { IPresenterType _presenter = (IPresenterType)container.ServiceContainer.Kernel[typeof(IPresenterType)]; if (typeof(IPresenter).IsAssignableFrom(_presenter.GetType())) { IPresenter presenter = (IPresenter)_presenter; object model = container.GetType().GetMethod("GetService").MakeGenericMethod(presenter.TypeOfModel).Invoke(container, null);; presenter.BindView(view); presenter.BindModel(model); return(_presenter); } else if (typeof(IPresenter2).IsAssignableFrom(_presenter.GetType())) { IPresenter2 presenter = (IPresenter2)_presenter; object[] models = new object[presenter.TypeOfModels.Length]; for (int i = 0; i < models.Length; i++) { models[i] = container.GetType().GetMethod("GetService").MakeGenericMethod(presenter.TypeOfModels[i]).Invoke(container, null);; } presenter.BindView(view); presenter.BindModels(models); return(_presenter); } } return(default(IPresenterType)); }
public View() { InitializeComponent(); presenter = new PlayerPresenter(this, new PlayerModel(this.Handle)); #region Event Bindings Load += (s, e) => { Reset(); presenter.BindModel(); }; FormClosed += (s, e) => presenter.Dispose(); openToolStripMenuItem.Click += (s, e) => OpenFileClicked.Invoke(s, e); clearCacheToolStripMenuItem.Click += (s, e) => ClearCacheClicked.Invoke(s, e); playPauseToolStripMenuItem.Click += (s, e) => PlayPauseInvoked.Invoke(s, e); playPauseButton.Click += (s, e) => PlayPauseInvoked.Invoke(s, e); stopButton.Click += (s, e) => StopInvoked.Invoke(s, e); stopToolStripMenuItem.Click += (s, e) => StopInvoked.Invoke(s, e); aboutToolStripMenuItem.Click += (s, e) => AboutClicked.Invoke(s, e); exitToolStripMenuItem.Click += (s, e) => Close(); timeline.MouseMove += (s, e) => { if (TimelinePushed) { PlaybackPosition = Math.Min(timeline.Width - slider.Width, Math.Max(e.X, 0)) / Convert.ToDouble(timeline.Width - slider.Width); } }; timeline.MouseDown += (s, e) => { TimelinePushed = true; PlaybackPosition = Math.Min(timeline.Width - slider.Width, Math.Max(e.X, 0)) / Convert.ToDouble(timeline.Width - slider.Width); }; timeline.MouseUp += (s, e) => TimelinePushed = false; timeline.MouseCaptureChanged += (s, e) => TimelinePushed = false; #endregion }