void OnPopRequested(object sender, NavigationRequestedEventArgs nre)
        {
            if ((Element as IPageController).InternalChildren.Count == _naviFrame.NavigationStack.Count)
            {
                UpdateNavigationBar(PreviousPage, PreviousNaviItem);

                if (nre.Animated)
                {
                    _naviFrame.Pop();

                    _currentTaskSource = new TaskCompletionSource <bool>();
                    nre.Task           = _currentTaskSource.Task;

                    // There is no TransitionFinished (AnimationFinished) event after Pop the last page
                    if (_naviFrame.NavigationStack.Count == 0)
                    {
                        CompleteCurrentNavigationTask();
                    }
                }
                else
                {
                    CurrentNaviItem?.Delete();
                }

                if (_naviItemMap.ContainsKey(nre.Page))
                {
                    _naviItemMap.Remove(nre.Page);
                }
            }
        }
Exemple #2
0
        async Task PopModalInternal(bool animated)
        {
            TaskCompletionSource <bool> tcs = null;

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

            if (animated)
            {
                _internalNaviframe.Pop();
            }
            else
            {
                _internalNaviframe.NavigationStack.LastOrDefault()?.Delete();
            }

            bool shouldWait = animated && (_internalNaviframe.NavigationStack.Count != 0);

            await WaitForCompletion(shouldWait, tcs);
        }
Exemple #3
0
        EvasObject CreatePage(Window parent)
        {
            Box box = new Box(parent);

            box.Show();

            Label label = new Label(parent)
            {
                Text       = string.Format("{0} Page", _sequence++),
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button push = new Button(parent)
            {
                Text       = "Push",
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button pop = new Button(parent)
            {
                Text       = "pop",
                WeightX    = 1,
                AlignmentX = -1,
            };

            label.Show();
            push.Show();
            pop.Show();

            push.Clicked += (s, e) =>
            {
                _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };

            pop.Clicked += (s, e) =>
            {
                var item          = _navi.NavigationStack.LastOrDefault();
                int nativePointer = (int)(IntPtr)(item.Content);
                Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer);
                _navi.Pop();
                Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer);
            };

            push.Resize(500, 100);
            pop.Resize(500, 100);
            label.Resize(500, 100);
            box.SetLayoutCallback(() =>
            {
                Console.WriteLine("Layout callback with : {0}", box.Geometry);
                var rect = box.Geometry;
                label.Move(rect.X, rect.Y);
                push.Move(rect.X, rect.Y + 100);
                pop.Move(rect.X, rect.Y + 200);
            });

            box.PackEnd(label);
            box.PackEnd(push);
            box.PackEnd(pop);
            return(box);
        }
Exemple #4
0
        void Initialize()
        {
            Forms.Init(this);

            Instance = this;
            window   = new Window("Phoneword");
            window.BackButtonPressed += (s, e) =>
            {
                if (naviFrame.NavigationStack.Count > 1)
                {
                    naviFrame.Pop();
                }
                else
                {
                    Exit();
                }
            };
            window.Show();

            var conformant = new Conformant(window);

            conformant.Show();

            naviFrame = new Naviframe(window);
            conformant.SetContent(naviFrame);
            naviFrame.Show();

            var mainPage = new PhonewordPage().CreateEvasObject(window);

            naviFrame.Push(mainPage);
        }
Exemple #5
0
        void Initialize()
        {
            var conformant = new Conformant(_mainWindow);

            conformant.Show();

            _navi = new Naviframe(_mainWindow)
            {
                PreserveContentOnPop     = true,
                DefaultBackButtonEnabled = true
            };
            _navi.Show();
            conformant.SetContent(_navi);

            var rootPage = CreateMainPage(_mainWindow);

            _navi.Push(rootPage);

            _mainWindow.BackButtonPressed += (sender, e) =>
            {
                bool handled = _currentPage?.SendBackButtonPressed() ?? false;

                if (!handled)
                {
                    if (_navi.NavigationStack.Count == 1)
                    {
                        Exit();
                    }
                    _currentPage = null;
                    _navi.Pop();
                }
            };

            _navi.Popped += (sender, e) =>
            {
                _currentPage = null;
            };
        }
Exemple #6
0
        EvasObject CreatePage(Window parent)
        {
            Table table = new Table(parent);

            table.Geometry = square;
            table.Show();

            Label label = new Label(parent)
            {
                Text            = string.Format("<span color=#000000 font_size=15>{0} Page</span>", _sequence++),
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X, square.Y, square.Width, square.Height / 9)
            };

            Button push = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>Push</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X, square.Y + square.Height / 9, square.Width / 2, square.Height / 9)
            };

            Button pop = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>pop</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9, square.Width / 2, square.Height / 9)
            };

            Button insertBeforeTop = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>insertBeforeTop</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X, square.Y + square.Height / 9 * 2, square.Width / 2, square.Height / 9)
            };

            Button insertAfterTop = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>insertAfterTop</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9 * 2, square.Width / 2, square.Height / 9)
            };

            Button removeTop = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>removeTop</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X, square.Y + square.Height / 9 * 3, square.Width, square.Height / 9)
            };

            Button barChange = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>TitleBarColor Change</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X, square.Y + square.Height / 9 * 4, square.Width / 2, square.Height / 9)
            };

            Button barColorDefault = new Button(parent)
            {
                Text            = "<span color=#000000 font_size=15>TitleBarColor - Default</span>",
                WeightX         = 1,
                AlignmentX      = -1,
                BackgroundColor = Color.Black,
                Geometry        = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9 * 4, square.Width / 2, square.Height / 9)
            };

            label.Show();
            push.Show();
            pop.Show();
            insertBeforeTop.Show();
            insertAfterTop.Show();
            removeTop.Show();
            barChange.Show();
            barColorDefault.Show();

            push.Clicked += (s, e) =>
            {
                _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };

            pop.Clicked += (s, e) =>
            {
                var item          = _navi.NavigationStack.LastOrDefault();
                int nativePointer = (int)(IntPtr)(item.Content);
                Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer);
                _navi.Pop();
                Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer);
            };

            insertBeforeTop.Clicked += (s, e) =>
            {
                _navi.InsertBefore(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };

            insertAfterTop.Clicked += (s, e) =>
            {
                _navi.InsertAfter(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };
            removeTop.Clicked += (s, e) =>
            {
                var item          = _navi.NavigationStack.LastOrDefault();
                int nativePointer = (int)(IntPtr)(item.Content);
                Console.WriteLine("----- Before Call NaviItem.Delete() {0:x} ", nativePointer);
                item.Delete();
                Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer);
            };

            Random rand = new Random(DateTime.Now.Millisecond);

            barChange.Clicked += (s, e) =>
            {
                int currentIndex = _navi.NavigationStack.Count - 1;
                if (currentIndex >= 0)
                {
                    _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next()));
                }
            };

            barColorDefault.Clicked += (s, e) =>
            {
                int currentIndex = _navi.NavigationStack.Count - 1;
                if (currentIndex >= 0)
                {
                    _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.Default;
                }
            };

            table.Pack(label, 0, 0, 1, 1);
            table.Pack(push, 0, 1, 1, 1);
            table.Pack(pop, 1, 1, 1, 1);
            table.Pack(insertBeforeTop, 0, 2, 1, 1);
            table.Pack(insertAfterTop, 1, 2, 1, 1);
            table.Pack(removeTop, 0, 3, 1, 1);
            table.Pack(barChange, 0, 4, 1, 1);
            table.Pack(barColorDefault, 1, 4, 1, 1);

            return(table);
        }
Exemple #7
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);
        }
Exemple #8
0
        EvasObject CreatePage(Window parent)
        {
            Box box = new Box(parent);

            box.Show();

            Label label = new Label(parent)
            {
                Text       = string.Format("{0} Page", _sequence++),
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button push = new Button(parent)
            {
                Text       = "Push",
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button pop = new Button(parent)
            {
                Text       = "pop",
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button insertBeforeTop = new Button(parent)
            {
                Text       = "insertBeforeTop",
                WeightX    = 1,
                AlignmentX = -1,
            };
            Button insertAfterTop = new Button(parent)
            {
                Text       = "insertAfterTop",
                WeightX    = 1,
                AlignmentX = -1,
            };

            Button removeTop = new Button(parent)
            {
                Text       = "removeTop",
                WeightX    = 1,
                AlignmentX = -1,
            };

            Button barChange = new Button(parent)
            {
                Text       = "TitleBarColor Change",
                WeightX    = 1,
                AlignmentX = -1,
            };

            Button barColorDefault = new Button(parent)
            {
                Text       = "TitleBarColor - Default",
                WeightX    = 1,
                AlignmentX = -1,
            };

            label.Show();
            push.Show();
            pop.Show();
            insertBeforeTop.Show();
            insertAfterTop.Show();
            removeTop.Show();
            barChange.Show();
            barColorDefault.Show();

            push.Clicked += (s, e) =>
            {
                _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };

            pop.Clicked += (s, e) =>
            {
                var item          = _navi.NavigationStack.LastOrDefault();
                int nativePointer = (int)(IntPtr)(item.Content);
                Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer);
                _navi.Pop();
                Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer);
            };

            insertBeforeTop.Clicked += (s, e) =>
            {
                _navi.InsertBefore(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };

            insertAfterTop.Clicked += (s, e) =>
            {
                _navi.InsertAfter(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
            };
            removeTop.Clicked += (s, e) =>
            {
                var item          = _navi.NavigationStack.LastOrDefault();
                int nativePointer = (int)(IntPtr)(item.Content);
                Console.WriteLine("----- Before Call NaviItem.Delete() {0:x} ", nativePointer);
                item.Delete();
                Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer);
            };

            Random rand = new Random(DateTime.Now.Millisecond);

            barChange.Clicked += (s, e) =>
            {
                int currentIndex = _navi.NavigationStack.Count - 1;
                if (currentIndex >= 0)
                {
                    _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next()));
                }
            };

            barColorDefault.Clicked += (s, e) =>
            {
                int currentIndex = _navi.NavigationStack.Count - 1;
                if (currentIndex >= 0)
                {
                    _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.Default;
                }
            };

            box.PackEnd(label);
            box.PackEnd(push);
            box.PackEnd(pop);
            box.PackEnd(insertBeforeTop);
            box.PackEnd(insertAfterTop);
            box.PackEnd(removeTop);
            box.PackEnd(barChange);
            box.PackEnd(barColorDefault);

            return(box);
        }