private void BuildVisualTree() { // Create Solid Color Background SolidColorVisual background = _compositor.CreateSolidColorVisual(); background.Size = new System.Numerics.Vector2((float)this.ActualWidth, (float)this.ActualHeight); background.Color = Color.FromArgb(0xFF, 0x21, 0xBD, 0xEE); // put it at the bottom of the visual tree _rootVisual.Children.InsertAtBottom(background); // use current position for laying out as we iterate Vector3 currentGridPosition = new Vector3(horizontalSpace, horizontalSpace, 1.0f); Vector2 imageSize = new Vector2(imageDimension, imageDimension); foreach (Uri profileImageUri in GetProfileUrisForTwitterFollowers("@wincomposition")) { AddImageVisualForFollower(profileImageUri, currentGridPosition, imageSize); #region CalcNextOffset // simple dumb layout currentGridPosition.X += horizontalSpace + imageDimension; if (currentGridPosition.X + imageDimension > this.ActualWidth) { currentGridPosition.X = horizontalSpace; currentGridPosition.Y += imageDimension + verticalSpace; } #endregion } }
public Tile(ContainerVisual parent, float border) { _parent = parent; _border = border; // Create a placeholder picture frame: // - This is the parent of the actual image. // - Configure with a center-point in the middle to allow easy rotation. // - Don't add it to the parent yet. This enables the caller to specify more // properties (such as offset) without animating them before making the Tile visible. _frame = s_compositor.CreateSolidColorVisual(); _frame.Color = s_unselectedFrameColor; _frame.Opacity = 1.0f; // Since we can't currently animate colors, need to animate opacity instead. // At the least, we should be able to make this an effect and animate that. // - Start with opacity = 0 and fade in when selected. _selectedFrame = s_compositor.CreateSolidColorVisual(); _selectedFrame.Offset = new Vector3(); _selectedFrame.Color = s_selectedFrameColor; _selectedFrame.Opacity = 0.0f; _frame.Children.InsertAtBottom(_selectedFrame); // Begin a default animation for the rotation. StartNewRotationAnimation(); }
private void Host_Loaded(object sender, RoutedEventArgs e) { this.container = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(this.Host); this.compositor = container.Compositor; this.background = this.compositor.CreateSolidColorVisual(); this.background.Color = Colors.LightGreen; this.container.Children.InsertAtBottom(background); UpdateSize(); }
private void InitializeComposition() { // setup compositor and root visual this.compositor = new Compositor(); this.rootVisual = this.compositor.CreateContainerVisual(); // associate with the CoreWindow this.compositionTarget = this.compositor.CreateTargetForCurrentView(); this.compositionTarget.Root = this.rootVisual; // add a solid color background this.background = this.compositor.CreateSolidColorVisual(); this.background.Color = Colors.LightGreen; this.rootVisual.Children.InsertAtBottom(this.background); UpdateSize(); }
public void Dispose() { if (_rotationAnimator != null) { _rotationAnimator.Dispose(); _rotationAnimator = null; } if (_offsetAnimator != null) { _offsetAnimator.Dispose(); _offsetAnimator = null; } if (_selectedFrame != null) { _selectedFrame.Dispose(); _selectedFrame = null; } if (_content != null) { _content.Dispose(); _content = null; } if (_frame != null) { _frame.Dispose(); _frame = null; } if (_saturationEffect != null) { _saturationEffect.Dispose(); _saturationEffect = null; } // STEP4c: Clean-up effect animations. if (_saturationAnimator != null) { _saturationAnimator.Dispose(); _saturationAnimator = null; } }