I have a Window which displays a set of MediaElements in it. They consume a lot of memory. There is a preview option.
The preview needs to be synchronized with the main Window, where the MediaElementsare loaded and playing.
Presently, I run two instances of the controls which are loaded in the main Window and preview Window and it slows the entire application down. Sometimes some of the MediaElements go blank too.
Is it possible to display an instance of a Window or UserControl, which is already running or added as a child control, in a separate Panel, Canvas or Grid.
There are known limitations with using multiple MediaElements. It isn't recommended as you can see here and here.
I would recommend you try using the WPF MediaKit or the DirectShowNet library.
The WPF MediaKit provides a direct alternative to MediaElement.
It's MediaUriElement can be used like so
<DirectShowControls:MediaUriElement
Source="{Binding ElementName=fileDialog, Path=FilePath}"
Stretch="Uniform"
VideoRenderer="VideoMixingRenderer9"
LoadedBehavior="Play"/>
Solved the Synchronization Issue with the Main Window and the Preview window by using VisualBrush and assigning the Visual of it to the Main Window and this effectively helped me to reduce the memory usage.
Referece : Link:visual-brush-in-wpf
Related
I have a problem that is similar to that posted here. I have posted before about using Caliburn.Micro in an Excel Document customization where the WPF controls are on an ActionsPane without receiving much help.
I currently have this working by placing the ShellView user control onto the design surface of the ActionsPane inside the ElementHost. Most things work as normal with Caliburn.Micro, however I do not get any Activate or Deactivate events because I haven't got a reference to a Caliburn.Micro WindowManager.
If I create a new window manager and use it to show a window using ShowWindow, then the window appears as a completely separate window (not in the ActionPane) however I do get Activate/Deactivate events.
Is there some way to attach Caliburn.Micro's Window manager to the ActionPane within Excel. I already have a MEF Bootstrapper passing false to BootstrapperBase.
Regards
Alan
With the Weifen Luo DockPanel component, one can add to their .net project the ability to dock forms within other forms. The component is very well done.
Now, I see from this page at the project forum at github (where this component is now hosted), that it is possible, through the use of this dock.extender to allow the floating windows to have a normal winform look, that is, sizeable with regular Windows title bar, maximize box, minimize box, etc (see here, too). This also allows for the form's icon to show.
My problem is, and hence my question, is that the icon I assign in the form's properties will show in the designer, but one it runs in debug as a float-panel, a generic form icons appears in its place.
Now, I tried assigning the icon through code (both in the form's own code, and in the main application code too, where the form is called) rather than through properties, and that didn't work either.
So how do I get my own custom icon to show as the form's icon when the form is floated, and the extender is used? I am using the main docking panel in DockingWindow mode.
[EDIT]
I think this is a hard question! It's been 2 days and I've not gotten any answers!
This requires a change to the the FloatWindow class itself to set and update the Icon property internally as the content changes.
I have just checked the change in and it will be included in the 2.7 release of the library.
https://github.com/dockpanelsuite/dockpanelsuite/issues/35
I have an interesting case to solve:
I have a native (winapi) application, which uses MDI. This application allows me to extend itself with a simple scripting language. The scripts are launched on different thread than UI thread (although I can get the UI thread ID with appropriate functions). The scripting language also allow me to launch any c++ code (through LoadLibrary).
What I would like to achieve is to create a new window inside this application, which could host WPF and "attach it" as a MDI child window to MDI client (mdi area). Also, I would like this window to properly "talk" to MDI area, for example update list of windows in mdi menu.
So far, my first guess was to just create a WinForms window, host WPF inside, and then try to make it mdi child window by setting MDI client as it's parent (because my hosting application is not written in c#, I only have a handle, so I did this with User32.SetParent() P/Invoke). This worked almost well, after I attached my script thread to GUI thread, but I had few problems with it: the MDI menu with active windows did not update, the window did not interact correctly (it stayed on stop when it shouldn't etc.).
Then, I tried to set flags (style, exStyles) with SetWindowLongPtr. It changed my window's behavior a bit, but that was still not it.
Now I'm considering using CreateMDIWindow function, or doing it by SendMessage, according to docs sending message should create a window, even if I send it from different thread. The problem is, that this way would give me a native handle only, and I could not find (yet) any way of hosting WinForms / WPF inside it.
I'm curious if anyone tried to do something similar and had any results with it? Which way would be the best - trying to create a WinForms window and add it to MDI client, or create a native window and try to host WinForms in it (any particular way of doing that)?
Most answers for this question I have found are dealing with situation where hosting application is managed, so you can just set .MDIParent property, which won't work in this case I'm afraid.
I am integrating a webcam in a WPF application. I can see the camera feed in the main window, as I pass its HANDLE on to the DirectShow functions. But this is not what I want.
The main form has a Image control, where I'd like to see the output. However, in order to do this, I need the control's Handle.
Any hint on how to do this?
Thanks in advance,
Gianluca.
An Image Control in WPF, unlike Windows Forms, doesn't actually have an HWND.
WPF works differently than Windows Forms - each control is not a wrapper around a native "window" with a handle, but rather composed together using Direct3D at runtime by the layout system.
If you need to actually host output from a Webcam inside of a WPF window, you should look at using HwndHost (or a subclass). The simplest way is often to just host a Windows Forms control inside of a WindowsFormsHost, though managing an HWND yourself via HwndHost is more efficient.
Using an WindowsFormsHost and a picture box inside is a good solution that I used for a similar problem where I needed a handle to display a video stream. But be careful, in order to work, the Window that is hosting the WindowsFormsHost control must have AllowsTransparency="false"!
I have a application(not mine) that uses AxXtremeDockingPane by CodeJock to add dockable panels to the application.
AxXtremeDockingPane has a method called AttachToWindow(int handle) which when called will create a docking manger into the window with the handle supplied, which can be any application.
I was wondering if there are any other free/cheaper docking controls that will let you do the same thing?
What I am trying to do is, the main application(not mine) creates a docking manager in it's main window when the application runs but they made access to the AxXtremeDockingPane private meaning that I can not add my own panels to the main application window. The problem is if you try and make a new AxXtremeDockingPane and call AttachToWindow(int handle) using the handle to the main application or any child windows it throws a MemoryAccessViolation because there is already a docking manager there.
I would like to find another suite that can do the same thing, so I can create a new docking manager into the main window, so have AxXtremeDockingPane and {other control} in the main window.
Sorry bit hard to explain.
Does anyone know how I can do this, or know any tools that do.
I've never used it, but there is an open-source DockPanel suite on SourceForge here:
http://dockpanelsuite.com
It looks exactly like Visual Studio's DockPanel stuff based on the screenshots.