Csharp ile Grafik Grafik Obje oluturmak private void
Csharp ile Grafik
Grafik Obje oluşturmak private void Form 1_Paint(object sender, Paint. Event. Args e) { System. Drawing. Graphics graphics. Obj; graphics. Obj = this. Create. Graphics(); }
Kalem Oluşturmak private void Form 1_Paint(object sender, Paint. Event. Args e) { System. Drawing. Graphics graphics. Obj; graphics. Obj = this. Create. Graphics(); Pen my. Pen = new Pen(System. Drawing. Color. Red, 5); my. Pen. Dash. Style = System. Drawing 2 D. Dash. Style. Dash. Dot; my. Pen. Color = System. Drawing. Color. Royal. Blue; my. Pen. Width = 3; }
Çizgi Çizmek private void Form 1_Paint(object sender, Paint. Event. Args e) { System. Drawing. Graphics graphics. Obj; graphics. Obj = this. Create. Graphics(); Pen my. Pen = new Pen(System. Drawing. Color. Red, 5); graphics. Obj. Draw. Line(my. Pen, 20, 200, 210); }
Dikdörtgen Çizmek private void Form 1_Paint(object sender, Paint. Event. Args e) { System. Drawing. Graphics graphics. Obj; graphics. Obj = this. Create. Graphics(); Pen my. Pen = new Pen(System. Drawing. Color. Red, 5); 200); } Rectangle my. Rectangle = new Rectangle(20, 250, graphics. Obj. Draw. Rectangle(my. Pen, my. Rectangle);
Oval Çizmek private void Form 1_Paint(object sender, Paint. Event. Args e) { System. Drawing. Graphics graphics. Obj; graphics. Obj = this. Create. Graphics(); 5); 200); Pen my. Pen = new Pen(System. Drawing. Color. Green, Rectangle my. Rectangle = new Rectangle(20, 250, graphics. Obj. Draw. Ellipse(my. Pen, my. Rectangle); // veya graphicsobj. Draw. Ellipse(pen, x, y, width, height); }
Örnek Grafik-1 using System; private void button 1_Click(object sender, Event. Args e) using System. Collections. Generic; { using System. Component. Model; Graphics g = this. Create. Graphics(); using System. Data; Pen kalem = new Pen(Color. Red, 3. 7 f); using System. Drawing; // Brush firca = new Brushes(Color. Red); using System. Text; using System. Windows. Forms; g. Draw. Line(kalem, 30, 150); g. Draw. Pie(kalem, 50, 80, 0, 250); namespace grafik g. Draw. Ellipse(kalem, 150, 200); { public partial class Form 1 : Form } { } public Form 1() { Initialize. Component(); } }
Örnek Grafik-2 // Combobox ile şekil çizme using System; using System. Drawing; using System. Windows. Forms; { case 0: // Daire çiz my. Graphics. Draw. Ellipse( my. Pen, 50, 150 ); break; case 1: // Dikdörtgen Çiz my. Graphics. Draw. Rectangle( my. Pen, 50, 150 ); break; case 2: // Elips Çiz my. Graphics. Draw. Ellipse( my. Pen, 50, 85, 150, 115 ); break; case 3: // Pie çiz my. Graphics. Draw. Pie( my. Pen, 50, 150, 0, 45 ); break; case 4: // içi dolu daire çiz my. Graphics. Fill. Ellipse( my. Solid. Brush, 50, 150 ); break; case 5: // içi dolu dikdörtgen çiz my. Graphics. Fill. Rectangle( my. Solid. Brush, 50, 150 ); break; case 6: // içi dolu elips çiz my. Graphics. Fill. Ellipse( my. Solid. Brush, 50, 85, 150, 115 ); break; case 7: // içi dolu pie çiz my. Graphics. Fill. Pie( my. Solid. Brush, 50, 150, 0, 45 ); break; } // end switch public partial class Combo. Box. Test. Form : Form { public Combo. Box. Test. Form() { Initialize. Component(); } // seçilen seçeneğe göre şekil seçilir private void image. Combo. Box_Selected. Index. Changed( object sender, Event. Args e ) { // Graphics objesi yarat Graphics my. Graphics = base. Create. Graphics(); // Dark. Red(koyu kırmızı) renkli Pen (kalem) yarat Pen my. Pen = new Pen( Color. Dark. Red ); // Dark. Red(koyu kırmızı) renkli Solid. Brush(fırça) yarat Solid. Brush my. Solid. Brush = new Solid. Brush( Color. Dark. Red ); // white(beyaz) renk ile grafik alanını temizle my. Graphics. Clear( Color. White ); my. Graphics. Dispose(); // Graphics object yok et. } } // seçilen index sırasına göre şekil çiz switch ( image. Combo. Box. Selected. Index )
Grafik-3 using System; private void button 1_Click(object sender, Event. Args e) { using System. Collections. Generic; //create a unit pen. using System. Component. Model; using System. Data; Pen p = new Pen(Color. Black, 1. 0 f); using System. Drawing; Graphics g = this. Create. Graphics(); using System. Text; using System. Windows. Forms; g. Draw. Rectangle(Pens. Blue, 55, 40, 100, 120); g. Draw. Rectangle(p, 20, 30); namespace Windows. Applicationgrfx 1 g. Draw. Line(Pens. Red, 0, 0, 100); { g. Draw. Arc(p, 30, 0, 360); public partial class Form 1 : Form { } public Form 1() { Initialize. Component(); } } }
Microsoft Chart Controls double[] y. Values = { 10, 27. 5, 7, 12, 45. 5}; string[] x. Names = { “Mike”, “John”, “William”, “George”, “Alex” }; my. Chart. Series[0]. Points. Data. Bind. XY(x. Names, y. Values);
Toolbar Eklemek
• Chart Kontrolü Seçilir • Sonuç grafik görülür. • Series 1 yaratılır ve Özellikleri değiştirilir
Seri Verisi Eklemek Chart 1. Series["Series 1"]. Points. Add. XY(1, 15000); Chart 1. Series["Series 1"]. Points. Add. XY(2, 16000); Chart 1. Series["Series 1"]. Points. Add. XY(3, 13000); Chart 1. Series["Series 1"]. Points. Add. XY(4, 18000);
Bar Chart void Frm. Chart. Example_Load(object sender, Event. Args e) { Bar. Example(); //Show bar chart //Spline. Chart. Example(); } public void Bar. Example() { this. chart. Control. Series. Clear(); // Data arrays string[] series. Array = { "Cat", "Dog", "Bird", "Monkey" }; int[] points. Array = { 2, 1, 7, 5 }; // Set palette this. chart. Control. Palette = Chart. Color. Palette. Earth. Tones; // Set title this. chart. Control. Titles. Add("Animals"); } // Add series. for (int i = 0; i < series. Array. Length; i++) { Series series = this. chart. Control. Series. Add(series. Array[i]); series. Points. Add(points. Array[i]); }
Spline Chart private void Spline. Chart. Example() { this. chart. Control. Series. Clear(); this. chart. Control. Titles. Add("Total Income"); } Series series = this. chart. Control. Series. Add("Total Income"); series. Chart. Type = Series. Chart. Type. Spline; series. Points. Add. XY("September", 100); series. Points. Add. XY("Obtober", 300); series. Points. Add. XY("November", 800); series. Points. Add. XY("December", 200); series. Points. Add. XY("January", 600); series. Points. Add. XY("February", 400);
Zed. Graph Sınıfı private void Form 1_Resize( object sender, Event. Args e ) { Set. Size(); } private void Set. Size() { zed. Graph. Control 1. Location = new Point( 10, 10 ); zed. Graph. Control 1. Size = new Size( Client. Rectangle. Width - 20, Client. Rectangle. Height - 20 ); } private void Form 1_Load( object sender, Event. Args e ) { Create. Graph( zed. Graph. Control 1 ); Set. Size(); } private void Create. Graph( Zed. Graph. Control zgc ) { Graph. Pane my. Pane = zgc. Graph. Pane; my. Pane. Title. Text = "My Test Graphn(For Code. Project Sample)"; my. Pane. XAxis. Title. Text = "My X Axis"; my. Pane. YAxis. Title. Text = "My Y Axis"; double x, y 1, y 2; Point. Pair. List list 1 = new Point. Pair. List(); Point. Pair. List list 2 = new Point. Pair. List(); for ( int i = 0; i < 36; i++ ) { x = (double)i + 5; y 1 = 1. 5 + Math. Sin( (double)i * 0. 2 ); y 2 = 3. 0 * ( 1. 5 + Math. Sin( (double)i * 0. 2 ) ); list 1. Add( x, y 1 ); list 2. Add( x, y 2 ); } Line. Item my. Curve = my. Pane. Add. Curve( "Porsche", list 1, Color. Red, Symbol. Type. Diamond ); Line. Item my. Curve 2 = my. Pane. Add. Curve( "Piper", list 2, Color. Blue, Symbol. Type. Circle ); zgc. Axis. Change(); }
- Slides: 16