public override UIElement[] CreateLabels(ITicksInfo <int> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

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

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

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

                if (0 <= tick && tick < collection.Count)
                {
                    string text = collection[tick].ToString();
                    res[i] = new TextBlock
                    {
                        Text    = text,
                        ToolTip = text
                    };
                }
                else
                {
                    res[i] = null;
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public override UIElement[] CreateLabels(ITicksInfo <T> ticksInfo)
        {
            var ticks = ticksInfo.Ticks;

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

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

                string labelText = GetString(labelInfo);

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

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

                res[i] = label;

                ApplyCustomView(labelInfo, label);
            }

            return(res);
        }
Exemplo n.º 3
0
 protected void ApplyCustomView(LabelTickInfo <T> info, UIElement label)
 {
     if (CustomView != null)
     {
         CustomView(info, label);
     }
 }
Exemplo n.º 4
0
        protected virtual string GetString(LabelTickInfo <T> tickInfo)
        {
            string text = null;

            if (CustomFormatter != null)
            {
                text = CustomFormatter(tickInfo);
            }
            if (text == null)
            {
                text = GetStringCore(tickInfo);

                if (text == null)
                {
                    throw new ArgumentNullException(Strings.Exceptions.TextOfTickShouldNotBeNull);
                }
            }
            if (LabelStringFormat != null)
            {
                text = string.Format(LabelStringFormat, text);
            }

            return(text);
        }
Exemplo n.º 5
0
 protected virtual string GetStringCore(LabelTickInfo <T> tickInfo)
 {
     return(tickInfo.Tick.ToString());
 }