internal WindowEx(Window window) { this.Log(); Two.Window = window; Dispatcher = DispatcherEx.Create(window.Dispatcher); window.CoreWindow.Closed += (s, e) => WindowExManager.Instances.Remove(this); window.Closed += (s, e) => WindowExManager.Instances.Remove(this); window.Activate(); IsMainView = CoreApplication.MainView == CoreApplication.GetCurrentView(); _displayInformation = new Lazy <DisplayInformation>(() => { Two.Window.Activate(); return(Dispatcher.Dispatch(() => DisplayInformation.GetForCurrentView())); }); _applicationView = new Lazy <ApplicationView>(() => { Two.Window.Activate(); return(Dispatcher.Dispatch(() => ApplicationView.GetForCurrentView())); }); _uIViewSettings = new Lazy <UIViewSettings>(() => { Two.Window.Activate(); return(Dispatcher.Dispatch(() => UIViewSettings.GetForCurrentView())); }); }
private static Devices GetDesktopMode() { var settings = UIViewSettings.GetForCurrentView(); return(settings.UserInteractionMode == UserInteractionMode.Mouse ? Devices.Desktop : Devices.Tablet); }
/// <summary> /// Retrieves the current <see cref="DeviceFormFactor"/> for the current device. /// </summary> /// <param name="versionInfo">Extended class.</param> /// <returns><see cref="DeviceFormFactor"/> value representing the current device type.</returns> public static DeviceFormFactor GetDeviceFormFactor(this AnalyticsVersionInfo versionInfo) { // TODO: If we have better ways of detecting specific platforms we should put them in here too, // but should still expose on AnalyticsVersionInfo as that's where most people are currently looking for this. switch (versionInfo.DeviceFamily) { case "Windows.Desktop": return(UIViewSettings.GetForCurrentView()?.UserInteractionMode == UserInteractionMode.Mouse ? DeviceFormFactor.Desktop : DeviceFormFactor.Tablet); case "Windows.Mobile": return(DeviceFormFactor.Mobile); case "Windows.Xbox": return(DeviceFormFactor.Xbox); case "Windows.Holographic": return(DeviceFormFactor.Holographic); case "Windows.Universal": return(DeviceFormFactor.IoT); case "Windows.Team": return(DeviceFormFactor.SurfaceHub); default: return(DeviceFormFactor.Other); } }
//private bool estaDisparando; public Game() { listaDefensas = new List <Defensa>(); listaEnemigos = new List <NaveEnemiga>(); listaImagenesNavesEnemigas = new List <Image>(); //haPulsado = false; //haLevantado = false; this.InitializeComponent(); mediaPlayer = new MediaElement(); this.grid.Children.Add(mediaPlayer); cargaNaves(); cargaDefensas(); //Window.Current.Content.KeyDown += KeyDownEvent; cantidadNaves = 60; cantidadDefensas = 32; vMGame = (VMGame)this.DataContext; //vMGame.canvas = this.canvas; timer.Interval = new TimeSpan(0, 0, 0, 0, 100); timer.Tick += Timer_Tick; timer.Start(); timerDisparoEnemigo.Interval = new TimeSpan(0, 0, 0, 2, 0); timerDisparoEnemigo.Tick += tickDisparoEnemigo; timerDisparoEnemigo.Start(); //Si esta en modo tactil if (UIViewSettings.GetForCurrentView().UserInteractionMode != UserInteractionMode.Touch) { this.relativeBotonesTactiles.Children.Remove(this.btnIzq); this.relativeBotonesTactiles.Children.Remove(this.btnDcha); this.relativeBotonesTactiles.Children.Remove(this.btnDisparo); } }
private void DetermineItemSize() { if (FitScreenToggle != null && FitScreenToggle.IsOn == true && ImageGridView != null && ZoomSlider != null) { // The 'margins' value represents the total of the margins around the // image in the grid item. 8 from the ItemTemplate root grid + 8 from // the ItemContainerStyle * (Right + Left). If those values change, // this value needs to be updated to match. int margins = (int)this.Resources["LargeItemMarginValue"] * 4; double gridWidth = ImageGridView.ActualWidth - (int)this.Resources["DesktopWindowSidePaddingValue"]; if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile" && UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch) { margins = (int)this.Resources["SmallItemMarginValue"] * 4; gridWidth = ImageGridView.ActualWidth - (int)this.Resources["MobileWindowSidePaddingValue"]; } double ItemWidth = ZoomSlider.Value + margins; // We need at least 1 column. int columns = (int)Math.Max(gridWidth / ItemWidth, 1); // Adjust the available grid width to account for margins around each item. double adjustedGridWidth = gridWidth - (columns * margins); ItemSize = (adjustedGridWidth / columns); } else { ItemSize = ZoomSlider.Value; } }
public void UpdateUi() { var uiMode = UIViewSettings.GetForCurrentView().UserInteractionMode; if (uiMode == Windows.UI.ViewManagement.UserInteractionMode.Touch) { TabButton.Width = 48; } else { TabButton.Width = 0; } if (Config.Contains(Config.FontFamily)) { this.messagesView.FontFamily = new FontFamily(Config.GetString(Config.FontFamily)); } if (Config.Contains(Config.FontSize)) { this.messagesView.FontSize = Convert.ToDouble(Config.GetString(Config.FontSize)); } if (currentChannel != "Server") { topicScroll.Visibility = MainPage.instance.ShowTopic ? Visibility.Visible : Visibility.Collapsed; } else { topicScroll.Visibility = Visibility.Collapsed; } }
void UpdateContent() { InteractionMode = UIViewSettings.GetForCurrentView().UserInteractionMode; // Update styles CheckBoxStyle = InteractionMode == UserInteractionMode.Mouse ? MouseCheckBoxStyle : TouchCheckBoxStyle; }
private static PlatformIdiom GetIdiom() { #if ANDROID var context = XamarinFormsAndroidToolkitExtensions.GetContext(); int minWidthDp = context.Resources.Configuration.SmallestScreenWidthDp; return(minWidthDp >= 600 ? PlatformIdiom.Tablet : PlatformIdiom.Phone); #elif TOUCH return(XamarinFormsTouchToolkitExtensions.GetIdiom()); #elif WINDOWS_UWP switch (AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Mobile": return(PlatformIdiom.Phone); case "Windows.Desktop": return(UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse ? PlatformIdiom.Desktop : PlatformIdiom.Tablet); default: return(PlatformIdiom.Unknown); } #else return(PlatformIdiom.Unknown); #endif }
internal WindowWrapper(Window window) { Window = window; Dispatcher = new DispatcherWrapper(window.Dispatcher); window.CoreWindow.Closed += (s, e) => WindowWrapperManager.Instances.Remove(this); window.Closed += (s, e) => WindowWrapperManager.Instances.Remove(this); window.Activate(); IsMainView = CoreApplication.MainView == CoreApplication.GetCurrentView(); _DisplayInformation = new Lazy <DisplayInformation>(() => { Window.Activate(); return(Dispatcher.Dispatch(() => DisplayInformation.GetForCurrentView())); }); _ApplicationView = new Lazy <ApplicationView>(() => { Window.Activate(); return(Dispatcher.Dispatch(() => ApplicationView.GetForCurrentView())); }); _UIViewSettings = new Lazy <UIViewSettings>(() => { Window.Activate(); return(Dispatcher.Dispatch(() => UIViewSettings.GetForCurrentView())); }); }
private async void ScreenSizeChanged(CoreWindow sender, WindowSizeChangedEventArgs args) { var result = UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse; if (result != isInDesktopExperience) { isInDesktopExperience = result; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { DeviceFamily = DeviceFamily; }); } }
private void Window_VisibilityChanged(object sender, VisibilityChangedEventArgs e) { HandleActivated(e.Visible); if (e.Visible && TLContainer.Current.Passcode.IsLockscreenRequired) { ShowPasscode(); } else { if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch) { TLContainer.Current.Passcode.CloseTime = DateTime.Now; } else { TLContainer.Current.Passcode.CloseTime = DateTime.MaxValue; } } #if !DEBUG && !PREVIEW if (e.Visible) { var dispatcher = Window.Current.Dispatcher; Execute.BeginOnThreadPool(async() => { await new HockeyAppUpdateService().CheckForUpdatesAsync(Constants.HockeyAppId, dispatcher); }); } #endif }
private void InitLayout() { var coreTitleBar = CoreApplication.GetCurrentView().TitleBar; if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { extendTitle.Visibility = Windows.UI.Xaml.Visibility.Visible; coreTitleBar.ExtendViewIntoTitleBar = true; var titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.BackgroundColor = Colors.Transparent; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonForegroundColor = Colors.White; titleBar.ButtonHoverBackgroundColor = Color.FromArgb(122, 0, 0, 0); titleBar.ButtonHoverForegroundColor = Colors.White; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveForegroundColor = Colors.White; titleBar.ButtonPressedBackgroundColor = Colors.Transparent; titleBar.ButtonPressedForegroundColor = Colors.White; titleBar.ForegroundColor = Colors.White; titleBar.InactiveBackgroundColor = Colors.Transparent; titleBar.InactiveForegroundColor = Colors.White; } else { extendTitle.Visibility = Windows.UI.Xaml.Visibility.Collapsed; coreTitleBar.ExtendViewIntoTitleBar = false; } }
public static Rect GetFixedImageLocation(this SplashScreen splashScreen) { if (App.IsWindowsMobile) { const double splashScreenRatio = 620d / 300d; var screenWidth = Window.Current.Bounds.Width; var screenHeight = Window.Current.Bounds.Height; double width; double height; bool isContinuum = UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse; if (isContinuum) { height = 200; width = height * splashScreenRatio; } else { var orientations = DisplayInformation.GetForCurrentView().CurrentOrientation; var isPortrait = orientations == DisplayOrientations.Portrait || orientations == DisplayOrientations.PortraitFlipped; width = isPortrait ? screenWidth : screenHeight; height = width / splashScreenRatio; } return(new Rect( (screenWidth - width) / 2, (screenHeight - height) / 2, width, height)); } return(splashScreen.ImageLocation); }
public static async Task SavePhotoAsync(TLPhotoSize photoSize, int date, bool downloads) { var location = photoSize.Location; var fileName = string.Format("{0}_{1}_{2}.jpg", location.VolumeId, location.LocalId, location.Secret); if (File.Exists(FileUtils.GetTempFileName(fileName))) { var resultName = "photo_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".jpg"; if (downloads) { var folder = await GetDownloadsAsync(); if (folder == null) { return; } StorageFile file; if (StorageApplicationPermissions.FutureAccessList.ContainsItem(fileName)) { file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(fileName); } else { file = await folder.CreateFileAsync(resultName, CreationCollisionOption.GenerateUniqueName); StorageApplicationPermissions.FutureAccessList.AddOrReplace(fileName, file); var result = await FileUtils.GetTempFileAsync(fileName); await result.CopyAndReplaceAsync(file); } if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { var options = new FolderLauncherOptions(); options.ItemsToSelect.Add(file); await Launcher.LaunchFolderAsync(folder, options); } } else { var picker = new FileSavePicker(); picker.FileTypeChoices.Add("JPEG Image", new[] { ".jpg" }); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.SuggestedFileName = resultName; var file = await picker.PickSaveFileAsync(); if (file != null) { var result = await FileUtils.GetTempFileAsync(fileName); await result.CopyAndReplaceAsync(file); } } } }
private void DetectPlatform() { switch (AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Mobile": UseNativeCamera = false; break; case "Windows.Desktop": if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { UseNativeCamera = true; } else { UseNativeCamera = false; } break; case "Windows.Universal": //return DeviceFormFactorType.IoT; break; case "Windows.Team": break; default: break; //return DeviceFormFactorType.Other; } }
private void Window_Activated(object sender, WindowActivatedEventArgs e) { // there is currently a bug that prevents the VisualStateManager to // detect the initial state when the application is restored in // "Desktop" mode. // So we register to this event once, and make the changes ourselves. var mode = UIViewSettings.GetForCurrentView().UserInteractionMode; if (mode == UserInteractionMode.Mouse) { BottomCommandBar.Visibility = Visibility.Collapsed; Header.Visibility = Visibility.Collapsed; TopCommandBar.Visibility = Visibility.Visible; Grid.SetRow(SplitView, 0); Grid.SetRowSpan(SplitView, 2); } else { BottomCommandBar.Visibility = Visibility.Visible; Header.Visibility = Visibility.Visible; TopCommandBar.Visibility = Visibility.Visible; Grid.SetRow(SplitView, 1); Grid.SetRowSpan(SplitView, 1); } // we do not want to be notified next time Window.Current.Activated -= Window_Activated; }
public static DeviceType DetectDeviceType() { switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Xbox": return(DeviceType.XBOX); case "Windows.Desktop": return(UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse ? DeviceType.Desktop : DeviceType.Tablet); case "Windows.Mobile": return(DeviceType.Mobile); case "Windows.Universal": return(DeviceType.IOT); case "Windows.Team": return(DeviceType.SurfaceHub); default: return(DeviceType.Other); } }
private void UpdateTrigger() { var _currentDeviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily; var _currentInteractionMode = UIViewSettings.GetForCurrentView().UserInteractionMode; SetActive(InteractionMode == _currentInteractionMode && _currentDeviceFamily == "Windows.Mobile"); }
public static void FocusMaybe(this RichEditBox textBox, FocusState focusState) { if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { textBox.Focus(focusState); } }
private void UpdateTrigger() { try { var qualifiers = ResourceContext.GetForCurrentView().QualifierValues; if (qualifiers.ContainsKey("DeviceFamily") && qualifiers["DeviceFamily"] == "Mobile") { if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse || ProjectionManager.ProjectionDisplayAvailable) { SetActive(this.IsInDesktopMode); IsActive = this.IsInDesktopMode; } else { SetActive(!this.IsInDesktopMode); IsActive = !this.IsInDesktopMode; } } else if (qualifiers.ContainsKey("DeviceFamily") && qualifiers["DeviceFamily"] == "Desktop") { SetActive(this.IsInDesktopMode); IsActive = this.IsInDesktopMode; } } catch (Exception ex) { Debug.WriteLine("Trigger Update: {0}", ex.Message); } }
private void MvxWindowsPage_SizeChanged(object sender, SizeChangedEventArgs e) { switch (UIViewSettings.GetForCurrentView().UserInteractionMode) { case UserInteractionMode.Mouse: VisualStateManager.GoToState(this, "MouseLayout", true); DragArea.Visibility = Visibility.Visible; break; case UserInteractionMode.Touch: default: VisualStateManager.GoToState(this, "TouchLayout", true); DragArea.Visibility = Visibility.Collapsed; break; } ApplicationView applicationView = ApplicationView.GetForCurrentView(); if (applicationView.IsFullScreenMode == true) { MasterColumn.Width = new GridLength(0); MasterView.Visibility = Visibility.Collapsed; DragArea.Visibility = Visibility.Collapsed; NavigationBar.IsPaneVisible = false; } else if (applicationView.IsFullScreenMode == false) { MasterColumn.Width = new GridLength(450); MasterView.Visibility = Visibility.Visible; DragArea.Visibility = Visibility.Visible; NavigationBar.IsPaneVisible = true; } }
private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) { if (args.VirtualKey == VirtualKey.Escape && !args.KeyStatus.IsKeyReleased) { if (StickersPanel.Visibility == Visibility.Visible) { StickersPanel.Visibility = Visibility.Collapsed; args.Handled = true; } if (ViewModel.SelectionMode != ListViewSelectionMode.None) { ViewModel.SelectionMode = ListViewSelectionMode.None; args.Handled = true; } if (args.Handled) { Focus(FocusState.Programmatic); if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { TextField.Focus(FocusState.Keyboard); } } } }
public static void RefreshFormFactorType() { switch (AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Mobile": FormFactorType = DeviceFormFactorType.Phone; break; case "Windows.Desktop": try { FormFactorType = UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse ? DeviceFormFactorType.Desktop : DeviceFormFactorType.Tablet; } catch //UI is not present at this point, we'll assume Desktop. { FormFactorType = DeviceFormFactorType.Desktop; } break; case "Windows.Universal": FormFactorType = DeviceFormFactorType.IoT; break; case "Windows.Team": FormFactorType = DeviceFormFactorType.SurfaceHub; break; default: FormFactorType = DeviceFormFactorType.Other; break; } }
public static DeviceFormFactorType GetDeviceFormFactorType() { switch (AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Mobile": return(DeviceFormFactorType.Phone); case "Windows.Desktop": return(UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse ? DeviceFormFactorType.Desktop : DeviceFormFactorType.Tablet); case "Windows.Universal": return(DeviceFormFactorType.IoT); case "Windows.Team": return(DeviceFormFactorType.SurfaceHub); default: return(DeviceFormFactorType.Other); } }
private void OnLoaded(object sender, RoutedEventArgs e) { // Register events m_coreTitleBar.IsVisibleChanged += CoreTitleBarIsVisibleChanged; m_coreTitleBar.LayoutMetricsChanged += CoreTitleBarLayoutMetricsChanged; m_uiSettings.ColorValuesChanged += ColorValuesChanged; m_accessibilitySettings.HighContrastChanged += OnHighContrastChanged; Window.Current.Activated += OnWindowActivated; // Register RequestedTheme changed callback to update title bar system button colors. m_rootFrameRequestedThemeCallbackToken = Utils.ThemeHelper.RegisterAppThemeChangedCallback(RootFrame_RequestedThemeChanged); // Set properties SetTitleBarControlColors(); SetTitleBarHeightAndPadding(); // As of Windows 10 1903: when an app runs on a PC (without Tablet mode activated) // properties of CoreApplicationViewTitleBar aren't initialized during the first seconds after launch. var forceDisplay = AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop" && UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse; SetTitleBarVisibility(forceDisplay); }
private async void SizeChanged(object sender, WindowSizeChangedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SetActive(UIViewSettings.GetForCurrentView().UserInteractionMode == _mode); }); }
private Visibility CalculateOnCanvasBackVisibility() { // by design it is not visible when not applicable var cangoback = Frame.CanGoBack; if (!cangoback) { return(Visibility.Collapsed); } // mobile always has a visible back button var mobilefam = ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].Equals("Mobile"); if (mobilefam) { return(Visibility.Collapsed); } // simply don't know what to do with else var desktopfam = ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].Equals("Desktop"); if (!desktopfam) { return(Visibility.Collapsed); } // touch always has a bisible back button var touchmode = UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch; if (touchmode) { return(Visibility.Collapsed); } // full screen back button is only visible when mouse reveals title (prefered behavior is on-canvas visible) var fullscreen = ApplicationView.GetForCurrentView().IsFullScreen; if (fullscreen) { return(Visibility.Visible); } // hide the button if the shell button is visible var optinback = SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility.Equals(AppViewBackButtonVisibility.Visible); if (optinback) { // shell button will not be visible if there is no title bar var hastitle = !CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar; if (hastitle) { return(Visibility.Collapsed); } } // at this point, we show the on-canvas button return(Visibility.Visible); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch) { Splitter.DisplayMode = SplitViewDisplayMode.Overlay; } MainContentFrame.Navigate(typeof(Pages.ItaListPage)); }
private void UpdateTrigger() { // Get the current device family and interaction mode. var _currentDeviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily; var _currentInteractionMode = UIViewSettings.GetForCurrentView().UserInteractionMode; // The trigger will be activated if the current device family is Windows.Mobile // and the UserInteractionMode matches the interaction mode value in XAML. SetActive(InteractionMode == _currentInteractionMode && _currentDeviceFamily == "Windows.Mobile"); }
private void OnLoaded(object sender, RoutedEventArgs e) { InputPane.GetForCurrentView().Showing += InputPane_Showing; InputPane.GetForCurrentView().Hiding += InputPane_Hiding; if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { CaptionInput.Focus(FocusState.Keyboard); } }