public MXTouchViewGroupItem(IMXView view, String title, String iconFile) { this.ViewType = view.GetType(); this.View = view; this.Title = title; this.Image = UIImage.FromFile(iconFile); }
public MXTouchViewGroupItem(IMXView view, String title, String iconFile) { this.ViewType = view.GetType(); this.View = view; this.Title = title; this.Icon = iconFile; }
/// <summary> /// Inserts the specified <see cref="IMXView"/> object into an appropriate stack and renders it. /// </summary> /// <param name="view">The view to be inserted into a stack.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="view"/> is <c>null</c>.</exception> public void DisplayView(IMXView view) { if (view == null) { throw new ArgumentNullException("view"); } var entry = view as IHistoryEntry; if (entry != null && entry.StackID == null) { entry.StackID = view.GetType().FullName; } var navContext = new iLayer.NavigationContext { OutputOnPane = GetPreferredPaneForView(view), NavigatedActiveTab = iApp.CurrentNavContext.ActiveTab, NavigatedActivePane = iApp.CurrentNavContext.ActivePane, }; var stack = FindStack(view); var layer = view.GetModel() as iLayer; if (layer != null) { if (stack.Contains(view)) { layer.NavContext.NavigatedActivePane = navContext.NavigatedActivePane; layer.NavContext.ClearPaneHistoryOnOutput = false; } layer.NavContext.OutputOnPane = navContext.OutputOnPane; layer.NavContext.NavigatedActiveTab = navContext.NavigatedActiveTab; navContext = layer.NavContext; } var originalPane = navContext.OutputOnPane; if (stack.Contains(view)) { originalPane = stack.FindPane(); iApp.CurrentNavContext.ActivePane = originalPane; navContext.NavigatedActivePane = originalPane; if (entry != null) { entry.OutputPane = originalPane; } } for (navContext.OutputOnPane = Pane.Popover; navContext.OutputOnPane > originalPane; navContext.OutputOnPane--) { var clearStack = FromNavContext(navContext); if (clearStack != null && clearStack.FindPane() > originalPane) { clearStack.PopToRoot(); } } stack.DisplayView(view, navContext.NavigatedActivePane < navContext.OutputOnPane || navContext.ClearPaneHistoryOnOutput); }
/// <summary> /// Displays the specified view in the stack. /// </summary> /// <param name="stack">The stack to display the view.</param> /// <param name="view">The view to be displayed.</param> /// <param name="forceRoot"><c>true</c> to empty the history stack; otherwise <c>false</c></param> public static void DisplayView(this IHistoryStack stack, IMXView view, bool forceRoot) { var entry = view as IHistoryEntry; var behaviorOptions = Device.Reflector.GetCustomAttributes(view.GetType(), true).OfType <StackBehaviorAttribute>().Select(stackAtt => stackAtt.Options).FirstOrDefault(); var viewForcesRoot = (behaviorOptions & StackBehaviorOptions.ForceRoot) != 0; if (viewForcesRoot || forceRoot) { var root = stack.Views.FirstOrDefault(); if (root == null) { stack.PushView(view); } else { var rootAtt = Device.Reflector.GetCustomAttribute <StackBehaviorAttribute>(root.GetType(), true); if (!viewForcesRoot && rootAtt != null && (rootAtt.Options & StackBehaviorOptions.ForceRoot) != 0) { // If current root is already ForceRoot, let it be stack.PopToRoot(); stack.PushView(view); } else { // Otherwise replace it stack.ReplaceView(root, view); stack.PopToView(view); } } } else { var current = entry == null ? null : stack.Views.OfType <IHistoryEntry>().FirstOrDefault(e => e.StackID == entry.StackID); if (current != null) { if (current != entry) { stack.ReplaceView((IMXView)current, view); } stack.PopToView(view); } else { stack.PushView(view); } } }
public void Add(MXViewPerspective perspective, IMXView view) { _viewMap.Add(perspective, view); _typeMap.Add(perspective, view.GetType()); }
public static void AddView <Model>(IMXView view, string perspective) { Instance.AddView(new MXViewPerspective(typeof(Model), perspective), view.GetType(), view); }
// Model to View associations public static void AddView <Model>(IMXView view) { Instance.AddView(new MXViewPerspective(typeof(Model), ViewPerspective.Default), view.GetType(), view); }
/// <summary> /// Adds the specified view to the view map. /// </summary> /// <param name="perspective">The view's perspective.</param> /// <param name="view">The initialized view value.</param> public static void AddView <TModel>(IMXView view, string perspective) { Instance.AddView(typeof(TModel), view.GetType(), perspective, view); }
public void Add(MXViewPerspective perspective, IMXView view) { _viewMap[perspective] = view; _typeMap[perspective] = view.GetType(); }
/* * public static IMXController NavigateFromButton(string url, Dictionary<string, string> parameters, UIBarButtonItem button) * { * //_stashButton = button; * a * return Navigate(url, parameters); * } */ void LoadViewForController(IMXView fromView, IMXController controller, string viewPerspective) { HideLoading(); // get the view, create it if it has yet been created IMXView view = Views.GetOrCreateView(controller.ModelType, viewPerspective); if (view == null) { Debug.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 view.SetModel(controller.GetModel()); // pull the type from the view ViewNavigationContext navigationContext = MXTouchNavigation.GetViewNavigationContext(view); UIViewController viewController = view as UIViewController; if (navigationContext == ViewNavigationContext.InContext) { view.Render(); // 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) { var viewType = view.GetType(); // Check the type itself and its interfaces viewGroupItem = vg.Items.Find(item => item.ViewType == viewType || viewType.GetInterface(item.ViewType.ToString()) != null); if (viewGroupItem != null) { viewGroup = vg; break; } } if (viewGroup != null) { // activate the group! _touchNavigation.PushToViewGroup(viewGroup, viewGroupItem, viewController); } else { view.Render(); switch (navigationContext) { case ViewNavigationContext.Master: _touchNavigation.PushToMaster(viewController); break; case ViewNavigationContext.Detail: _touchNavigation.PushToDetail(viewController); break; case ViewNavigationContext.Modal: _touchNavigation.PushToModel(viewController); break; } } } // handle initial view display if not already handled ShowView(); }
internal Pane GetPreferredPaneForView(IMXView view) { if (view == null) { throw new ArgumentNullException("view"); } // Order of importance: iLayer > IHistoryEntry > PreferredPane var layer = view.GetModel() as iLayer; if (layer != null) { return(layer.NavContext.OutputOnPane); } var entry = view as IHistoryEntry; if (entry != null && entry.OutputPane != Pane.Tabs) { return(entry.OutputPane); } var topPane = TopmostPane.OutputOnPane; var paneAttribute = Device.Reflector.GetCustomAttribute <PreferredPaneAttribute>(view.GetType(), true); if (topPane < Pane.Detail && paneAttribute == null) { if (topPane == Pane.Tabs) { return(Pane.Master); } var detail = FromNavContext(Pane.Detail, 0); if (detail != null && detail.FindPane() == Pane.Detail) { return(Pane.Detail); } } return(paneAttribute != null && paneAttribute.Pane > topPane ? paneAttribute.Pane : topPane); }