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>();
|
List<Verb> commands = new List<Verb>();
|
||||||
Drawer drawer;
|
Drawer drawer;
|
||||||
|
|
||||||
public void DrawAllCommands() {
|
public void DrawAllCommands(Graphics updateGraphicsElement) {
|
||||||
|
graphics = updateGraphicsElement;
|
||||||
|
drawer.ResetDrawer();
|
||||||
|
drawer.SetGraphics(updateGraphicsElement);
|
||||||
|
|
||||||
foreach (Verb verb in this.commands) {
|
foreach (Verb verb in this.commands) {
|
||||||
verb.ExecuteVerb();
|
verb.ExecuteVerb();
|
||||||
}
|
}
|
||||||
@@ -110,6 +114,8 @@ namespace Advanced_Software_Engineering {
|
|||||||
brush = new SolidBrush(defaultColor);
|
brush = new SolidBrush(defaultColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetGraphics(Graphics graphics) => this.graphics = graphics;
|
||||||
|
|
||||||
public void MovePen(Point point) => penPosition = point;
|
public void MovePen(Point point) => penPosition = point;
|
||||||
public Point GetPenPosition() => new Point(penPosition.X, penPosition.Y);
|
public Point GetPenPosition() => new Point(penPosition.X, penPosition.Y);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -58,11 +58,13 @@
|
|||||||
//
|
//
|
||||||
// panel1
|
// 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.BackColor = System.Drawing.Color.White;
|
||||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.panel1.Name = "panel1";
|
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.TabIndex = 2;
|
||||||
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawPreviewPane_Paint);
|
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawPreviewPane_Paint);
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Advanced_Software_Engineering
|
|||||||
Graphics graphics;
|
Graphics graphics;
|
||||||
Commander commander;
|
Commander commander;
|
||||||
|
|
||||||
|
int repaintCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The draw preview window.
|
/// The draw preview window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -27,6 +29,7 @@ namespace Advanced_Software_Engineering
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
|
graphics.ResetClip();
|
||||||
commander = new Commander(graphics);
|
commander = new Commander(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +37,7 @@ namespace Advanced_Software_Engineering
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
|
graphics.ResetClip();
|
||||||
commander = new Commander(graphics, commands);
|
commander = new Commander(graphics, commands);
|
||||||
|
|
||||||
//disable components
|
//disable components
|
||||||
@@ -47,9 +51,15 @@ namespace Advanced_Software_Engineering
|
|||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawPreviewPane_Paint(object sender, EventArgs e) {
|
||||||
|
DrawPreviewPane_Paint(sender, null);
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e)
|
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)
|
private void SubmitCommand(object sender, EventArgs e)
|
||||||
@@ -65,5 +75,6 @@ namespace Advanced_Software_Engineering
|
|||||||
public void RemoveAllCommands() {
|
public void RemoveAllCommands() {
|
||||||
commander.RemoveAllCommands();
|
commander.RemoveAllCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user