コード例 #1
0
            /**
             * 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);
                }
            }
コード例 #2
0
            /**
             * 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);
                }
            }
コード例 #3
0
            /**
             * 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);
                    });
                }
            }
コード例 #4
0
            /**
             * Applies transition to the current content and calls the given delegate in a specific moment
             * (before/after animation) in order to distingues between transition applied on the current
             * "page/screen" or the next.
             *
             * @param aDelegate a delegate invoked in different moments, depending on the transition type.
             * The delegate must be responsible for switching screens/context/adding children widgets.
             * @param transitionType a transition type.
             */
            public static void doScreenTransition(Delegate_SwitchContentDelegate aDelegate, int transitionType)
            {
                if (null != aDelegate)
                {
                    TransitionElement transition = null;
                    bool doTransitionOnCurrentScreen = false;
                    switch (transitionType)
                    {
                        case MoSync.Constants.MAW_TRANSITION_TYPE_SLIDE_RIGHT:
                             transition = new SlideTransition();
                            (transition as SlideTransition).Mode = SlideTransitionMode.SlideRightFadeIn;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_SLIDE_LEFT:
                            transition = new SlideTransition();
                            (transition as SlideTransition).Mode = SlideTransitionMode.SlideLeftFadeIn;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_SWIVEL_IN:
                            transition = new SwivelTransition();
                            (transition as SwivelTransition).Mode = SwivelTransitionMode.FullScreenIn;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_SWIVEL_OUT:
                            transition = new SwivelTransition();
                            (transition as SwivelTransition).Mode = SwivelTransitionMode.FullScreenOut;
                            doTransitionOnCurrentScreen = true;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_TURNSTILE_FOREWARD:
                            transition = new TurnstileTransition();
                            (transition as TurnstileTransition).Mode = TurnstileTransitionMode.ForwardOut;
                            doTransitionOnCurrentScreen = true;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_TURNSTILE_BACKWARD:
                            transition = new TurnstileTransition();
                            (transition as TurnstileTransition).Mode = TurnstileTransitionMode.BackwardIn;
                            break;
                        case MoSync.Constants.MAW_TRANSITION_TYPE_NONE:
                        default:
                            aDelegate();
                            return;
                    }
                    PhoneApplicationPage page = (PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content;

                    ITransition transInterf = transition.GetTransition(page);
                    transInterf.Completed += delegate
                    {
                        transInterf.Stop();
                        if (doTransitionOnCurrentScreen)
                        {
                            aDelegate();
                        }
                    };
                    transInterf.Begin();
                    if (!doTransitionOnCurrentScreen)
                    {
                        aDelegate();
                    }
                }
            }
コード例 #5
0
ファイル: MoSyncScreen.cs プロジェクト: andersmalm/MoSync
 /**
  * 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);
     });
 }
コード例 #6
0
            /**
             * 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);
                }
            }
コード例 #7
0
ファイル: MoSyncScreen.cs プロジェクト: milesm/MoSync
 /**
  * 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);
     });
 }
コード例 #8
0
            /**
             * 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);
                }
            }
コード例 #9
0
            /**
             * 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);
                    });
                }
            }
コード例 #10
0
            /**
             * Applies transition to the current content and calls the given delegate in a specific moment
             * (before/after animation) in order to distingues between transition applied on the current
             * "page/screen" or the next.
             *
             * @param aDelegate a delegate invoked in different moments, depending on the transition type.
             * The delegate must be responsible for switching screens/context/adding children widgets.
             * @param transitionType a transition type.
             */
            static public void doScreenTransition(Delegate_SwitchContentDelegate aDelegate, int transitionType)
            {
                if (null != aDelegate)
                {
                    TransitionElement transition     = null;
                    bool doTransitionOnCurrentScreen = false;
                    switch (transitionType)
                    {
                    case MoSync.Constants.MAW_TRANSITION_TYPE_SLIDE_RIGHT:
                        transition = new SlideTransition();
                        (transition as SlideTransition).Mode = SlideTransitionMode.SlideRightFadeIn;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_SLIDE_LEFT:
                        transition = new SlideTransition();
                        (transition as SlideTransition).Mode = SlideTransitionMode.SlideLeftFadeIn;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_SWIVEL_IN:
                        transition = new SwivelTransition();
                        (transition as SwivelTransition).Mode = SwivelTransitionMode.FullScreenIn;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_SWIVEL_OUT:
                        transition = new SwivelTransition();
                        (transition as SwivelTransition).Mode = SwivelTransitionMode.FullScreenOut;
                        doTransitionOnCurrentScreen           = true;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_TURNSTILE_FOREWARD:
                        transition = new TurnstileTransition();
                        (transition as TurnstileTransition).Mode = TurnstileTransitionMode.ForwardOut;
                        doTransitionOnCurrentScreen = true;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_TURNSTILE_BACKWARD:
                        transition = new TurnstileTransition();
                        (transition as TurnstileTransition).Mode = TurnstileTransitionMode.BackwardIn;
                        break;

                    case MoSync.Constants.MAW_TRANSITION_TYPE_NONE:
                    default:
                        aDelegate();
                        return;
                    }
                    PhoneApplicationPage page = (PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content;

                    ITransition transInterf = transition.GetTransition(page);
                    transInterf.Completed += delegate
                    {
                        transInterf.Stop();
                        if (doTransitionOnCurrentScreen)
                        {
                            aDelegate();
                        }
                    };
                    transInterf.Begin();
                    if (!doTransitionOnCurrentScreen)
                    {
                        aDelegate();
                    }
                }
            }