WPF/C#: WPF Path Maker Tool/Sample? - c#

I am just wondering if it's possible to create a WPF application that allows users to use a certain pen to plot directions to make a certain path and able to display the path data.
The idea is almost the same with this one: http://blogs.msdn.com/b/gavingear/archive/2007/02/15/intoducing-pathmaker-a-tool-for-creating-path-markup-for-wpf-e.aspx
I also found a good sample where I can draw lines and stuff inside the canvas: http://www.codeproject.com/KB/WPF/WPF_DrawTools.aspx
I'm just looking for a good head start. Any suggestions?

Jesema is another one that might be helpful for you:
http://marlongrech.wordpress.com/jasema/
If you want something where you can draw stuff inside a canvas, there's livegeometry
http://livegeometry.codeplex.com/
but that one has the path data abstracted away (that's more similar to your draw tools example).
Hope those help!

I know this question is quite old, but I found that Inkscape supports save to XAML.
See this article: http://www.software-architects.com/devblog/2008/01/13/Graphic-In-XAML-And-WPF

Related

Erase part of image and replace with background ios

I create the application on iOS using Xamarain.iOS, where one of the functions is erase the object from a photo of room and insert another element on this place. The application is in the process of planning and I looking for some libraries that will assist. Currently I found only openCV, but I have a problem with binding it to Xamarin.iOS. Over the binding I am still working, but I wanted to know if there are any alternatives to openCV. I was very long time looking for any library that would assist and maybe someone knows a better option.
I want do something like this: https://itunes.apple.com/us/app/easy-eraser-remove-unwanted/id839750800?mt=8
Check whether below sample is useful or not
https://github.com/craighowarth/WipeAwayView
It is used to erase the upper layer to reveal the underneath image or view.
Hope it helps you...!

Drawing Lines in WPF-Forms with crayon-shader?

we have a project at university where we have to create fractals that are controllable by the user (with kinect). We are still in an early phase where we evaluate some ideas (though we already got some working prototypes). Our idea right now is to use a blackboard-image as background and draw the fractals on top of it. To make this look more natural we'd like to use some crayon effects on the lines we draw.
Our internet-research produced two main ideas to achieve this:
Paint an image of a photoshop-like brush for every moueposition of a line.
Use shaders on drawline-functions.
The first does work for an early test, but looks awful. I guess the latter would be the best approach, but the information in the internet seems to be lacking regarding this topic. At least I didn't find anything that really helped a lot. The Questions is:
Has anyone links or general tips on how to achieve this effect, or is it not possible in C#/WPF. Might there be an even better way? And how can I apply a created shader to drawline-method/brushes?
Thanks in advance and kind regards
Michael
EDIT
Nice tip from #Bradley Uffner ! (unfortunately he deleted his answer)
There is a tutorial here on how to achieve such effect :
http://alastaira.wordpress.com/2013/11/01/hand-drawn-shaders-and-creating-tonal-art-maps/
Another thing I've found recently which might interests you :
http://blogs.msdn.com/b/hemipteran/archive/2014/03/26/generating-noise-for-applications.aspx
I've didn't read well the title of your question, Windows Forms do not support shaders at all.
Be more specific about the meaning of a crayon shader
Regarding using shaders in WPF, you cannot apply them at a line-level but on a Control level instead.
This the class representing a shader in WPF:
http://msdn.microsoft.com/en-us/library/system.windows.media.effects.effect(v=vs.110).aspx
What I suggest
use an Image and set its Source property to use a WriteableBitmap
use the excellent WriteableBitmapEx library to easily draw on it, basically it's the WriteableBitmap in WPF but with many extension methods for drawing lines, circles, rectangles etc ...
then apply your shader to the Effect property of Image
For developing your shader
Use Shazzam, it allows you to develop an HLSL shader for WPF in a cool interface, preview it instantly and it will generate the Effect class ready to paste on your project.
There might be a couple of interesting shader for you in DOSBox SVN-Daum
Here's an example of the cartoon shader :
Obviously there will be quite some work as copy-pasting the shader to Shazzam won't work right away but you'll know what are the maths behind achieving the effect.
Mark the answer as accepted if you are satisfied with it :D if not edit your question and add more details.

Drawing a string that follows a path using GDI+

I've been scratching my head over this all day. I need to dynamically create an image that contains a string provided by the client. The only problem is, the string needs to be drawn along a curve like the image below. I would also like to specify the angle of the curve because this text needs to be displayed on a number of products, and the curve varies on each product.
I've attempted to loop through the string and display each character and give each one a specific coordinate to resemble a parabola, but in order for that to be useful, each character needs to be rotated to fit the curve. Does anyone have any suggestions from the System.Drawing library that may be of use to me?
I found this article on Code Project related to drawing text along a path in VB.NET - I'm sure a standard code converter could change this automatically to C# for you and it may solve your problem!
http://www.codeproject.com/Articles/13864/Text-on-Path-with-VB-NET
After doing a bit of research, it seems that WPF is the best route to take when generating warped text. A few google searches led me to this project. There is a minimal amount of XAML, and it's still written in C#. Credit goes to #lneir on codeproject for providing this remarkable bit of code. It's scalable, flexible, and wonderfully written, and the best part... no bezier curves.
I also mentioned that this text needs to be rendered on a dynamically created image. Turns out you can convert any WPF control to an image. Here's a link I found.
Thanks for the responses.

Using Graph# for drawing graph

I want to draw a graph like the one i've attached here:
I dont wanna re invent the wheel and start to draw circles and so on, so i googled for libraries and what i found is Graph#. Unfortunately there is no documentation/tutorial, so i'm a little confused that is this what i need or not!
What I need is to be able to choose colors for vertexes, set font and size, thickness of edges and distance from the root. Anyone can help me? Any example of graph#? any other library?
Any help is appreciated, thanks
You can achieve this using the GraphX library based on Graph# (http://graphx.codeplex.com)
Although some modifications will be needed to do so such as templates change or algorithm customizations. If you have any questions please feel free to ask in the Discussions page on the site. Cheers.

C#/.NET: Creating Dynamic Visuals in C#

NOTE: I am not exactly sure how to title or tag this question, so if you have any ideas, PLEASE help!
I'm currently envisioning a few possible projects that involve dynamically rendering something (whether it is a point, a line, text, or music notes on a staff, for hypothetical example), but, if I were to undertake these projects, I'm not really sure how to approach this design. What I'm curious about is sort of how programs like Word, or Geometer's Sketchpad, or Finale, create a blank "canvas" and render text, geometry, or music on it, respectively - how can this be done in C#, or in .NET, in general?
First of all, what is the best framework/platform to use: WinForms, WPF, something else? I'm open to many options, as I'm just trying to understand the different ways this can be done.
Next, how can I create such a "canvas" (if we go back to that metaphor) using the different frameworks you answered for part 1? And also, how can I render stuff onto it?
I hope my question isn't too confusing or n00bie. I just don't know how to approach such a prospect. Thanks!
UPDATE: I have now posted a follow-up question which is less broad. I have provided an hypothetical example of what I would like to accomplish. However, I will still accept an answer here, even though my question isn't fully answered.
WPF would probably suit your project well. I like the book Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, it covers most of the topics you're asking about.
You'll probably get better answers with a more focused question. The scope of your question is too large to be answered easily or concisely.
WPF makes it easier to refactor designs for such a project by easily moving shape drawing code between just drawing simple shapes and contents of controls. If you need the richness of custom controls, WPF allows a fairly smooth transition.
Most of the graphics can be defined in XAML which means you can export them from programs like Illustrator or anything that generates the standard SVG vector graphics, via an SVG-XAML converter.
I like WPF Unleashed and it has a nice discussion of 2D graphics and how to use the DrawingContext class for such a visual editor.
Do you know that there's an event called Paint? Everytime Windows OS needs to displays or repaint something on your form, this event is triggered. So, you create a Paint event handler, and everything is possible in that. For eg:
Word: you have a WordDocument data structure with the formatted tags and stuffs, you paint each character/ each word or each block of words one-by-one using a desired brush/paint and font. You might also wanna paint your background and stuff... If, for example the user change the font of 1 particular block, your WordDocument must change something to reflect that font change. And then you do an myForm.Invalidate() to repaint your form (and thus update your font). => Dynamically update your GUI.
Sketchpad: you need datastructures such as Line, Point, Triangle, etc. And then, each time OnPaint is triggered, you paint it dynamically. E.g: myGraphics.DrawLine(..), myGraphics.DrawCircle(..)
Similarly to Finale.
One thing you should do is to handle your data structure and drawing classes carefully, and instead of drawing everything in your OnPaint() method, you create several DrawMe(..) methods in your entity classes, and ask them to draw themselves. E.g: myCircle.DrawMe(..), myScore.DrawMe(..)
Hope that'll help,
Ben
There is no universal answer to your question - it is too generic.
Are you talking about dynamicly created controls, standard UI components (dropdowns, buttons)?
Is it vector graphics - like in drawings, or may be it is 2D image processing - or is it 3D?

Categories