के साथ रहता है मैं एक छात्र हूं और मैं यहां चारों ओर नया हूं। मेरे पास एक पेंट-जैसी प्रोग्राम बनाने के लिए एक कोर्स प्रोजेक्ट है। मेरे पास आधार श्रेणी आकार ड्रासल्फ के साथ है, ect शामिल है। आयत और एलीप्स और त्रिकोण के लिए विधियों और कक्षाएं अब के लिए। इसके अलावा मेरे पास दो अन्य वर्गीकृत डिस्प्लेप्रोसेसर है जो ड्राइंग के लिए कक्षा है, और डायलॉगप्रोसेसर, जो उपयोगकर्ता के साथ संवाद को नियंत्रित करता है। परियोजना के लिए थीस की आवश्यकता है।आकार घूर्णन करते समय, यह घूर्णन वाले
public class DisplayProcessor
{
public DisplayProcessor()
{
}
/// <summary>
/// List of shapes
/// </summary>
private List<Shape> shapeList = new List<Shape>();
public List<Shape> ShapeList
{
get { return shapeList; }
set { shapeList = value; }
}
/// <summary>
/// Redraws all shapes in shapeList
/// </summary>
public void ReDraw(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
Draw(e.Graphics);
}
public virtual void Draw(Graphics grfx)
{
int n = shapeList.Count;
Shape shape;
for (int i = 0; i <= n - 1; i++)
{
shape = shapeList[i];
DrawShape(grfx, shape);
}
}
public virtual void DrawShape(Graphics grfx, Shape item)
{
item.DrawSelf(grfx);
}
}
और एक दूसरे निर्धारण, यहाँ:
public class DialogProcessor : DisplayProcessor
{
public DialogProcessor()
{
}
private Shape selection;
public Shape Selection
{
get { return selection; }
set { selection = value; }
}
private bool isDragging;
public bool IsDragging
{
get { return isDragging; }
set { isDragging = value; }
}
private PointF lastLocation;
public PointF LastLocation
{
get { return lastLocation; }
set { lastLocation = value; }
}
public void AddRandomRectangle()
{
Random rnd = new Random();
int x = rnd.Next(100, 1000);
int y = rnd.Next(100, 600);
RectangleShape rect = new RectangleShape(new Rectangle(x, y, 100, 200));
rect.FillColor = Color.White;
ShapeList.Add(rect);
}
}
तो, मैं एक आकृति है, जो उपयोगकर्ता द्वारा चयन किया जाता है बारी बारी से करना चाहते हैं। मैं इस तरह कोशिश करता हूं। यह घूमता है, लेकिन मैं यह मिलता है: http://www.freeimagehosting.net/qj3zp
public class RectangleShape : Shape
{
public override void DrawSelf(Graphics grfx)
{
grfx.TranslateTransform(Rectangle.X + Rectangle.Width/2, Rectangle.Y + Rectangle.Height/2);
grfx.RotateTransform(base.RotationAngle);
grfx.TranslateTransform(- (Rectangle.X + Rectangle.Width/2), -(Rectangle.Y + Rectangle.Height/2));
grfx.FillRectangle(new SolidBrush(FillColor), Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height);
grfx.DrawRectangle(Pens.Black, Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height);
grfx.ResetTransform();
}
}
मैंने अपना प्रश्न संपादित किया है। मुझे उम्मीद है कि अब और स्पष्ट है। – vortex