void LoadController(IMXView fromView, IMXController controller, Dictionary <string, string> parameters) { string perspective = controller.Load(parameters); if (!Instance.CancelLoad && perspective != null) // done if failed { MXViewPerspective viewPerspective = new MXViewPerspective(controller.ModelType, perspective); // quick check (viable for ALL platforms) to see if there is some kind of a mapping set up if (!Instance.Views.ContainsKey(viewPerspective)) { throw new Exception("There is no View mapped for " + viewPerspective.ToString()); } // if we have a view lying around assign it from the map, more of a curtesy to the derived container that anything controller.View = Instance.Views.GetView(viewPerspective); if (controller.View != null) { controller.View.SetModel(controller.GetModel()); } // give the derived container the ability to do something // with the fromView if it exists or to create it if it doesn't Instance.OnControllerLoadComplete(fromView, controller, viewPerspective); } // clear CancelLoad, we're done Instance.CancelLoad = false; }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete"); Type viewType = Views.GetViewType(viewPerspective); if (viewType != null) { // stash the model away so we can get it back when the view shows up! ViewModels[controller.ModelType] = controller.GetModel(); LastContext = fromView as Activity ?? ApplicationContext; if (NavigationHandler != null) { // allow first crack at the view creation to the person over-riding NavigationHandler(viewType); } else if (LastContext != null) { // use the last context to instantiate the new view Intent intent = new Intent(LastContext, viewType); intent.AddFlags(ActivityFlags.NewTask); LastContext.StartActivity(intent); } else { Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete: View not found for " + viewPerspective.ToString()); throw new TypeLoadException("View not found for " + viewPerspective.ToString()); } } else { Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete: View not found for " + viewPerspective.ToString()); throw new TypeLoadException("View not found for " + viewPerspective.ToString()); } }
public Type GetViewType(MXViewPerspective viewPerspective) { Type type; _typeMap.TryGetValue(viewPerspective, out type); return(type); }
public IMXView GetView(MXViewPerspective viewPerspective) { IMXView view = null; _viewMap.TryGetValue(viewPerspective, out view); return(view); }
public IMXView GetOrCreateView(MXViewPerspective viewPerspective) { IMXView view = null; if (_viewMap.TryGetValue(viewPerspective, out view)) { // if we have a type registered and haven't yet created an instance, this will be null if (view != null) { return(view); } } Type viewType = null; if (_typeMap.TryGetValue(viewPerspective, out viewType)) { // Instantiate an instance of the view from it's type view = (IMXView)Activator.CreateInstance(viewType); // add to the map for later. _viewMap[viewPerspective] = view; } else { // No view throw new ArgumentException("No View Perspective found for: " + viewPerspective.ToString(), "viewPerspective"); } return(view); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { Debug.WriteLine("OnControllerLoadComplete"); Type viewType = Views.GetViewType(viewPerspective); if (viewType != null) { // stash the model away so we can get it back when the view shows up! ViewModels[controller.ModelType] = controller.GetModel(); var activity = fromView as Page; if (NavigationHandler != null) { // allow first crack at the view creation to the person over-riding NavigationHandler(viewType); } else if (activity != null) { // start the next view NavigationFrame.NavigationService.Navigate(activity); } else { RenderViewFromPerspective(controller, viewPerspective); NavigationFrame.NavigationService.Navigate(Views.GetView(viewPerspective) as Page); } } else { Debug.WriteLine("OnControllerLoadComplete: View not found for " + viewPerspective.ToString()); throw new TypeLoadException("View not found for " + viewPerspective.ToString()); } }
public void LoadViewForController(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { HideLoading(); if (controller.View == null) { // get the view, create it if it has yet been created controller.View = Views.GetOrCreateView(viewPerspective); if (controller.View == null) { Console.WriteLine("View not found for perspective!" + viewPerspective.ToString()); throw new ArgumentException("View creation failed for perspective!" + viewPerspective.ToString()); } } // asign the view it's model and render the contents of the view controller.View.SetModel(controller.GetModel()); controller.View.Render(); // pull the type from the view ViewNavigationContext navigationContext = MXTouchNavigation.GetViewNavigationContext(controller.View); UIViewController viewController = controller.View as UIViewController; // iFactr binding options if (viewController == null) viewController = RenderLayer(controller.View); //slideoutNavigation.PushToModel(viewController); Menu.TopView = viewController; ShowView(); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective perspective) { // store of the stack for later NavHistory.Push(new NavDetail(controller.Uri, controller.Parameters)); // render the view MXConsoleContainer.RenderViewFromPerspective(controller, perspective); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { Console.WriteLine("Controller Load End"); _appDelegate.InvokeOnMainThread( delegate { LoadViewForController(fromView, controller, viewPerspective); if (ControllerLoadComplete != null) ControllerLoadComplete(controller); }); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { //Console.WriteLine("Controller Load End"); Xamarin.Forms.Device.BeginInvokeOnMainThread(()=>{ LoadViewForController(fromView, controller, viewPerspective); if (ControllerLoadComplete != null) ControllerLoadComplete(controller); }); }
public Type GetViewType(MXViewPerspective viewPerspective) { MXViewBinding binding; if (!_bindingMap.TryGetValue(viewPerspective.Key, out binding)) { throw new KeyNotFoundException("Could not find view for " + viewPerspective.ToString()); } return(binding.ViewType); }
protected virtual void AddView(MXViewPerspective viewPerspective, Type viewType, IMXView view) { if (view == null) { Views.Add(viewPerspective, viewType); } else { Views.Add(viewPerspective, view); } }
internal void RenderView(MXViewPerspective viewPerspective, object model) { IMXView view = GetOrCreateView(viewPerspective); if (view == null) { // No view perspective found for model throw new ArgumentException("No View Perspective found for: " + viewPerspective.ToString(), "viewPerspective"); } view.SetModel(model); view.Render(); }
public void Add(MXViewPerspective perspective, Type viewType) { if (!viewType.GetInterfaces().Contains(typeof(IMXView))) { throw new ArgumentException("Type provided does not implement IMXView interface.", "viewType"); } _typeMap.Add(perspective, viewType); _viewMap.Add(perspective, null); MXViewPerspective vp = new MXViewPerspective(perspective.ModelType, perspective.Perspective); System.Diagnostics.Debug.Assert(_typeMap.ContainsKey(vp)); System.Diagnostics.Debug.Assert(_viewMap.ContainsKey(vp)); }
public IMXView CreateView(MXViewPerspective viewPerspective) { MXViewBinding binding; if (!_bindingMap.TryGetValue(viewPerspective.Key, out binding)) { // No view throw new ArgumentException("No View Perspective found for: " + viewPerspective.ToString(), "viewPerspective"); } // Instantiate an instance of the view from it's type var view = (IMXView)Activator.CreateInstance(binding.ViewType); return(view); }
public void Add(MXViewPerspective perspective, Type viewType) { #if !NETFX_CORE && !WINDOWS_PHONE if (!viewType.GetInterfaces().Contains(typeof(IMXView))) { throw new ArgumentException("Type provided does not implement IMXView interface.", "viewType"); } #endif _typeMap[perspective] = viewType; _viewMap[perspective] = null; MXViewPerspective vp = new MXViewPerspective(perspective.ModelType, perspective.Perspective); System.Diagnostics.Debug.Assert(_typeMap.ContainsKey(vp)); System.Diagnostics.Debug.Assert(_viewMap.ContainsKey(vp)); }
protected static void StartViewForController(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { Type viewType = Instance.Views.GetViewType(viewPerspective); if (viewType == null) { Console.WriteLine("View not found for " + viewPerspective.ToString()); throw new TypeLoadException("View not found for " + viewPerspective.ToString()); } Uri viewUri = new Uri("/" + viewType.Name + ".xaml", UriKind.Relative); // get the uri from the MXPhoneView attribute, if present object[] attributes = viewType.GetCustomAttributes(true); for (int i = 0; i < attributes.Length; i++) { if (attributes[i] is MXPhoneViewAttribute) { viewUri = new Uri(((MXPhoneViewAttribute)attributes[i]).Uri, UriKind.Relative); break; } } // stash the model away so we can get it back when the view shows up! ViewModels[controller.ModelType] = controller.GetModel(); var page = fromView as PhoneApplicationPage; if (!(controller.View is PhoneApplicationPage) && controller.View != null && RenderLayer != null) { controller.View.Render(); viewUri = RenderLayer(controller.View); } if (page != null) { // NOTE: assumes XAML file matches type name and no sub directories page.NavigationService.Navigate(viewUri); } else { if (_rootFrame != null) { _rootFrame.Navigate(viewUri); } // failure, called too early or Something Very Bad Happened(tm)... } }
public bool ContainsKey(MXViewPerspective viewPerspective) { return(_bindingMap.ContainsKey(viewPerspective.Key)); }
public void LoadViewForController(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { hideLoading(); if (controller.View == null) { // get the view, create it if it has yet been created controller.View = Views.GetOrCreateView(viewPerspective); if (controller.View == null) { //Console.WriteLine("View not found for perspective!" + viewPerspective.ToString()); throw new ArgumentException("View creation failed for perspective!" + viewPerspective.ToString()); } } // asign the view it's model and render the contents of the view controller.View.SetModel(controller.GetModel()); controller.View.Render(); // pull the type from the view //ViewNavigationContext navigationContext = MXFormsNavigation.GetViewNavigationContext(controller.View); Page page = controller.View as Page; // iFactr binding options if (page == null) page = RenderLayer(controller.View); ViewNavigationContext navigationContext = MXFormsNavigation.GetViewNavigationContext(controller.View); formsNavigation.PushToModel(page); }
public MXShowViewRequest(MXViewPerspective viewPerspective, object viewModel) { ViewPerspective = viewPerspective; ViewModel = viewModel; }
public void Add(MXViewPerspective perspective, IMXView view) { _viewMap.Add(perspective, view); _typeMap.Add(perspective, view.GetType()); }
/* public static IMXController NavigateFromButton(string url, Dictionary<string, string> parameters, UIBarButtonItem button) { //_stashButton = button; return Navigate(url, parameters); } */ void LoadViewForController(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { HideLoading(); if (controller.View == null) { // get the view, create it if it has yet been created controller.View = Views.GetOrCreateView(viewPerspective); if (controller.View == null) { Console.WriteLine("View not found for perspective!" + viewPerspective.ToString()); throw new ArgumentException("View creation failed for perspective!" + viewPerspective.ToString()); } } // asign the view it's model and render the contents of the view controller.View.SetModel(controller.GetModel()); controller.View.Render(); // pull the type from the view ViewNavigationContext navigationContext = MXTouchNavigation.GetViewNavigationContext(controller.View); UIViewController viewController = controller.View as UIViewController; if (navigationContext == ViewNavigationContext.Modal) { // treat as a modal/popup view _touchNavigation.PushToModel(viewController); } else if (navigationContext == ViewNavigationContext.InContext) { // it's just an in-context view, just slap it on top of the view that navigated it here! UIViewController parentViewController = fromView as UIViewController; parentViewController.NavigationController.PushViewController(viewController, true); } else { UIViewController vc = viewController; if (_touchNavigation.HasTabBar) { _touchNavigation.PushViewInTabBar(vc, false); } else { switch (navigationContext) { case ViewNavigationContext.Detail: _touchNavigation.PushToDetail(vc); break; case ViewNavigationContext.Master: _touchNavigation.PushToMaster(vc); break; case ViewNavigationContext.Modal: _touchNavigation.PushToModel(vc); break; } } } // handle initial view display if not already handled ShowView(); }
public static void RenderViewFromPerspective(IMXController controller, MXViewPerspective perspective) { Instance.Views.RenderView(perspective, controller.GetModel()); }
/* public static IMXController NavigateFromButton(string url, Dictionary<string, string> parameters, UIBarButtonItem button) { //_stashButton = button; return Navigate(url, parameters); } */ void LoadViewForController(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { HideLoading(); if (controller.View == null) { // get the view, create it if it has yet been created controller.View = Views.GetOrCreateView(viewPerspective); if (controller.View == null) { Console.WriteLine("View not found for perspective!" + viewPerspective.ToString()); throw new ArgumentException("View creation failed for perspective!" + viewPerspective.ToString()); } } // asign the view it's model and render the contents of the view controller.View.SetModel(controller.GetModel()); controller.View.Render(); // pull the type from the view ViewNavigationContext navigationContext = MXTouchNavigation.GetViewNavigationContext(controller.View); UIViewController viewController = controller.View as UIViewController; if (navigationContext == ViewNavigationContext.Modal) { // treat as a modal/popup view _touchNavigation.PushToModel(viewController); } else if (navigationContext == ViewNavigationContext.InContext) { // it's just an in-context view, just slap it on top of the view that navigated it here! UIViewController parentViewController = fromView as UIViewController; parentViewController.NavigationController.PushViewController(viewController, true); } else { // if the view is one of the views in the group MXTouchViewGroup viewGroup = null; MXTouchViewGroupItem viewGroupItem = null; foreach (MXTouchViewGroup vg in ViewGroups) { viewGroupItem = vg.Items.Find( item => item.ViewType == controller.View.GetType() ); if (viewGroupItem != null) { viewGroup = vg; break; } } if (viewGroup != null) { // activate the group! _touchNavigation.PushToViewGroup(viewGroup, viewGroupItem, controller.View as UIViewController); } else { switch (navigationContext) { case ViewNavigationContext.Detail: _touchNavigation.PushToDetail(viewController); break; case ViewNavigationContext.Master: _touchNavigation.PushToMaster(viewController); break; } } } // handle initial view display if not already handled ShowView(); }
public void Add(MXViewPerspective perspective, IMXView view) { _viewMap[perspective] = view; _typeMap[perspective] = view.GetType(); }
public void Add(MXViewPerspective viewPerspective, Type viewType) { _bindingMap.Add(viewPerspective.Key, new MXViewBinding(viewType, viewPerspective)); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { Deployment.Current.Dispatcher.BeginInvoke(() => { StartViewForController(fromView, controller, viewPerspective); }); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { controller.RenderView(); }
public bool ContainsKey(MXViewPerspective viewPerspective) { return(_viewMap.ContainsKey(viewPerspective)); }
public MXViewBinding(Type viewType, MXViewPerspective viewPerspective) { ViewPerspective = viewPerspective; ViewType = viewType; }
/// <summary> /// Raises the load complete event after the Controller has completed loading its Model, the View may be populated /// and the derived classs should check if it exists and do something with it if needed for the platform, either free it, /// pop off the views in a stack above it or whatever makes sense to the platform /// </summary> /// <param name='controller'> /// Controller. /// </param> /// <param name='viewPerspective'> /// View perspective. /// </param> protected abstract void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective);
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { _viewModelLifeCycleHelper.OnControllerLoadComplete(controller); base.OnControllerLoadComplete(fromView, controller, viewPerspective); }
protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, MXViewPerspective viewPerspective) { controller.RenderView(); if (controller.View.GetType().BaseType.GetGenericTypeDefinition() != typeof(MXWebkitView<>) && RenderLayer != null) { HtmlGenericControl control = RenderLayer(controller.View); if (controller.Uri == App.NavigateOnLoad) { MXWebkitView<object>.WriteToResponse(controller.ModelType.ToString(), control.Attributes["title"], control); } else { MXWebkitView<object>.WriteAjaxToResponse(controller.ModelType.ToString(), control.Attributes["title"], control); } } }
public int CompareTo(object obj) { MXViewPerspective p = (MXViewPerspective)obj; return(this.GetHashCode() == p.GetHashCode() ? 0 : -1); }