Exemplo n.º 1
0
 int GetPointIndex(IniFile.Section section, int index)
 {
     if (section["Points" + index.ToString()] != null)
     {
         return(section.ReadInt("Points" + index.ToString()));
     }
     return(section.ReadInt("Point" + index.ToString()));
 }
Exemplo n.º 2
0
        void ProcessPoint(IniFile.Section section)
        {
            var type         = section.ReadInt("Type");
            var parentFigure = section["ParentFigure"];

            if (!parentFigure.IsEmpty())
            {
                EnsureSectionProcessed("Figure" + parentFigure);
                return;
            }

            if (type == 8)
            {
                FindAndProcessArcWithPoint(section.GetTitleNumber("Point"));
                return;
            }

            if (type == 9)
            {
                FindAndProcessMidPoint(section.GetTitleNumber("Point"));
                return;
            }

            var x     = section.ReadDouble("X");
            var y     = section.ReadDouble("Y");
            var point = Factory.CreateFreePoint(drawing, new Point(x, y));

            point.Name = section["Name"];
            SetPointStyle(section, point);
            Actions.Actions.Add(drawing, point);
            var pointIndex = section.GetTitleNumber("Point");

            points[pointIndex] = point;
        }
Exemplo n.º 3
0
        void ProcessButton(IniFile.Section section)
        {
            var type = section.ReadInt("Type");

            if (type != 0)
            {
                return;
            }

            var button = new ShowHideControl();

            button.Drawing            = drawing;
            button.Checkbox.IsChecked = section.ReadBool("InitiallyVisible", false);
            button.AddDependencies(GetPointList(section));
            button.MoveTo(section.ReadDouble("X"), section.ReadDouble("Y"));
            SetButtonStyle(section, button);
            Actions.Actions.Add(drawing, button);

            var text = section["Caption"].Replace("~~", Environment.NewLine);

            if (section["Charset"] == "0")
            {
                text = text.Replace('I', '²');
            }

            button.Checkbox.Content = text;

            ReadButtonDependencies(section, button);

            button.UpdateFigureVisibility();
            buttons[section.GetTitleNumber("Button")] = button;
        }
Exemplo n.º 4
0
        IFigure GetParent(IniFile.Section section, int index)
        {
            var parentIndex       = section.ReadInt("Parents" + index.ToString());
            var pointSectionTitle = "Figure" + parentIndex.ToString();

            EnsureSectionProcessed(pointSectionTitle);
            return(figures[parentIndex]);
        }
Exemplo n.º 5
0
        void ProcessGeneral(IniFile.Section section)
        {
            var workArea = section["WorkArea"];

            if (workArea != null)
            {
                workArea = workArea.Trim('(', ')');
                var values = workArea.Split(',');
                var left   = values[0];
                var bottom = values[1];
                var right  = values[2];
                var top    = values[3];
                var minX   = double.Parse(left);
                var minY   = double.Parse(bottom);
                var maxX   = double.Parse(right);
                var maxY   = double.Parse(top);
                drawing.CoordinateSystem.SetViewport(minX, maxX, minY, maxY);
            }

            var showAxes = section.ReadBool("ShowAxes", Settings.Instance.ShowGrid);
            var showGrid = section.ReadBool("ShowGrid", Settings.Instance.ShowGrid);

            drawing.CoordinateGrid.Visible = showAxes || showGrid;

            var pointCount = section.ReadInt("PointCount");

            points = new PointBase[pointCount + 1];

            var figureCount = section.ReadInt("FigureCount");

            figures = new IFigure[figureCount];

            var labelCount = section.ReadInt("LabelCount");

            labels = new LabelBase[labelCount + 1];

            var buttonCount = section.ReadInt("ButtonCount");

            buttons = new ShowHideControl[buttonCount + 1];

            var staticGraphicCount = section.ReadInt("StaticGraphicCount");

            staticGraphics = new IFigure[staticGraphicCount + 1];
        }
Exemplo n.º 6
0
        IList <IFigure> GetPointList(IniFile.Section section)
        {
            var numberOfPoints = section.ReadInt("NumberOfPoints");
            var result         = new List <IFigure>();

            for (var i = 1; i <= numberOfPoints; i++)
            {
                var point = GetPoint(section, i);
                result.Add(point);
            }

            return(result);
        }
Exemplo n.º 7
0
        private IEnumerable <int> ReadIndices(IniFile.Section section, string key)
        {
            var index = 1;

            var currentKey = key + "#" + index.ToString();

            while (section.Entries.ContainsKey(currentKey))
            {
                yield return(section.ReadInt(currentKey));

                index++;
                currentKey = key + "#" + index.ToString();
            }
        }
Exemplo n.º 8
0
        void ReadAnalyticPoint(IniFile.Section section)
        {
            var numberOfPoints = section.ReadInt("NumberOfPoints");

            for (var i = 1; i < numberOfPoints; i++)
            {
                GetPoint(section, i);
            }

            var x = section["XS"];
            var y = section["YS"];

            var point = Factory.CreatePointByCoordinates(drawing, x, y);

            AddFigure(section, point);
            AddFigurePoint(section, point, 0);
        }
Exemplo n.º 9
0
        void ProcessSG(IniFile.Section section)
        {
            var type = section.ReadInt("Type");

            switch (type)
            {
            case 0:     // Polygon
                ReadPolygon(section);
                break;

            case 1:     // Bezier
                ReadBezier(section);
                break;

            case 2:     // Vector
                ReadVector(section);
                break;

            default:
                break;
            }
        }
Exemplo n.º 10
0
        void SetPointStyle(IniFile.Section section, IFigure figure)
        {
            figure.Visible = !section.ReadBool("Hide", false) && section.ReadBool("Visible", true);

            var fillColor     = section.ReadColor("FillColor");
            var fillStyle     = section.ReadInt("FillStyle");
            var foreColor     = section.ReadColor("ForeColor");
            var physicalWidth = section.ReadDouble("PhysicalWidth");

            if (fillStyle == 1)
            {
                fillColor = Colors.Transparent;
            }

            var pointStyle = new PointStyle()
            {
                Fill        = new SolidColorBrush(fillColor),
                Color       = foreColor,
                Size        = physicalWidth,
                StrokeWidth = 0.7
            };

            figure.Style = drawing.StyleManager.FindExistingOrAddNew(pointStyle);
        }
Exemplo n.º 11
0
        void ProcessFigure(IniFile.Section section)
        {
            var figureType = section.ReadInt("FigureType");

            switch (figureType)
            {
            case 1:     // Segment
                ReadSegment(section);
                break;

            case 2:     // Ray
                ReadRay(section);
                break;

            case 3:     // Line
                ReadLine2Points(section);
                break;

            case 4:     // ParallelLine
                ReadParallelLine(section);
                break;

            case 5:     // PerpendicularLine
                ReadPerpendicularLine(section);
                break;

            case 6:     // Circle
                ReadCircle(section);
                break;

            case 7:     // CircleByRadius
                ReadCircleByRadius(section);
                break;

            case 8:     // Arc
                ReadArc(section);
                break;

            case 9:     // MidPoint
                ReadMidPoint(section);
                break;

            case 10:     // SymmPoint
                ReadSymmPoint(section);
                break;

            case 11:     // SymmPointByLine
                ReadSymmPointByLine(section);
                break;

            case 12:     // InvertedPoint
                ReadInvertedPoint(section);
                break;

            case 13:     // IntersectionPoint
                ReadIntersectionPoint(section);
                break;

            case 14:     // PointOnFigure
                ReadPointOnFigure(section);
                break;

            case 15:     // MeasureDistance
                ReadMeasureDistance(section);
                break;

            case 16:     // MeasureAngle
                ReadMeasureAngle(section);
                break;

            case 17:     // AnLineGeneral
                ReadAnalyticLineGeneral(section);
                break;

            case 21:     // AnCircle
                ReadAnalyticCircle(section);
                break;

            case 22:     // AnalyticPoint
                ReadAnalyticPoint(section);
                break;

            case 23:     // Locus
                ReadLocus(section);
                break;

            case 24:     // AngleBisector
                ReadAngleBisector(section);
                break;

            default:
                break;
            }
        }