Exemple #1
0
    public static float GetFloat(string key)
    {
        if (Floats == null)
        {
            Floats = new Dictionary <string, float>();
        }

        return((Floats.ContainsKey(key)) ? Floats[key] : 0f);
    }
Exemple #2
0
        /// <summary>
        /// Заливка контура пути
        /// </summary>
        /// <returns></returns>
        private Action Fill()
        {
            var fillColor   = Colors.ContainsKey("FillColor") ? Colors["FillColor"] : Color.White;
            var fillOpacity = Floats.ContainsKey("FillOpacity") ? (int)Floats["FillOpacity"] : 255;

            return(() =>
            {
                using (var brush = new SolidBrush(Color.FromArgb(fillOpacity, fillColor)))
                    Graphics.FillPath(brush, Path);
            });
        }
Exemple #3
0
        /// <summary>
        /// Рисоание контура пути
        /// </summary>
        /// <returns></returns>
        private Action Draw()
        {
            var fillColor   = Colors.ContainsKey("FillColor") ? Colors["FillColor"] : Color.Black;
            var fillOpacity = Floats.ContainsKey("FillOpacity") ? (int)Floats["FillOpacity"] : 255;
            var penWidth    = Floats.ContainsKey("PenWidth") ? Floats["PenWidth"] : 1;

            return(() =>
            {
                using (var pen = new Pen(Color.FromArgb(fillOpacity, fillColor), penWidth))
                    Graphics.DrawPath(pen, Path);
            });
        }
Exemple #4
0
        private Action Text(string args)
        {
            var ar = new Args(this, args);

            if (ar.Markers.Count < 1)
            {
                throw new Exception("Expected one marker");
            }
            var text      = ar.Strings.Count > 0 ? ar.Strings[0] : ar.Text;
            var emSize    = Floats.ContainsKey("FontSize") ? Floats["FontSize"] : 8;
            var fontName  = Strings.ContainsKey("FontName") ? Strings["FontName"] : "Arial";
            var textAlign = Strings.ContainsKey("TextAlign") ? Strings["TextAlign"] : "TopLeft";

            if (ar.Markers.Count == 1)
            {
                return () =>
                       {
                           Path.Reset();
                           using (var sf = GetTextAlign(textAlign))
                               Path.AddString(text, new FontFamily(fontName), 0, emSize, ar.Markers[0], sf);
                       }
            }
            ;
            if (ar.Markers.Count == 3)
            {
                return () =>
                       {
                           Path.Reset();
                           var layoutRect = new RectangleF(ar.Markers[0],
                                                           new SizeF(ar.Markers[1].X - ar.Markers[0].X, ar.Markers[2].Y - ar.Markers[0].Y));
                           using (var sf = GetTextAlign(textAlign))
                               Path.AddString(text, new FontFamily(fontName), 0, emSize, layoutRect, sf);
                       }
            }
            ;
            return(() => { });
        }