private void btnDeleteLastLayer_Click(object sender, RoutedEventArgs e) { var tabItem = RightContainer.Items.First(s => s.Name == "layer" + layerIndex); RightContainer.Remove(tabItem); layerIndex--; }
public TCTabControl() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { return; } Items = new ObservableCollection <TabItem>(); RightContainer.ApplyTemplate(); scrHead = UIHelper.FindChild <ScrollViewer>(RightContainer, "scrol"); scrHead.ScrollChanged += Xxx_ScrollChanged; tgMenuBtn = UIHelper.FindChild <ToggleButton>(RightContainer, "tgBtn"); // tgMenuBtn.Click += TgMenuBtn_Click; DropTabMenu = UIHelper.FindChild <Popup>(RightContainer, "popTabItem"); LBTabMenu = DropTabMenu.Child as ListBox; }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { // Initialize Composition UI infrastructure. _leftRoot = LeftContainer.GetVisual(); _middleRoot = MiddleContainer.GetVisual(); _rightRoot = RightContainer.GetVisual(); _compositor = _leftRoot.Compositor; _imageFactory = CompositionImageFactory.CreateCompositionImageFactory(_compositor); // Hook the sprite visuals into the XAML visual tree. _leftSpriteVisual = _compositor.CreateSpriteVisual(); var side = (float)Math.Min(LeftPresenter.ActualWidth, LeftPresenter.ActualHeight); _leftSpriteVisual.Size = new Vector2(side, side); _leftRoot.Children.InsertAtTop(_leftSpriteVisual); _middleSpriteVisual = _compositor.CreateSpriteVisual(); side = (float)Math.Min(MiddlePresenter.ActualWidth, MiddlePresenter.ActualHeight); _middleSpriteVisual.Size = new Vector2(side, side); _middleRoot.Children.InsertAtTop(_middleSpriteVisual); _rightSpriteVisual = _compositor.CreateSpriteVisual(); side = (float)Math.Min(RightPresenter.ActualWidth, RightPresenter.ActualHeight); _rightSpriteVisual.Size = new Vector2(side, side); _rightRoot.Children.InsertAtTop(_rightSpriteVisual); // Create CompositionSurfaceBrush _imageBrush = _compositor.CreateSurfaceBrush(); // Create an image source to load var imageSource = _imageFactory.CreateImageFromUri(new Uri("ms-appx:///Assets/flowers.jpg")); _imageBrush.Surface = imageSource.Surface; // Create and apply the first effect. _firstEffect = new SaturationEffect { Name = "firstEffect", Source = new CompositionEffectSourceParameter("source") }; var firstEffectFactory = _compositor.CreateEffectFactory(_firstEffect, new[] { "firstEffect.Saturation" }); _effectBrush1 = firstEffectFactory.CreateBrush(); _leftSpriteVisual.Brush = _effectBrush1; // Create and apply the second effect. var secondEffect = new InvertEffect { Name = "secondEffect", Source = new CompositionEffectSourceParameter("source") }; var secondEffectFactory = _compositor.CreateEffectFactory(secondEffect); _effectBrush2 = secondEffectFactory.CreateBrush(); _middleSpriteVisual.Brush = _effectBrush2; // Create and apply the combined effect. _combinedEffect = new InvertEffect { Name = "chained", Source = _firstEffect }; var combinedEffectFactory = _compositor.CreateEffectFactory(_combinedEffect, new[] { "firstEffect.Saturation" }); _combinedBrush = combinedEffectFactory.CreateBrush(); _rightSpriteVisual.Brush = _combinedBrush; // Chain the brushes _effectBrush1.SetSourceParameter("source", _imageBrush); _effectBrush2.SetSourceParameter("source", _imageBrush); _combinedBrush.SetSourceParameter("source", _imageBrush); }