private void LoadCSF()
        {
            listCons = new List <ContinuousFuzzySetBLL>();
            string path = Directory.GetCurrentDirectory() + @"\lib\";

            listCons = ContinuousFuzzySetBLL.GenerateAllConFS(path);
        }
Example #2
0
        private void RefreshData()
        {
            gridCtrLibraryCons.DataSource = null;
            dt = new DataTable();
            dt.Columns.Add("gridColCheck", typeof(bool));
            dt.Columns.Add("gridColName", typeof(String));
            dt.Columns.Add("gridColBtLeft", typeof(Double));
            dt.Columns.Add("gridColTopLeft", typeof(Double));
            dt.Columns.Add("gridColTopRight", typeof(Double));
            dt.Columns.Add("gridColBtRight", typeof(Double));
            string path = Directory.GetCurrentDirectory() + @"\lib\";

            this.list = ContinuousFuzzySetBLL.GenerateAllConFS(path);
            for (int i = 0; i < list.Count; i++)
            {
                DataRow row = dt.NewRow();
                row[0] = false;
                row[1] = list[i].FuzzySetName;
                row[2] = list[i].BottomLeft;
                row[3] = list[i].TopLeft;
                row[4] = list[i].TopRight;
                row[5] = list[i].BottomRight;
                dt.Rows.Add(row);
            }
            gridCtrLibraryCons.DataSource = dt;
        }
Example #3
0
        private Boolean CheckLogicValue(ContinuousFuzzySetBLL contfs)
        {
            Double bl = 0; if (txtBotLeft.Text != "")
            {
                bl = Double.Parse(txtBotLeft.Text);
            }
            Double tl = 0; if (txtTopLeft.Text != "")
            {
                tl = Double.Parse(txtTopLeft.Text);
            }
            Double tr = 0; if (txtTopRight.Text != "")
            {
                tr = Double.Parse(txtTopRight.Text);
            }
            Double br = 0; if (txtBotRight.Text != "")

            {
                br = Double.Parse(txtBotRight.Text);
            }

            if (!contfs.SetValue(bl, tl, tr, br))
            {
                XtraMessageBox.Show("Values of fuzzy set must be continous!");
                return(false);
            }
            return(true);
        }
Example #4
0
        private static ContinuousFuzzySetBLL ReadEachConFS(string path)//Also content the path and name
        {
            ContinuousFuzzySetBLL result = new ContinuousFuzzySetBLL();

            try
            {
                using (StreamReader reader = new StreamReader(path))
                {
                    String   str  = reader.ReadLine();
                    String[] list = str.Split(',');

                    //Only 4 members
                    if (list.Length == 4)
                    {
                        result.FuzzySetName = FuzzySetName(path);
                        result.BottomLeft   = Double.Parse(list[0]);
                        result.TopLeft      = Double.Parse(list[1]);
                        result.TopRight     = Double.Parse(list[2]);
                        result.BottomRight  = Double.Parse(list[3]);
                    }
                }

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Example #5
0
 private void gridViewLibraryCons_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
 {
     if (e.Column.FieldName != "gridColCheck" && e.Button == MouseButtons.Right)
     {
         ContinuousFuzzySetBLL    cons = new ContinuousFuzzySetBLL(gridViewLibraryCons.GetRowCellValue(e.RowHandle, "gridColName").ToString(), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(e.RowHandle, "gridColBtLeft")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(e.RowHandle, "gridColTopLeft")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(e.RowHandle, "gridColTopRight")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(e.RowHandle, "gridColBtRight")));
         FrmAddContinuousFuzzySet frm  = new FrmAddContinuousFuzzySet(cons);
         frm.ShowDialog();
         RefreshData();
     }
 }
Example #6
0
        private List <ContinuousFuzzySetBLL> GetSelectedRows()
        {
            List <ContinuousFuzzySetBLL> result = new List <ContinuousFuzzySetBLL>();

            for (int i = 0; i < gridViewLibraryCons.DataRowCount; i++)
            {
                if (gridViewLibraryCons.GetRowCellValue(i, "gridColCheck").ToString() == "True")
                {
                    ContinuousFuzzySetBLL cons = new ContinuousFuzzySetBLL(gridViewLibraryCons.GetRowCellValue(i, "gridColName").ToString(), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(i, "gridColBtLeft")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(i, "gridColTopLeft")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(i, "gridColTopRight")), Convert.ToDouble(gridViewLibraryCons.GetRowCellValue(i, "gridColBtRight")));
                    result.Add(cons);
                }
            }
            return(result);
        }
Example #7
0
        }//Delete and Re Add file

        internal static ContinuousFuzzySetBLL GetContinuousFuzzySetByName(string name)
        {
            ContinuousFuzzySetBLL result = new ContinuousFuzzySetBLL(name);

            try
            {
                string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\lib\", "*.conFS");
                foreach (var item in filePaths)
                {
                    if (FuzzySetName(item) == name)
                    {
                        result = ReadEachConFS(item);
                        break;
                    }
                }

                return(result);
            }
            catch
            {
                return(result);
            }
        }
Example #8
0
 private void gridCtrLibraryCons_EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == NavigatorButtonType.Append)
     {
         FrmAddContinuousFuzzySet frm = new FrmAddContinuousFuzzySet();
         frm.ShowDialog();
         RefreshData();
         e.Handled = true;
     }
     if (e.Button.ButtonType == NavigatorButtonType.Remove)
     {
         if (XtraMessageBox.Show("Are you sure delete this row?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
         {
             string path = Directory.GetCurrentDirectory() + @"\lib\";
             if (gridViewLibraryCons.GetSelectedRows()[0] >= 0)
             {
                 var datarow = gridViewLibraryCons.GetDataRow(gridViewLibraryCons.GetSelectedRows()[0]);
                 var name    = datarow["gridColName"];
                 path = path + name + ".conFS";
                 ContinuousFuzzySetBLL.DeleteFS(path);
             }
         }
     }
 }
Example #9
0
 public FrmAddContinuousFuzzySet(ContinuousFuzzySetBLL cons)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.cons = cons;
 }
Example #10
0
 public FrmAddContinuousFuzzySet()
 {
     InitializeComponent();
     this.cons = null;
 }
Example #11
0
        private void btSaveConFuzzy_Click(object sender, EventArgs e)
        {
            double x;

            if (txtNameConsFuzzy.Text.Trim() != "" && Double.TryParse(txtNameConsFuzzy.Text.Trim(), out x) == true)
            {
                if (txtBotLeft.Text.Trim() == "" && txtTopLeft.Text.Trim() == "" && txtTopRight.Text.Trim() == "" && txtBotRight.Text.Trim() == "")
                {
                    String name     = txtNameConsFuzzy.Text.Trim() + ".conFS";
                    string path     = Directory.GetCurrentDirectory() + @"\lib\";
                    String contentx = txtNameConsFuzzy.Text.Trim() + "," + txtNameConsFuzzy.Text.Trim() + "," + txtNameConsFuzzy.Text.Trim() + "," + txtNameConsFuzzy.Text.Trim();
                    if (ContinuousFuzzySetBLL.UpdateFS(path, contentx, name) == 1)
                    {
                        XtraMessageBox.Show("Save DONE!");
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show("Save FAILED");
                    }
                }
            }
            else
            {
                if (!CheckNull())
                {
                    return;
                }
                ContinuousFuzzySetBLL newFS = new ContinuousFuzzySetBLL();
                if (!CheckLogicValue(newFS))
                {
                    return;
                }
                String name = txtNameConsFuzzy.Text.Trim() + ".conFS";

                String content = txtBotLeft.Text.Trim();

                string path = Directory.GetCurrentDirectory() + @"\lib\";

                if (txtTopLeft.Text.Trim() == "" && txtTopRight.Text.Trim() != "")
                {
                    content += "," + txtTopRight.Text.Trim() + "," + txtTopRight.Text.Trim() + "," + txtTopRight.Text.Trim();
                    if (ContinuousFuzzySetBLL.UpdateFS(path, content, name) == 1)
                    {
                        XtraMessageBox.Show("Save DONE!");
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show("Save FAILED");
                    }
                }
                else if (txtTopLeft.Text.Trim() != "" && txtTopRight.Text.Trim() == "")
                {
                    content += "," + txtTopLeft.Text.Trim() + "," + txtTopLeft.Text.Trim() + "," + txtTopRight.Text.Trim();
                    //if (newFS.Update() == 1)
                    if (ContinuousFuzzySetBLL.UpdateFS(path, content, name) == 1)
                    {
                        XtraMessageBox.Show("Save DONE!");
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show("Save FAILED");
                    }
                }
                else
                {
                    content += "," + txtTopLeft.Text.Trim() + "," + txtTopRight.Text.Trim() + "," + txtBotRight.Text.Trim();
                    //if (newFS.Update() == 1)
                    if (ContinuousFuzzySetBLL.UpdateFS(path, content, name) == 1)
                    {
                        XtraMessageBox.Show("Save DONE!");
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show("Save FAILED");
                    }
                }
            }
        }