Beispiel #1
0
        private void DrawChart(Graphics g, FuzzyLogicController.MFs.MemberShipFunction mf, List <double> Range, bool isSelected)
        {
            List <double> pts = mf.Params;

            Graphics gfx = g;

            #region Graphs
            Point[] points = new Point[pts.Count];
            for (int i = 0; i < pts.Count; i++)
            {
                double value = (pts[i] - Range[0]) / (Range[1] - Range[0]);
                int    pos   = Convert.ToInt32(value * (ChartPanel.Bounds.Width));
                if (i == 0 || i == pts.Count - 1)
                {
                    points[i] = new Point(pos, ChartPanel.Bounds.Height - 20);
                }
                else
                {
                    points[i] = new Point(pos, 40);
                }
            }
            if (!isSelected)
            {
                gfx.DrawLines(new Pen(Color.Red), points);
            }
            else
            {
                gfx.DrawLines(new Pen(new SolidBrush(Color.Blue), 3), points);
            }


            int diff     = Convert.ToInt32((points[pts.Count - 1].X - points[0].X) / 2);
            int strvalue = points[0].X + diff;

            if (!isSelected)
            {
                Font font = new Font("SanSerif", 10, FontStyle.Italic);
                gfx.DrawString(mf.Name, font, new SolidBrush(Color.Red), new PointF(strvalue - 25, 20));
            }
            else
            {
                Font font = new Font("SanSerif", 12, FontStyle.Italic);
                gfx.DrawString(mf.Name, font, new SolidBrush(Color.Blue), new PointF(strvalue - 25, 20));
            }
            #endregion
            #region Axis
            gfx.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(0, ChartPanel.Height - 19), new Point(ChartPanel.Width, ChartPanel.Height - 19));
            double Step  = (Range[1] - Range[0]) / (10 - 1);
            double Steps = Range[0];
            for (int i = 0; i < 10; i++)
            {
                Steps = Steps + Step;
                double value = (Steps - Range[0]) / (Range[1] - Range[0]);
                int    pos   = Convert.ToInt32(value * (ChartPanel.Bounds.Width));
                PointF point = new PointF(pos, ChartPanel.Bounds.Height - 15);
                gfx.DrawString(Convert.ToInt32(Steps).ToString(), new Font(FontFamily.GenericSansSerif, 10), new SolidBrush(Color.Black), point);
            }
            #endregion
        }
Beispiel #2
0
 private void popualteMF(FuzzyLogicController.MFs.MemberShipFunction mf)
 {
     MFNameTxT.Text  = mf.Name;
     MFParamTxT.Text = mf.Params[0].ToString();
     for (int i = 1; i < mf.Params.Count; i++)
     {
         MFParamTxT.Text = MFParamTxT.Text + ", " + mf.Params[i];
     }
     if (mf is FuzzyLogicController.MFs.Trimf)
     {
         MFTypeCombo.SelectedIndex = 0;
     }
     else if (mf is FuzzyLogicController.MFs.Trapmf)
     {
         MFTypeCombo.SelectedIndex = 1;
     }
 }