Example #1
0
    /// Resize shape, so it fits recognition square.
    /// If square is 10x10, then coordinates are -5..5, -5..5
    private static List <Vector3> ResizeShapeToFitRecognitionSquare(List <Vector3> points)
    {
        List <Vector3> resizedPoints = new List <Vector3>(points.Count);
        SymbolSize     initialSize   = SymbolsHelper.GetWidthAndHeightOfShape(points);

        for (int i = 0; i != points.Count; i++)
        {
            resizedPoints.Add(points[i] * (RecognitionSquareDimension / initialSize.MaxDimension));
        }
        return(resizedPoints);
    }
Example #2
0
        public static IControl WithShaft(RectangleEdge edge, SymbolSize size = SymbolSize.Contain, Brush brush = default(Brush))
        {
            var stroke = Stroke.Create(1.0, brush | Theme.Active);

            return(ResizeSymbol(edge, size, Control.BindNativeFrame(frame =>
                                                                    WithoutShaft(edge, brush, frame)
                                                                    .WithOverlay(
                                                                        edge.NormalAxis() == Axis2D.Horizontal
                                                        ? Shapes.Line(
                                                                            Point.Create(frame.Left(), frame.Center().Y),
                                                                            Point.Create(frame.Right(), frame.Center().Y),
                                                                            stroke)
                                                        : Shapes.Line(
                                                                            Point.Create(frame.Center().X, frame.Top()),
                                                                            Point.Create(frame.Center().X, frame.Bottom()),
                                                                            stroke))))
                   .WithBackground(Color.Transparent));     // TODO: not sure why this is needed
        }
Example #3
0
        static IControl ResizeSymbol(RectangleEdge edge, SymbolSize size, IControl control)
        {
            switch (size)
            {
            case SymbolSize.Small:
                return(control.WithSize(edge.NormalAxis() == Axis2D.Horizontal
                                                ? Size.Create <Points>(4, 7)
                                                : Size.Create <Points>(7, 4)));

            case SymbolSize.Medium:
                return(control.WithSize(edge.NormalAxis() == Axis2D.Horizontal
                                                ? Size.Create <Points>(5, 9)
                                                : Size.Create <Points>(9, 5)));

            case SymbolSize.Large:
                return(control.WithSize(edge.NormalAxis() == Axis2D.Horizontal
                                                ? Size.Create <Points>(7, 13)
                                                : Size.Create <Points>(13, 7)));

            default:
                return(control);
            }
        }
Example #4
0
        public void ToXml(XmlWriter writer)
        {
            var provider = new NumberFormatInfo {
                NumberDecimalSeparator = GlobalProfile.DecimalSymbolStandard.ToString()
            };

            var cultureInfo = new CultureInfo("")
            {
                NumberFormat = { NumberDecimalSeparator = GlobalProfile.DecimalSymbolStandard.ToString() }
            };

            cultureInfo.TextInfo.ListSeparator = GlobalProfile.ArgumentsSeparatorStandard.ToString();

            var colorConverter          = TypeDescriptor.GetConverter(typeof(Color));
            var symbolTypeEnumConverter = TypeDescriptor.GetConverter(typeof(SymbolTypeEnum));

            writer.WriteAttributeString("symbolantialias", AntiAlias.ToString().ToLower());
            writer.WriteAttributeString("symbolsize", SymbolSize.ToString(provider));
            writer.WriteAttributeString("symboltype", symbolTypeEnumConverter.ConvertToString(SymbolType));
            writer.WriteAttributeString("symbolborderthickness", BorderThickness.ToString(provider));
            writer.WriteAttributeString("symbolbordercolor", colorConverter.ConvertToString(null, cultureInfo, BorderColor));
            writer.WriteAttributeString("symbolfillcolor", colorConverter.ConvertToString(null, cultureInfo, FillColor));
        }
Example #5
0
 public static IControl WithoutShaft(RectangleEdge edge, SymbolSize size = SymbolSize.Contain, Brush brush = default(Brush))
 {
     return(ResizeSymbol(edge, size, Control.BindNativeFrame(frame =>
                                                             WithoutShaft(edge, brush, frame)))
            .WithBackground(Color.Transparent));     // TODO: not sure why this is needed
 }