-1

How to make a circle with text inside ?? then move it from one location to another, and then access it later (to delete it).

I want to make something like this

princevezt
  • 67
  • 1
  • 11
  • 1
    You can create a `Circle` class containing some properties and a `Draw` method which accepts a `Graphics` object and draw the circle on graphics object. Then you can stole your circles in a data structure which you need and draw them on a surface. Moving objects is just changing circle properties and then invalidating drawing surface and so on. Take a look at this example: [how can i treat the circle as a control after drawing it?](http://stackoverflow.com/questions/38345828/how-can-i-treat-the-circle-as-a-control-after-drawing-it) – Reza Aghaei Oct 31 '16 at 13:47
  • Or use a Chart with EllipseAnnotations. But plan ahead for the full scope of what you want to do! – TaW Oct 31 '16 at 13:50

3 Answers3

2

Your question is really very broad and you got a few nice links you should study to learn all about GDI+ drawing.

But if taken literally there is a slightly exotic alternative which puts the burdon of most chores onto the Chart control from DataVisualization.Charting.

You can create EllipseAnnotations and add them to a Chart control.

Disable the Axes and clear the Legends and then use code like this to add a moveable circle wit thext inside:

EllipseAnnotation ea = new EllipseAnnotation();
ea.X = 11;  // put at..
ea.Y = 11;  // 11% of the chart's area
ea.AllowMoving = true;
ea.BackColor = Color.BlanchedAlmond;
ea.Text = (chart1.Annotations.Count + 1) + "";
chart1.Annotations.Add(ea);

enter image description here

Note that there are quite a few annotation types available. which allow you to add Rectangles, Images, Polygons, Lines and pure Text.

And another pro is that saving or loading the graphics takes only one line each, as you can serialize a Chart out of the box! :-)

TaW
  • 53,122
  • 8
  • 69
  • 111
0

GraphX for .NET is an advanced open-source graph layout and visualization library that supports different layout algorithms and provides many means for visual customizations It is capable of rendering large amount of vertices

https://github.com/panthernet/GraphX

-1

To draw shapes follow here.Also you need a complete tut,you can follow here

Some insight is here:

To draw a simple shape at design time Drag the OvalShape or RectangleShape control from the Visual Basic PowerPacks tab (to install, see Visual Basic Power Packs Controls)in the Toolbox to a form or container control.

Drag the sizing and move handles to size and position the shape. You can also size and position the shape by changing the Size and Position properties in the Properties window To create a rectangle with rounded corners, select the CornerRadius property in the Properties window and set it to a value that is greater than 0. In the Properties window, optionally set additional properties to change the appearance of the shape.

To draw a simple shape at run time On the Project menu, click Add Reference. In the Add Reference dialog box, select Microsoft.VisualBasic.PowerPacks.VS, and then click OK. In the Code Editor, add an Imports or using statement at the top of the module:

using Microsoft.VisualBasic.PowerPacks; Add the following code in an Event procedure:

ShapeContainer canvas = new ShapeContainer();
// To draw an oval, substitute 
// OvalShape for RectangleShape.
RectangleShape theShape = new RectangleShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the Shape.
theShape.Parent = canvas;
// Set the size of the shape.
theShape.Size = new System.Drawing.Size(200, 300);
// Set the location of the shape.
theShape.Location = new System.Drawing.Point(100, 100);
// To draw a rounded rectangle, add the following code:
theShape.CornerRadius = 12; 

Customizing Shapes When you use the default settings, the OvalShape and RectangleShape controls are displayed with a solid black border that is one pixel wide and a transparent background. You can change the width, style, and color of the border by setting properties. Additional properties enable you to change the background of a shape to a solid color, a pattern, a gradient fill, or an image. Before you change the background of a shape, you should know how several of the properties interact. The BackColor property setting has no effect unless the BackStyle property is set to Opaque. If the FillStyle property is set to Solid, the FillColor overrides the BackColor. If the FillStyle property is set to a pattern value such as Horizontal or Vertical, the pattern will be displayed in the FillColor. The background will be displayed in the BackColor, provided that the BackStyle property is set to Opaque. In order to display a gradient fill, the FillStyle property must be set to Solid and the FillGradientStyle property must be set to a value other than None. Setting the BackgroundImage property to an image overrides all other background settings.

This SO link I found is also nice here

Community
  • 1
  • 1
khakishoiab
  • 9,673
  • 2
  • 16
  • 22
  • Please refrain from link-only answers. Links die. If you can't include the essence of the links put them into comments instead! – TaW Oct 31 '16 at 13:53
  • 1
    ok will do @TaW.The question is broad in its essense and needs thorough knowledge. – khakishoiab Oct 31 '16 at 13:56
  • *"The question is broad in its essense"* Then you should **[flag to close the question as off-topic](http://stackoverflow.com/help/privileges/flag-posts)** instead of answering it. You can do so by clicking on the "flag" link under the question. Thanks. – Pang Nov 01 '16 at 01:20