Exemplo n.º 1
0
        void SetLabelStyle(IniFile.Section section, IFigure figure)
        {
            figure.Visible = !section.ReadBool("Hide", false) && section.ReadBool("Visible", true);

            var fontName = section["FontName"];
            double? fontSize = section.TryReadDouble("FontSize");
            bool fontUnderline = section.ReadBool("FontUnderline", false);
            var foreColor = section.ReadColor("ForeColor");
            var backColor = section.ReadColor("BackColor");

            TextStyle style = new TextStyle()
            {
                FontFamily = new FontFamily(fontName),
                Color = foreColor,
                Underline = fontUnderline
            };
            if (fontSize.HasValue)
            {
                style.FontSize = fontSize.Value * 1.7;
            }

            figure.Style = drawing.StyleManager.FindExistingOrAddNew(style);
        }
Exemplo n.º 2
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;
            }

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

            figure.Style = drawing.StyleManager.FindExistingOrAddNew(pointStyle);
        }
Exemplo n.º 3
0
        void SetFigureStyle(IniFile.Section section, IFigure figure)
        {
            figure.Visible = !section.ReadBool("Hide", false) && section.ReadBool("Visible", true);

            var fillColor = section.ReadColor("FillColor");
            var foreColor = section.ReadColor("ForeColor");
            double drawWidth = section.TryReadDouble("DrawWidth") ?? 1.0;
            if (drawWidth < 0.1)
            {
                drawWidth = 0.1;
            }
            int? drawStyle = section.TryReadInt("DrawStyle");
            int? fillStyle = section.TryReadInt("FillStyle");
            int? drawMode = section.TryReadInt("DrawMode");
            if (fillStyle == null || fillStyle == 6)
            {
                fillColor = Colors.Transparent;
            }
            DoubleCollection strokeDashArray = null;
            if (drawStyle != null && drawStyle != 0)
            {
                strokeDashArray = new DoubleCollection();
                switch (drawStyle)
                {
                    case 1:
                        strokeDashArray.Add(15 / drawWidth, 6 / drawWidth);
                        break;
                    case 2:
                        strokeDashArray.Add(3 / drawWidth, 3 / drawWidth);
                        break;
                    case 3:
                        strokeDashArray.Add(10 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth);
                        break;
                    case 4:
                        strokeDashArray.Add(10 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth);
                        break;
                    default:
                        break;
                }
            }

            IFigureStyle style;

            if (figure is IShapeWithInterior)
            {
                if (fillColor != Colors.Transparent && drawMode != 13)
                {
                    fillColor.A = 128;
                }
                style = new ShapeStyle()
                {
                    Fill = new SolidColorBrush(fillColor),
                    Color = foreColor,
                    StrokeWidth = drawWidth,
                    StrokeDashArray = strokeDashArray
                };
            }
            else
            {
                if (foreColor == Colors.Transparent)
                {
                    System.Diagnostics.Debugger.Break();
                }
                style = new LineStyle()
                {
                    Color = foreColor,
                    StrokeWidth = drawWidth,
                    StrokeDashArray = strokeDashArray
                };
            }

            figure.Style = drawing.StyleManager.FindExistingOrAddNew(style);
        }
Exemplo n.º 4
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.º 5
0
        void ProcessButton(IniFile.Section section)
        {
            int type = section.ReadInt("Type");
            if (type != 0)
            {
                return;
            }

            ShowHideControl 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.Add(drawing, button);

            string 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.º 6
0
 public void ReadBool()
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.IsFalse(ini.ReadBool("Test", "b", true));
         Assert.IsFalse(ini.ReadBool("Test", "i", false));
         Assert.IsTrue(ini.ReadBool("Test", "doesnotexist", true));
     }
 }
Exemplo n.º 7
0
 public void WriteBool()
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.IsFalse(ini.ReadBool("Section1",
                                     "doesnotexist", false));
         ini.WriteBool("Section1", "doesnotexist", true);
         Assert.IsTrue(ini.ReadBool("Section1", "doesnotexist", false));
     }
 }