How to update colors in DrawingImage

Our application has been converted to use vector images using the DrawingImage paradigm. I would like to make colors / brushes inside the DrawingImage variable and no luck with that.

WHY: My reasoning for this is that we use themes in our application, and I would like to change all the images when changing the theme. Technically, I just want to change the colors, not the image.

WHAT I GOT: I declared colors (I say colors because different types of pens / brushes are used in the image) as DynamicResource connecting to a specific brush, and then tried to update this brush with snapping, and I don't get the change. I also tried redrawing the image by attaching it and then redrawing it when the ApplicationThemeChanged event fires. It still doesn't work, which surprises me.

NOTE: I basically want to do this in buttons and have extended the Button class to add functionality by calling it VectorButton. I want to say that I have a VectorButton.cs file available for making changes.

If you need code samples for something specific, just ask and I'll send it. I think this is pretty clear.

Thanks for the help in advance!

DrawingImage Example (I replace ResourceDictionaries when the theme changes. Each resource dictionary has a copy of PrimaryColor, but with a different color value.)

<DrawingImage x:Key="myVectorIconDrawingImage"> <DrawingImage.Drawing> <DrawingGroup> <DrawingGroup.ClipGeometry> <RectangleGeometry Rect="0,0,744.09448,1052.3622" /> </DrawingGroup.ClipGeometry> <DrawingGroup> <GeometryDrawing Brush="{DynamicResource PrimaryColor}"> <GeometryDrawing.Pen> <Pen Brush="{DynamicResource PrimaryColor}" Thickness="1" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter" /> </GeometryDrawing.Pen> <GeometryDrawing.Geometry> <PathGeometry FillRule="EvenOdd" Figures="M239.0625,299L239.0625,349 289.0625,349 289.0625,299 239.0625,299z M309.5625,299.5L309.5625,348.53125 507.59375,348.53125 507.59375,299.5 309.5625,299.5z M239.0625,384L239.0625,434 289.0625,434 289.0625,384 239.0625,384z M309.5625,384.5L309.5625,433.53125 507.59375,433.53125 507.59375,384.5 309.5625,384.5z M239.0625,469L239.0625,519 289.0625,519 289.0625,469 239.0625,469z M309.5625,469.5L309.5625,518.53125 507.59375,518.53125 507.59375,469.5 309.5625,469.5z" /> </GeometryDrawing.Geometry> </GeometryDrawing> </DrawingGroup> </DrawingGroup> </DrawingImage.Drawing> </DrawingImage> 
+5
source share
1 answer

I suggest you look into pixel shaders .

0
source

All Articles