我应该采用什么方法 [英] What method should i implement
问题描述
以下是我的代码示例:
由用户在运行时设置公共变量的图形类.几何和下降线这两个类
The following are my code samples:
The Graphical Classes in which public variables are set by users at runtime. The two classes Geometry and FallingLines
public class Geometry
{
private int width;
private int height;
public int repetation = 6;
public bool IsOffset = true;
public GeometricalShapes shape = GeometricalShapes.Circle;
private List<Rectangle> rectangle;
private int offSetTimes = 3;
public Geometry(int width, int height)
{
this.width = width;
this.height = height;
}
public GraphicsPath[] Draw()
{
//implementation
}
private int[] GetIncBoxSize(int repetation)
{
//implementation
}
private GraphicsPath GetPath(int x, int y, int wt, int ht)
{
//implementation
}
}
public class FallingLines
{
public int width;
public int height;
public bool IsTop = true;
public bool IsBtm = false;
public bool IsOffset = true;
public int repetation = 10;
public LineType lineType = LineType.Irregular;
public FallingLines(int width, int height)
{
this.width = width;
this.height = height;
}
public GraphicsPath[] Draw()
{
// implementation
}
private Rectangle[] GetRectangle(int randomOffset)
{
// implementation
}
private GraphicsPath GetPath(int x, int y, int width, int height)
{
// implementation
}
private Point[] GetPoints(int count)
{
// implementation
}
private Point[] DrawWave(Point top, Point btm, int cntWave)
{
// implementation
}
private GraphicsPath DrawIrregularity(Point[] points, int width)
{
// implementation
}
private Point[] GetRandomPointInLine(Point[] points, int curveCnt)
{
// implementation
}
private Point[] DrawIrregularWave(Point top, Point btm, int width)
{
// implementation
}
}
我将为用户制作控件,以便他们可以操作.
所以,我想要一些可以来回交互的东西.
我希望MyForm将信息发送到这些类,反之亦然.稍后按下按钮后,我希望Draw()将graphicsPath []返回到我的mainForm.
我该怎么做...
I will be making controls for the user so that they can manipulate.
So, i want something that can interact back and forth.
I want my MyForm to send info to these classes and vice versa. later after a Button Press i want the Draw() to return the graphicsPath[] to my mainForm.
How do i do these...
推荐答案
您的GraphicsClass类必须实现接口.由于所有类都有一个共同的属性和一个方法,因此我建议
Your GraphicsClass classes have to implement an Interface. Since all classes have one property and one method in common, I''d suggest
public Interface IGraphics
{
bool a { get; set; }
GraphicsPath Draw();
}
我不需要您的交互器"类.
I do not sse any need for your "interactor" class.
//是与下面的图形类交互的抽象类....
//should this be an abstract class which interact with Graphical Classes below....
是的,根据一种可能性
Yes ,as per one possibility
这篇关于我应该采用什么方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!