Private
Public Access
The window now correctly repaints
This commit is contained in:
1 parent
614e72434e
commit
2a6ae05a0c
3 files changed
+23
-4
No files matched your search
@@ -12,7 +12,11 @@ namespace Advanced_Software_Engineering {
|
||||
List<Verb> commands = new List<Verb>();
|
||||
Drawer drawer;
|
||||
|
||||
public void DrawAllCommands() {
|
||||
public void DrawAllCommands(Graphics updateGraphicsElement) {
|
||||
graphics = updateGraphicsElement;
|
||||
drawer.ResetDrawer();
|
||||
drawer.SetGraphics(updateGraphicsElement);
|
||||
|
||||
foreach (Verb verb in this.commands) {
|
||||
verb.ExecuteVerb();
|
||||
}
|
||||
@@ -110,6 +114,8 @@ namespace Advanced_Software_Engineering {
|
||||
brush = new SolidBrush(defaultColor);
|
||||
}
|
||||
|
||||
public void SetGraphics(Graphics graphics) => this.graphics = graphics;
|
||||
|
||||
public void MovePen(Point point) => penPosition = point;
|
||||
public Point GetPenPosition() => new Point(penPosition.X, penPosition.Y);
|
||||
|
||||
|
||||
+4
-2
@@ -58,11 +58,13 @@
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.BackColor = System.Drawing.Color.White;
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(537, 501);
|
||||
this.panel1.Size = new System.Drawing.Size(537, 474);
|
||||
this.panel1.TabIndex = 2;
|
||||
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawPreviewPane_Paint);
|
||||
//
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Advanced_Software_Engineering
|
||||
Graphics graphics;
|
||||
Commander commander;
|
||||
|
||||
int repaintCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The draw preview window.
|
||||
/// </summary>
|
||||
@@ -27,6 +29,7 @@ namespace Advanced_Software_Engineering
|
||||
InitializeComponent();
|
||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||
graphics = panel1.CreateGraphics();
|
||||
graphics.ResetClip();
|
||||
commander = new Commander(graphics);
|
||||
}
|
||||
|
||||
@@ -34,6 +37,7 @@ namespace Advanced_Software_Engineering
|
||||
InitializeComponent();
|
||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||
graphics = panel1.CreateGraphics();
|
||||
graphics.ResetClip();
|
||||
commander = new Commander(graphics, commands);
|
||||
|
||||
//disable components
|
||||
@@ -47,9 +51,15 @@ namespace Advanced_Software_Engineering
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void DrawPreviewPane_Paint(object sender, EventArgs e) {
|
||||
DrawPreviewPane_Paint(sender, null);
|
||||
}
|
||||
|
||||
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
commander.DrawAllCommands();
|
||||
graphics = panel1.CreateGraphics();
|
||||
commander.DrawAllCommands(graphics);
|
||||
Console.WriteLine("Graphics repainted " + ++repaintCount + "times");
|
||||
}
|
||||
|
||||
private void SubmitCommand(object sender, EventArgs e)
|
||||
@@ -65,5 +75,6 @@ namespace Advanced_Software_Engineering
|
||||
public void RemoveAllCommands() {
|
||||
commander.RemoveAllCommands();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user