// Add OuterGlow effect. void OnFocusCreateGlow(object sender, RoutedEventArgs args) { // Get a reference to the TextBox. TextBox myTextBox = (TextBox)sender; // Initialize a new OuterGlowBitmapEffect that will be applied // to the TextBox. OuterGlowBitmapEffect myGlowEffect = new OuterGlowBitmapEffect(); // Set the size of the glow to 30 pixels. myGlowEffect.GlowSize = 30; // Set the color of the glow to blue. Color myGlowColor = new Color(); myGlowColor.ScA = 1; myGlowColor.ScB = 1; myGlowColor.ScG = 0; myGlowColor.ScR = 0; myGlowEffect.GlowColor = myGlowColor; // Set the noise of the effect to the maximum possible (range 0-1). myGlowEffect.Noise = 1; // Set the Opacity of the effect to 40%. Note that the same effect // could be done by setting the ScA property of the Color to 0.4. myGlowEffect.Opacity = 0.4; // Apply the bitmap effect to the TextBox. myTextBox.BitmapEffect = myGlowEffect; }
// Capture the mouse event and hit test the coordinate point value against // the child visual objects. void MouseLeftButtonDownHandler(object sender, System.Windows.Input.MouseButtonEventArgs e) { ToolTipController.Hide(); // Retreive the coordinates of the mouse button event. Point pt = e.GetPosition(this); DrawingVisual hit = VisualTreeHelper.HitTest(this, pt).VisualHit as DrawingVisual; if (hit != null) { string tag = hit.ReadLocalValue(FrameworkElement.TagProperty) as string; if (tag != null) { foreach (DrawingVisual v in _graph.Children) { v.BitmapEffect = null; } OuterGlowBitmapEffect glow = new OuterGlowBitmapEffect(); glow.GlowColor = Colors.Blue; glow.GlowSize = 1; glow.Opacity = 0.8; glow.Freeze(); hit.BitmapEffect = glow; } } }
public void SetGlowOnDrawingVisual(DrawingVisual visual, Color color) { OuterGlowBitmapEffect glow = new OuterGlowBitmapEffect(); glow.GlowColor = color; glow.GlowSize = 1; glow.Opacity = 0.8; glow.Freeze(); visual.BitmapEffect = glow; }
/* OuterGlowBitmapEffect is deprecated. Try substituting one of the glow 'drop shadow' alternatives * I used in the FXEffects project... * */ private void button3_Click(object sender, RoutedEventArgs e) { // Animate Glow effect DoubleAnimation glowAnimation = new DoubleAnimation(0, 50, TimeSpan.FromMilliseconds(2000)); glowAnimation.RepeatBehavior = RepeatBehavior.Forever; glowAnimation.AutoReverse = true; OuterGlowBitmapEffect myGlowEffect = new OuterGlowBitmapEffect(); myGlowEffect.GlowColor = Colors.Violet; myGlowEffect.GlowSize = 0; button3.BitmapEffect = myGlowEffect; button3.BitmapEffect.BeginAnimation(OuterGlowBitmapEffect.GlowSizeProperty, glowAnimation); }
private void ellipse1_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { // Animate Glow effect DoubleAnimation glowAnimation = new DoubleAnimation(0, 20, TimeSpan.FromMilliseconds(500)); glowAnimation.RepeatBehavior = new RepeatBehavior(2); glowAnimation.AutoReverse = true; OuterGlowBitmapEffect myGlowEffect = new OuterGlowBitmapEffect(); myGlowEffect.GlowColor = Colors.Aquamarine; myGlowEffect.GlowSize = 0; ellipse1.BitmapEffect = myGlowEffect; ellipse1.BitmapEffect.BeginAnimation(OuterGlowBitmapEffect.GlowSizeProperty, glowAnimation); ellipse1.Fill = new SolidColorBrush(Colors.Cyan); }
public RenderTargetBitmap CreateBitmap(string text, Typeface typeface, double fontSize) { RenderTargetBitmap renderTargetBitmap = (RenderTargetBitmap)null; try { Pen pen = this.CreatePen(); Brush brush = this.CreateBrush(); FormattedText formattedText = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, fontSize, (Brush)Brushes.White); Geometry geometry = formattedText.BuildGeometry(new System.Windows.Point(50.0, 50.0)); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); BitmapEffectGroup bitmapEffectGroup = new BitmapEffectGroup(); DropShadowBitmapEffect shadowBitmapEffect = new DropShadowBitmapEffect(); OuterGlowBitmapEffect glowBitmapEffect = new OuterGlowBitmapEffect(); BevelBitmapEffect bevelBitmapEffect = new BevelBitmapEffect(); BlurBitmapEffect blurBitmapEffect = new BlurBitmapEffect(); EmbossBitmapEffect embossBitmapEffect = new EmbossBitmapEffect(); /* foreach (Nubik.Tools.SpriteFont.Enums.Effect effect in (IEnumerable<Nubik.Tools.SpriteFont.Enums.Effect>)GlobalObject<Settings>.Instance.EffectOrder.Values) * { * if (effect == Nubik.Tools.SpriteFont.Enums.Effect.DropShadow && GlobalObject<Settings>.Instance.DropShadow.IsEnabled) * bitmapEffectGroup.Children.Add((BitmapEffect)shadowBitmapEffect); * else if (effect == Nubik.Tools.SpriteFont.Enums.Effect.OuterGlow && GlobalObject<Settings>.Instance.OuterGlow.IsEnabled) * bitmapEffectGroup.Children.Add((BitmapEffect)glowBitmapEffect); * else if (effect == Nubik.Tools.SpriteFont.Enums.Effect.Bevel && GlobalObject<Settings>.Instance.Bevel.IsEnabled) * bitmapEffectGroup.Children.Add((BitmapEffect)bevelBitmapEffect); * else if (effect == Nubik.Tools.SpriteFont.Enums.Effect.Blur && GlobalObject<Settings>.Instance.Blur.IsEnabled) * bitmapEffectGroup.Children.Add((BitmapEffect)blurBitmapEffect); * else if (effect == Nubik.Tools.SpriteFont.Enums.Effect.Emboss && GlobalObject<Settings>.Instance.Emboss.IsEnabled) * bitmapEffectGroup.Children.Add((BitmapEffect)embossBitmapEffect); * }*/ drawingContext.PushEffect((BitmapEffect)bitmapEffectGroup, (BitmapEffectInput)null); drawingContext.DrawGeometry(brush, pen, geometry); drawingContext.Close(); if (double.IsInfinity(geometry.Bounds.X) || double.IsInfinity(geometry.Bounds.Y)) { return(renderTargetBitmap); } int pixelWidth = 0; int pixelHeight = 0; try { pixelWidth = Convert.ToInt32(geometry.Bounds.X + geometry.Bounds.Width) + 50; pixelHeight = Convert.ToInt32(geometry.Bounds.Y + geometry.Bounds.Height) + 50; } catch (Exception ex) { Console.WriteLine(ex); } renderTargetBitmap = new RenderTargetBitmap(pixelWidth, pixelHeight, 96.0, 96.0, PixelFormats.Pbgra32); renderTargetBitmap.Render((Visual)drawingVisual); try { renderTargetBitmap.Freeze(); } catch (Exception ex) { Console.WriteLine(ex); } } catch (Exception ex) { Console.WriteLine(ex); } return(renderTargetBitmap); }
static MoveablesPanel() { highlight = new OuterGlowBitmapEffect(); highlight.GlowColor = Colors.HotPink; }