Exemplo n.º 1
0
        public override void Echo(TimeScaler Scaler)
        {
            using (DrawingContext dc = this.RenderOpen())
            {
                if (Line.Header != null)
                {
                    var ft = new FormattedText(Line.Header,
                        System.Globalization.CultureInfo.CurrentCulture,
                        System.Windows.FlowDirection.LeftToRight,
                        LabelTypeFace, 10, Foreground);

                    var x = Scaler.GetHorizontalOffset(Scaler.LeftDate) + 1;
                    var w = ft.Width + 4;
                    var y = Scaler.GetVerticalOffset(this.Line) + 1;
                    var h = ft.Height + 2;

                    Rect r = new Rect(x, y, w, h);
                    r = RoundRect(r);

                    var gl = new GuidelineSet();
                    AddRectToGuidlineSet(gl, r);
                    dc.PushGuidelineSet(gl);

                    dc.DrawRoundedRectangle(Background, null, r, 2, 2);

                    dc.DrawText(ft, new Point(x + 2, y + 1));

                    dc.Pop();   // GuidelineSet
                }
            }
        }
 public override void Echo(TimeScaler Scaler)
 {
     using (DrawingContext dc = this.RenderOpen())
     {
         var x = Scaler.GetHorizontalOffset(StartDate);
         var w = Scaler.GetWidth(EndDate - StartDate);
         var y = Scaler.GetVerticalOffset(this.Line);
         var h = Scaler.GetHeight(this.Line);
         //var pb = new Pen(new SolidColorBrush(Color.Subtract((Foreground as SolidColorBrush).Color, Colors.Green)), 2);
         var pb = new Pen(new SolidColorBrush(Colors.Violet), 2);
         dc.DrawRectangle(Foreground, pb, new System.Windows.Rect(-x-w, y, w, h));
     }
 }
Exemplo n.º 3
0
        public override void Echo(TimeScaler Scaler)
        {
            //this.Opacity = 0.5;
            using (DrawingContext dc = this.RenderOpen())
            {
                var x = Scaler.GetHorizontalOffset(StartDate);
                var w = Scaler.GetWidth(EndDate - StartDate);
                var y = Scaler.GetVerticalOffset(this.Line);
                var h = Scaler.GetHeight(this.Line);

                Rect r = new Rect(x, y + h * (1 - Value), w, h * Value);
                r = RoundRect(r);

                var gl = new GuidelineSet();
                AddRectToGuidlineSet(gl, r, 0);
                dc.PushGuidelineSet(gl);

                dc.DrawRectangle(Background, null, r);

                dc.Pop();   // GuidelineSet
            }
        }
Exemplo n.º 4
0
        public override void Echo(TimeScaler Scaler)
        {
            using (DrawingContext dc = this.RenderOpen())
            {
                var x = Scaler.GetHorizontalOffset(StartDate);
                var w = Scaler.GetWidth(EndDate - StartDate);
                var y = Scaler.GetVerticalOffset(this.Line);
                var h = Scaler.GetHeight(this.Line);
                Pen pb = new Pen(StrokeBrush ?? Background, 1);

                Rect r = new Rect(x, y, w, h);
                r = RoundRect(r);

                var gl = new GuidelineSet();
                AddRectToGuidlineSet(gl, r, pb.Thickness);
                dc.PushGuidelineSet(gl);

                dc.DrawRectangle(Background, pb, r);

                if (LabelText != null)
                {
                    var ZeroX = Scaler.GetHorizontalOffset(Scaler.LeftDate);
                    var TextX = Math.Max(x, ZeroX) + 2;

                    var ft = new FormattedText(this.LabelText,
                        System.Globalization.CultureInfo.CurrentCulture,
                        System.Windows.FlowDirection.LeftToRight,
                        LabelTypeFace, 8, Foreground);

                    if (TextX + ft.Width + 10 <= x + w)
                        dc.DrawText(ft, new Point(TextX, y + 3));
                }

                dc.Pop();   // GuidelineSet
            }
        }
Exemplo n.º 5
0
        public override void Echo(TimeScaler Scaler)
        {
            using (DrawingContext dc = this.RenderOpen())
            {
                var x1 = Scaler.GetHorizontalOffset(StartDate);
                var x2 = Scaler.GetHorizontalOffset(EndDate);
                var y = Scaler.GetVerticalOffset(this.Line) + 2;
                var ZeroX = Scaler.GetHorizontalOffset(Scaler.LeftDate);

                Pen MajorPen = new Pen(Brushes.Black, 1);
                Pen MinorPen = new Pen(new SolidColorBrush(Color.FromArgb(32, 0, 0, 0)), 1) { DashStyle = DashStyles.Dash };

                {
                    var gl = new GuidelineSet();
                    gl.GuidelinesX.Add(GetGuideline(x1));
                    gl.GuidelinesX.Add(GetGuideline(x2));
                    gl.GuidelinesY.Add(GetGuideline(y, MajorPen.Thickness));
                    dc.PushGuidelineSet(gl);
                    dc.DrawLine(MajorPen, new Point(x1, y), new Point(x2, y));
                    dc.Pop();   // GuidelineSet
                }

                var Tick = GetTickFormats(Scaler.Scale, 0);

                DateTime tick = DateTime.MinValue + TimeSpan.FromSeconds(Math.Ceiling((StartDate - DateTime.MinValue).TotalSeconds / Tick.SmallTickLength.TotalSeconds) * Tick.SmallTickLength.TotalSeconds) - Tick.SmallTickLength;

                var ticks = Enumerable.Range(0, int.MaxValue)
                    .Select(i => (tick += Tick.SmallTickLength))
                    .TakeWhile(t => t <= EndDate)
                    .ToList();

                foreach (var t in ticks)
                {
                    var gli = new GuidelineSet();

                    var tx = Math.Round(Scaler.GetHorizontalOffset(t));

                    gli.GuidelinesX.Add(GetGuideline(tx, MajorPen.Thickness));
                    gli.GuidelinesY.Add(GetGuideline(y - 1, MajorPen.Thickness));
                    gli.GuidelinesY.Add(GetGuideline(y + 2, MajorPen.Thickness));
                    gli.GuidelinesY.Add(GetGuideline(y - 2, MinorPen.Thickness));
                    gli.GuidelinesY.Add(GetGuideline(0, MinorPen.Thickness));
                    dc.PushGuidelineSet(gli);

                    dc.DrawLine(MajorPen, new Point(tx, y - 1), new Point(tx, y + 2));
                    dc.DrawLine(MinorPen, new Point(tx, 0), new Point(tx, y - 2));

                    var ft = new FormattedText(t.ToString(Tick.SmallTickFormat),
                        System.Globalization.CultureInfo.CurrentCulture,
                        System.Windows.FlowDirection.LeftToRight,
                        ValueLabelTypeFace, 10, Brushes.Black);

                    dc.DrawText(ft, new Point(Math.Max(tx, ZeroX), y + 3));

                    dc.Pop();
                }

                var BigTicks = Enumerable.Repeat(StartDate, 1)
                    .Concat(ticks)
                    .GroupBy(Tick.BigTickKeySelector).Select(g => g.First())
                    .Select(bt =>
                        new
                        {
                            ft = new FormattedText(bt.ToString(Tick.BigTickFormat),
                                    System.Globalization.CultureInfo.CurrentCulture,
                                    System.Windows.FlowDirection.LeftToRight,
                                    ValueLabelTypeFace, 10, Brushes.Black),
                            p = new Point(
                                    Math.Max(Scaler.GetHorizontalOffset(bt), ZeroX),
                                    y + 10 * ValueLabelTypeFace.XHeight + 8)
                        })
                        .ToList();

                if (BigTicks.Count > 1 && BigTicks[0].p.X + BigTicks[0].ft.Width + 2 >= BigTicks[1].p.X)
                    BigTicks.RemoveAt(0);

                foreach (var bt in BigTicks)
                {
                    dc.DrawText(bt.ft, bt.p);
                }

            }
        }