Beispiel #1
0
        protected override void OnMouseDown(List <SeriesEditParameter> parameters,
                                            MouseEventArgs e, Keys modifierKeys, out IChartInteractiveObject objectToEdit)
        {
            objectToEdit = null;
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            var pointD = Chart.Owner.MouseToWorldCoords(e.X, e.Y);

            var incompleted = data.Find(s => s.IsBeingCreated);

            if (incompleted != null)
            {
                return;
            }

            // создать линию, которая будет рисоваться в режиме "резинка"
            var lineType        = SeriesEditParameter.TryGetParamValue(parameters, "Type", TrendLine.TrendLineStyle.Отрезок);
            var lineColor       = SeriesEditParameter.TryGetParamValue(parameters, "Stroke", Color.Black);
            var fillColor       = SeriesEditParameter.TryGetParamValue(parameters, "Filling", Color.White);
            var alphaColor      = SeriesEditParameter.TryGetParamValue(parameters, "Transparency", 192);
            var isHorisont      = SeriesEditParameter.TryGetParamValue(parameters, "Horizontal", false);
            var isHorisontShift = SeriesEditParameter.TryGetParamValue(parameters, "Horizontal_Shift", true);
            var showTags        = SeriesEditParameter.TryGetParamValue(parameters, "Subtitles", true);

            var shiftPressed = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;

            if (!isHorisont)
            {
                isHorisont = shiftPressed && isHorisontShift;
            }

            var span = new TrendLine
            {
                Owner          = this,
                LineStyle      = isHorisont ? TrendLine.TrendLineStyle.Линия : lineType,
                LineColor      = lineColor,
                ShapeFillColor = fillColor,
                ShapeAlpha     = alphaColor,
                IsBeingCreated = true,
                ShowTags       = showTags
            };

            span.AddPoint(pointD.X, pointD.Y);
            if (Owner.Owner.Owner.AdjustObjectColorsOnCreation)
            {
                span.AjustColorScheme(Owner.Owner.Owner);
            }

            // автоматом добавить вторую точку на одной высоте
            if (isHorisont)
            {
                var shouldEdit = SeriesEditParameter.TryGetParamValue(parameters, "Edit", true);
                AddSecondPointAuto(span);
                if (shouldEdit)
                {
                    objectToEdit = span;
                }
            }
            data.Add(span);
        }