내 사각형 및 원형에 대한 DefaultLineThickness 외에 자체 두께로 Line 클래스의 코드를 설정하려고합니다. g.DrawLine (Pens.Black, 25, 40, 126, 126)을 사용하고 싶습니다. 그것은 자신의 클래스에 있어야하고 내가 다른 모양으로 한 것을 계승해야합니다. 내 문제가 있지만 XAML에서 가장 가까운이 주제를 발견하고 다른 곳은 원, 사각형, 및 라인에서 원유 자전거를 만들려고 노력하는 단순한 g.DrawLine클래스의 선 및 두께 그리기 : 방법 그룹/OverLoad 문제
http://www.c-sharpcorner.com/uploadfile/mahesh/line-in-wpf/
입니다.
* 편집 주위를 노는 데 충분한 시간이 지나면 나는 내 목표를 넘어 섰다. 내 유일한 문제는 내가 모든 것을 연결하고 X-번호로 선 두께를 설정 한 후, 그것 때문에 '방법 그룹'
Form1의 코드
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Bicycle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
LineOne l1 = new LineOne(new PointF(50, 40));
l1.setFilledState(false);
l1.setLineColor(Color.Black);
l1.setLineThickness = (6);
//cannot assign to 'setLineThickness' because it is a method group'
l1.Draw(g);
sRectangle r2 = new sRectangle(new PointF(151, 160));
r2.setFilledState(true);
r2.setLineColor(Color.Green);
r2.setFilledColor(Color.Honeydew);
r2.Draw(g);
sRectangleEmpty r1 = new sRectangleEmpty(new PointF(150, 150));
r1.setFilledState(false);
r1.setLineColor(Color.Blue);
r1.Draw(g);
sCircle c1 = new sCircle(new PointF(180, 130));
c1.setFilledState(true);
c1.setLineColor(Color.Orange);
c1.setFilledColor(Color.Ivory);
c1.Draw(g);
sCircleEmpty c2 = new sCircleEmpty(new PointF(120, 130));
c2.setFilledState(false);
c2.setLineColor(Color.Black);
c2.Draw(g);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
의 수를 할당 할 수 없습니다 것을 나에게 오류를주고 있다는 것입니다
라인 코드
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Bicycle
{
class LineOne : sRectangle
{
private void setDrawingAttributes()
{
const int lenght = 10;
Pen SmallPen = new Pen(Brushes.DeepSkyBlue);
SmallPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
PointF p1 = PointF.Add(location, new Size(-lenght/2, 0));
}
private void init()
{
setDrawingAttributes();
}
public LineOne()
{
init();
}
public LineOne(PointF p)
: base(p)
{
init();
}
public override void Draw(Graphics g)
{
g.DrawEllipse(pen, rect);
}
}
}
형상 코드
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Bicycle
{
class Shape
{
private Color DefaultLineColor = Color.Black;
private Color DefaultFillColor = Color.Blue;
private float DefaultLineThickness = 2;
protected bool bOutLine;
protected bool bFilled;
protected Pen pen;
protected Brush brush;
protected PointF location;
private void setDrawingAttributes()
{
pen = new Pen(DefaultLineColor, DefaultLineThickness);
brush = new SolidBrush(DefaultFillColor);
}
private void init()
{
bOutLine = true;
setDrawingAttributes();
}
public Shape()
{
init();
}
public Shape(PointF p)
{
location = p;
init();
}
public Color getFillColor()
{
return (DefaultFillColor);
}
public bool getFilledState()
{
return (bFilled);
}
public Color getLineColor()
{
return (DefaultLineColor);
}
public float getLineThickness()
{
return (DefaultLineThickness);
}
public bool getOutLineState()
{
return (bOutLine);
}
public bool isOutLine()
{
return (bOutLine);
}
public bool isFilled()
{
return (bFilled);
}
public void setFilledColor(Color C)
{
DefaultFillColor = C;
setDrawingAttributes();
}
public void setLineColor(Color C)
{
DefaultLineColor = C;
setDrawingAttributes();
}
public void setLineThickness(float value)
{
DefaultLineThickness = value;
setDrawingAttributes();
}
public void setFilledState(bool value)
{
bFilled = value;
}
public void setOutLineState(bool value)
{
bOutLine = value;
}
}
}
아, 감사합니다. 나는 g.DrawEllipse (pen, rect)에 내 회선 코드를 사용하는 실수를 한 것으로 알고 있습니다. 보다는 오히려 (bOutLine) g.DrawLine (pen, rect); 내 원을 원으로 만들기 위해 코드를 재정의하는 것과 마찬가지로 선을 강제로 그려야했습니다. 나는 그것이 원을 그렸을 때 어떻게 일했는지 알지 못한다.하지만 '선을 그리기위한 과부하 메도 드 없음'이라는 두 줄을 쓴다. – user3550796