PDA

View Full Version : سوال: مشکل در قطعه کد طراحی لوگو با ویژوال سی شارپ 2013



PA4XPRO
جمعه 06 آذر 1394, 20:09 عصر
من همیشه در رفع خطا ها مشکل دارم،ممنون اگه کسی کمک کنه

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
String text1 = "سیستم ثبت نام دانشگاه";
GraphicsPath pach1 = new GraphicsPath();
Point Point2 = new Point(298, 325);
pach1.AddString(text1, FontFamily.GenericSerif, 1, 32f.Point2, StringFormat.GenericDefault);
Rectangle[] Patchrect = {new Rectangle(200, 200, 300, 200), new Rectangle(300, 300, 300, 200)};
pach1.AddRectangles(Pathrect);
Region = new Region(pach1);
Point2 = new Point(0, 0);
Point point1 = PointToScreen(Point2);
e.Graphics.TranslateTransform((float) (Left - point1.X), (float) (Top - Point1.Y));
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillPath(Brushes.Deepskyblue, pach1);
e.Graphics.Drawpath(new Pen(Color.DarkMagenta, 10f), path1);
}
}


Error 1 The name 'InitializeComponent' does not exist in the current context line: 20
Error 2 'float' does not contain a definition for 'Point2' and no extension method 'Point2' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?) line: 28
Error 3 The name 'Pathrect' does not exist in the current context line:35

Error 4 The name 'Point1' does not exist in the current context 39
Error 5 'System.Drawing.Brushes' does not contain a definition for 'Deepskyblue line: 41
Error 6 'System.Drawing.Graphics' does not contain a definition for 'Drawpath' and no extension method 'Drawpath' accepting a first argument of type 'System.Drawing.Graphics' could be found (are you missing a using directive or an assembly reference?) line: 42
Error 7 The name 'path1' does not exist in the current context line: 42

reza_ali202000
جمعه 06 آذر 1394, 23:57 عصر
من همیشه در رفع خطا ها مشکل دارم،ممنون اگه کسی کمک کنه

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
String text1 = "سیستم ثبت نام دانشگاه";
GraphicsPath pach1 = new GraphicsPath();
Point Point2 = new Point(298, 325);
pach1.AddString(text1, FontFamily.GenericSerif, 1, 32f.Point2, StringFormat.GenericDefault);
Rectangle[] Patchrect = {new Rectangle(200, 200, 300, 200), new Rectangle(300, 300, 300, 200)};
pach1.AddRectangles(Pathrect);
Region = new Region(pach1);
Point2 = new Point(0, 0);
Point point1 = PointToScreen(Point2);
e.Graphics.TranslateTransform((float) (Left - point1.X), (float) (Top - Point1.Y));
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillPath(Brushes.Deepskyblue, pach1);
e.Graphics.Drawpath(new Pen(Color.DarkMagenta, 10f), path1);
}
}


Error 1 The name 'InitializeComponent' does not exist in the current context line: 20
Error 2 'float' does not contain a definition for 'Point2' and no extension method 'Point2' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?) line: 28
Error 3 The name 'Pathrect' does not exist in the current context line:35

Error 4 The name 'Point1' does not exist in the current context 39
Error 5 'System.Drawing.Brushes' does not contain a definition for 'Deepskyblue line: 41
Error 6 'System.Drawing.Graphics' does not contain a definition for 'Drawpath' and no extension method 'Drawpath' accepting a first argument of type 'System.Drawing.Graphics' could be found (are you missing a using directive or an assembly reference?) line: 42
Error 7 The name 'path1' does not exist in the current context line: 42



سلام دوست عزیز
توی محیط ویژوال استادیو باگ گیری خیلی راحته. مخصوصا این نوع خطاهای کامپایلری
با دبل کیک روی خطا مشکل رو اعلام میکنه و به راحتی قابل حله.

String text1 = "سیستم ثبت نام دانشگاه";
GraphicsPath pach1 = new GraphicsPath();
Point Point2 = new Point(298, 325);
pach1.AddString(text1, FontFamily.GenericSerif, 1, 32f,Point2, StringFormat.GenericDefault);
Rectangle[] Patchrect = { new Rectangle(200, 200, 300, 200), new Rectangle(300, 300, 300, 200) };
pach1.AddRectangles(Patchrect);
Region = new Region(pach1);
Point2 = new Point(0, 0);
Point point1 = PointToScreen(Point2);
e.Graphics.TranslateTransform((float)(Left - point1.X), (float)(Top - point1.Y));
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillPath(Brushes.DeepSkyBlue, pach1);
e.Graphics.DrawPath(new Pen(Color.DarkMagenta, 10f), path1);

PA4XPRO
شنبه 07 آذر 1394, 01:12 صبح
ممنون داداش که جواب دادی،من تا حالا سی شارپ کار نکردم این اولین برنامه سی شارپه که نوشتم و چند سال پیش فقط با ویژوال استودیو 2005 کار کردم