protected void OutputForm(iLayer layer, Fieldset fieldset) { System.Console.WriteLine(); Link link = layer.ActionButtons.FirstOrDefault(b => b.Action == iFactr.Core.Controls.Button.ActionType.Submit); if (link == null) { return; } link = (Link)link.Clone(); layer.FieldValuesRequested -= GetFieldValues; layer.FieldValuesRequested += GetFieldValues; var parameters = layer.GetFieldValues(); if (link.Parameters == null) { link.Parameters = parameters; } else { foreach (var key in parameters.Keys) { link.Parameters[key] = parameters[key]; } } if (link.RequestType == RequestType.ClearPaneHistory) { ClearHistory(); } iApp.Navigate(link); }
/// <summary> /// Initiates a navigation using the specified Link. /// </summary> /// <param name='link'>A <see cref="Link"/> containing the URL to navigate to with the parameters to pass through.</param> /// <param name="fromView">The <see cref="IMXView"/> instance from which the navigation was initiated.</param> public static void Navigate(Link link, IMXView fromView) { if (link == null) { Log.Warn("Navigation to null link cancelled."); return; } // Add layer's ActionParameters to Link var layer = fromView == null ? null : fromView.GetModel() as iLayer; if (layer != null && layer.ActionParameters != null) { if (link.Parameters == null) { link.Parameters = new Dictionary <string, string>(); } link.Parameters.AddRange(layer.ActionParameters); } if (fromView is ITabView) { CurrentNavContext.ActivePane = Pane.Tabs; CurrentNavContext.ActiveTab = (fromView as ITabView).SelectedIndex; } else { var entry = fromView as IHistoryEntry; if (entry != null) { CurrentNavContext.ActivePane = entry.OutputPane == Pane.Tabs ? Pane.Master : entry.OutputPane; } else if (layer != null) { CurrentNavContext.ActivePane = layer.NavContext.OutputOnPane; } } #region Link actions if (fromView != null) { link.Address = Resolve(PaneManager.Instance.GetNavigatedURI(fromView), link.Address); } if (link.Action == ActionType.Submit) { var listview = fromView as IListView; if (listview != null) { var newLink = link.Clone(); newLink.Action = ActionType.Undefined; listview.Submit(newLink); return; } var gridview = fromView as IGridView; if (gridview != null) { var newLink = link.Clone(); newLink.Action = ActionType.Undefined; gridview.Submit(newLink); return; } } if (link.Action == ActionType.None) { return; } #endregion if (!string.IsNullOrEmpty(link.ConfirmationText)) { var newLink = link.Clone(); newLink.ConfirmationText = null; var alert = new Alert(link.ConfirmationText, Factory.GetResourceString("ConfirmTitle"), AlertButtons.OKCancel); alert.OKLink = newLink; alert.Show(); return; } if (link.Address == null) { Log.Warn("Navigation to null URI cancelled."); return; } var parameters = link.Parameters == null ? new Dictionary <string, string>() : new Dictionary <string, string>(link.Parameters); Factory.LastActivityDate = DateTime.Now; Log.Info("Navigating to: " + link.Address); // Determine which mapping has a matching pattern to the URL to navigate to var navMap = Instance.NavigationMap.MatchUrl(link.Address); iLayer navLayer; // If there is no result, assume the URL is external and create a new Browser Layer if (navMap == null) { if (link.RequestType == RequestType.NewWindow) { new BrowserView <string>().LaunchExternal(link.Address); Factory.StopBlockingUserInput(); return; } var browserLayer = new Browser(link.Address); browserLayer.OnLoadComplete += TargetFactory.TheApp.LayerLoadCompleted; navLayer = browserLayer; } else { navLayer = navMap.Controller as iLayer; } // UI elements could be accessed while figuring out nav context, so ensure that it happens on the UI thread Thread.ExecuteOnMainThread(() => { Pane pane = Pane.Master; var topPane = PaneManager.Instance.TopmostPane.OutputOnPane; var stack = PaneManager.Instance.FromNavContext(topPane); if (fromView == null && stack != null && stack.CurrentView != null) { var history = stack.CurrentView as IHistoryEntry; CurrentNavContext.ActivePane = history == null ? topPane : history.OutputPane; } if (navLayer != null) { // Set up the Layer's navigation context var navContext = navLayer.NavContext; navContext.NavigatedUrl = link.Address == string.Empty && navMap != null ? navMap.Pattern : link.Address; var navUriEntry = PaneManager.Instance.NavigatedURIs.FirstOrDefault(p => p.Value == navContext.NavigatedUrl); var existingView = navUriEntry.Key as IHistoryEntry; var activePane = CurrentNavContext.ActivePane; var targetPane = existingView == null ? navLayer.FindTarget() : existingView.OutputPane; stack = PaneManager.Instance.FromNavContext(targetPane, CurrentNavContext.ActiveTab); if (existingView != null && !stack.Contains(existingView as IMXView)) { targetPane = navLayer.FindTarget(); } if (targetPane > activePane && (targetPane != Pane.Detail || Factory.LargeFormFactor && Instance.FormFactor == FormFactor.SplitView)) { navContext.ClearPaneHistoryOnOutput = true; } else { if (CurrentNavContext.ActivePane != targetPane && (stack == null || stack.Views.OfType <IHistoryEntry>().All(v => v.StackID != navLayer.Name))) { targetPane = PaneManager.Instance.TopmostPane.OutputOnPane; } navContext.OutputOnPane = activePane = CurrentNavContext.ActivePane = targetPane; navContext.ClearPaneHistoryOnOutput = false; } // Always render to Master from Tabs, otherwise target the targetPane navContext.OutputOnPane = (activePane == Pane.Tabs) ? Pane.Master : targetPane; navContext.NavigatedActivePane = activePane; navContext.NavigatedActiveTab = CurrentNavContext.ActiveTab; navLayer.LayerStyle = Instance.Style.Clone(); pane = navContext.OutputOnPane; } Link navLink = link.Clone(); navLink.Parameters = parameters; if (PaneManager.Instance.ShouldNavigate(navLink, pane, NavigationType.Forward)) { Factory.ActivateLoadTimer(link.LoadIndicatorTitle, link.LoadIndicatorDelay); // Initiate the layer loading for the associated layer passing all parameters CurrentNavContext.ActiveLayer = navLayer; if (navMap == null) { Factory.LoadLayer(fromView, navLayer, navLink.Address, navLink.Parameters); } else { MXContainer.Navigate(fromView, navLink.Address, navLink.Parameters); } } else { Factory.StopBlockingUserInput(); } }); }