Exemplo n.º 1
0
        public Scenario3()
        {
            this.InitializeComponent();

            // Retrieve information about whether or not a keyboard is present
            Windows.Devices.Input.KeyboardCapabilities kbdCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
            keyboardText.Text = "Keyboard present = " + kbdCapabilities.KeyboardPresent.ToString();

            // Retrieve information about the capabilities of the device's mouse.  This includes:
            // - Whether or not a mouse is present
            // - The number of buttons on the mouse
            // - Whether or not the mouse has a vertical scroll wheel
            // - Whether or not the mouse has a horizontal scroll wheel
            // - Whether or not the user has elected to swap the mouse buttons, causing
            //   the right mouse button to be the primary button
            Windows.Devices.Input.MouseCapabilities mouseCapabilities = new Windows.Devices.Input.MouseCapabilities();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Mouse present = " + mouseCapabilities.MousePresent.ToString() + "\n");
            sb.Append("Number of buttons = " + mouseCapabilities.NumberOfButtons.ToString() + "\n");
            sb.Append("Vertical wheel present = " + mouseCapabilities.VerticalWheelPresent.ToString() + "\n");
            sb.Append("Horizontal wheel present = " + mouseCapabilities.HorizontalWheelPresent.ToString() + "\n");
            sb.Append("Buttons swapped = " + mouseCapabilities.SwapButtons.ToString());
            mouseText.Text = sb.ToString();

            // Retrieve information about the capabilities of the device's mouse.  This includes:
            // - Whether or not the device supports touch
            // - The supported number of simultaneous touch contacts
            Windows.Devices.Input.TouchCapabilities touchCapabilities = new Windows.Devices.Input.TouchCapabilities();
            sb = new System.Text.StringBuilder();
            sb.Append("Touch present = " + touchCapabilities.TouchPresent.ToString() + "\n");
            sb.Append("Touch contacts supported = " + touchCapabilities.Contacts.ToString());
            touchText.Text = sb.ToString();
        }
Exemplo n.º 2
0
        internal void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                // There does not appear to be a way of finding out if a touch device supports pressure.
                // XNA does not expose a pressure value, so let's assume it doesn't support it.
                hasPressure = false;

#if WINDOWS_STOREAPP
                // Is a touch device present?
                var caps = new Windows.Devices.Input.TouchCapabilities();
                isConnected = caps.TouchPresent != 0;

                // Iterate through all pointer devices and find the maximum number of concurrent touches possible
                maximumTouchCount = 0;
                var pointerDevices = Windows.Devices.Input.PointerDevice.GetPointerDevices();
                foreach (var pointerDevice in pointerDevices)
                    maximumTouchCount = Math.Max(maximumTouchCount, (int)pointerDevice.MaxContacts);
#else
		        isConnected = true;
		        maximumTouchCount = 8;
#endif
            }
		}
        public Scenario3()
        {
            this.InitializeComponent();

            // Retrieve information about whether or not a keyboard is present
            Windows.Devices.Input.KeyboardCapabilities kbdCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
            keyboardText.Text = "Keyboard present = " + kbdCapabilities.KeyboardPresent.ToString();

            // Retrieve information about the capabilities of the device's mouse.  This includes:
            // - Whether or not a mouse is present
            // - The number of buttons on the mouse
            // - Whether or not the mouse has a vertical scroll wheel
            // - Whether or not the mouse has a horizontal scroll wheel
            // - Whether or not the user has elected to swap the mouse buttons, causing
            //   the right mouse button to be the primary button
            Windows.Devices.Input.MouseCapabilities mouseCapabilities = new Windows.Devices.Input.MouseCapabilities();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Mouse present = " + mouseCapabilities.MousePresent.ToString() + "\n");
            sb.Append("Number of buttons = " + mouseCapabilities.NumberOfButtons.ToString() + "\n");
            sb.Append("Vertical wheel present = " + mouseCapabilities.VerticalWheelPresent.ToString() + "\n");
            sb.Append("Horizontal wheel present = " + mouseCapabilities.HorizontalWheelPresent.ToString() + "\n");
            sb.Append("Buttons swapped = " + mouseCapabilities.SwapButtons.ToString());
            mouseText.Text = sb.ToString();

            // Retrieve information about the capabilities of the device's mouse.  This includes:
            // - Whether or not the device supports touch
            // - The supported number of simultaneous touch contacts
            Windows.Devices.Input.TouchCapabilities touchCapabilities = new Windows.Devices.Input.TouchCapabilities();
            sb = new System.Text.StringBuilder();
            sb.Append("Touch present = " + touchCapabilities.TouchPresent.ToString() + "\n");
            sb.Append("Touch contacts supported = " + touchCapabilities.Contacts.ToString());
            touchText.Text = sb.ToString();
        }
Exemplo n.º 4
0
        internal void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                // There does not appear to be a way of finding out if a touch device supports pressure.
                // XNA does not expose a pressure value, so let's assume it doesn't support it.
                hasPressure = false;

#if WINRT
                // Is a touch device present?
                var caps = new Windows.Devices.Input.TouchCapabilities();
                isConnected = caps.TouchPresent != 0;

                // Iterate through all pointer devices and find the maximum number of concurrent touches possible
                maximumTouchCount = 0;
                var pointerDevices = Windows.Devices.Input.PointerDevice.GetPointerDevices();
                foreach (var pointerDevice in pointerDevices)
                {
                    maximumTouchCount = Math.Max(maximumTouchCount, (int)pointerDevice.MaxContacts);
                }
#else
                isConnected       = true;
                maximumTouchCount = 8;
#endif
            }
        }
        static string ConstructUserAgent()
        {
            // unfortunately, there isn't much info we can get from Windows 8 Store apps
            Windows.Devices.Input.TouchCapabilities tc = new Windows.Devices.Input.TouchCapabilities();
            var hasTouch = tc.TouchPresent > 0;

            return(string.Format("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0{0})", hasTouch ? "; Touch" : ""));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string Buffer;
            Windows.Devices.Input.TouchCapabilities TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();

            Buffer = string.Format("There is {0} digitizer present\n", TouchCapabilities.TouchPresent != 0 ? "a" : "no");
            Buffer += string.Format("The digitizer supports {0} contacts\n", TouchCapabilities.Contacts);

            TouchOutputTextBlock.Text = Buffer;
        }
Exemplo n.º 7
0
        internal void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                // There does not appear to be a way of finding out if a touch device supports pressure.
                // XNA does not expose a pressure value, so let's assume it doesn't support it.
                hasPressure = false;

#if WINDOWS_STOREAPP
                // Is a touch device present?
                var caps = new Windows.Devices.Input.TouchCapabilities();
                isConnected = caps.TouchPresent != 0;

                // Iterate through all pointer devices and find the maximum number of concurrent touches possible
                maximumTouchCount = 0;
                var pointerDevices = Windows.Devices.Input.PointerDevice.GetPointerDevices();
                foreach (var pointerDevice in pointerDevices)
                    maximumTouchCount = Math.Max(maximumTouchCount, (int)pointerDevice.MaxContacts);
#elif WINDOWS
                maximumTouchCount = GetSystemMetrics(SM_MAXIMUMTOUCHES);
                isConnected = (maximumTouchCount > 0);
#elif ANDROID
                // http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_TOUCHSCREEN
                var pm = Game.Activity.PackageManager;
                isConnected = pm.HasSystemFeature(PackageManager.FeatureTouchscreen);
                if (pm.HasSystemFeature(PackageManager.FeatureTouchscreenMultitouchJazzhand))
                    maximumTouchCount = 5;
                else if (pm.HasSystemFeature(PackageManager.FeatureTouchscreenMultitouchDistinct))
                    maximumTouchCount = 2;
                else
                    maximumTouchCount = 1;
#elif IOS
                //iPhone supports 5, iPad 11
                isConnected = true;
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                    maximumTouchCount = 5;
                else //Pad
                    maximumTouchCount = 11;
#elif WINDOWS_PHONE
                // There is no API on WP8, XNA returns 4 according to the docs
                // http://msdn.microsoft.com/en-nz/library/ff434208.aspx
                // http://en.wikipedia.org/wiki/Windows_Phone_8#Hardware_requirements
                isConnected = true;
                maximumTouchCount = 4;
#elif PSM
                isConnected = true;
                maximumTouchCount = 2; //TODO: This number is made up, needs to be tested on Vita
#else
                //Touch isn't implemented in OpenTK, so no linux or mac https://github.com/opentk/opentk/issues/80
                isConnected = false;
#endif
            }
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string Buffer;

            Windows.Devices.Input.TouchCapabilities TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();

            Buffer  = string.Format("There is {0} digitizer present\n", TouchCapabilities.TouchPresent != 0 ? "a" : "no");
            Buffer += string.Format("The digitizer supports {0} contacts\n", TouchCapabilities.Contacts);

            TouchOutputTextBlock.Text = Buffer;
        }
        public virtual void Initialize(DeviceManager deviceManager)
        {
            TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();

            // Initialize a TextFormat
            textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };
            textFormat2 = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center };

            sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Tomato);

            strokeProperties = new StrokeStyleProperties();
            strokeProperties.StartCap = CapStyle.Round;
            strokeProperties.EndCap = CapStyle.Round;
            strokeProperties.LineJoin = LineJoin.Round;

            strokeStyle = new StrokeStyle(deviceManager.FactoryDirect2D, strokeProperties);
        }
Exemplo n.º 10
0
        public virtual void Initialize(DeviceManager deviceManager)
        {
            TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();

            // Initialize a TextFormat
            textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20)
            {
                TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center
            };
            textFormat2 = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20)
            {
                TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center
            };

            sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Tomato);

            strokeProperties          = new StrokeStyleProperties();
            strokeProperties.StartCap = CapStyle.Round;
            strokeProperties.EndCap   = CapStyle.Round;
            strokeProperties.LineJoin = LineJoin.Round;

            strokeStyle = new StrokeStyle(deviceManager.FactoryDirect2D, strokeProperties);
        }
Exemplo n.º 11
0
        internal void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                // There does not appear to be a way of finding out if a touch device supports pressure.
                // XNA does not expose a pressure value, so let's assume it doesn't support it.
                hasPressure = false;

#if WINDOWS_STOREAPP
                // Is a touch device present?
                var caps = new Windows.Devices.Input.TouchCapabilities();
                isConnected = caps.TouchPresent != 0;

                // Iterate through all pointer devices and find the maximum number of concurrent touches possible
                maximumTouchCount = 0;
                var pointerDevices = Windows.Devices.Input.PointerDevice.GetPointerDevices();
                foreach (var pointerDevice in pointerDevices)
                {
                    maximumTouchCount = Math.Max(maximumTouchCount, (int)pointerDevice.MaxContacts);
                }
#elif WINDOWS
                maximumTouchCount = GetSystemMetrics(SM_MAXIMUMTOUCHES);
                isConnected       = (maximumTouchCount > 0);
#elif ANDROID
                // http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_TOUCHSCREEN
                var pm = Game.Activity.PackageManager;
                isConnected = pm.HasSystemFeature(PackageManager.FeatureTouchscreen);
                if (pm.HasSystemFeature(PackageManager.FeatureTouchscreenMultitouchJazzhand))
                {
                    maximumTouchCount = 5;
                }
                else if (pm.HasSystemFeature(PackageManager.FeatureTouchscreenMultitouchDistinct))
                {
                    maximumTouchCount = 2;
                }
                else
                {
                    maximumTouchCount = 1;
                }
#elif IOS
                //iPhone supports 5, iPad 11
                isConnected = true;
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    maximumTouchCount = 5;
                }
                else //Pad
                {
                    maximumTouchCount = 11;
                }
#elif WINDOWS_PHONE
                // There is no API on WP8, XNA returns 4 according to the docs
                // http://msdn.microsoft.com/en-nz/library/ff434208.aspx
                // http://en.wikipedia.org/wiki/Windows_Phone_8#Hardware_requirements
                isConnected       = true;
                maximumTouchCount = 4;
#elif PSM
                isConnected       = true;
                maximumTouchCount = 2; //TODO: This number is made up, needs to be tested on Vita
#else
                //Touch isn't implemented in OpenTK, so no linux or mac https://github.com/opentk/opentk/issues/80
                isConnected = false;
#endif
            }
        }