I have a number of images and I want to drag every image to a certain point or target.
The problem here is that when I drag the image which I want to get the copy or you can say the clone of that image, it should be able to be dragged any number of times whenever I feel like doing so. Currently, that is not the case and I am unable to make out what should be done here further. This is my code :
<Image Height="100" Width="100" ManipulationStarted="abc_ManipulationStarted" ManipulationCompleted="abc_ManipulationCompleted" x:Name="abc" Source="/Assets/a.png" MouseLeave="abc_MouseLeave">
<Image.RenderTransform>
<CompositeTransform x:Name="ImageTransformation2" ScaleX="1" ScaleY="1"/>
</Image.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="Image_DragDelta4" DragCompleted="GestureListener_DragCompleted" />
</toolkit:GestureService.GestureListener>
</Image>
Appreciate any suggestions or guidance here.
If I understand correctly, you want to clone your image everytime you drag from it.
Then you won't be able to do that on xaml code. You will have to create a new Image object in you C# code-behind and place it where your original image is placed: this will be your new "base image".
What you will really will be moving will be the image you declared via xaml (at least for the first time).
If you need any more assistance, or if I didn't understand the problem correctly please let me know.
Related
I'm currently working on a window that focuses on some elements on screen while blurring the rest of the area.
Using common methods like the WindowCompositionAttribute and the others are not suitable for this situation as there are limitations to it and it doesn't meet the standards regarding the intensity of the blur, contrast and colors which should be strict.
What i have managed to solve my problem was building an image stream with a light image encoder to enhance performance but then that wasn't enough. So, i thought of writing a motion detection algorithm to only steam when there's motion, but it still didn't change the performance drops.
What i need is something like those of the native OSX windows and Windows 10 Start Menu, so how are they created and run efficiently without any heavy load on the performance?
To create a new Window from scratch you have to set WindowsStyle to none (AllowTransparency="True" can be set only along with WindowsStyle="None") and from there build the style of the window.
However, you will face several issues if you follow this approach:
-no buttons (minimize, close)
-no support for fullscreen (taskbar issues)
I would suggest you to have a base view and include the other views inside the main view(which has the blur effect).
The blur effect could be obtained easily by doing something like below:
<Grid>
<Grid Margin="5" Background="#FF3782DC">
<!--<Grid.Background>
<Image Source="test.png"></Image>
</Grid.Background>-->
<Grid.Effect>
<BlurEffect Radius="100" />
</Grid.Effect>
</Grid>
<TextBlock
x:Name="textBlock"
Height="61"
Margin="136,82,211,0"
VerticalAlignment="Top"
Text="test"
TextWrapping="Wrap" />
</Grid>
I've set a color for the background, but you could set an image as background and by default it would be blurred (here you should set a binding and every time the view changes, you have to take a snapshot of the screen and set the source of the Image). However you will probably have some performance issues, but with a good encoder (JPEGencoder) it will be fast enough.
Hope that helps you!
I just started using Geomectry Drawing in xaml and I came across this interesting article https://msdn.microsoft.com/en-us/library/aa480159.aspx. Here, I find out that the following drawingbrush gives a graph diagram as an output.
<DrawingBrush x:Name="gridBackgroundBrush"
Viewport="0,0,10,10"
ViewportUnits="Absolute"
TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="Green" />
<GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="Green" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
From further reading, I figure out that M means starting point or move to, L means line and Z means close but could not figure out how this will give me two lines - one horizontal and one vertical? Any help understanding this will be highly appreciated. Thanks.
So here's a quick break down for you.
Your example is a DrawingBrush which is explicitly set to TileMode="Tile" which is the equivalent of repeat-x/repeat-y if you're more familiar with CSS as example. So it's instructed to repeat itself up-down/left-right repeating.
Your two bits of your Geometry Drawing if translated individually are two squares with one stretching vertical, one stretching horizontal. While your explicitly set ViewportUnits is dictating the size and position effectively making repeated columns and rows.
Your Path Geometry uses Path Markup Syntax to draw these lines as you pointed out. For a more visual explanation replace your Brush on each.
<GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="Red" />
<GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="Blue" />
...and voila! You have yourself a repeated line background with effective vertical/horizontal columns creating your grid. See links for more detail and hope this helps. Cheers!
Oh, and the question you got that from also had a link that would have shed a little light on it but not as much as you'd like so I didn't mark this duplicate.
ADDENDUM:
A little more clarification. Though if you want to learn more I'd follow the documentation link someone spent a lot of time writing to answer this already. Think if you have an x,y grid you're drawing points on.
Say you're using the pen tool in something like Adobe Illustrator, or Blend. Your first click is setting your M as your start point based on the relative size of the container. Then you click in another spot...well now you effectively have a L line.
So when we see: M0,0 L1,0 that's our first starting Line. In this case it's the top corner stretching to the right corner since there's not another anchor in the line between the two points. The next set acts as the anchor to tell that line to change it's direction to make the side, and so on, and so fourth until you hit the end at Z. Hope this helps but I would encourage the documentation first.
Here they are individually if you feel like tinkering with numbers and learning:
<Path Data="M0,0 L1,0 1,0.1, 0,0.1Z"
Height="150" Width="150" Stroke="Red" />
<Path Data="M0,0 L0,1 0.1,1, 0.1,0Z"
Height="150" Width="150" Stroke="Blue" />
I came cross the same thing when I used GMaps V3. It is an SVG path notation path that allows you to draw on WPF and on browsers too. You can find the complete documentation in the link.
I have clipped Image:
<Image Name="Img" Source="/UntitledImage.jpg">
<Image.Clip>
<EllipseGeometry Center="115,115" RadiusX="50" RadiusY="50"></EllipseGeometry>
</Image.Clip>
</Image>
or:
<Image Name="oldImg" Source="/UntitledImage.jpg">
<Image.Clip>
<RectangleGeometry Rect="115,115,50,50"></RectangleGeometry>
</Image.Clip>
</Image>
I want added blur for each edge for Image after clip.
I want manage thick blur area for Image.
Is it possible?
Rather than creating a blurred version of each image, why not put a semi-transparent image over the top of the image to give the appearance of a blurred edge instead?
This would, I expect, be much quicker and simpler.
This solution might be a little heavier for your purpose, but I suppose it will serve any need you could have.
You can try to use Nokia Imaging SDK to process your images. The SDK usage is very simple and well documented In the developer library.
Also, before you decide, the link above contains sample apps to explore the effects.
I am trying to flip and rotate image in C# (for Windows Store App).
And it becomes complicated if I try to flip image which is rotated first by some angle say x.
I see
Image.RotateFlip
method is available only in for Dektop apps.
Is there any existing API that can help in this situation? Any help appreciated :)
If you are working on a Windows Store App (in C#), I am assuming that you are using XAML for your GUI. If that is the case and you want to perform a rotation, This bit of markup should do it.
For Rotation :
<Image Source="/Assets/Logo.png" >
<Image.RenderTransform>
<RotateTransform Angle="90"/>
</Image.RenderTransform>
</Image>
For Flipping :
<Image Source="/Assets/Logo.png">
<Image.RenderTransform>
<ScaleTransform ScaleY="-1"/>
</Image.RenderTransform>
</Image>
If you want to perform an animation, you might want to take a look at this answer.
I want to be able to have an Image object render just a portion an image, that I will control programatically. For example, this is what I have so far:
<Image Grid.Column="1" Grid.Row="1" Grid.RowSpan="3" Height="160"
HorizontalAlignment="Right" Name="avatarImage" Stretch="None"
VerticalAlignment="Center" Width="160"
Source="/Crystal%20Cloud;component/data/images/characters.png"
Margin="0,0,40,0" />
I want to only render one of the characters at a time, and use the button to change which one it renders. Can I do this, and if so, how?
You can definitely use the ImageBrush.Transform to extract the portion of the bitmap that you are interested in, and if you do not require very high frame rates that is the way to go.
However if you are going to need to optimize the frame rate then you can dynamically extract the individual bitmaps from the sprite sheet and cache those bitmaps and display them as required. The blog post below provides some code that you can use to extract the individual bitmaps, that you can then cache.
http://taylorza.blogspot.com/2009/08/silverlight-spritesheet-management-with.html
Remember the key to performance here is that you cache the bitmaps and do not go through all the trouble of extracting them each time you need a new image.
You also can place your image inside a Canvas and define a clip for it (visible portion). Then for animating the character you can programatically change the Top and Left of the image in time intervals:
<Canvas Width="200" Height="100">
<Canvas.Clip>
<RectangleGeometry Rect="0, 0, 200, 100"/>
</Canvas.Clip>
<Image x:Name="imgCharacter" Source="..." Canvas.Left="..." Canvas.Top="..." />
</Canvas>
imgCharacter.SetValue(Canvas.LeftProperty, currentFrame.Left);
imgCharacter.SetValue(Canvas.LeftProperty, currentFrame.Top);