Elementhosted WPF-Mediaelement does not allow rotation - c#

I am having a windows forms app.
I want to use a mediaelement in it, so I use the elementhost. I create a wpf usercontrol in which I put a mediaelement. In my app I write the following having the goal in mind to rotate the element.
System.Windows.Controls.MediaElement wm = new
System.Windows.Controls.MediaElement();
wm.LayoutTransform.Value.Rotate(22.0);
elementHost1.Child = wm;
wm.Source = new Uri(dateiname);
wm.Play();
dateiname is the filename.
It plays but it is not rotated. How to rotate wm's video?

Maybe a little later. Try this:
RotateTransform rt = new RotateTransform {Angle = 20.0};
wm.LayoutTransform = rt;

Related

XAML/UWP add drop shadow to shapes on canvas

So I am rendering a variety of shapes on a Canvas, think PowerPoint. The user can CRUD shapes on the Canvas.
I would now like to add a DropShadow to a Shape.
Only, I have no idea how to actually do that. Community Toolkit does not seem to allow adding a dropshadow in Code-Behind (at least there is no docu). The other few solutions found online seem to apply ways that are either not UWP-compatible, or deprecated...
Any help?
The DropShadow class provides means of creating a configurable shadow that can be applied to a SpriteVisual or LayerVisual (subtree of Visuals). You can try to use it to add drop shadow to your shapes. First create a new DropShadow and associate it to your visual. For example:
Compositor compositor = ElementCompositionPreview.GetElementVisual(YourShape).Compositor;
var shadowVisual = compositor.CreateSpriteVisual();
Vector2 newSize = new Vector2(0, 0);
if (YourShape is FrameworkElement element)
{
newSize = new Vector2((float)element.ActualWidth, (float)element.ActualHeight);
}
shadowVisual.Size = newSize;
var dropShadow = compositor.CreateDropShadow();
dropShadow.BlurRadius = 10;
dropShadow.Opacity = 0.3f;
dropShadow.Offset = new Vector3(10,10,10);
dropShadow.Color = Windows.UI.Colors.Black;
shadowVisual.Shadow = dropShadow;
ElementCompositionPreview.SetElementChildVisual(YourShape, shadowVisual);
For more details about DropShadow, you can refer to this document.

How to apply color effects on a camera based app for windows phone 8.1 WinRT?

I am developing a magnifying app on windows phone 8.1 WinRT for visual impaired users and in the magnification page (camera based),i want to apply color effects and contrast for more accessibility (black in white , yellow in blue , yellow in black , black in white ,... )
http://www.1800pocketpc.com/wp-content/uploads/2014/10/Microsoft-Pocket-Magnifier-700x437.jpg
Do anyone know how to deal with that ?
I believe the easiest way for you to do it is using the Lumia Imaging SDK (https://msdn.microsoft.com/en-us/library/dn859593.aspx) which works for WinRT platform. There is for example ContrastFilter class which would probably suit you very well. Here's how to use it:
using (var filterEffect = new FilterEffect(source))
{
// Initialize the filter and add the filter to the FilterEffect collection
var filter = new ContrastFilter(0.5);
filterEffect.Filters = new IFilter[] { filter };
// Create a target where the filtered image will be rendered to
var target = new WriteableBitmap(width, height);
// Create a new renderer which outputs WriteableBitmaps
using (var renderer = new WriteableBitmapRenderer(filterEffect, target))
{
// Render the image with the filter(s)
await renderer.RenderAsync();
// Set the output image to Image control as a source
ImageControl.Source = target;
}
await SaveEffectAsync(filterEffect, "ContrastFilter.jpg", outputImageSize);
}
And before anyone says that it's a copy/paste from the sdk docs - it's ok as I've written that sample to the original docs :)

How to control speed of audio in Media Element in Window Store App

I am playing audio with media element by converting text to speech in my app.
here is my code
var synth = new SpeechSynthesizer();
var voice=SpeechSynthesizer.AllVoices;
synth.Voice = voice[2];
var text = "My name is John";
var stream = await synth.SynthesizeTextToStreamAsync(text);
var me = new MediaElement();
me.SetSource(stream, stream.ContentType);
me.Play();
Audio here being played is fast .I want that audio should play slowly. I tried Playback property of media element but its does not work.How to control speed of play back in media element?
Use DefaultPlaybackRate property:
var me = new MediaElement();
me.DefaultPlaybackRate = 0.5;
me.SetSource(stream, stream.ContentType);
me.Play();
You can also use PlaybackRate property if you don't want it to persist throughout the lifetime of the MediaElement. This happens because PlaybackRate will have DefaultPlaybackRate value when Play method is called till playback ends.
Reference

Windows Phone 7 Creating video streams

Hi i am creating a project in windows phone 7 that will capture videos and transport it to some other device. Here is my code so far.
// Initialize the camera if it exists on the device.
if (videoCaptureDevice != null)
{
captureSource = new CaptureSource();
fileSink = new FileSink();
// Create the VideoBrush for the viewfinder.
videoRecorderBrush = new VideoBrush();
CompositeTransform transform = new CompositeTransform();
transform.CenterX = 0.5;
transform.CenterY = 0.5;
transform.Rotation = 90;
videoRecorderBrush.RelativeTransform = transform;
videoRecorderBrush.SetSource(captureSource);
// Display the viewfinder image on the rectangle.
viewfinderRectangle.Fill = videoRecorderBrush;
// Start video capture and display it on the viewfinder.
captureSource.Start();
// Set the button state and the message.
}
What i want is to save the the video that was captured to some kind of buffer,so that i can send it and the other device can see that video (Video Call). Any ideas?
bsically you can go for this sample fro msdn
the voip sample
for a normal description of how to make application here's a link in silverlight
you can mapp at least some code and understanding from here ..
video call silverlight

Zoom for WP7 app

I'm lookin for a control for a WP7 app that allows zooming by pinch. I saw on codeplex smth like DeepZoomContener but is doesn't do well. Any ideas? I just need zoom to 150% by pinching that's all.
Regards.
Thx Mick but this messed up with my layout a bit. I did something more simple.
I use the Silverlight Toolkit for WP7 and add the pinch GetureListener to my grid
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener PinchDelta="GestureListener_PinchDelta" />
</toolkit:GestureService.GestureListener>
and code in event
private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
{
if (e.DistanceRatio < 1.0 || e.DistanceRatio > 1.4)
{
return;
}
// Create the animation for pinch
Storyboard storyboard = new Storyboard();
DoubleAnimation pinchXAnimation = new DoubleAnimation();
pinchXAnimation.To = e.DistanceRatio;
pinchXAnimation.Duration = TimeSpan.FromSeconds(0.3);
storyboard.Children.Add(pinchXAnimation);
Storyboard.SetTargetProperty(pinchXAnimation, new PropertyPath("GridScaling.ScaleX"));
Storyboard.SetTarget(pinchXAnimation, GridScaling);
DoubleAnimation pinchYAnimation = new DoubleAnimation();
pinchYAnimation.To = e.DistanceRatio;
pinchYAnimation.Duration = TimeSpan.FromSeconds(0.3);
storyboard.Children.Add(pinchYAnimation);
Storyboard.SetTargetProperty(pinchYAnimation, new PropertyPath("GridScaling.ScaleY"));
Storyboard.SetTarget(pinchYAnimation, GridScaling);
storyboard.Begin();
}
Checkout Laurent Bugnions control.
MultiTouch Behavior for Windows Phone 7
MultiTouch Behavior: Update for Windows Phone 7 tools beta

Categories

Resources