|
|
Comments and Discussions
|
|
 |

|
5 from me also.
The author clearly had a mental grasp on what was needed and what was not. Very well documented also.
|
|
|
|
|

|
Excellent Control! Thanks so much for sharing.
I was wondering if you could tell me how to invert the primary marker: that is, what array of points would I use to have the arrow pointing away from the center of the control as opposed to pointing towards the center of the control?
|
|
|
|

|
Todd,
The default marker is built using this code inside the control:
PointF[] markerPoly = new PointF[4];
markerPoly[0] = new PointF(0.35F, 0.00F);
markerPoly[1] = new PointF(0.80F, 0.20F);
markerPoly[2] = new PointF(0.70F, 0.00F);
markerPoly[3] = new PointF(0.80F, -0.20F);
To make the marker point away from the center, you could just move around the X values. To replace the primary marker, you would first clear the existing markers, and then add your own.
This code would work (assuming you have a CircleControl named 'cc'):
cc.MarkerSets.Clear();
PointF[] markerPoly = new PointF[4];
markerPoly[0] = new PointF(0.80F, 0.00F);
markerPoly[1] = new PointF(0.35F, 0.20F);
markerPoly[2] = new PointF(0.45F, 0.00F);
markerPoly[3] = new PointF(0.35F, -0.20F);
CircleControl.Marker m = new CircleControl.Marker(CircleControl.MakeArgb(0.7f, Color.DarkGray),
Color.Black,
2.0f,
markerPoly);
CircleControl.MarkerSet set = new CircleControl.MarkerSet();
set.Add(m);
cc.MarkerSets.Add(set);
I hope this helps!
|
|
|
|

|
Great! Thanks much for your help.
|
|
|
|
|
|
|

|
+5=> Thanks for this great UserControl example, with several visually interesting demo projects, and very thorough documentation, including a 'real,' help file !
fyi: no problem converting, compiling, and using, in VS 2010 Pro, .NET 4.0 Client FrameWork.
best, Bill
"Reason is the natural order of truth; but imagination is the organ of
meaning." C.S. Lewis
|
|
|
|

|
Cool stuff.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|

|
good work my 5
|
|
|
|
|

|
I'd like a marker that is a circle, maybe with gradient shading. How can I make a circle from an array of PointF?
How can I position a marker within a specific ring? I'd like to move a marker to the outermost ring.
|
|
|
|

|
(I'll answer each of your questions in a separate response).
Your first question - how to make a circular marker using PointF's with gradient shading.
Presently, the only way is to calculate an arbitrary number of points on the circle, and enter them into a PointF array. The more points entered, the greater the work, but the smoother the circle.
The following code generates a circular marker with a radial color gradient going from red to blue. To use this code, create a Windows Application, and add a CircleControl named cc to the form. Paste the following code into the form's constructor immediately after the call to InitializeComponent().
cc.MarkerSets.Clear();
List<PointF> points = new List<PointF>();
points.Add(new PointF( 0.200f, 0.000f));
points.Add(new PointF( 0.220f, 0.100f));
points.Add(new PointF( 0.300f, 0.200f));
points.Add(new PointF( 0.400f, 0.240f));
points.Add(new PointF( 0.500f, 0.240f));
points.Add(new PointF( 0.600f, 0.200f));
points.Add(new PointF( 0.680f, 0.100f));
points.Add(new PointF( 0.700f, 0.000f));
points.Add(new PointF( 0.680f, -0.100f));
points.Add(new PointF( 0.600f, -0.200f));
points.Add(new PointF( 0.500f, -0.240f));
points.Add(new PointF( 0.400f, -0.240f));
points.Add(new PointF( 0.300f, -0.200f));
points.Add(new PointF( 0.220f, -0.100f));
points.Add(new PointF( 0.200f, -0.000f));
CircleControl.Marker m = new CircleControl.Marker(
new PointF(0.200f, 0.000f), new PointF(0.700f, 0.000f), Color.Red, Color.Blue, Color.Green, 1.0f, points.ToArray(), 0.0f, MouseButtons.Left, true);
CircleControl.MarkerSet set = new CircleControl.MarkerSet();
set.Add(m);
cc.MarkerSets.Add(set);
I am planning a future addition to the class which will allow for Marker's composed of GraphicPath objects, which will allow for a wide variety of shapes. But until then, you must used PointF arrays.
|
|
|
|

|
Your second question - how to position a marker within a specific ring.
The position of a ring is defined by it's radius and the sum of the radii of previously defined rings. The radial position of a marker is defined by the minimum and maximum x values in the PointF array.
To position a marker within a particular ring, the minimum and maximum x values of the points of the marker must fall within the minimum and maximum radii values of the ring.
The following code generates a CircleControl with three rings. The first ring (light blue) extends from the center to a radius of 0.3. The second ring (orange) extends from a radius of 0.3 to 0.6, and the final ring (dark green) extends from a radius 0.6 to 1.0. There is single marker (a yellow triangle), which rotates only over the final ring.
To use this code, create a Windows Application, and add a CircleControl named cc to the form. Paste the following code into the form's constructor immediately after the call to InitializeComponent().
cc.Rings.Clear();
cc.Rings.Add(0.30f, Color.LightBlue);
cc.Rings.Add(0.30f, Color.Orange);
cc.Rings.Add(0.40f, Color.DarkGreen);
cc.MarkerSets.Clear();
List<PointF> points = new List<PointF>();
points.Add(new PointF( 0.70f, 0.00f));
points.Add(new PointF( 0.90f, 0.10f));
points.Add(new PointF( 0.90f, -0.10f));
points.Add(new PointF( 0.70f, 0.00f));
CircleControl.Marker m = new CircleControl.Marker(
Color.Yellow, Color.Black, 1.0f, points.ToArray(), 0.0f, MouseButtons.Left);
CircleControl.MarkerSet set = new CircleControl.MarkerSet();
set.Add(m);
cc.MarkerSets.Add(set);
Note - as explained in the class documentation, the length and position of most CircleControl objects is specified relative to the size of the control, where 1.0 is defined as the distance from the center of the control to the nearest edge.
|
|
|
|
|

|
Useful, visually appealing, and extremely well presented!
|
|
|
|

|
Very slick. Perfect in every way. OK, I know the author, but it's still very, very good.
|
|
|
|

|
Super control. I will use it in many way that you may have not envisioned at your end!
|
|
|
|

|
Thanks for your vote, and I'm truly glad that you'll be using my code. There is no higher compliment.
|
|
|
|
|

|
Thanks for your vote! I never thought I'd get so many "5" votes on my first submission.
|
|
|
|
|
|

|
I applaud you for a cool control but more importantly for presenting a clear, concise description on how to use it! Many of the Code Project articles have good stuff to present but require every reader to duplicate the work of discovery in understanding and using it. I further commend you for your use and mention of Sandcastle. It is a great package, particularly when you add Sandcastle Help File Builder, but it is still challenging to use. I took all my notes on my experience with it and cobbled together an article just published last week that may interest you:
Taming Sandcastle: A .NET Programmer's Guide to Documenting Your Code.
|
|
|
|

|
Thanks for your comments.
I agree - Sandcastle is poorly documented. It took many iterations to get the help to appear just as I wanted. Nice to know it's not just me
I've read your Sandcastle article - it is Excellent! I really wish I'd read it before embarking on the task of documenting this project.
Coding
|
|
|
|

|
Really nice Taming Sandcastle article.
Any chance of that becoming a downloadable PDF? I would love to be able to put that on my iPad with my other coding books. Its a wonderful example and reference.
|
|
|
|

|
Absolutely! At the very top of the article there is a callout that shows the ratings and, below that, versions of the article in EPUB and PDF formats.
One thing that is not there (yet) though is my latest addition to accompany the article--a one-page wallchart describing everything you need to know about doc-comments. Just released last week, it is available here.
|
|
|
|

|
I'm a complete dork who didn't see that. I scanned the article. Saw it was great and filed away the bookmark for later reading when I can devote myself to it. I should have looked more closely.
Thank you for providing such an invaluable tool to the community.
|
|
|
|

|
No problem. Besides it gave me a chance to refer you to the wallchart as a bonus.
Thanks for the kind words!
|
|
|
|

|
Like it. Hope to see a WPF version as well.
|
|
|
|

|
Jaime,
Thanks for you vote. Alas, I am not a WPF programmer, so you'll not be seeing a WPF version (from me) anytime in the near future.
Graham
|
|
|
|

|
this is a great control!
but I only gave you a 4 because in your article you did not explain how you made it.
thanks for publishing this.
my code is perfect until i don't find a bug...
|
|
|
|

|
Christ,
I'm glad you liked the control.
Point taken about the lack of explanation in the article.
Graham
|
|
|
|

|
Need more info on the control. As a reader I am not interested to run your application rather than reading it first.
|
|
|
|

|
hi,
I ran your demoss until my anti-virus software told me not to. Its usually best to heed its advice though its done that to me with my own projects in the past.
the CircleControl looks really cool! it has a great look and seems quite flexible except my C# doesn't like it either, this is the first time I've ever seem an MS IDE step up and say "Don't run this source code it'll kill your computer" (or words to that effect). I'm sure you're not a terrorist but there seems to be something wrong. maybe its my computer, maybe it isn't... I don't know. but when I referenced the .dll file from the executables .zip file C# doesn't know its there and the intellisense can't find it.
in your article you don't explain how you wrote it. how it works. as opposed to how to 'use it'.
I wish i could use this source code but my computer's having a problem digesting it,
Christ
my code is perfect until i don't find a bug...
|
|
|
|

|
It might be a VIRUS issue, might be NOT. I remember one of my C program, when I was learning the language. When I wrote a printf() and run, my AVG antivirus was blocking it saying "VIRUS". Once I removed that particular line, it was working fine. The issue was specific to that code in my PC. I run the same code in another PC of my institute. No problem was there. Once I read your message, I recalled the same instance with me from my past...
|
|
|
|

|
Christ,
After reading your comments, I uploaded both .ZIP files, the .CHM file, and all of the .EXE files to www.virustotal.com, and they all came back clean (the site www.virustotal.com runs scans from all the major virus scanning vendors on uploaded files - it is a very useful tool). So I really have no idea why your anti-virus software gave a warning.
As for IDE warning, what version of Visual Studio are you using? I only have access to 2005. Would you be able to specify the exact wording of the warning/error message, or better yet, include a screen shot?
Thanks for reading the article and trying the software!
Graham
|
|
|
|

|
thank you for your response,
I'm using C#2010 at the moment and since I have run, compiled and integrated your control into my project the IDE no longer cries and neither does my anti-virus software so I cannot repeat to you what it said. My guess is i have gremlins and these gremlins do not like it when i down load a perfectly good controller like yours off the internet and use it in my own projects. gremlins are particular that way and when they don't understand the first thing about code and code-reuse they start to have issues.
thanks again for your controller and will be looking forward to more of your projects in the future,
Christ
my code is perfect until i don't find a bug...
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A circular motion control
| Type | Article |
| Licence | CPOL |
| First Posted | 12 Sep 2010 |
| Views | 40,895 |
| Downloads | 3,474 |
| Bookmarked | 145 times |
|
|