Is there any way in silverlight to assign multiple images at time to selecting single image and set it's source it will assign to all the images in the wrappanel.
Thanks...!!
Maybe something like this?
foreach(Image image in imageWrappanel.Children) {
image.Source = selectedImage.source;
}
Assuming you have a wrappanel named imageWrappanel and the selected Image is called selectedImage.
Related
Wondering if there is an method to save the image of multiple (overlapping) elements in WPF. I know you can pass and element to something such as, 'bitmap.Render(visual)' but if we have for example a polygon and a circle on top of an image we would like to save the combined elements (eg: flatten these layers) and save the image to a file.
Only way I can think of is to create a new container such as a panel, remove the items from the existing one and add to the new one. Get the visual then add them back.
That or Clemens good comment on the original post.
I'm working on a module that displays DWG files in WPF. I've managed to use CadLib library but it's working very slowly and I want to make it faster. I found out that if I convert that DWG file to SVG format and then print it to my XPS printer and rename the file to ZIP, I can get .page file which is basically a XAML file that displays the original SVG object in XAML.
I want to display this XAML code on a custom control and be able to pan / zoom it around. I tried to place this XAML code in a Canvas and it did manage to show up there, but now I'm stuck trying to pan / zoom the shape that was drawn there. Also, the mouse events are fired only when you click the actual drawing itself, and not the Canvas, which will be hard for the user to click...
Any help would be highly appreciated :)
You could try creating nested Canvases : One that holds the vectors and is moved on demand, one that is fixed and serves as the viewport. Haven't tried that, but it should be feasible...
Situation looks like that:
I have many icons in application and they are used in few different sizes.
I use icons as DynamicResource for example like that:
<igRibbon:MenuTool (...) LargeImage="{DynamicResource IconAdd}" />
<s:Item (...) Icon="{DynamicResource IconAdd}"/>
Some of icons are in .xaml and some in .png format
I add new icons for example like that:
<BitmapImage x:Key="IconAdd" UriSource="../Icons/IconAdd.png" />
The problem:
I would like to have icons in .ico format that I can use as DynamicResource.
I want images in .ico because this file format allows to have few different image sizes in one file. Icons in .xaml are fully resizable but they took to much time to load (because I have really a lot of them!).
Is it possible to add .ico file as DynamicResource and add x:key to it?
Even if I somehow add those .ico images, will they change size (depending on how much place they have)?
Yes, it is possible to add .ico files as a DynamicResource (and of course, because it is a resource, it must have an x:Key).
They will not automatically change size, however. Each size is extractable from the .ico like this, in which I make an Image for each of the icon's frames set to the exact size of the frame, and then add that Image to a StackPanel called imageStack:
var iconUri = new URI( "pack://application:,,,/MyIcon.ico", UriKind.RelativeOrAbsolute );
var iconDecoder = new IconBitmapDecoder( iconUri,
BitmapCreationOptions.None, BitmapCacheOption.Default );
foreach ( var frame in iconDecoder.Frames ) {
var img = new Image(){
Height = frame.PixelHeight,
Width = frame.PixelWidth,
Source = frame }
imageStack.Children.Add( img );
}
When you just use the .ico directly, it will choose whichever frame has the largest pixel resolution and resize that bitmap based on the size of the Image control, or whatever content alignment/sizing properties are in place for your Image, Button, or other control that is displaying it.
A few options for controlling which frame is added that aren't complete, but may serve as ideas towards a solution:
Programmatically split apart the icon into BitmapFrames and add them to the ResourceDictionary with keys like 'MyIcon16', 'MyIcon32', and so on.
Create a MarkupExtension or IValueConverter to extract a frame matching certain criteria such as index or size.
Since you are using DynamicResource, you can change which frame is associated with a particular resource key at any time.
You could control it by scope. You could have the 32x32 frame as a resource in the Window's ResourceDictionary with the key 'MyIcon', and have the 64x64 frame as a resource with the same key in a different scope, such as a Grid within that Window. Anything using {DynamicResource MyIcon} in the Grid will show the 64x64 frame, while everything else in the window shows the 32x32 frame.
I want to implement previews/thumbnails in my project, therefor i need the graphical output of a control as bitmap. I have a third party control which loads documents and displays them. Is it possible to fetch the output of an control and store it in a bitmap object without adding it to the UI? And If how?
Edit: I probably should said that before, but i don't know if that's important. The ThirdParty Control is an OCX(ActiveX control).
in a Form do:
Bitmap myBitmap = new Bitmap(button1.Width, button1.Height);
// button1.Draw..., not 'this.Draw...'!
button1.DrawToBitmap(myBitmap, button1.DisplayRectangle);
myBitmap.Save(#"C:\test.bmp");
I have 2 listboxes with images. i want to hide the image of first listbox when i use that image in second listbox. and also i want to know the nooftimes that i added image to the second listbox. In the second listbox image should show count of that image(on the image itself) no of images that image added.
Any suggestions..
Thanks in advance
Are you trying to create a picklist?