/** * Override the AddChild function */ public override void AddChild(IWidget child) { if (child is Screen) { MoSync.Util.RunActionOnMainThreadSync(() => { mAddChildDelegate = delegate() { if (mPage.Children.Count > 0) { mPage.Children.RemoveAt(mPage.Children.Count - 1); } mPage.Children.Add((child as Screen).View); Grid.SetColumn(mPage.Children[mPage.Children.Count - 1] as Grid, 0); Grid.SetRow(mPage.Children[mPage.Children.Count - 1] as Grid, 0); ToggleApplicationBar((child as Screen)); }; MoSyncScreenTransitions.doScreenTransition(mAddChildDelegate, mPushTransitionType); }); /** * Manualy add the child to the children array */ mChildren.Add(child); (child as Screen).SetParent(this); } }
/** * The pop implementation */ public void Pop() { PostPopEvent(); /** * If the stack is not empty show the top element of the stack */ if (0 < mStack.Count) { MoSync.Util.RunActionOnMainThreadSync(() => { mAddChildDelegate = delegate() { if (mPage.Children.Count > 0) { mPage.Children.RemoveAt(mPage.Children.Count - 1); } mPage.Children.Add((mStack.Peek() as Screen).View); Grid.SetColumn(mPage.Children[mPage.Children.Count - 1] as Grid, 0); Grid.SetRow(mPage.Children[mPage.Children.Count - 1] as Grid, 0); ToggleApplicationBar((mStack.Peek() as Screen)); }; MoSyncScreenTransitions.doScreenTransition(mAddChildDelegate, mPopTransitionType); }); } }
/** * ShowWithTansition function implementation. Shows next screen with transitions. * * @param screenTransitionType a transition type. */ public void ShowWithTransition(int screenTransitionType) { MoSync.Util.RunActionOnMainThreadSync(() => { PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual; //If the application bar visibility flag is set on true then the application bar is //ready to be shown. if (GetApplicationBarVisibility()) { //Sets the application bar for the mainPage.xaml to our custom application bar. (frame.Content as PhoneApplicationPage).ApplicationBar = mApplicationBar; } mSwitchContentDelegate = delegate() { //Sets the content of the mainPage.xaml as our screen content. (frame.Content as PhoneApplicationPage).Content = mPage; }; MoSyncScreenTransitions.doScreenTransition(mSwitchContentDelegate, screenTransitionType); }); }
/** * The pop from back call implementation */ public void PopFromBackButtonPressed() { postPopEvent(); /** * If the stack is not empty show the top element of the stack */ if (0 < mStack.Count) { mAddChildDelegate = delegate() { if (mPage.Children.Count > 0) { mPage.Children.RemoveAt(mPage.Children.Count - 1); } mPage.Children.Add((mStack.Peek() as Screen).View); Grid.SetColumn(mPage.Children[mPage.Children.Count - 1] as Grid, 0); Grid.SetRow(mPage.Children[mPage.Children.Count - 1] as Grid, 0); ToggleApplicationBar((mStack.Peek() as Screen)); }; MoSyncScreenTransitions.doScreenTransition(mAddChildDelegate, mPopTransitionType); } }