Пример #1
0
        protected static void SetModelFromParameters(string url, Dictionary <string, string> parameters)
        {
            IMXController controller = Instance.GetController(url, ref parameters);

            if (controller.GetModel() != null)
            {
                foreach (string key in parameters.Keys)
                {
                    SetPropertyOnModel(key, controller.GetModel(), parameters[key]);
                }
            }
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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;
        }
Пример #5
0
        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());
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
        protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string perspective, string navigatedUri)
        {
            // store of the stack for later
            NavHistory.Push(new NavDetail(navigatedUri, null));

            // render the view
            RenderViewFromPerspective(controller.ModelType, perspective, controller.GetModel());
        }
Пример #8
0
        protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string perspective, string navigatedUri)
        {
            // store of the stack for later
            NavHistory.Push(new NavDetail(navigatedUri, null));

            // render the view
            RenderViewFromPerspective(controller.ModelType, perspective, controller.GetModel());
        }
        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);
            }


            if (Menu.NavigationController != null && fromView != null)
            {
                if (Menu.NavigationController.ViewControllers.Contains(viewController))
                {
                    Menu.NavigationController.PopToViewController(viewController, true);
                }
                else
                {
                    Menu.NavigationController.PushViewController(viewController, true);
                }
            }
            else
            {
                if (Menu.NavigationController != null)
                {
                    Menu.NavigationController.PopToRootViewController(true);
                }

                Menu.TopView = viewController;
            }

            ShowView();
        }
Пример #10
0
        protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string viewPerspective, string navigatedUri)
        {
            try
            {
                RenderViewFromPerspective(controller.ModelType, viewPerspective, controller.GetModel());
            }
            catch (ArgumentException ae)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine("Failed to Render a view");
#endif
                throw new Exception("Webkit container failed to find a view", ae);
            }
        }
Пример #11
0
        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 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);

            if (Menu.NavigationController != null && fromView != null)
            {

                if (Menu.NavigationController.ViewControllers.Contains(viewController))
                    Menu.NavigationController.PopToViewController(viewController, true);
                else
                    Menu.NavigationController.PushViewController(viewController, true);
            }
            else
            {
                if (Menu.NavigationController != null)
                    Menu.NavigationController.PopToRootViewController(true);

                Menu.TopView = viewController;
            }

            ShowView();
        }
Пример #13
0
        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();

                Activity activity = fromView as Activity;
                if (NavigationHandler != null)
                {
                    // allow first crack at the view creation to the person over-riding
                    NavigationHandler(viewType);
                }
                else if (activity != null)
                {
                    // use the context we have to start the next view
                    Intent intent = new Intent(activity, viewType);
                    intent.AddFlags(ActivityFlags.NewTask);
                    intent.AddFlags(ActivityFlags.ClearTop);
                    activity.StartActivity(intent);
                }
                else if (ApplicationContext != null)
                {
                    // use the application context to instantiate the new new
                    Intent intent = new Intent(ApplicationContext, viewType);
                    intent.AddFlags(ActivityFlags.NewTask);
                    ApplicationContext.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());
            }
        }
        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 (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)...
            }
        }
Пример #15
0
        protected void StartViewForController(IMXView fromView, IMXController controller, string viewPerspective)
        {
            Type viewType = Views.GetViewType(controller.ModelType, viewPerspective);

            if (viewType == null)
            {
                Console.WriteLine("View not found for " + viewPerspective);
                throw new TypeLoadException("View not found for " + viewPerspective);
            }

            var viewUri = new Uri("/" + viewType.Name + ".xaml", UriKind.Relative);

            // get the uri from the MXPhoneView attribute, if present
            object[] attributes = viewType.GetCustomAttributes(true);
            foreach (MXPhoneViewAttribute t in attributes.OfType <MXPhoneViewAttribute>())
            {
                viewUri = new Uri((t).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 (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)...
            }
        }
Пример #16
0
        /// <summary>
        /// Occurs after a successful controller load.
        /// </summary>
        /// <param name="fromView">The <see cref="IMXView"/> that kicked off the navigation.</param>
        /// <param name="controller">The <see cref="IMXController"/> that received the navigation.</param>
        /// <param name="viewPerspective">The <see cref="ViewPerspective"/> returned by the controller load.</param>
        /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param>
        protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string viewPerspective, string navigatedUri)
        {
            Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete");

            Type viewType = Views.GetViewType(controller.ModelType, 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
                    var intent = new Intent(LastContext, viewType);
                    intent.AddFlags(ActivityFlags.NewTask);
                    LastContext.StartActivity(intent);
                }
                else
                {
                    Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete: View not found for " + viewPerspective);
                    throw new TypeLoadException("View not found for " + viewPerspective);
                }
            }
            else
            {
                Android.Util.Log.Debug("MXDroidContainer", "OnControllerLoadComplete: View not found for " + viewPerspective);
                throw new TypeLoadException("View not found for " + viewPerspective);
            }
        }
Пример #17
0
		/*
		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();
		}
Пример #18
0
 protected override void OnControllerLoadComplete(IMXView fromView, IMXController controller, string viewPerspective, string navigatedUri)
 {
     try
     {
         RenderViewFromPerspective(controller.ModelType, viewPerspective, controller.GetModel());
     }
     catch (ArgumentException ae)
     {
     #if DEBUG
         System.Diagnostics.Debug.WriteLine("Failed to Render a view");
     #endif
         throw new Exception("Webkit container failed to find a view", ae);
     }
 }
Пример #19
0
 public static void RenderViewFromPerspective(IMXController controller, MXViewPerspective perspective)
 {
     Instance.Views.RenderView(perspective, controller.GetModel());
 }
Пример #20
0
        /*
        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();
        }
Пример #21
0
        /// <summary>
        /// Executes the rendering logic for the view of the specified <see cref="IMXController"/> instance before painting it on the screen.
        /// </summary>
        /// <param name="controller">The controller to output.</param>
        /// <param name="perspective">The perspective that is mapped to the view that will be rendered.</param>
        /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="controller"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">Thrown when there is no view mapped to the <paramref name="perspective"/>.</exception>
        public void OutputController(IMXController controller, string perspective, string navigatedUri)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            var     ilayer = controller as iLayer;
            IMXView view   = Views.GetView(controller.ModelType, perspective);

            if (view == null)
            {
                if (ilayer != null)
                {
                    view        = ilayer.GetView();
                    ilayer.View = view;
                }
                else
                {
                    var viewType = Views.GetViewType(controller.ModelType, perspective);
                    if (viewType == null)
                    {
                        object model = controller.GetModel();
                        if (model != null && Device.Reflector.HasAttribute(model.GetType(), typeof(ViewAttribute), false))
                        {
                            view = ReflectiveUIBuilder.GenerateView(model);
                        }
                        else
                        {
                            throw new InvalidOperationException("There is no view or view type mapped to the given perspective.");
                        }
                    }
                    else
                    {
                        view = (IMXView)Activator.CreateInstance(viewType);
                    }
                }
            }

            view.SetModel(controller.GetModel());

            var entry = view as IHistoryEntry;

            if (entry != null)
            {
                entry.OutputPane = PaneManager.Instance.GetPreferredPaneForView(view);
            }

            view.Render();

            {
                var handler = ViewOutputting;
                if (handler != null)
                {
                    var args = new ViewOutputCancelEventArgs(controller, view);
                    handler(this, args);

                    if (args.Cancel)
                    {
                        return;
                    }
                }
            }

            var tabs = view as ITabView;

            if (tabs != null)
            {
                PaneManager.Instance.Tabs = tabs;
            }

            PaneManager.Instance.NavigatedURIs[view] = navigatedUri;
            OnOutputView(view);

            { // Handler scope
                var handler = ViewOutputted;
                if (handler != null)
                {
                    handler(this, new ViewOutputEventArgs(controller, view));
                }
            }

            StopBlockingUserInput();
        }
Пример #22
0
 /// <summary>
 /// Renders the view described by the perspective.
 /// </summary>
 /// <param name="controller">The controller requesting the view.</param>
 /// <param name="perspective">The perspective describing the view.</param>
 public IMXView RenderViewFromPerspective(IMXController controller, string perspective)
 {
     return(RenderViewFromPerspective(controller.ModelType, perspective, controller.GetModel()));
 }
Пример #23
0
		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);



		}
Пример #24
0
        /*
         * 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();
        }