Ejemplo n.º 1
0
            public ScanController(ScanLayer scanLayer)
            {
                _layer = scanLayer;
                string fontName = null;
                double fontSize = 12;

                if (_layer.LayerStyle != null && _layer.LayerStyle.DefaultLabelStyle != null)
                {
                    fontName = _layer.LayerStyle.DefaultLabelStyle.FontFamily;
                    fontSize = _layer.LayerStyle.DefaultLabelStyle.FontSize;
                }
                if (!string.IsNullOrEmpty(fontName))
                {
                    float size;
                    if (!float.TryParse(fontSize.ToString(), out size))
                    {
                        TouchFactory.Instance.Logger.Warn("Could not parse " + fontSize + "(double) to a float value");
                        size = 12;
                    }
                    _layerFont = TouchStyle.ToFont(UIFont.FromName(fontName, size));
                }

                callback               = scanLayer.Callback;
                barcodeKey             = ScanLayer.BarcodeKey;
                completeButtonText     = scanLayer.Callback.Text ?? iApp.Factory.GetResourceString("Done");
                backgroundColor        = _layer.LayerStyle.LayerBackgroundColor;
                barcodeSeparatorChar   = ScanLayer.BarcodeSeparatorChar;
                ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            }
Ejemplo n.º 2
0
            public CameraScanController(CameraScanLayer layer, Link callback, string parametersKey)
            {
                _layer           = layer;
                _callback        = callback;
                _barcodeValueKey = parametersKey;
                DuplicateWait    = layer.DuplicateTimeout;
                //				Autorotate = TouchFactory.Instance.Platform == MobilePlatform.iPad;
                ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

                string fontName = null;
                double fontSize = 12;

                if (_layer.LayerStyle != null && _layer.LayerStyle.DefaultLabelStyle != null)
                {
                    fontName = _layer.LayerStyle.DefaultLabelStyle.FontFamily;
                    fontSize = _layer.LayerStyle.DefaultLabelStyle.FontSize;
                }
                if (!string.IsNullOrEmpty(fontName))
                {
                    _layerFont = TouchStyle.ToFont(UIFont.FromName(fontName, LastValueScanOverlay.LabelFontSize));
                }
            }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        private void DisplayLayer(iLayer layer)
        {
            LastAddress = layer.NavContext.NavigatedUrl;
            ResetNavigationKeys();

            System.Console.Title = TheApp.Title;
            System.Console.Clear();

            if (!string.IsNullOrEmpty(layer.Title))
            {
                System.Console.WriteLine(layer.Title);
            }

            if (layer is NavigationTabs)
            {
                OutputTabs((NavigationTabs)layer);
            }
            else
            {
                foreach (var item in layer.Items)
                {
                    if (item is iBlock)
                    {
                        OutputBlock((iBlock)item);
                    }
                    else if (item is iPanel)
                    {
                        OutputPanel((iPanel)item);
                    }
                    else if (item is iList)
                    {
                        OutputList((iList)item);
                    }
                    else if (item is iMenu)
                    {
                        OutputMenu((iMenu)item);
                    }
                    else if (item is Fieldset)
                    {
                        OutputForm(layer, (Fieldset)item);
                    }
                }
                OutputActions(layer.ActionButtons);
            }

            if (layer.BackButton != null && layer.BackButton.Action != iFactr.Core.Controls.Button.ActionType.None)
            {
                layer.BackButton.Address = TheApp.NavigateOnLoad;
            }

            System.Console.WriteLine();
            System.Console.WriteLine("0. {0} ...", GetResourceString("Back") ?? "Back");
            System.Console.WriteLine();

            string input  = System.Console.ReadLine();
            Link   action = new Link(TheApp.NavigateOnLoad);

            try
            {
                int key = Convert.ToInt16(input);

                if (key == 0 && navHistory.Count > 1)
                {
                    navHistory.Pop().Unload();
                    var nextLayer = navHistory.Peek();
                    DisplayLayer(nextLayer);
                }
                action = navigationKeys[key];
            }
            catch
            {
                action = new Link(input == string.Empty ? TheApp.NavigateOnLoad : input);
            }

            if (action.Address != null && action.Address.StartsWith("##"))
            {
                if (action.Address == "##PREV##")
                {
                    page--;
                }
                else if (action.Address == "##NEXT##")
                {
                    page++;
                }
                else if (action.Address == "##SEARCH##")
                {
                    System.Console.Write("{0}: ", GetResourceString("SearchHint") ?? "Search");
                    input      = System.Console.ReadLine();
                    searchTerm = input;
                    page       = 0;
                }
                else if (action.Address == "##CLEAR##")
                {
                    searchTerm = string.Empty;
                    page       = 0;
                }
                DisplayLayer(layer);
                return;
            }

            if (!string.IsNullOrEmpty(action.ConfirmationText))
            {
                System.Console.Write(action.ConfirmationText + " (y/N) ");
                string confirm = System.Console.ReadLine();
                if (confirm.ToLower().Trim()[0] != 'y')
                {
                    DisplayLayer(layer);
                    return;
                }
            }

            System.Console.WriteLine();
            LastAddress = action.Address;

            if (action.RequestType == RequestType.ClearPaneHistory)
            {
                ClearHistory();
            }

            iApp.Navigate(action);
        }
Ejemplo n.º 5
0
        /// <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();
                }
            });
        }
Ejemplo n.º 6
0
 /// <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>
 public static void Navigate(Link link)
 {
     Navigate(link, null);
 }