private void btnAddDot_Click(object sender, EventArgs e) { if (!(dgwItems.Tag as FuzzySet).Discrete) { return; } if (dgwItems.Tag is FuzzySet1D) { FuzzySet1D set = dgwItems.Tag as FuzzySet1D; try { double x = double.Parse(tbDotX1.Text); double y = double.Parse(tbDotX2.Text); set.AddDot(x, y); } catch { return; } set.ToMatrix(dgwItems); pGraph.Tag = set.Render(pGraph.Size); pGraph.Invalidate(); } if (dgwItems.Tag is FuzzySet2D) { FuzzySet2D set = dgwItems.Tag as FuzzySet2D; try { double x = double.Parse(tbDotX1.Text); double y = double.Parse(tbDotX2.Text); double z = double.Parse(tbDotX3.Text); set.RemoveDot(x, y); set.AddDot(x, y, z); } catch { return; } set.ToMatrix(dgwItems); pGraph.Tag = set.Render(pGraph.Size); pGraph.Invalidate(); } }
public frmModule() { InitializeComponent(); #region Dgw & List sets = new List <FuzzySet>(); dgwSets.DataSource = null; dgwSets.Columns.Clear(); { DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.ValueType = typeof(string); col.Name = "Name"; col.HeaderText = Properties.Resources.Name; col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; col.ReadOnly = false; col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dgwSets.Columns.Add(col); } { DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.ValueType = typeof(string); col.Name = "Dimension"; col.HeaderText = Properties.Resources.Dimension; col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; col.ReadOnly = true; col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dgwSets.Columns.Add(col); } #endregion #if DEBUG { FuzzySet1D fs = new FuzzySet1D(); fs.Name = "A"; fs.AddDot(1.0, 1.0); fs.AddDot(2.0, 0.3); fs.AddDot(2.5, 0.4); fs.AddDot(3.0, 0.7); sets.Add(fs); } { FuzzySet1D fs = new FuzzySet1D(); fs.Name = "B"; fs.AddDot(1.0, 0.2); fs.AddDot(3.0, 0.1); fs.AddDot(4.0, 0.3); fs.AddDot(5.0, 0.4); sets.Add(fs); } { FuzzySet1D fs = new FuzzySet1D(); fs.Name = "C"; fs.AddDot(1.0, 0.1); fs.AddDot(3.0, 0.1); fs.AddDot(4.0, 0.1); fs.AddDot(5.0, 0.1); sets.Add(fs); } { FuzzySet1D fs = new FuzzySet1D(); fs.Name = "D"; fs.AddDot(1.0, 0.5); fs.AddDot(3.0, 0.5); fs.AddDot(4.0, 0.5); fs.AddDot(5.0, 0.5); sets.Add(fs); } { FuzzySet2D fs = new FuzzySet2D(); fs.Name = "E"; fs.AddDot(1.0, 1.0, 0.5); fs.AddDot(3.0, 3.0, 0.5); fs.AddDot(4.0, 4.0, 0.5); fs.AddDot(5.0, 5.0, 0.5); sets.Add(fs); } { FuzzySet2D fs = new FuzzySet2D(); fs.Name = "F"; fs.AddDot(1.0, 0.3, 0.3); fs.AddDot(3.0, 1.7, 0.1); fs.AddDot(4.0, 3.6, 0.3); fs.AddDot(5.0, 8.0, 0.7); sets.Add(fs); } #endif UpdateListToDgw(); }