private void addBtn_Click(object sender, EventArgs e) { float scaleX = (float)this.xScale.Value; if (scaleX == 0) { scaleX = 1f; } float scaleY = (float)this.yScale.Value; if (scaleY == 0) { scaleY = 1f; } //the created instance can always be cast to ILineGraphProvider, because the items in sourceBox.DataSource are only added //by AddProviderType<T>() where T : ILineGraphProvider ILineGraphProvider provider = (ILineGraphProvider)Activator.CreateInstance((Type)sourceBox.SelectedItem); if (provider.AskForParameters()) { this.drawer = new LineGraphDrawer(provider, scaleX, scaleY, this.colorBtn.BackColor, this.markPointsBox.Checked); this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.Cancel; } this.Close(); }
public LineGraphDrawer(ILineGraphProvider provider, float scaleX, float scaleY, Color color, bool markPoints) { this.provider = provider; this.color = color; this.scaleX = scaleX; this.scaleY = scaleY; this.markPoints = markPoints; }