예제 #1
0
        public InfoStrip Clone()
        {
            InfoStrip newStrip = new InfoStrip(_id);

            newStrip.StartX        = StartX;
            newStrip.StartY        = StartY;
            newStrip.EndX          = EndX;
            newStrip.EndY          = EndY;
            newStrip.Label         = Label;
            newStrip.StripTemplate = StripTemplate;
            newStrip.Fill          = Fill;
            newStrip.UseDates      = UseDates;
            newStrip.StartDate     = StartDate;
            newStrip.EndDate       = EndDate;

            return(newStrip);
        }
예제 #2
0
        private static void OnLabelChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            InfoStrip owner = (InfoStrip)obj;

            owner.OnPropertyChanged("Label");
        }
예제 #3
0
        private void RefreshStrips()
        {
            Axis xAxis;
            Axis yAxis;

            GetAxes(out xAxis, out yAxis);

            if (xAxis == null || yAxis == null || xAxis.RootCanvas == null)
            {
                return;
            }

            ClearExisting(xAxis);

            Rect viewport = GetViewportRect(xAxis);
            Rect window   = _owner.WindowRect;

            foreach (InfoStrip strip in this.InfoStrips)
            {
                InfoStrip toAdd = strip.Clone();

                bool         isInverted = xAxis.IsInverted;
                ScalerParams param      = new ScalerParams(window, viewport, isInverted);

                if (!toAdd.UseDates)
                {
                    if (double.IsNaN(toAdd.StartX))
                    {
                        toAdd.StartX = viewport.Left;
                    }
                    else
                    {
                        toAdd.StartX = xAxis.GetScaledValue(toAdd.StartX, param);
                        //NOTE: prior to 12.1 release:
                        //toAdd.StartX = xAxis.GetScaledValue(toAdd.StartX, window, viewport);
                    }
                    if (double.IsNaN(toAdd.EndX))
                    {
                        toAdd.EndX = viewport.Right;
                    }
                    else
                    {
                        toAdd.EndX = xAxis.GetScaledValue(toAdd.EndX, param);
                        //NOTE: prior to 12.1 release:
                        //toAdd.EndX = xAxis.GetScaledValue(toAdd.EndX, window, viewport);
                    }
                }
                else
                {
                    toAdd.StartX = xAxis.GetScaledValue(toAdd.StartDate.Ticks, param);
                    toAdd.EndX   = xAxis.GetScaledValue(toAdd.EndDate.Ticks, param);
                    //NOTE: prior to 12.1 release:
                    //toAdd.StartX = xAxis.GetScaledValue(toAdd.StartDate.Ticks, window, viewport);
                    //toAdd.EndX = xAxis.GetScaledValue(toAdd.EndDate.Ticks, window, viewport);
                }
                // check if y-axis is inverted
                isInverted = yAxis.IsInverted;
                param      = new ScalerParams(window, viewport, isInverted);

                if (double.IsNaN(toAdd.StartY))
                {
                    toAdd.StartY = viewport.Top;
                }
                else
                {
                    toAdd.StartY = yAxis.GetScaledValue(toAdd.StartY, param);
                    //NOTE: prior to 12.1 release:
                    //toAdd.StartY = yAxis.GetScaledValue(toAdd.StartY, window, viewport);
                }
                if (double.IsNaN(toAdd.EndY))
                {
                    toAdd.EndY = viewport.Bottom;
                }
                else
                {
                    toAdd.EndY = yAxis.GetScaledValue(toAdd.EndY, param);
                    //NOTE: prior to 12.1 release:
                    //toAdd.EndY = yAxis.GetScaledValue(toAdd.EndY, window, viewport);
                }
                if (toAdd.StripTemplate == null)
                {
                    toAdd.StripTemplate = this.InfoStripTemplate;
                }

                if (toAdd.StripTemplate != null &&
                    !double.IsNaN(toAdd.StartY) &&
                    !double.IsInfinity(toAdd.StartY) &&
                    !double.IsNaN(toAdd.StartX) &&
                    !double.IsInfinity(toAdd.StartX))
                {
                    ContentControl stripControl = new ContentControl();
                    stripControl.ContentTemplate = toAdd.StripTemplate;
                    stripControl.Content         = toAdd;
                    Canvas.SetLeft(stripControl, toAdd.StartX);
                    Canvas.SetTop(stripControl, toAdd.StartY);

                    xAxis.RootCanvas.Children.Add(stripControl);
                }
            }
        }