public override UIElement[] CreateLabels(ITicksInfo<DateTime> ticksInfo)
		{
			object info = ticksInfo.Info;
			var ticks = ticksInfo.Ticks;

			if (info is DifferenceIn)
			{
				DifferenceIn diff = (DifferenceIn)info;
				DateFormat = GetDateFormat(diff);
			}

			LabelTickInfo<DateTime> tickInfo = new LabelTickInfo<DateTime> { Info = info };

			UIElement[] res = new UIElement[ticks.Length];
			for (int i = 0; i < ticks.Length; i++)
			{
				tickInfo.Tick = ticks[i];

				string tickText = GetString(tickInfo);
				UIElement label = new TextBlock { Text = tickText, ToolTip = ticks[i] };
				ApplyCustomView(tickInfo, label);
				res[i] = label;
			}

			return res;
		}
        public override UIElement[] CreateLabels(ITicksInfo <double> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

            Init(ticks);

            UIElement[]            res      = new UIElement[ticks.Length];
            LabelTickInfo <double> tickInfo = new LabelTickInfo <double> {
                Info = ticksInfo.Info
            };

            for (int i = 0; i < res.Length; i++)
            {
                tickInfo.Tick  = ticks[i];
                tickInfo.Index = i;

                string label = GetString(tickInfo);
                res[i] = new TextBlock
                {
                    Text    = label,
                    ToolTip = ticks[i].ToString()
                };

                ApplyCustomView(tickInfo, res[i]);
            }
            return(res);
        }
        public override UIElement[] CreateLabels(ITicksInfo <DateTime> ticksInfo)
        {
            object info  = ticksInfo.Info;
            var    ticks = ticksInfo.Ticks;

            if (info is DifferenceIn)
            {
                DifferenceIn diff = (DifferenceIn)info;
                DateFormat = GetDateFormat(diff);
            }

            LabelTickInfo <DateTime> tickInfo = new LabelTickInfo <DateTime> {
                Info = info
            };

            UIElement[] res = new UIElement[ticks.Length];
            for (int i = 0; i < ticks.Length; i++)
            {
                tickInfo.Tick = ticks[i];

                string    tickText = GetString(tickInfo);
                UIElement label    = new TextBlock {
                    Text = tickText, ToolTip = ticks[i]
                };
                ApplyCustomView(tickInfo, label);
                res[i] = label;
            }

            return(res);
        }
		public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
		{
			var ticks = ticksInfo.Ticks;

			Init(ticks);

			UIElement[] res = new UIElement[ticks.Length];
			LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };
			for (int i = 0; i < res.Length; i++)
			{
				tickInfo.Tick = ticks[i];
				tickInfo.Index = i;

				string labelText = GetString(tickInfo);

				TextBlock label = (TextBlock)GetResourceFromPool();
				if (label == null)
				{
					label = new TextBlock();
				}

				label.Text = labelText;
				label.ToolTip = ticks[i].ToString();

				res[i] = label;

				ApplyCustomView(tickInfo, label);
			}
			return res;
		}
    public override UIElement[] CreateLabels(ITicksInfo <double> ticksInfo)
    {
        var ticks = ticksInfo.Ticks;

        Init(ticks);
        UIElement[]            res      = new UIElement[ticks.Length];
        LabelTickInfo <double> tickInfo = new LabelTickInfo <double> {
            Info = ticksInfo.Info
        };

        for (int i = 0; i < res.Length; i++)
        {
            tickInfo.Tick  = ticks[i];
            tickInfo.Index = i;
            string labelText = "";

            labelText = Labels[Convert.ToInt32(tickInfo.Tick)];

            TextBlock label = (TextBlock)GetResourceFromPool();
            if (label == null)
            {
                label = new TextBlock();
            }
            label.Text = labelText;
            res[i]     = label;
            ApplyCustomView(tickInfo, label);
        }
        return(res);
    }
Exemple #6
0
        /// <summary>
        /// Creates labels by given ticks info.
        /// Is not intended to be called from your code.
        /// </summary>
        /// <param name="ticksInfo">The ticks info.</param>
        /// <returns>
        /// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
        /// </returns>
        public override UIElement[] CreateLabels(ITicksInfo <double> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

            Init(ticks);

            UIElement[] res = new UIElement[ticks.Length];

            LabelTickInfo <double> tickInfo = new LabelTickInfo <double> {
                Info = ticksInfo.Info
            };

            for (int i = 0; i < res.Length; i++)
            {
                var tick = ticks[i];
                tickInfo.Tick  = tick;
                tickInfo.Index = i;

                string labelText = GetString(tickInfo);

                TextBlock label;
                if (labelText.Contains('E'))
                {
                    string[] substrs   = labelText.Split('E');
                    string   mantissa  = substrs[0];
                    string   exponenta = substrs[1];
                    exponenta = exponenta.TrimStart('+');
                    Span span = new Span();
                    span.Inlines.Add(String.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
                    Span exponentaSpan = new Span(new Run(exponenta));
                    exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
                    exponentaSpan.FontSize          = 8;
                    span.Inlines.Add(exponentaSpan);

                    label = new TextBlock(span);
                    LabelProviderProperties.SetExponentialIsCommonLabel(label, false);
                }
                else
                {
                    label = (TextBlock)GetResourceFromPool();
                    if (label == null)
                    {
                        label = new TextBlock();
                    }

                    label.Text = labelText;
                }
                res[i]        = label;
                label.ToolTip = tick.ToString(CultureInfo.CurrentCulture);

                ApplyCustomView(tickInfo, label);
            }

            return(res);
        }
		/// <summary>
		/// Creates labels by given ticks info.
		/// Is not intended to be called from your code.
		/// </summary>
		/// <param name="ticksInfo">The ticks info.</param>
		/// <returns>
		/// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
		/// </returns>
		public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
		{
			var ticks = ticksInfo.Ticks;

			Init(ticks);

			UIElement[] res = new UIElement[ticks.Length];

			LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };

			for (int i = 0; i < res.Length; i++)
			{
				var tick = ticks[i];
				tickInfo.Tick = tick;
				tickInfo.Index = i;

				string labelText = GetString(tickInfo);

				TextBlock label;
				if (labelText.Contains('E'))
				{
					string[] substrs = labelText.Split('E');
					string mantissa = substrs[0];
					string exponenta = substrs[1];
					exponenta = exponenta.TrimStart('+');
					Span span = new Span();
					span.Inlines.Add(String.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
					Span exponentaSpan = new Span(new Run(exponenta));
					exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
					exponentaSpan.FontSize = 8;
					span.Inlines.Add(exponentaSpan);

					label = new TextBlock(span);
					LabelProviderProperties.SetExponentialIsCommonLabel(label, false);
				}
				else
				{
					label = (TextBlock)GetResourceFromPool();
					if (label == null)
					{
						label = new TextBlock();
					}

					label.Text = labelText;
				}
				res[i] = label;
				label.ToolTip = tick.ToString(CultureInfo.CurrentCulture);

				ApplyCustomView(tickInfo, label);
			}

			return res;
		}
Exemple #8
0
		protected override string GetStringCore(LabelTickInfo<double> tickInfo)
		{
			string res;
			if (!shouldRound)
			{
				res = tickInfo.Tick.ToString();
			}
			else
			{
				int round = Math.Min(15, Math.Max(-15, rounding - 2));
				res = RoundHelper.Round(tickInfo.Tick, round).ToString();
			}

			return res;
		}
Exemple #9
0
        public override UIElement[] CreateLabels(ITicksInfo <double> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

            Init(ticks);

            UIElement[] res = new UIElement[ticks.Length];

            LabelTickInfo <double> tickInfo = new LabelTickInfo <double> {
                Info = ticksInfo.Info
            };

            for (int i = 0; i < res.Length; i++)
            {
                tickInfo.Tick  = ticks[i];
                tickInfo.Index = i;

                string label = GetString(tickInfo);

                if (label.Contains('E'))
                {
                    string[] substrs   = label.Split('E');
                    string   mantissa  = substrs[0];
                    string   exponenta = substrs[1];
                    exponenta = exponenta.TrimStart('+');
                    Span span = new Span();
                    span.Inlines.Add(String.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
                    Span exponentaSpan = new Span(new Run(exponenta));
                    exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
                    exponentaSpan.FontSize          = 8;
                    span.Inlines.Add(exponentaSpan);
                    res[i] = new TextBlock(span);
                }
                else
                {
                    res[i] = new TextBlock {
                        Text = label
                    };
                }
                ((TextBlock)res[i]).ToolTip = ticks[i].ToString(CultureInfo.CurrentCulture);

                ApplyCustomView(tickInfo, res[i]);
            }

            return(res);
        }
		public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
		{
			var ticks = ticksInfo.Ticks;

			Init(ticks);

			UIElement[] res = new UIElement[ticks.Length];

			LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };
			
			for (int i = 0; i < res.Length; i++)
			{
				tickInfo.Tick = ticks[i];
				tickInfo.Index = i;

				string label = GetString(tickInfo);

				if (label.Contains('E'))
				{
					string[] substrs = label.Split('E');
					string mantissa = substrs[0];
					string exponenta = substrs[1];
					exponenta = exponenta.TrimStart('+');
					Span span = new Span();
					span.Inlines.Add(String.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
					Span exponentaSpan = new Span(new Run(exponenta));
					exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
					exponentaSpan.FontSize = 8;
					span.Inlines.Add(exponentaSpan);
					res[i] = new TextBlock(span);
				}
				else
				{
					res[i] = new TextBlock { Text = label };
				}
				((TextBlock)res[i]).ToolTip = ticks[i].ToString(CultureInfo.CurrentCulture);

				ApplyCustomView(tickInfo, res[i]);
			}

			return res;
		}
        public override UIElement[] CreateLabels(ITicksInfo <TimeSpan> ticksInfo)
        {
            object info  = ticksInfo.Info;
            var    ticks = ticksInfo.Ticks;

            LabelTickInfo <TimeSpan> tickInfo = new LabelTickInfo <TimeSpan>();

            UIElement[] res = new UIElement[ticks.Length];
            for (int i = 0; i < ticks.Length; i++)
            {
                tickInfo.Tick = ticks[i];
                tickInfo.Info = info;

                string    tickText = GetString(tickInfo);
                UIElement label    = new TextBlock {
                    Text = tickText, ToolTip = ticks[i]
                };
                res[i] = label;
            }
            return(res);
        }
Exemple #12
0
        protected override string GetStringCore(LabelTickInfo <double> tickInfo)
        {
            double value = tickInfo.Tick / customBase;

            string customBaseStr = customBaseString ?? customBase.ToString();
            string result;

            if (value == 1)
            {
                result = customBaseStr;
            }
            else if (value == -1)
            {
                result = "-" + customBaseStr;
            }
            else
            {
                result = value.ToString() + customBaseStr;
            }

            return(result);
        }
Exemple #13
0
        /// <summary>
        /// Creates the labels by given ticks info.
        /// </summary>
        /// <param name="ticksInfo">The ticks info.</param>
        /// <returns>
        /// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
        /// </returns>
        public override UIElement[] CreateLabels(ITicksInfo <T> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;
            var info  = ticksInfo.Info;

            LabelTickInfo <T> tickInfo = new LabelTickInfo <T>();

            UIElement[] res = new UIElement[ticks.Length];
            for (int i = 0; i < res.Length; i++)
            {
                tickInfo.Tick = ticks[i];
                tickInfo.Info = info;

                string text = GetString(tickInfo);

                res[i] = new TextBlock
                {
                    Text    = text,
                    ToolTip = ticks[i].ToString()
                };
            }
            return(res);
        }
        public override UIElement[] CreateLabels(ITicksInfo <TAxis> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

            if (ticks.Length == 0)
            {
                return(EmptyLabelsArray);
            }

            startIndex = (int)ticksInfo.Info;

            UIElement[] result = new UIElement[ticks.Length];

            LabelTickInfo <TAxis> labelInfo = new LabelTickInfo <TAxis> {
                Info = ticksInfo.Info
            };

            for (int i = 0; i < result.Length; i++)
            {
                var tick = ticks[i];
                labelInfo.Tick  = tick;
                labelInfo.Index = i;

                string labelText = GetString(labelInfo);

                TextBlock label = new TextBlock {
                    Text = labelText
                };

                ApplyCustomView(labelInfo, label);

                result[i] = label;
            }

            return(result);
        }
		public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
		{
			var ticks = ticksInfo.Ticks;

			Init(ticks);

			UIElement[] res = new UIElement[ticks.Length];
			LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };
			for (int i = 0; i < res.Length; i++)
			{
				tickInfo.Tick = ticks[i];
				tickInfo.Index = i;

				string label = GetString(tickInfo);
				res[i] = new TextBlock
				{
					Text = label,
					ToolTip = ticks[i].ToString()
				};

				ApplyCustomView(tickInfo, res[i]);
			}
			return res;
		}
        public override UIElement[] CreateLabels(ITicksInfo <DateTime> ticksInfo)
        {
            object info  = ticksInfo.Info;
            var    ticks = ticksInfo.Ticks;

            UIElement[] res       = new UIElement[ticks.Length - 1];
            int         labelsNum = 3;

            if (info is DifferenceIn)
            {
                DifferenceIn diff = (DifferenceIn)info;
                DateFormat = GetDateFormat(diff);
            }
            else if (info is MajorLabelsInfo)
            {
                MajorLabelsInfo mInfo = (MajorLabelsInfo)info;
                DifferenceIn    diff  = (DifferenceIn)mInfo.Info;
                DateFormat = GetDateFormat(diff);
                labelsNum  = mInfo.MajorLabelsCount + 1;

                //DebugVerify.Is(labelsNum < 100);
            }

            DebugVerify.Is(ticks.Length < 10);

            LabelTickInfo <DateTime> tickInfo = new LabelTickInfo <DateTime>();

            for (int i = 0; i < ticks.Length - 1; i++)
            {
                tickInfo.Info = info;
                tickInfo.Tick = ticks[i];

                string tickText = GetString(tickInfo);

                Grid grid = new Grid {
                };

                // doing binding as described at http://sdolha.spaces.live.com/blog/cns!4121802308C5AB4E!3724.entry?wa=wsignin1.0&sa=835372863

                grid.SetBinding(Grid.BackgroundProperty, new Binding {
                    Path = new PropertyPath("(0)", DateTimeAxis.MajorLabelBackgroundBrushProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor)
                    {
                        AncestorType = typeof(AxisControlBase)
                    }
                });
                Rectangle rect = new Rectangle
                {
                    StrokeThickness = 2
                };
                rect.SetBinding(Rectangle.StrokeProperty, new Binding {
                    Path = new PropertyPath("(0)", DateTimeAxis.MajorLabelRectangleBorderPropertyProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor)
                    {
                        AncestorType = typeof(AxisControlBase)
                    }
                });

                Grid.SetColumn(rect, 0);
                Grid.SetColumnSpan(rect, labelsNum);

                for (int j = 0; j < labelsNum; j++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }

                grid.Children.Add(rect);

                for (int j = 0; j < labelsNum; j++)
                {
                    var tb = new TextBlock
                    {
                        Text = tickText,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Margin = new Thickness(0, 3, 0, 3)
                    };
                    Grid.SetColumn(tb, j);
                    grid.Children.Add(tb);
                }

                ApplyCustomView(tickInfo, grid);

                res[i] = grid;
            }

            return(res);
        }
        public override List<FrameworkElement> CreateLabels(ITicksInfo<DateTime> ticksInfo)
        {
            object info = ticksInfo.Info;
            var ticks = ticksInfo.Ticks;
            FrameworkElement[] res = new FrameworkElement[ticks.Length - 1];
            int labelsNum = 3;

            if (info is DifferenceIn)
            {
                DifferenceIn diff = (DifferenceIn)info;
                DateFormat = GetDateFormat(diff);
            }
            else if (info is MayorLabelsInfo)
            {
                MayorLabelsInfo mInfo = (MayorLabelsInfo)info;
                DifferenceIn diff = (DifferenceIn)mInfo.Info;
                DateFormat = GetDateFormat(diff);
                labelsNum = mInfo.MayorLabelsCount + 1;

                //DebugVerify.Is(labelsNum < 100);
            }

            DebugVerify.Is(ticks.Length < 10);

            LabelTickInfo<DateTime> tickInfo = new LabelTickInfo<DateTime>();
            for (int i = 0; i < ticks.Length - 1; i++)
            {
                tickInfo.Info = info;
                tickInfo.Tick = ticks[i];

                string tickText = GetString(tickInfo);

                Grid grid = new Grid
                {
                    Background = new SolidColorBrush(Colors.LightGray)
                };
                Rectangle rect = new Rectangle
                {
                    Stroke = new SolidColorBrush(Colors.DarkGray),
                    StrokeThickness = 2
                };
                Grid.SetColumn(rect, 0);
                Grid.SetColumnSpan(rect, labelsNum);

                for (int j = 0; j < labelsNum; j++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }

                grid.Children.Add(rect);

                for (int j = 0; j < labelsNum; j++)
                {
                    var tb = new TextBlock
                    {
                        Text = tickText,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Margin = new Thickness(0, 3, 0, 3)
                    };
                    Grid.SetColumn(tb, j);
                    grid.Children.Add(tb);
                }

                ApplyCustomView(tickInfo, grid);

                res[i] = grid;
            }

            return new List<FrameworkElement>(res);
        }
 public DateTimeLabelProvider()
 {
     tickInfo = new LabelTickInfo<DateTime>();
 }
 public ExponentialLabelProvider() {
     tickInfo = new LabelTickInfo<double>();
 }
Exemple #20
0
 public DateTimeLabelProvider()
 {
     tickInfo = new LabelTickInfo <DateTime>();
 }
 protected override string GetStringCore(LabelTickInfo <TAxis> tickInfo)
 {
     return(displayMemberMapping(collection[tickInfo.Index + startIndex]));
 }
Exemple #22
0
 public ExponentialLabelProvider()
 {
     tickInfo = new LabelTickInfo <double>();
 }
Exemple #23
0
        public override UIElement[] CreateLabels(ITicksInfo <DateTime> ticksInfo)
        {
            object info  = ticksInfo.Info;
            var    ticks = ticksInfo.Ticks;

            UIElement[] res       = new UIElement[ticks.Length - 1];
            int         labelsNum = 3;

            if (info is DifferenceIn)
            {
                DifferenceIn diff = (DifferenceIn)info;
                DateFormat = GetDateFormat(diff);
            }
            else if (info is MayorLabelsInfo)
            {
                MayorLabelsInfo mInfo = (MayorLabelsInfo)info;
                DifferenceIn    diff  = (DifferenceIn)mInfo.Info;
                DateFormat = GetDateFormat(diff);
                labelsNum  = mInfo.MayorLabelsCount + 1;

                //DebugVerify.Is(labelsNum < 100);
            }

            DebugVerify.Is(ticks.Length < 10);

            LabelTickInfo <DateTime> tickInfo = new LabelTickInfo <DateTime>();

            for (int i = 0; i < ticks.Length - 1; i++)
            {
                tickInfo.Info = info;
                tickInfo.Tick = ticks[i];

                string tickText = GetString(tickInfo);

                Grid grid = new Grid
                {
                    Background = Brushes.Beige
                };
                Rectangle rect = new Rectangle
                {
                    Stroke          = Brushes.Peru,
                    StrokeThickness = 2
                };
                Grid.SetColumn(rect, 0);
                Grid.SetColumnSpan(rect, labelsNum);

                for (int j = 0; j < labelsNum; j++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }

                grid.Children.Add(rect);

                for (int j = 0; j < labelsNum; j++)
                {
                    var tb = new TextBlock
                    {
                        Text = tickText,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Margin = new Thickness(0, 3, 0, 3)
                    };
                    Grid.SetColumn(tb, j);
                    grid.Children.Add(tb);
                }

                ApplyCustomView(tickInfo, grid);

                res[i] = grid;
            }

            return(res);
        }
        /// <summary>
        /// Creates labels by given ticks info.
        /// Is not intended to be called from your code.
        /// </summary>
        /// <param name="ticksInfo">The ticks info.</param>
        /// <returns>
        /// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
        /// </returns>
        public override UIElement[] CreateLabels(ITicksInfo <double> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

            Init(ticks);

            UIElement[] res = new UIElement[ticks.Length];

            LabelTickInfo <double> tickInfo = new LabelTickInfo <double> {
                Info = ticksInfo.Info
            };

            for (int i = 0; i < res.Length; i++)
            {
                var tick = ticks[i];
                tickInfo.Tick  = tick;
                tickInfo.Index = i;

                string labelText = GetString(tickInfo);

                TextBlock label;
                if (labelText.Contains('E'))
                {
                    string[] substrs   = labelText.Split('E');
                    string   mantissa  = substrs[0];
                    string   exponenta = substrs[1];
                    exponenta = exponenta.TrimStart('+');
                    Span span = new Span();
                    span.Inlines.Add(string.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
                    Span exponentaSpan = new Span(new Run(exponenta));
                    exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
                    exponentaSpan.FontSize          = 8;
                    span.Inlines.Add(exponentaSpan);

                    label = new TextBlock(span);
                    LabelProviderProperties.SetExponentialIsCommonLabel(label, false);
                }
                else
                {
                    label = (TextBlock)GetResourceFromPool();
                    if (label == null)
                    {
                        label = new TextBlock();
                    }

                    label.Text = labelText;
                }
                res[i]        = label;
                label.ToolTip = tick.ToString(CultureInfo.CurrentCulture);

                ApplyCustomView(tickInfo, label);
            }

            // need to make the number of digits after the decimal point all the same
            // so fill in between the "." and the "E" with zeros to make all the same
            var labelsWithDecimal = res.Cast <TextBlock>().Select(tb => tb.Text).Where(t => t.Contains(".")).ToArray();

            if (labelsWithDecimal.Length > 0)
            {
                int decimalPlaces = 0;
                foreach (var labelWithDecimal in labelsWithDecimal)
                {
                    if (labelsWithDecimal.Contains("E"))
                    {
                        decimalPlaces = Math.Max(decimalPlaces, labelWithDecimal.IndexOf("E") - labelWithDecimal.IndexOf(".") - 1);
                    }
                    else
                    {
                        decimalPlaces = Math.Max(decimalPlaces, labelWithDecimal.Length - labelWithDecimal.IndexOf(".") - 1);
                    }
                }

                foreach (TextBlock tb in res)
                {
                    string text           = tb.Text;
                    int    insertionPoint = text.Contains("E") ? text.IndexOf("E") : text.Length;
                    if (!text.Contains("."))
                    {
                        text = text.Insert(insertionPoint, ".");
                        insertionPoint++;
                    }
                    int currentPlaces = insertionPoint - text.IndexOf(".") - 1;
                    for (int i = currentPlaces; i < decimalPlaces; ++i)
                    {
                        text = text.Insert(insertionPoint, "0");
                    }
                    tb.Text = text;
                }
            }


            return(res);
        }
 protected override string GetStringCore(LabelTickInfo <DateTime> tickInfo)
 {
     return(tickInfo.Tick.ToString(dateFormat));
 }
        public override UIElement[] CreateLabels(ITicksInfo<DateTime> ticksInfo)
        {
            object info = ticksInfo.Info;
            var ticks = ticksInfo.Ticks;
            UIElement[] res = new UIElement[ticks.Length - 1];
            int labelsNum = 3;

            if (info is DifferenceIn)
            {
                DifferenceIn diff = (DifferenceIn)info;
                DateFormat = GetDateFormat(diff);
            }
            else if (info is MajorLabelsInfo)
            {
                MajorLabelsInfo mInfo = (MajorLabelsInfo)info;
                DifferenceIn diff = (DifferenceIn)mInfo.Info;
                DateFormat = GetDateFormat(diff);
                labelsNum = mInfo.MajorLabelsCount + 1;

                //DebugVerify.Is(labelsNum < 100);
            }

            DebugVerify.Is(ticks.Length < 10);

            LabelTickInfo<DateTime> tickInfo = new LabelTickInfo<DateTime>();
            for (int i = 0; i < ticks.Length - 1; i++)
            {
                tickInfo.Info = info;
                tickInfo.Tick = ticks[i];

                string tickText = GetString(tickInfo);

                Grid grid = new Grid { };

                // doing binding as described at http://sdolha.spaces.live.com/blog/cns!4121802308C5AB4E!3724.entry?wa=wsignin1.0&sa=835372863

                grid.SetBinding(Grid.BackgroundProperty, new Binding { Path = new PropertyPath("(0)", DateTimeAxis.MajorLabelBackgroundBrushProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor) { AncestorType = typeof(AxisControlBase) } });
                Rectangle rect = new Rectangle
                {
                    StrokeThickness = 2
                };
                rect.SetBinding(Rectangle.StrokeProperty, new Binding { Path = new PropertyPath("(0)", DateTimeAxis.MajorLabelRectangleBorderPropertyProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor) { AncestorType = typeof(AxisControlBase) } });

                Grid.SetColumn(rect, 0);
                Grid.SetColumnSpan(rect, labelsNum);

                for (int j = 0; j < labelsNum; j++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }

                grid.Children.Add(rect);

                for (int j = 0; j < labelsNum; j++)
                {
                    var tb = new TextBlock
                    {
                        Text = tickText,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Margin = new Thickness(0, 3, 0, 3)
                    };
                    Grid.SetColumn(tb, j);
                    grid.Children.Add(tb);
                }

                ApplyCustomView(tickInfo, grid);

                res[i] = grid;
            }

            return res;
        }