private static async Task AskUserInstallCodec(CodecRequiredEventArgs args) { // show message box to user // then open store page await args.OpenStorePageAsync(); // wait for app window to be re-activated var tcs = new TaskCompletionSource <object>(); WindowActivatedEventHandler handler = (s, e) => { if (e.WindowActivationState != CoreWindowActivationState.Deactivated) { tcs.TrySetResult(null); } }; Window.Current.Activated += handler; await tcs.Task; Window.Current.Activated -= handler; // now refresh codec checker, so next file might use HW acceleration (if codec was really installed) await CodecChecker.RefreshAsync(); }
private void Initialize() { if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { WindowActivatedEventHandler windowactivated = null; windowactivated = (s, e) => { Window.Current.Activated -= windowactivated; Current_SizeChanged(this, null); }; Window.Current.Activated += windowactivated; Window.Current.SizeChanged += Current_SizeChanged; } }
private void Initialize() { if (!DesignMode.DesignModeEnabled) { WindowActivatedEventHandler windowactivated = null; windowactivated = (s, e) => { Window.Current.Activated -= windowactivated; var currentUIMode = UIViewSettings.GetForCurrentView().UserInteractionMode.ToString(); SetActive(currentUIMode == UIMode); }; Window.Current.Activated += windowactivated; Window.Current.SizeChanged += Current_SizeChanged; } }
public static Popup ShowPane(FrameworkElement control, bool showLeft = true, Action <Popup> closedCallback = null) { var bounds = Window.Current.Bounds; control.Height = bounds.Height; var popup = new Popup(); var del = new WindowActivatedEventHandler((sender, e) => { if (e.WindowActivationState == CoreWindowActivationState.Deactivated) { popup.IsOpen = false; } }); var del2 = new SizeChangedEventHandler((sender, e) => { if (!showLeft) { popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth); } }); Window.Current.Activated += del; control.SizeChanged += del2; popup.IsLightDismissEnabled = true; popup.Child = control; popup.Closed += delegate { Window.Current.Activated -= del; control.SizeChanged -= del2; if (closedCallback != null) { closedCallback(popup); } }; popup.IsOpen = true; return(popup); }
private static Popup ShowDialog(FrameworkElement control, bool isLightDismissEnabled = false, bool isHorizontal = true, Action<Popup> closedCallback = null) { var popup = new Popup(); var parent = (FrameworkElement)Window.Current.Content; var windowActivated = new WindowActivatedEventHandler((sender, e) => { UpdatePopupControlSize(control, isHorizontal); UpdatePopupOffsets(control, isHorizontal, popup); }); var controlSizeChanged = new SizeChangedEventHandler((sender, e) => UpdatePopupOffsets(control, isHorizontal, popup)); Window.Current.Activated += windowActivated; UpdatePopupControlSize(control, isHorizontal); control.SizeChanged += controlSizeChanged; control.Tag = popup; var oldOpacity = parent.Opacity; parent.Opacity = 0.5; parent.IsHitTestVisible = false; var topAppBarVisibility = Visibility.Collapsed; var bottomAppBarVisibility = Visibility.Collapsed; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } popup.Child = control; popup.IsLightDismissEnabled = isLightDismissEnabled; popup.Closed += delegate { parent.Opacity = oldOpacity; parent.IsHitTestVisible = true; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) page.TopAppBar.Visibility = topAppBarVisibility; if (page.BottomAppBar != null) page.BottomAppBar.Visibility = bottomAppBarVisibility; } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) page.TopAppBar.Visibility = topAppBarVisibility; if (page.BottomAppBar != null) page.BottomAppBar.Visibility = bottomAppBarVisibility; } } Window.Current.Activated -= windowActivated; control.SizeChanged -= controlSizeChanged; if (closedCallback != null) closedCallback(popup); }; popup.IsOpen = true; popup.Tag = 0.0; InputPane.GetForCurrentView().Showing += (s, args) => UpdateElementLocation(popup); InputPane.GetForCurrentView().Hiding += (s, args) => { popup.VerticalOffset += (double)popup.Tag; popup.Tag = 0.0; }; return popup; }
public static Popup ShowPane(FrameworkElement control, bool showLeft = true, Action<Popup> closedCallback = null) { var bounds = Window.Current.Bounds; control.Height = bounds.Height; var popup = new Popup(); var del = new WindowActivatedEventHandler((sender, e) => { if (e.WindowActivationState == CoreWindowActivationState.Deactivated) popup.IsOpen = false; }); var del2 = new SizeChangedEventHandler((sender, e) => { if (!showLeft) popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth); }); Window.Current.Activated += del; control.SizeChanged += del2; popup.IsLightDismissEnabled = true; popup.Child = control; popup.Closed += delegate { Window.Current.Activated -= del; control.SizeChanged -= del2; if (closedCallback != null) closedCallback(popup); }; popup.IsOpen = true; return popup; }
public static Popup ShowDialog(FrameworkElement control, bool isLightDismissEnabled = false, bool isHorizontal = true, Action<Popup> closed = null) { var bounds = Window.Current.CoreWindow.Bounds; var parent = (FrameworkElement)Window.Current.Content; if (isHorizontal) control.Width = bounds.Width; else control.Height = bounds.Height; var popup = new Popup(); var del = new WindowActivatedEventHandler((sender, e) => { control.Width = bounds.Width; if (isHorizontal) popup.VerticalOffset = bounds.Top + (bounds.Height - control.ActualHeight) / 2; else popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth) / 2; }); var del2 = new SizeChangedEventHandler((sender, e) => { if (isHorizontal) popup.VerticalOffset = bounds.Top + (bounds.Height - control.ActualHeight) / 2; else popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth) / 2; }); Window.Current.Activated += del; control.SizeChanged += del2; control.Tag = popup; var oldOpacity = parent.Opacity; parent.Opacity = 0.5; parent.IsHitTestVisible = false; var topAppBarVisibility = Visibility.Collapsed; var bottomAppBarVisibility = Visibility.Collapsed; if (parent is Paging.Frame) { var page = ((Paging.Frame)parent).Content as Paging.Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } popup.Child = control; popup.IsLightDismissEnabled = isLightDismissEnabled; popup.Closed += delegate { parent.Opacity = oldOpacity; parent.IsHitTestVisible = true; if (parent is Paging.Frame) { var page = ((Paging.Frame)parent).Content as Paging.Page; if (page != null) { if (page.TopAppBar != null) page.TopAppBar.Visibility = topAppBarVisibility; if (page.BottomAppBar != null) page.BottomAppBar.Visibility = bottomAppBarVisibility; } } Window.Current.Activated -= del; control.SizeChanged -= del2; if (closed != null) closed(popup); openPopups--; }; openPopups++; popup.IsOpen = true; popup.Tag = 0.0; InputPane.GetForCurrentView().Showing += (s, args) => UpdateElementLocation(popup); InputPane.GetForCurrentView().Hiding += (s, args) => { popup.VerticalOffset += (double)popup.Tag; popup.Tag = 0.0; }; return popup; }
public static Popup ShowSettings(FrameworkElement control, Action<Popup> closed = null) { var bounds = Window.Current.CoreWindow.Bounds; control.Height = bounds.Height; var popup = new Popup(); var del1 = new WindowActivatedEventHandler((sender, e) => { if (e.WindowActivationState == CoreWindowActivationState.Deactivated) popup.IsOpen = false; }); var del2 = new SizeChangedEventHandler((sender, e) => { popup.HorizontalOffset = bounds.Left + (bounds.Width - control.ActualWidth); }); Window.Current.Activated += del1; control.SizeChanged += del2; popup.IsLightDismissEnabled = true; popup.Child = control; popup.Closed += delegate { Window.Current.Activated -= del1; control.SizeChanged -= del2; if (closed != null) closed(popup); openPopups--; }; openPopups++; popup.IsOpen = true; return popup; }
private static Popup ShowDialog(FrameworkElement control, bool isLightDismissEnabled = false, bool isHorizontal = true, Action <Popup> closedCallback = null) { var popup = new Popup(); var parent = (FrameworkElement)Window.Current.Content; var windowActivated = new WindowActivatedEventHandler((sender, e) => { UpdatePopupControlSize(control, isHorizontal); UpdatePopupOffsets(control, isHorizontal, popup); }); var controlSizeChanged = new SizeChangedEventHandler((sender, e) => UpdatePopupOffsets(control, isHorizontal, popup)); Window.Current.Activated += windowActivated; UpdatePopupControlSize(control, isHorizontal); control.SizeChanged += controlSizeChanged; control.Tag = popup; var oldOpacity = parent.Opacity; parent.Opacity = 0.5; parent.IsHitTestVisible = false; var topAppBarVisibility = Visibility.Collapsed; var bottomAppBarVisibility = Visibility.Collapsed; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) { topAppBarVisibility = page.TopAppBar.Visibility; page.TopAppBar.Visibility = Visibility.Collapsed; } if (page.BottomAppBar != null) { bottomAppBarVisibility = page.BottomAppBar.Visibility; page.BottomAppBar.Visibility = Visibility.Collapsed; } } } popup.Child = control; popup.IsLightDismissEnabled = isLightDismissEnabled; popup.Closed += delegate { parent.Opacity = oldOpacity; parent.IsHitTestVisible = true; if (parent is Paging.MtFrame) { var page = ((Paging.MtFrame)parent).CurrentPage.Page; if (page != null) { if (page.TopAppBar != null) { page.TopAppBar.Visibility = topAppBarVisibility; } if (page.BottomAppBar != null) { page.BottomAppBar.Visibility = bottomAppBarVisibility; } } } else if (parent is Frame) { var page = ((Frame)parent).Content as Page; if (page != null) { if (page.TopAppBar != null) { page.TopAppBar.Visibility = topAppBarVisibility; } if (page.BottomAppBar != null) { page.BottomAppBar.Visibility = bottomAppBarVisibility; } } } Window.Current.Activated -= windowActivated; control.SizeChanged -= controlSizeChanged; if (closedCallback != null) { closedCallback(popup); } }; popup.IsOpen = true; popup.Tag = 0.0; InputPane.GetForCurrentView().Showing += (s, args) => UpdateElementLocation(popup); InputPane.GetForCurrentView().Hiding += (s, args) => { popup.VerticalOffset += (double)popup.Tag; popup.Tag = 0.0; }; return(popup); }