Exemple #1
0
        async Task PushModalInternal(Page modal, bool animated)
        {
            TaskCompletionSource <bool> tcs = null;

            if (CurrentModalNavigationTask != null && !CurrentModalNavigationTask.IsCompleted)
            {
                var previousTask = CurrentModalNavigationTask;
                tcs = new TaskCompletionSource <bool>();
                CurrentModalNavigationTask = tcs.Task;
                await previousTask;
            }

            var      after  = _internalNaviframe.NavigationStack.LastOrDefault();
            NaviItem pushed = null;

            if (animated || after == null)
            {
                pushed = _internalNaviframe.Push(Platform.GetOrCreateRenderer(modal).NativeView, modal.Title);
            }
            else
            {
                pushed = _internalNaviframe.InsertAfter(after, Platform.GetOrCreateRenderer(modal).NativeView, modal.Title);
            }
            pushed.TitleBarVisible = false;

            bool shouldWait = animated && after != null;

            await WaitForCompletion(shouldWait, tcs);
        }
        void OnPopToRootRequested(object sender, NavigationRequestedEventArgs nre)
        {
            List <NaviItem> copyOfStack = new List <NaviItem>(_naviFrame.NavigationStack);
            NaviItem        rootItem    = copyOfStack.FirstOrDefault();
            NaviItem        topItem     = copyOfStack.LastOrDefault();

            foreach (NaviItem naviItem in copyOfStack)
            {
                if (naviItem != rootItem && naviItem != topItem)
                {
                    naviItem.Delete();
                }
            }

            if (topItem != rootItem)
            {
                UpdateNavigationBar(Element.Navigation.NavigationStack.Last(), rootItem);
                if (nre.Animated)
                {
                    _naviFrame.Pop();

                    _currentTaskSource = new TaskCompletionSource <bool>();
                    nre.Task           = _currentTaskSource.Task;
                }
                else
                {
                    topItem?.Delete();
                }
            }

            _naviItemMap.Clear();
            _naviItemMap[Element.Navigation.NavigationStack.Last()] = rootItem;
        }
Exemple #3
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            square = window.GetInnerSquare();

            Naviframe navi = new Naviframe(window)
            {
                PreserveContentOnPop     = true,
                DefaultBackButtonEnabled = true
            };

            _navi = navi;

            navi.Popped += (s, e) =>
            {
                Console.WriteLine("----- Naviframe was popped {0:x} ", (int)(IntPtr)e.Content);
            };

            NaviItem item = navi.Push(CreatePage(window), "0 Page");

            item.SetPartContent("title_left_btn", new Button(window)
            {
                Text = "LEFT", Style = "naviframe/title_left"
            });
            item.SetPartContent("title_right_btn", new Button(window)
            {
                Text = "RIGHT", Style = "naviframe/title_right"
            });
            navi.Show();
            conformant.SetContent(navi);
        }
Exemple #4
0
 protected override void OnMouseLeave(MouseEventArgs e)
 {
     base.OnMouseLeave(e);
     if (_Adornment.IsEmpty == false)
     {
         _Adornment.RemoveAllAdornments();
         _MouseHoverItem = null;
     }
 }
        void UpdateTitle(Page page, NaviItem item = null)
        {
            if (item == null)
            {
                item = GetNaviItemForPage(page);
            }

            item.SetPartText(PartTitle, SpanTitle(page.Title));
        }
        void UpdateNavigationBar(Page page, NaviItem item = null)
        {
            if (item == null)
            {
                item = GetNaviItemForPage(page);
            }

            UpdateTitle(page, item);
            UpdateBarBackgroundColor(item);
        }
 void UpdateBreadCrumbsBar(NaviItem item)
 {
     if (Element.OnThisPlatform().HasBreadCrumbsBar())
     {
         item.SetNavigationBarStyle();
         item.SetNavigationBar(GetBreadCrumbsBar());
     }
     else
     {
         item.SetNavigationBar(null, false);
     }
 }
 void UpdateBreadCrumbsBar(NaviItem item)
 {
     if (Element.OnThisPlatform().HasBreadCrumbsBar())
     {
         item.Style = StyleNavigationBar;
         item.SetPartContent(PartNavigationBar, GetBreadCrumbsBar());
     }
     else
     {
         item.SetPartContent(PartNavigationBar, null, false);
     }
 }
Exemple #9
0
 public static NaviItem SetTabBarStyle(this NaviItem item)
 {
     if (Device.Idiom == TargetIdiom.TV)
     {
         //According to TV UX Guideline, item style should be set to "tabbar" in case of TabbedPage only for TV profile.
         item.Style = ThemeConstants.NaviItem.Styles.TV.TabBar;
     }
     else
     {
         item.Style = ThemeConstants.NaviItem.Styles.Default;
     }
     return(item);
 }
Exemple #10
0
        void UpdateHasNavigationBar(Page page)
        {
            NaviItem item = GetNaviItemForPage(page);

            //According to TV UX Guideline, item style should be set to "tabbar" in case of TabbedPage only for TV profile.
            if (Device.Idiom == TargetIdiom.TV)
            {
                item.Style = page is TabbedPage ? "tabbar" : "default";
            }
            item.TitleBarVisible = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
            UpdateToolbarItem(page, item);
            UpdateBarBackgroundColor(item);
            UpdateBreadCrumbsBar(item);
        }
        void UpdateHasBackButton(Page page, NaviItem item = null)
        {
            if (item == null)
            {
                item = GetNaviItemForPage(page);
            }

            EButton button = null;

            if ((bool)page.GetValue(NavigationPage.HasBackButtonProperty) && _naviFrame.NavigationStack.Count > 1)
            {
                button = CreateNavigationButton((string)page.GetValue(NavigationPage.BackButtonTitleProperty));
            }
            item.SetPartContent(PartBackButton, button);
        }
Exemple #12
0
        // GET: Nav
        public ActionResult Menu()
        {
            var             courseList    = db.Courses.ToList();
            var             moduleList    = db.Modules.ToList();
            var             activityList  = db.Activities.ToList();
            var             documentList  = db.Documents.ToList();
            List <NaviItem> menuViewModel = new List <NaviItem>();
            NaviItem        nav           = new NaviItem()
            {
                Courses = courseList, Modules = moduleList, Activities = activityList, Documents = documentList
            };

            menuViewModel.Add(nav);
            return(PartialView("_Navigation", menuViewModel));
        }
    private NaviItem InitNaviNode(int id)
    {
        NaviItem epass = null;

        Debug.Assert(id < naviObj.nodeList.Count, "out index");
        var nodeInfo = naviObj.nodeList[id];

        if (!nodeDic.ContainsKey(id))
        {
            var           parent = this.parent;
            List <string> path   = new List <string>();
            for (int i = 0; i < nodeInfo.naviNodes.Count; i++)
            {
                var item = nodeInfo.naviNodes[i];
                path.Add(item.name);
                RectTransform rect = null;
                if (i < nodeInfo.naviNodes.Count - 1)
                {
                    rect = FindTran(path.ToArray());
                }
                else
                {
                    var name = string.Format("{0}.{1}", i, item.name);
                    var obj  = new GameObject(name, typeof(RectTransform));
                    rect             = obj.GetComponent <RectTransform>();
                    epass            = rect.gameObject.AddComponent <NaviItem>();
                    epass.nodeInfo   = nodeInfo;
                    epass.onComplete = NextNavi;
                    nodeDic.Add(id, epass);
                }
                rect.SetParent(parent, false);
                rect.transform.localPosition = item.localPosition;
                rect.transform.localScale    = item.localScale;
                rect.pivot            = item.pivot;
                rect.anchoredPosition = item.anchoredPosition;
                rect.anchorMax        = item.anchorMax;
                rect.anchorMin        = item.anchorMin;
                rect.sizeDelta        = item.sizeDelta;
                parent = rect;
            }
        }
        else
        {
            epass = nodeDic[id];
        }

        return(epass);
    }
Exemple #14
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.RangeHighlight) == false)
            {
                return;
            }
            if (_MouseHoverItem != null)
            {
                var p = e.GetPosition(_MouseHoverItem);
                if (p.X != 0 && p.Y != 0 && _MouseHoverItem.Contains(p))
                {
                    return;
                }
            }
            for (int i = Items.Count - 1; i >= 0; i--)
            {
                var item = Items[i] as NaviItem;
                if (item == null || item.Contains(e.GetPosition(item)) == false)
                {
                    continue;
                }

                _MouseHoverItem = item;
                if (_Adornment.IsEmpty == false)
                {
                    _Adornment.RemoveAllAdornments();
                }
                var span = item.Node.Span.CreateSnapshotSpan(_View.TextSnapshot);
                if (span.Length > 0)
                {
                    try {
                        HighlightNodeRanges(item.Node, span);
                    }
                    catch (ObjectDisposedException) {
                        // ignore
                        _MouseHoverItem = null;
                    }
                }
                return;
            }
            if (_Adornment.IsEmpty == false)
            {
                _Adornment.RemoveAllAdornments();
                _MouseHoverItem = null;
            }
        }
        void UpdateToolbarItem(Page page, NaviItem item = null)
        {
            if (item == null)
            {
                item = GetNaviItemForPage(page);
            }

            if (_naviFrame.NavigationStack.Count == 0 || item == null || item != _naviFrame.NavigationStack.Last())
            {
                return;
            }

            Native.Button rightButton = GetToolbarButton(ToolbarButtonPosition.Right);
            item.SetPartContent(PartRightToolbar, rightButton);

            Native.Button leftButton = GetToolbarButton(ToolbarButtonPosition.Left);
            item.SetPartContent(PartLeftToolbar, leftButton);
            UpdateHasBackButton(page, item);
        }
 private void ActiveStep(int id)
 {
     foreach (var item in nodeDic)
     {
         if (item.Key == id)
         {
             Current = item.Value;
             Current.gameObject.SetActive(true);
             navimask.MoveToNode(Current.GetComponent <RectTransform>());
             if (onStepActive != null)
             {
                 onStepActive.Invoke(Current);
             }
         }
         else
         {
             item.Value.gameObject.SetActive(false);
         }
     }
 }
        void UpdateHasNavigationBar(Page page)
        {
            NaviItem item = GetNaviItemForPage(page);

            if (NavigationPage.GetTitleView(page) != null)
            {
                item.TitleBarVisible = false;
                Native.TitleViewPage tvPage = item.Content as Native.TitleViewPage;
                if (tvPage != null)
                {
                    tvPage.HasNavigationBar = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
                }
                return;
            }

            item.SetTabBarStyle();
            item.TitleBarVisible = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
            UpdateToolbarItem(page, item);
            UpdateBarBackgroundColor(item);
            UpdateBreadCrumbsBar(item);
        }
Exemple #18
0
        async void Update(object sender, EventArgs e)
        {
            CancellationHelper.CancelAndDispose(ref _cancellationSource, true);
            var cs = _cancellationSource;

            if (cs != null)
            {
                try {
                    await Update(cs.Token);
                }
                catch (OperationCanceledException) {
                    // ignore
                }
            }
            async Task Update(CancellationToken token)
            {
                var nodes = await UpdateModelAsync(token);

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(token);

                var c = Math.Min(Items.Count, nodes.Count);
                int i, i2;

                for (i = 1, i2 = 0; i < c && i2 < c; i2++)
                {
                    var n = nodes[i2];
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }
                    var n2 = (Items[i] as NaviItem).Node;
                    if (n2 == n)
                    {
                        // keep the NaviItem if node is not updated
                        ++i;
                        continue;
                    }
                    if (n.IsKind(SyntaxKind.NamespaceDeclaration))
                    {
                        continue;
                    }
                    break;
                }
                if ((i == 1 || i2 < nodes.Count && nodes[i2].IsTypeOrNamespaceDeclaration()) && _RootItem.FilterText.Length == 0)
                {
                    // clear type and namespace menu items if a type is changed
                    _RootItem.ClearItems();
                }
                c = Items.Count;
                while (c > i)
                {
                    Items.RemoveAt(--c);
                }
                c = nodes.Count;
                while (i2 < c)
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }
                    var node = nodes[i2];
                    if (node.IsKind(SyntaxKind.NamespaceDeclaration))
                    {
                        _RootItem.SetText(node.GetDeclarationSignature());
                        ++i2;
                        continue;
                    }
                    bool highlight = node.IsMemberDeclaration();
                    var  newItem   = new NaviItem(this, node, highlight, false);
                    if (highlight)
                    {
                        newItem.IsChecked = true;
                    }
                    Items.Add(newItem);
                    ++i2;
                }
            }
        }
Exemple #19
0
 public static NaviItem SetNavigationBarStyle(this NaviItem item)
 {
     item.Style = ThemeConstants.NaviItem.Styles.NavigationBar;
     return(item);
 }
Exemple #20
0
 public static void SetNavigationBar(this NaviItem item, EvasObject content, bool preserveOldContent = false)
 {
     item.SetPartContent(ThemeConstants.NaviItem.Parts.NavigationBar, content, preserveOldContent);
 }
Exemple #21
0
 public static void SetRightToolbarButton(this NaviItem item, EvasObject content, bool preserveOldContent = false)
 {
     item.SetPartContent(ThemeConstants.NaviItem.Parts.RightToolbarButton, content, preserveOldContent);
 }
Exemple #22
0
 public static void SetTitle(this NaviItem item, string text)
 {
     item.SetPartText(ThemeConstants.NaviItem.Parts.Title, text);
 }
 void UpdateBarBackgroundColor(NaviItem item)
 {
     item.TitleBarBackgroundColor = Element.BarBackgroundColor.ToPlatformEFL();
 }
Exemple #24
0
        Widget CreatePage(Window win, string pageName)
        {
            Box box = new Box(win);

            ((IAccessibleObject)box).Name = pageName;

            box.Show();

            Button abutton = new Button(win)
            {
                Text       = "Accessibility-normal",
                WeightX    = 1,
                AlignmentX = -1
            };

            ((IAccessibleObject)abutton).TranslationDomain = "kr";
            ((IAccessibleObject)abutton).Name        = "Accessibility";
            ((IAccessibleObject)abutton).Description = "Description for Accessibility";

            Label abutton_label = new Label(win)
            {
                WeightX    = 1,
                AlignmentX = -1
            };

            abutton_label.Text =
                "domain : " + ((IAccessibleObject)abutton).TranslationDomain +
                ", name : " + ((IAccessibleObject)abutton).Name +
                ", desc : " + ((IAccessibleObject)abutton).Description;

            Button bbutton = new Button(win)
            {
                Text       = "Accessibility-provider",
                WeightX    = 1,
                AlignmentX = -1
            };

            ((IAccessibleObject)bbutton).NameProvider        = (obj) => "Name-provider";
            ((IAccessibleObject)bbutton).DescriptionProvider = (obj) => "Description-provider";

            Label bbutton_label = new Label(win)
            {
                WeightX    = 1,
                AlignmentX = -1
            };

            bbutton_label.Text =
                "name : " + ((IAccessibleObject)bbutton).Name +
                ", desc : " + ((IAccessibleObject)bbutton).Description;

            Button cbutton = new Button(win)
            {
                Text       = "Readingtype,CanHighlight",
                WeightX    = 1,
                AlignmentX = -1
            };

            ((IAccessibleObject)cbutton).ReadingInfoType =
                ReadingInfoType.Name | ReadingInfoType.Role | ReadingInfoType.Description;
            ((IAccessibleObject)cbutton).Name        = "FooFoo";
            ((IAccessibleObject)cbutton).Role        = AccessRole.Text;
            ((IAccessibleObject)cbutton).Description = "FooFooButton";
            Label name_onoff_label = new Label(win)
            {
                Text = "ReadingInfoType.Name : " +
                       ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Name) != 0 ? "on" : "off"),
                WeightX    = 1,
                AlignmentX = -1
            };
            Label role_onoff_label = new Label(win)
            {
                Text = "ReadingInfoType.Role : " +
                       ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Role) != 0 ? "on" : "off"),
                WeightX    = 1,
                AlignmentX = -1
            };
            Label description_onoff_label = new Label(win)
            {
                Text = "ReadingInfoType.Description : " +
                       ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Description) != 0 ? "on" : "off"),
                WeightX    = 1,
                AlignmentX = -1
            };
            Label state_onoff_label = new Label(win)
            {
                Text = "ReadingInfoType.State : " +
                       ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.State) != 0 ? "on" : "off"),
                WeightX    = 1,
                AlignmentX = -1
            };

            Button saybutton = new Button(win)
            {
                Text       = "HHGG with false",
                WeightX    = 1,
                AlignmentX = -1
            };

            Button saybutton2 = new Button(win)
            {
                Text       = "HHGG with true",
                WeightX    = 1,
                AlignmentX = -1
            };

            int    labelIndex = 0;
            Button roleButton = new Button(win)
            {
                WeightX    = 1,
                AlignmentX = -1
            };

            roleButton.Clicked += (s, e) =>
            {
                if (labelIndex >= accessRoleValues.Length)
                {
                    labelIndex = 0;
                }

                IAccessibleObject obj  = roleButton as IAccessibleObject;
                AccessRole        role = (AccessRole)accessRoleValues.GetValue(labelIndex);
                obj.Role        = role;
                roleButton.Text = Enum.GetName(typeof(AccessRole), obj.Role);

                labelIndex++;
            };

            Label label = new Label(win)
            {
                Text       = string.Format("{0} Apple", sequence++),
                WeightX    = 1,
                AlignmentX = -1
            };

            ((IAccessibleObject)label).Name = "Apple";

            Button push = new Button(win)
            {
                Text       = "Push",
                WeightX    = 1,
                AlignmentX = -1
            };

            ((IAccessibleObject)push).Name = "PushButton";

            Button pop = new Button(win)
            {
                Text       = "pop",
                WeightX    = 1,
                AlignmentX = -1,
            };

            ((IAccessibleObject)pop).Name = "PopButton";

            abutton.Show();
            abutton_label.Show();
            bbutton.Show();
            bbutton_label.Show();
            cbutton.Show();
            name_onoff_label.Show();
            role_onoff_label.Show();
            description_onoff_label.Show();
            state_onoff_label.Show();
            saybutton.Show();
            saybutton2.Show();
            roleButton.Show();
            label.Show();
            push.Show();
            pop.Show();

            push.Clicked += (s, e) =>
            {
                NaviItem item = navi.Push(CreatePage(win, string.Format("Apple {0}", sequence - 1)), string.Format("Page {0}", sequence - 1));
            };

            Label statusLog = new Label(win)
            {
                WeightX    = 1,
                AlignmentX = -1
            };

            statusLog.Show();

            saybutton.Clicked += (s, e) =>
            {
                AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", false)
                .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); });
            };
            saybutton2.Clicked += (s, e) =>
            {
                AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", true)
                .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); });
            };

            pop.Clicked += (s, e) =>
            {
                var item = navi.NavigationStack.LastOrDefault();
                navi.Pop();
            };

            box.PackEnd(abutton);
            box.PackEnd(abutton_label);
            box.PackEnd(bbutton);
            box.PackEnd(bbutton_label);
            box.PackEnd(cbutton);
            box.PackEnd(name_onoff_label);
            box.PackEnd(role_onoff_label);
            box.PackEnd(description_onoff_label);
            box.PackEnd(state_onoff_label);
            box.PackEnd(saybutton);
            box.PackEnd(saybutton2);
            box.PackEnd(roleButton);
            box.PackEnd(label);
            box.PackEnd(push);
            box.PackEnd(pop);
            box.PackEnd(statusLog);

            return(box);
        }
 void UpdateBarBackgroundColor(NaviItem item)
 {
     item.TitleBarBackgroundColor = Element.BarBackgroundColor.ToNative();
 }