Silverlight Drawingbrush - silverlight

I'm new in Silverlight, and I'm looking for something like a drawing brush on Silverlight without success. I saw Tamir Khason blog on building a drawing brush in Silverlight and i download the code without any success
i'm taking about the next link:
http://www.codeproject.com/KB/silverlight/Silverlight-DrawingBrush.aspx
Can someone find the way to implement the DrawingBrush???
Thanks.
Eyal

There is no direct support.
You need to write code with the WritableBitmap class available in Silverlight 3.
We were able to create a VisualBrush kind of thing using the WritableBitmap.

Related

How to use the WinRT SwapChainPanel control in a WPF window?

I added references to WinRT dlls to a WPF project and I want to use SwapChainPanel inside of a WPF window.
Is it really possible? For now I cant get it work.
The NuGet package description for Microsoft.Toolkit.Wpf.UI.Controls mentions a SwapChainPanel but I have not found any samples using this control in WPF.
SwapChainPanel : Provides a hosting surface, where Microsoft DirectX swap chains provide content that can be rendered into a XAML UI. A SwapChainPanel element is a key component for an app that renders Microsoft DirectX graphics and then presents those visuals within a XAML page.
It's not currently officially supported - might require some private APIs in Windows, though since Stardock could implement its ModernMix - there might be some way to get it working. The thing is though - you don't have to do that. You can render content with DirectX to a WPF window in other ways. I haven't done that and it might be quite a bit of work to do, but so is anything in DirectX. You can look into DirectComposition or D3DImage class. Perhaps the article on using Direct2D with WPF can be a good sample solution.
You dont have to, as says Filip Skakun, but you can ! Just give a try to SlimDX or SharpDX. They're DirectX's implementations in C#.

Silverlight 4 WriteableBitmap to Bitmap

This is my first Silverlight app and my first go at C#. I have a C# class library that I access from Silverlight using COM. The C# library has a method that takes a Bitmap as an argument, however from what I can see Silverlight only has a WritableBitmap. Is there a way to convert a WritableBitmap to a Bitmap in Silverlight? Some other answers I have read give functions for the conversion, but the functions all return a Bitmap, which obviously throws an error when I try and build. Can anyone help?
Finally got it working by converting the WritableBitmap into a byte array, passing it through and then building the bitmap again on the other side.
I want to make sure I am understanding you correctly, you are using Silverlight to talk to a C# windows library using COM, the c# libraru is using classes that Silverlight does not have any references to, correct?
If this is the case, I would immediately look into using WPF instead of Silverlight, can you do this? The Bitmap class is really just a wrapper for a GDI+ image, which is why you wont really be able to use it in Silverlight.

.NET WPF Diagrams/Graphs

I need WPF component (beter if it will be free) for easy drawing such process graphics like on the image. Can you give an advice what to use? Thanks.
At the end i have used WPF toolkit. Its free and with few customizations can be used to draw such diagrams as i needed. Example of using is here.

How can I obtain a sketch or hand-drawn look in Silverlight for various controls?

I am looking to create a Silverlight application that employs a control style similar to what one might see when using Balsamiq Mockups or SketchFlow.
I am not sure how this look is best achieved in Silverlight. My initial thought is that clever use of a pixel shader effect on the desired control might just do the trick, however, my searches for a similar solution have failed.
What might be the best approach for drawing controls with a hand-drawn look in Silverlight?
Can this be done with a custom pixel shader?
Note: I am using Silverlight 3, but would not be opposed to using Silverlight 4 Beta if it provided a more elegant solution to the problem.
This guy has a HandDrawnBorder style in the source he provides on his website. An example of using his styles is shown here. It does say that this is for the Beta2 of WPF but that the source should compile and be usable in later releases.
EDIT: Looks like the download is broken. Might have to do some hunting...
Check out UX Musings Rough theme.
There's also a nice set of sketch style icons I found on Icon Finder.

Displaying PDFs in Silverlight

I want to make a PDF document reader, and the only thing I've found to help me is "Amyuni PDF Suite" that will turn the PDF into XAML and stream that. Are there any other controls for displaying PDFs in Silverlight? Or could I add an IFrame into Silverlight and let the client render it?
Cheers
Nik
Or could I add an IFrame into Silverlight and let the client render it?
Silverlight doesn't really have that capability. You can make your Silverlight control transparent, and have an HTML div block that sits above your Silverlight control, which you could then load a PDF in, but as for displaying a PDF within Silverlight, I think you're out of luck.
Edit:
This question has some info on how to accomplish transparent Silverlight controls, I hope it helps!
If you're ok with buying the pdf converter you can do something like this:
CanvasObject.Children.Add(XamlReader.Load("xaml string from pdf converter"));
And the pdf should be rendered inside your CanvasObject.
I really think you'll get the best result with some type of conversion to XAML. I imagine it can't be that hard to write the converter yourself, I might be wrong though.
Looks like First Floor Software has a solution but it's still in preview.
http://firstfloorsoftware.com/blog/pdf-for-silverlight-preview/
What we are actually trying to do is convert the PDF to SVG, then use something like: http://www.codeplex.com/XamlTune to then go to Xaml
you can use server side conversion of PDF say into set of bitmaps or as mentioned above SVG and return by WCF service to Silverlight client.

Resources