static void OnHubTileSizeChanged(object sender, SizeChangedEventArgs e) { HubTile hubTile = (HubTile)sender; hubTile.SizeChanged -= OnHubTileSizeChanged; // In order to avoid getting into a bad state, we'll shift the HubTile // back to the Expanded state. If we were already in the Expanded state, // then we'll manually shift the title panel to the right location, // since the visual state manager won't do it for us in that case. if (hubTile.State != ImageState.Expanded) { hubTile.State = ImageState.Expanded; VisualStateManager.GoToState(hubTile, Expanded, false); } else if (hubTile._titlePanel != null) { CompositeTransform titlePanelTransform = hubTile._titlePanel.RenderTransform as CompositeTransform; if (titlePanelTransform != null) { titlePanelTransform.TranslateY = -hubTile.Height; } } HubTileService.InitializeReference(hubTile); }
/// <summary> /// Triggers the transition between visual states. /// </summary> /// <param name="obj">The dependency object.</param> /// <param name="e">The event information.</param> private static void OnSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { HubTile hubTile = (HubTile)obj; // And now we'll update the width and height to match the new size. switch (hubTile.Size) { case TileSize.Default: hubTile.Width = 173; hubTile.Height = 173; break; case TileSize.Small: hubTile.Width = 99; hubTile.Height = 99; break; case TileSize.Medium: hubTile.Width = 210; hubTile.Height = 210; break; case TileSize.Large: hubTile.Width = 432; hubTile.Height = 210; break; } hubTile.SizeChanged += OnHubTileSizeChanged; HubTileService.FinalizeReference(hubTile); }
/// <summary> /// Remove all references of a hub tile before finalizing it. /// </summary> /// <param name="tile">The hub tile that is to be finalized.</param> internal static void FinalizeReference(HubTile tile) { WeakReference wref = new WeakReference(tile, TrackResurrection); HubTileService.RemoveReferenceFromEnabledPool(wref); HubTileService.RemoveReferenceFromFrozenPool(wref); HubTileService.RemoveReferenceFromStalledPipeline(wref); }
/// <summary> /// Removes the frozen image from the enabled image pool or the stalled image pipeline. /// Adds the non-frozen image to the enabled image pool. /// </summary> /// <param name="obj">The dependency object.</param> /// <param name="e">The event information.</param> private static void OnIsFrozenChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { HubTile tile = (HubTile)obj; if ((bool)e.NewValue) { HubTileService.FreezeHubTile(tile); } else { HubTileService.UnfreezeHubTile(tile); } }
/// <summary> /// This event handler gets called as soon as a hub tile is removed from the visual tree. /// Any existing reference of this hub tile is eliminated from the service singleton. /// </summary> /// <param name="sender">The hub tile.</param> /// <param name="e">The event information.</param> void HubTile_Unloaded(object sender, RoutedEventArgs e) { HubTileService.FinalizeReference(this); }
/// <summary> /// This event handler gets called as soon as a hub tile is added to the visual tree. /// A reference of this hub tile is passed on to the service singleton. /// </summary> /// <param name="sender">The hub tile.</param> /// <param name="e">The event information.</param> void HubTile_Loaded(object sender, RoutedEventArgs e) { HubTileService.InitializeReference(this); }