예제 #1
0
파일: slgaus.cs 프로젝트: msvoboda/slgaus
        //*********** kresleni dat **********
        protected void PaintDataList(PaintEventArgs e)
        {
            for (int i = 0; i < DataList.Count; i++)
            {
                SLMath.SLValueList ValueList = DataList[i];
                int     navic   = 3 - (ValueList.Count - 4) % 3;
                Point[] points  = new Point[ValueList.Count + navic];
                Pen     barva   = new Pen(ValueList.ColorLine);
                Brush   BrBarva = new SolidBrush(ValueList.ColorLine);

                if (ValueList.ShowPoints == false && ValueList.ShowLine == false)
                {
                    continue;
                }

                for (int j = 0; j < ValueList.Count; j++)
                {
                    //int pocetF = ValueList.Count;
                    SLMath.SLValueXY valXY = (SLMath.SLValueXY)ValueList[j];
                    if (valXY.isValid() == false)
                    {
                        continue;
                    }


                    int bodX1 = (int)(x_abs((float)valXY.X));
                    int bodY1 = (int)(y_abs((float)valXY.Y));

                    points[j] = new Point(bodX1, bodY1);

                    if (j == ValueList.Count - 1)
                    {
                        for (int c = 0; c < navic; c++)
                        {
                            points[ValueList.Count + c] = new Point(bodX1, bodY1);
                        }
                    }

                    // kresli kolecka ... pokud najedeme mysi na bod

                    /*
                     * if ((RealMouseX >= (float)valXY.X-0.1 && RealMouseX <= (float)valXY.X+0.1) && (RealMouseY >= (float)valXY.Y-0.1 && RealMouseY <= (float)valXY.Y+0.1))
                     *      e.Graphics.FillEllipse(BrBarva,bodX1-ValueList.PointSize-1,bodY1-ValueList.PointSize-1,2*ValueList.PointSize+2,2*ValueList.PointSize+2);*/
                    //
                    if (ValueList.ShowPoints == true)
                    {
                        if (ValueList.PointStyle == SLMath.SLValueList.PointStyles.Cross)
                        {
                            e.Graphics.DrawLine(barva, bodX1 - ValueList.PointSize, bodY1, bodX1 + ValueList.PointSize, bodY1);
                            e.Graphics.DrawLine(barva, bodX1, bodY1 - ValueList.PointSize, bodX1, bodY1 + ValueList.PointSize);
                        }
                        if (ValueList.PointStyle == SLMath.SLValueList.PointStyles.Circle)
                        {
                            e.Graphics.FillEllipse(BrBarva, bodX1 - ValueList.PointSize, bodY1 - ValueList.PointSize, 2 * ValueList.PointSize + 1, 2 * ValueList.PointSize + 1);
                        }
                        if (ValueList.PointStyle == SLMath.SLValueList.PointStyles.Cube)
                        {
                            e.Graphics.FillRectangle(BrBarva, bodX1 - ValueList.PointSize, bodY1 - ValueList.PointSize, ValueList.PointSize * 2 + 1, ValueList.PointSize * 2 + 1);
                        }
                        if (ValueList.PointStyle == SLMath.SLValueList.PointStyles.Diamond)
                        {
                            // Create points that define polygon.
                            Point   point1     = new Point(bodX1 - ValueList.PointSize, bodY1);
                            Point   point2     = new Point(bodX1, bodY1 - ValueList.PointSize);
                            Point   point3     = new Point(bodX1 + ValueList.PointSize, bodY1);
                            Point   point4     = new Point(bodX1, bodY1 + ValueList.PointSize);
                            Point[] diamPoints = { point1, point2, point3, point4 };
                            // Draw polygon to screen.
                            e.Graphics.FillPolygon(BrBarva, diamPoints);
                        }
                        if (ValueList.PointStyle == SLMath.SLValueList.PointStyles.Triangle)
                        {
                            // Create points that define polygon.
                            Point   point1    = new Point(bodX1 - (2 * ValueList.PointSize / 3) - 1, (bodY1 + ValueList.PointSize / 3) + 1);
                            Point   point2    = new Point(bodX1 + (2 * ValueList.PointSize / 3) + 1, (bodY1 + ValueList.PointSize / 3) + 1);
                            Point   point3    = new Point(bodX1, (bodY1 - 2 * ValueList.PointSize / 3) - 1);
                            Point   point4    = new Point(bodX1 - (2 * ValueList.PointSize / 3) - 1, (bodY1 + ValueList.PointSize / 3) - 1);
                            Point[] tryPoints = { point1, point2, point3, point4 };
                            // Draw polygon to screen.
                            e.Graphics.FillPolygon(BrBarva, tryPoints);
                        }
                    }

                    /*
                     * if (ValueList.ShowLine == true)
                     * {
                     *      if (ValueList.AproxStyle == SLMath.SLValueList.AproximationStyles.aLine)
                     *      {
                     *              e.Graphics.DrawLine(barva,bodX1,bodY1,bodX2,bodY2);
                     *      }
                     *      if (ValueList.AproxStyle == SLMath.SLValueList.AproximationStyles.aBezier)
                     *      {
                     *
                     *      }
                     * }*/
                }
                if (ValueList.ShowLine == true)
                {
                    if (ValueList.AproxStyle == SLMath.SLValueList.AproximationStyles.aLine)
                    {
                        e.Graphics.DrawLines(barva, points);
                    }
                    if (ValueList.AproxStyle == SLMath.SLValueList.AproximationStyles.aBezier)
                    {
                        e.Graphics.DrawBeziers(barva, points);
                    }
                    if (ValueList.AproxStyle == SLMath.SLValueList.AproximationStyles.aSpline)
                    {
                        e.Graphics.DrawCurve(barva, points);
                    }
                }
            }
        }