示例#1
0
        /// <summary>
        ///
        /// </summary>
        public DeviceGestureService()
        {
            IsHardwareBackButtonPresent   = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed");
            IsHardwareCameraButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "CameraPressed");

            IsKeyboardPresent = new KeyboardCapabilities().KeyboardPresent != 0;
            IsMousePresent    = new MouseCapabilities().MousePresent != 0;
            IsTouchPresent    = new TouchCapabilities().TouchPresent != 0;

            if (IsHardwareBackButtonPresent)
            {
                HardwareButtons.BackPressed += OnHardwareButtonsBackPressed;
            }

            if (IsHardwareCameraButtonPresent)
            {
                HardwareButtons.CameraHalfPressed += OnHardwareButtonCameraHalfPressed;
                HardwareButtons.CameraPressed     += OnHardwareButtonCameraPressed;
                HardwareButtons.CameraReleased    += OnHardwareButtonCameraReleased;
            }

            if (IsMousePresent)
            {
                MouseDevice.GetForCurrentView().MouseMoved += OnMouseMoved;
            }

            SystemNavigationManager.GetForCurrentView().BackRequested += OnSystemNavigationManagerBackRequested;

            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated;

            Window.Current.CoreWindow.PointerPressed += OnPointerPressed;
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        public DeviceGestureService()
        {
            IsHardwareBackButtonPresent   = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed");
            IsHardwareCameraButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "CameraPressed");

            IsKeyboardPresent = new KeyboardCapabilities().KeyboardPresent != 0;
            IsMousePresent    = new MouseCapabilities().MousePresent != 0;
            IsTouchPresent    = new TouchCapabilities().TouchPresent != 0;
        }
示例#3
0
        public ForumTopicPage()
        {
            this.InitializeComponent();
            ViewModel.ScrollInfoProvider = this;
            ViewModel.RequestScroll     += ViewModelOnRequestScroll;
            var touchCapabilities = new TouchCapabilities();

            OccludingRectanglesVisibility = touchCapabilities.TouchPresent != 0
                ? Visibility.Visible
                : Visibility.Collapsed;
        }
        private void ListView_Loaded(object sender, RoutedEventArgs e)
        {
            //not working, always null

            //_scrollViewer = ListView.GetVisualDescendents().OfType<ScrollViewer>().FirstOrDefault();
            //if (_scrollViewer != null)
            //    _scrollViewer.ViewChanged += ScrollViewer_ViewChanged;

            var touchCapabilities = new TouchCapabilities();

            _supportsTouch = touchCapabilities.TouchPresent > 0 || DeviceHelper.IsMobile(); //on the emulator TouchCapabilities doesn't work correctly

            if (!_supportsTouch)
            {
                ScrollViewer.SetHorizontalScrollMode(ListView, ScrollMode.Disabled);
            }
        }
示例#5
0
        private void HandleTouchDetailsClick(Object sender, RoutedEventArgs e)
        {
            var    capabilities = new TouchCapabilities();
            String message;

            if (capabilities.TouchPresent == 1)
            {
                var rawMessage =
                    "Touch support is available.  " +
                    "Up to {0} touch points are supported.";

                message = String.Format(rawMessage, capabilities.Contacts);
            }
            else
            {
                message = "Touch support is not available.";
            }
            ShowMessage(message, "Touch Properties");
        }
示例#6
0
        public static async Task <string> Dump(Exception e, bool shouldDumpCompleteDeviceInfos = false)
        {
            var builder   = new StringBuilder();
            var packageId = Package.Current.Id;
            var clientDeviceInformation = new EasClientDeviceInformation();
            var displayInformation      = DisplayInformation.GetForCurrentView();
            var touchCapabilities       = new TouchCapabilities();

            builder.AppendLine("***** Diagnositic Information *****");
            builder.AppendLine();
#if DEBUG
            builder.AppendLine("DEBUG");
            builder.AppendLine();
#endif
            builder.AppendLine("Video Diary Exception");
            builder.AppendLine();
            builder.AppendFormat(e.Message);
            builder.AppendLine();
            builder.AppendLine();

            builder.AppendFormat("Time: {0}", DateTime.Now.ToUniversalTime().ToString("r"));
            builder.AppendLine();
            builder.AppendFormat("App Name: {0}", packageId.Name);
            builder.AppendLine();
            builder.AppendFormat("App Version: {0}.{1}.{2}.{3}", packageId.Version.Major, packageId.Version.Minor, packageId.Version.Build, packageId.Version.Revision);
            builder.AppendLine();
            builder.AppendFormat("App Publisher: {0}", packageId.Publisher);
            builder.AppendLine();
            builder.AppendFormat("Supported Package Architecture: {0}", packageId.Architecture);
            builder.AppendLine();
            builder.AppendFormat("Store App Id: {0}", CurrentApp.AppId);
            builder.AppendLine();
            builder.AppendFormat("Culture: {0}", CultureInfo.CurrentCulture);
            builder.AppendLine();
            builder.AppendFormat("OS: {0}", clientDeviceInformation.OperatingSystem);
            builder.AppendLine();
            builder.AppendFormat("System Manufacturer: {0}", clientDeviceInformation.SystemManufacturer);
            builder.AppendLine();
            builder.AppendFormat("System Product Name: {0}", clientDeviceInformation.SystemProductName);
            builder.AppendLine();
            builder.AppendFormat("Friendly System Name: {0}", clientDeviceInformation.FriendlyName);
            builder.AppendLine();
            builder.AppendFormat("Friendly System ID: {0}", clientDeviceInformation.Id);
            builder.AppendLine();
            builder.AppendFormat("Current Memory Usage: {0:f3} MB", GC.GetTotalMemory(false) / 1024f / 1024f);
            builder.AppendLine();
            builder.AppendFormat("Window Bounds w x h: {0} x {1}", Window.Current.Bounds.Width, Window.Current.Bounds.Height);
            builder.AppendLine();
            builder.AppendFormat("Logical DPI: {0}", displayInformation.LogicalDpi);
            builder.AppendLine();
            builder.AppendFormat("Resolution Scale: {0}", displayInformation.ResolutionScale);
            builder.AppendLine();
            builder.AppendFormat("Current Orientation: {0}", displayInformation.CurrentOrientation);
            builder.AppendLine();
            builder.AppendFormat("Native Orientation: {0}", displayInformation.NativeOrientation);
            builder.AppendLine();
            builder.AppendFormat("Is Stereo Enabled: {0}", displayInformation.StereoEnabled);
            builder.AppendLine();
            builder.AppendFormat("Supports Keyboard: {0}", new KeyboardCapabilities().KeyboardPresent == 1);
            builder.AppendLine();
            builder.AppendFormat("Supports Mouse: {0}", new MouseCapabilities().MousePresent == 1);
            builder.AppendLine();
            builder.AppendFormat("Supports Touch (contacts): {0} ({1})", touchCapabilities.TouchPresent == 1, touchCapabilities.Contacts);
            builder.AppendLine();
            builder.AppendFormat("Is Network Available: {0}", NetworkInterface.GetIsNetworkAvailable());
            builder.AppendLine();
            builder.AppendFormat("Is Internet Connection Available: {0}", NetworkInformation.GetInternetConnectionProfile() != null);
            builder.AppendLine();

#if DEBUG
            builder.AppendFormat("Installed Location: {0}", Package.Current.InstalledLocation.Path);
            builder.AppendLine();
            builder.AppendFormat("App Temp  Folder: {0}", ApplicationData.Current.TemporaryFolder.Path);
            builder.AppendLine();
            builder.AppendFormat("App Local Folder: {0}", ApplicationData.Current.LocalFolder.Path);
            builder.AppendLine();
            builder.AppendFormat("App Roam  Folder: {0}", ApplicationData.Current.RoamingFolder.Path);
            builder.AppendLine();
            builder.AppendLine();

            builder.AppendFormat("Network Host Names: ");
            foreach (var hostName in NetworkInformation.GetHostNames())
            {
                builder.AppendFormat("{0} ({1}), ", hostName.DisplayName, hostName.Type);
            }

            if (shouldDumpCompleteDeviceInfos)
            {
                var devInfos = await DeviceInformation.FindAllAsync();

                builder.AppendLine();
                builder.AppendLine("Complete Device Infos:");
                foreach (var devInfo in devInfos)
                {
                    builder.AppendFormat("Name: {0} Id: {1} - Properties: ", devInfo.Name, devInfo.Id);
                    foreach (var pair in devInfo.Properties)
                    {
                        builder.AppendFormat("{0} = {1}, ", pair.Key, pair.Value);
                    }
                    builder.AppendLine();
                }
            }
#endif

            return(builder.ToString());
        }
示例#7
0
        public static async Task <string> DumpAsync(Exception e, bool shouldDumpCompleteDeviceInfos = false)
        {
            var builder = new StringBuilder();
            var clientDeviceInformation = new EasClientDeviceInformation();
            var displayInformation      = DisplayInformation.GetForCurrentView();
            var touchCapabilities       = new TouchCapabilities();

            builder.AppendLine("***** Diagnostic Information *****\r\n\n");
#if DEBUG
            builder.AppendLine("DEBUG\r\n");
#endif
            builder.AppendLine("MVP Companion Exception\r\n");
            builder.AppendFormat(e.Message + $"{e.Message}");

            builder.AppendFormat($"Time: {DateTime.Now.ToUniversalTime():r}\r\n");
            builder.AppendFormat($"App Name: MVP Companion for Windows\r\n");
            builder.AppendFormat($"App Version: {Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString()}\r\n");
            builder.AppendFormat($"Store App Id: {CurrentApp.AppId}\r\n");
            builder.AppendFormat($"Culture: {CultureInfo.CurrentCulture}\r\n");
            builder.AppendFormat($"OS: {clientDeviceInformation.OperatingSystem}\r\n");
            builder.AppendFormat($"System Manufacturer: {clientDeviceInformation.SystemManufacturer}\r\n");
            builder.AppendFormat($"System Product Name: {clientDeviceInformation.SystemProductName}\r\n");
            builder.AppendFormat($"Friendly System Name: {clientDeviceInformation.FriendlyName}\r\n");
            builder.AppendFormat($"Friendly System ID: {clientDeviceInformation.Id}\r\n");
            builder.AppendFormat($"Current Memory Usage: {GC.GetTotalMemory(false) / 1024f / 1024f:f3} MB\r\n");
            builder.AppendFormat($"Window Bounds: {App.Current.MainWindow.Width} x {App.Current.MainWindow.Height}\r\n");
            builder.AppendFormat($"Logical DPI: {displayInformation.LogicalDpi}\r\n");
            builder.AppendFormat($"Resolution Scale: {displayInformation.ResolutionScale}\r\n");
            builder.AppendFormat($"Current Orientation: {displayInformation.CurrentOrientation}\r\n");
            builder.AppendFormat($"Native Orientation: {displayInformation.NativeOrientation}\r\n");
            builder.AppendFormat($"Is Stereo Enabled: {displayInformation.StereoEnabled}\r\n");
            builder.AppendFormat($"Supports Keyboard: {new KeyboardCapabilities().KeyboardPresent == 1}\r\n");
            builder.AppendFormat($"Supports Mouse: {new MouseCapabilities().MousePresent == 1}\r\n");
            builder.AppendFormat($"Supports Touch (contacts): {touchCapabilities.TouchPresent == 1} ({touchCapabilities.Contacts})\r\n");
            builder.AppendFormat($"Is Network Available: {NetworkInterface.GetIsNetworkAvailable()}\r\n");
            builder.AppendFormat($"Is Internet Connection Available: {NetworkInformation.GetInternetConnectionProfile() != null}\r\n");

            if (shouldDumpCompleteDeviceInfos)
            {
                builder.AppendFormat($"App Temp  Folder: {ApplicationData.Current.TemporaryFolder.Path}\r\n");
                builder.AppendFormat($"App Local Folder: {ApplicationData.Current.LocalFolder.Path}\r\n");
                builder.AppendFormat($"App Roam  Folder: {ApplicationData.Current.RoamingFolder.Path}\r\n\n");

                builder.AppendFormat("Network Host Names:\r\n");

                foreach (var hostName in NetworkInformation.GetHostNames())
                {
                    builder.AppendFormat($"{hostName.DisplayName} ({hostName.Type}), \r\n");
                }

                var devInfos = await DeviceInformation.FindAllAsync();

                builder.AppendLine("\r\n\nComplete Device Infos:\r\n");

                foreach (var devInfo in devInfos)
                {
                    builder.AppendFormat($"Name: {devInfo.Name} Id: {devInfo.Id} - Properties: \r\n");

                    foreach (var pair in devInfo.Properties)
                    {
                        builder.AppendFormat($"{pair.Key} = {pair.Value}, \r\n");
                    }
                }
            }

            return(builder.ToString());
        }
        public static bool HaveTouchCapabilities()
        {
            var touch = new TouchCapabilities();

            return(touch.TouchPresent > 0);
        }
示例#9
0
 public WindowsUwpDeviceInfo()
 {
     _deviceInfo        = new EasClientDeviceInformation();
     _touchCapabilities = new TouchCapabilities();
 }
        /// <summary>
        /// Returns whether the current device is Touch Enabled. Get more touch capabilities information by using <see cref="TouchCapabilities"/>.
        /// </summary>
        public static bool IsTouchEnabled()
        {
            TouchCapabilities touch = new TouchCapabilities();

            return(touch.TouchPresent > 0);
        }