Exemplo n.º 1
0
        /// <summary>
        ///  <para>Called when the back button has been pressed for the application page this object is listening to.</para>
        ///  <para>Converts the back navigation event to a back key event that is compatible with Corona.</para>
        /// </summary>
        /// <param name="sender">The page that raised this event.</param>
        /// <param name="e">Provides a "Cancel" property that will prevent navigating back if set true.</param>
        private void OnPageNavigatingBack(Corona.WinRT.Interop.UI.IPage sender, CoronaLabs.WinRT.CancelEventArgs e)
        {
            // Do not continue if the given event was already handled/canceled.
            if (e.Cancel)
            {
                return;
            }

            // Create event arguments for a "back" key.
            var keyEventArgs = CreateKeyEventFor(Corona.WinRT.Interop.Input.Key.Back);

            // Raise a key down event.
            if (this.ReceivedKeyDown != null)
            {
                this.ReceivedKeyDown(this, keyEventArgs);
                if (keyEventArgs.Handled)
                {
                    e.Cancel = true;
                    return;
                }
            }

            // Raise a key up event.
            if (this.ReceivedKeyUp != null)
            {
                this.ReceivedKeyUp(this, keyEventArgs);
                if (keyEventArgs.Handled)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  <para>Called when the page that is hosting the rendering surface has changed orientations.</para>
        ///  <para>Raises a "Resized" event if the orientation has changed from portrait to landscape or vice-versa.</para>
        /// </summary>
        /// <param name="sender">The page that raised this event.</param>
        /// <param name="e">Event arguments providing the new page orientation.</param>
        private void OnOrientationChanged(
            Corona.WinRT.Interop.UI.IPage sender, Corona.WinRT.Interop.UI.PageOrientationEventArgs e)
        {
            // Do not continue if the orientation has not changed.
            // Note: This can happen if this adapter was once given a different page reference.
            if (fLastReceivedOrientation == e.Orientation)
            {
                return;
            }

            // Raise a "Resized" event if the orientation has changed from portrait to landscape or vice-versa.
            // This is because this adapter provides the surface width and height relative to the app's orientation.
            bool wasResized =
                (fLastReceivedOrientation == Corona.WinRT.Interop.UI.PageOrientation.Unknown) ||
                (e.Orientation == Corona.WinRT.Interop.UI.PageOrientation.Unknown) ||
                (fLastReceivedOrientation.IsLandscape != e.Orientation.IsLandscape);

            fLastReceivedOrientation = e.Orientation;
            if (wasResized && (this.Resized != null))
            {
                this.Resized(this, CoronaLabs.WinRT.EmptyEventArgs.Instance);
            }
        }