WPF - copying items with brushes attached - wpf

I'm developing a multi track video player in wpf and need to be able to copy the video that is playing in one grid layout of the main window into a seperate window that will go out of a projector. The videos are loaded and drawn onto rectangles using drawing brush and are added to a grid. I can't call clone on the rectangle, or the grid, or the canvas, so I'm currently resorting to copying the drawing brushes, passing them through to the otherwindow class and reassigning them to newly drawn rectangles.
However, this gets even worse as I'm 'cross-fading' between two video by drawing another rectangle with a new video in front, then changing the opacity value of the front video to gradually block out the one behind. So I now have two brushes on two rectangles tied to storyboards to animate, and I'm having to pass everything through and basically compute everything twice.
Is there any sensible way of doing this? I'd love to be able to literally grab the pixels from one area of the main video and display them in the second window, but everything seems abstracted away.
Any suggestions would be a massive help

Have you looked at VisualBrush?

Related

Creating a WPF divided diagram

So there's this tutorial about creating a diagram in WPF.
http://www.codeproject.com/Articles/24681/WPF-Diagram-Designer-Part
I've read it, and still studying it to understand it completely.
At the end of this tutorial, you can basically add shapes, move/rotate/scale them, and since they are created in a vector form, they are keeping their resolutions, there are also connectors that can connect each shape with another.
My goal, since I need to create a simulator which shows how internet protocols are delivered, is to create a divided diagram in which Side A communicates with Side B. it could read an automata and simulate the transitions in the diagram.
I'm thinking of how to deliever this, and since I don't have a lot of knowledge in WPF, I wonder in which way should I implement it.
Should I create 2 different Canvases? or maybe dividing 1 canvas with two sides?
The main issue I'm dealing with, is that when a shape is being dragged to the end margin of the window, then the window allow me to slide it so I can see the rest of the field, this is being done by increasing the size of the Canvas, as seen in the Tutorial Part 1.
However, if my canvas is divided by two, and there's a border in the middle, how can I create two sliders for each of the sides?
I was wondering if you can give me any tips about how approaching this idea, since my knowledge in WPF is still very limited.
Here is my point of view, but it would be very useful if you would provide a more/less final sketch of your app. I recommend using Telerik AppMock but paint will also suffice ;).
From what I have understood you should need 3 canvases.
1-st is canvas on the left.
2-nd is canvas on the right.
3-rd is on top of both canvases.
When you want to drag an element, you must set opacity of the clicked element to be a bit transparent and leave it on its place(1st canvas), add copy of dragged element in to the 3rd canvas. When you do leftmousebuttonup(drop dragged item), you have to check where was it dropped and if it was droppend on the 2nd canvas you add it to this canvas. To position element on the canvas you can use Canvas.SetLeft and accordingly SetRight method.
You can put 1st and 2nd canvases into Grid. Even if Canvases will be bigger if Grid, view will be cut only to the size of the Grid.
Moreover, to allow canvases manipulation, add there (to the Grid) a scrollviewer which will Translate Transform the canvases given to their sizes.
Later, try to use MVVM pattern to fill your Canvases with data.
I would also suggest an ObservableColletion of drawable (you can use FrameworkElement as base class) and draggable objects. Different for every Canvas.
Good luck!

Image glimmer or sparkle animation

I've been searching for awhile, but haven't been able to find anything. I'd like to be able to add kind of a glimmer or sparkly animation on an image element in wpf.
Essentially the effect here I'm after here is the same that you get with trading cards that are "foil's".
I'd like to have an image, and then be able to add this animation to it at will. I'm thinking maybe some kind of user control, or template possibly. Hopefully generic enough that I can just toss an image at it and it will just overlay the image and run.
Any ideas?
A simple construction that easily can be turned into a control is by nesting the image in a Grid and adding a second Grid (on top) as a sibling.
De second grid can be given a linear gradient brush that is primarily transparent but does contain a white glimmer.
This brush can be animated; you could move it and change the opacity of the grid/brush.
This way you do not change the image.

How to display a background control in transparent overlapping control?

I'm building a form with two layers of controls. The bottom layer is a set of Panels with defined properties, one of which is a color different from the form background. The top layer is a set of picture boxes I'm using to display a circle. I've set the PictureBox Background to Color.Transparent, and I've offset it from the underlying Panel by one pixel to get the form to draw the underlying Panel. However, the area around the circle in the PictureBox is displaying the Form Background color, not the panel color. I don't want to draw the circle in the Panel, because I want the circles to move between Panels, and actually look like just a circle that's floating across the form independent of the Panel board underneath. Think of the effect as moving a piece on a board game (you see the peg move across the board, possibly on a diagonal not following the normal game path, then stop in a place on the game).
How can I get the PictureBox to have the underlying Form and panels show through, not just the form background color? I'm using C# Visual Studio 2010, and I'm not a terribly experienced programmer, so a code example would be helpful. An image of the form is at:
http://www.imageurlhost.com/images/salgmpcxvcz830c3flt.jpg
Found a way around the problem. I got rid of the Panels for the spaces in the game, and instead drew them as rectangles on the form's background image.

WPF/C#: Images rotating from a listview?

I just want ask for your comments/suggestions on how to create a customized listview (if that's a good implementation) in WPF that displays images coming from a table from a database (more like a playlist) that rotates similar to a film (moving horizontally - on loop)
Any ideas?
If you have a list of Images, you can create an Image control for each one, put each Image control in a horizontal StackPanel, put the StackPanel inside a Canvas (of whatever size of the "film"), and animate the Left property of the Canvas to have the images roll.
Of course, if you need that the images wrap (the first one after the last one), you could forget about the StackPanel and move each Image separately.

How can I animate a transition when moving a child from one panel to another in Silverlight

I would like to animate a transition when moving content between two panels. I am getting a bit map image of a detail record and docking it as a thumbnail in the panel below. The docking area is in a footer grid and the content detail is in another grid that sits above the dock area (the dock and the main content area live in separate rows of the root layout control - another grid).
I have tried implementing this with a ScaleTransform and a TranslateTransform, simultaneously shrinking the image and moving it towards the footer control. When it moves into the footer control, it gets clipped even though the image Canvas.ZIndex property is set to a very high number. Eventually the thumnbail will need to be a child of a StackPanel that sits inside the footer grid.
Thanks for your consideration and help.
I had a similar problem (clipping) with a WPF animation I had. The problem was that the owner of the animation needed to be a parent of both containers for the animation to work (in my case I made it the actual window holding the containers).
Without any code, I can't see if that is your problem, but I thought I would throw it out there.
You can see my code where I animate moving from one container to another here:
http://wiassistant.codeplex.com/sourcecontrol/changeset/view/36638?projectName=WIAssistant#924851
(See the AnimatePaneBox method at the bottom of the file.) This may or may not be useful to you.
I've done something similar by creating a Canvas that sits over the top of both containers, using a WritableBitmap (if necessary) to create a rendering of the object that you're moving and attach it to that Canvas, animate the bitmap (translate, scale, opacity, whatever), and then pop the new object in under it at the end of the animation. It can be brittle if your controls need to be able to move or resize, but in most of my circumstances it's been a reliable hack.

Resources