예제 #1
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);
        }
예제 #2
0
        public CartesianGrid()
        {
            //ShapeStyle arrowStyle = new ShapeStyle()
            //{
            //    Color = Color.FromArgb(255, 128, 128, 255),
            //    Fill = new SolidColorBrush(Color.FromArgb(255, 128, 128, 255)),
            //    StrokeWidth = 1,
            //    Name = "ArrowStyle"
            //};
            LineStyle axisStyle = new LineStyle()
            {
                Color       = Color.FromArgb(255, 128, 128, 255),
                Name        = "AxisStyle",
                StrokeWidth = 1
            };
            LineStyle gridStyle = new LineStyle()
            {
                Color       = Colors.LightGray,
                Name        = "GridStyle",
                StrokeWidth = 0.5
            };
            TextStyle labelsStyle = new TextStyle()
            {
                Color    = Color.FromArgb(255, 128, 128, 255),
                FontSize = 12.0,
                Name     = "LabelsStyle"
            };

            OriginPoint         = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 0);
            XUnitPoint          = Factory.CreatePointByCoordinates(Drawing, () => 1, () => 0);
            YUnitPoint          = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 1);
            OriginPoint.Name    = "Origin";
            XUnitPoint.Name     = "XUnitPoint";
            YUnitPoint.Name     = "YUnitPoint";
            OriginPoint.Visible = false;
            XUnitPoint.Visible  = false;
            YUnitPoint.Visible  = false;

            XAxisLine      = Factory.CreateAxis(Drawing, new[] { OriginPoint, XUnitPoint });
            YAxisLine      = Factory.CreateAxis(Drawing, new[] { OriginPoint, YUnitPoint });
            XAxisLine.Name = "XAxisLine";
            YAxisLine.Name = "YAxisLine";
            AxisLabels     = new AxisLabelsCollection()
            {
                Drawing = Drawing
            };
            GridLines = new RectangularGridLinesCollection()
            {
                Drawing = Drawing
            };

            //XAxisLine.Arrow.Style = arrowStyle;
            XAxisLine.Line.Style = axisStyle;
            //YAxisLine.Arrow.Style = arrowStyle;
            YAxisLine.Line.Style = axisStyle;
            GridLines.Style      = gridStyle;
            AxisLabels.Style     = labelsStyle;

            Children.Add(
                OriginPoint,
                XUnitPoint,
                YUnitPoint,
                XAxisLine,
                YAxisLine,
                AxisLabels,
                GridLines
                );
        }
예제 #3
0
파일: DGFReader.cs 프로젝트: ondrej11/o106
        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);
        }
예제 #4
0
        public CartesianGrid()
        {
            //ShapeStyle arrowStyle = new ShapeStyle()
            //{
            //    Color = Color.FromArgb(255, 128, 128, 255),
            //    Fill = new SolidColorBrush(Color.FromArgb(255, 128, 128, 255)),
            //    StrokeWidth = 1,
            //    Name = "ArrowStyle"
            //};
            LineStyle axisStyle = new LineStyle()
            {
                Color = Color.FromArgb(255, 128, 128, 255),
                Name = "AxisStyle",
                StrokeWidth = 1
            };
            LineStyle gridStyle = new LineStyle()
            {
                Color = Colors.LightGray,
                Name = "GridStyle",
                StrokeWidth = 0.5
            };
            TextStyle labelsStyle = new TextStyle()
            {
                Color = Color.FromArgb(255, 128, 128, 255),
                FontSize = 12.0,
                Name = "LabelsStyle"
            };

            OriginPoint = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 0);
            XUnitPoint = Factory.CreatePointByCoordinates(Drawing, () => 1, () => 0);
            YUnitPoint = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 1);
            OriginPoint.Name = "Origin";
            XUnitPoint.Name = "XUnitPoint";
            YUnitPoint.Name = "YUnitPoint";
            OriginPoint.Visible = false;
            XUnitPoint.Visible = false;
            YUnitPoint.Visible = false;

            XAxisLine = Factory.CreateAxis(Drawing, new[] { OriginPoint, XUnitPoint });
            YAxisLine = Factory.CreateAxis(Drawing, new[] { OriginPoint, YUnitPoint });
            XAxisLine.Name = "XAxisLine";
            YAxisLine.Name = "YAxisLine";
            AxisLabels = new AxisLabelsCollection() { Drawing = Drawing };
            GridLines = new RectangularGridLinesCollection() { Drawing = Drawing };

            //XAxisLine.Arrow.Style = arrowStyle;
            XAxisLine.Line.Style = axisStyle;
            //YAxisLine.Arrow.Style = arrowStyle;
            YAxisLine.Line.Style = axisStyle;
            GridLines.Style = gridStyle;
            AxisLabels.Style = labelsStyle;

            Children.Add(
                OriginPoint,
                XUnitPoint,
                YUnitPoint,
                XAxisLine,
                YAxisLine,
                AxisLabels,
                GridLines
                );
        }
예제 #5
0
        public virtual void AddDefaultStyles()
        {
            var freePointStyle = new PointStyle()
            {
                Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 100))
            };
            var pointOnFigureStyle = new PointStyle()
            {
                Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0))
            };
            var dependentPointStyle = new PointStyle()
            {
                Name = "DependentPointStyle",
                Fill = new SolidColorBrush(Color.FromArgb(200, 192, 192, 192))
            };
            var lineStyle  = new LineStyle();
            var lineStyle2 = new LineStyle()
            {
                Name  = "OtherLine",
                Color = Color.FromArgb(200, 0, 0, 255)
            };
            var shapeWithLineStyle = new ShapeStyle();
            var shapeStyle         = new ShapeStyle()
            {
                Color = Colors.Transparent
            };
            var shapeStyle2 = new ShapeStyle()
            {
                Name  = "OtherShape",
                Color = Colors.Transparent,
                Fill  = new SolidColorBrush(Color.FromArgb(100, 200, 255, 200))
            };
            var hyperLinkStyle = new TextStyle()
            {
                FontSize   = 18,
                FontFamily = new FontFamily("Segoe UI")
            };
            var textStyle = new TextStyle()
            {
                FontSize   = 18,
                FontFamily = new FontFamily("Segoe UI")
            };
            var headerStyle = new TextStyle()
            {
                FontSize   = 40,
                FontFamily = new FontFamily("Segoe UI")
            };

            var newStyles = new IFigureStyle[]
            {
                freePointStyle,
                pointOnFigureStyle,
                dependentPointStyle,
                lineStyle,
                lineStyle2,
                shapeStyle,
                shapeStyle2,
                shapeWithLineStyle,
                textStyle,
                headerStyle,
                hyperLinkStyle,
            };

            list.AddRange(newStyles);

            numDefaultStyles = newStyles.Length;
        }
예제 #6
0
        public CartesianGrid()
        {
            //ShapeStyle arrowStyle = new ShapeStyle()
            //{
            //    Color = Color.FromArgb(255, 128, 128, 255),
            //    Fill = new SolidColorBrush(Color.FromArgb(255, 128, 128, 255)),
            //    StrokeWidth = 1,
            //    Name = "ArrowStyle"
            //};
            LineStyle axisStyle = new LineStyle()
            {
                Color           = Color.FromArgb(255, 128, 128, 255),
                Name            = "AxisStyle",
                StrokeWidth     = 0.5,
                StrokeDashArray = null
            };

            // Hiển thị màu cho lưới ở các vị trí điểm nổi bật
            System.Windows.Media.Color normalGridLine    = System.Windows.Media.Colors.DarkGray;
            System.Windows.Media.Color highLightGridLine = System.Windows.Media.Colors.WhiteSmoke;
            //??

            LineStyle gridStyle = new LineStyle()
            {
                Color           = Colors.WhiteSmoke,
                Name            = "GridStyle",
                StrokeWidth     = 0.1,
                StrokeDashArray = null
            };
            TextStyle labelsStyle = new TextStyle()
            {
                Color = Color.FromArgb(255, 128, 128, 255),
                //Color = Color.FromArgb(255, 201, 201, 201),
                FontSize = 12.0,
                Name     = "LabelsStyle"
            };

            OriginPoint         = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 0);
            XUnitPoint          = Factory.CreatePointByCoordinates(Drawing, () => 1, () => 0);
            YUnitPoint          = Factory.CreatePointByCoordinates(Drawing, () => 0, () => 1);
            OriginPoint.Name    = "Origin";
            XUnitPoint.Name     = "XUnitPoint";
            YUnitPoint.Name     = "YUnitPoint";
            OriginPoint.Visible = false;
            XUnitPoint.Visible  = false;
            YUnitPoint.Visible  = false;

            XAxisLine      = Factory.CreateAxis(Drawing, new[] { OriginPoint, XUnitPoint });
            YAxisLine      = Factory.CreateAxis(Drawing, new[] { OriginPoint, YUnitPoint });
            XAxisLine.Name = "XAxisLine";
            YAxisLine.Name = "YAxisLine";
            AxisLabels     = new AxisLabelsCollection()
            {
                Drawing = Drawing
            };
            GridLines = new RectangularGridLinesCollection()
            {
                Drawing = Drawing
            };

            //XAxisLine.Arrow.Style = arrowStyle;
            XAxisLine.Line.Style = axisStyle;
            //YAxisLine.Arrow.Style = arrowStyle;
            YAxisLine.Line.Style = axisStyle;
            GridLines.Style      = gridStyle;
            AxisLabels.Style     = labelsStyle;

            Children.Add(
                OriginPoint,
                XUnitPoint,
                YUnitPoint,
                XAxisLine,
                YAxisLine,
                AxisLabels,
                GridLines
                );
        }