public override IChartInteractiveObject LoadObject(XmlElement objectNode, CandleChartControl owner, bool trimObjectsOutOfHistory = false)
        {
            var obj = new FiboChannel();

            obj.LoadFromXML(objectNode, owner);
            obj.Owner = this;
            data.Add(obj);
            return(obj);
        }
        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)
            {
                // добавить третью точку
                incompleted.Point3 = new PointD(
                    (incompleted.linePoints[0].X + incompleted.linePoints[1].X) / 2,
                    (incompleted.linePoints[0].Y + incompleted.linePoints[1].Y) / 2);
                channelBeingCreated = incompleted;
                return;
            }

            // ReSharper disable UseObjectOrCollectionInitializer
            var channel = new FiboChannel {
                Owner = this, IsBeingCreated = true
            };

            // ReSharper restore UseObjectOrCollectionInitializer
            channel.DrawText  = SeriesEditParameter.TryGetParamValue(parameters, "DrawLabels", false);
            channel.LineColor = SeriesEditParameter.TryGetParamValue(parameters, "Color", Color.DarkBlue);
            channel.LineStyle = SeriesEditParameter.TryGetParamValue(parameters, "LineType", TrendLine.TrendLineStyle.Отрезок);
            channel.AddPoint(pointD.X, pointD.Y);
            channel.AddPoint(pointD.X, pointD.Y);
            channelBeingCreated = channel;

            if (Owner.Owner.Owner.AdjustObjectColorsOnCreation)
            {
                channel.AjustColorScheme(Owner.Owner.Owner);
            }
            data.Add(channel);
        }
        protected override bool OnMouseUp(List <SeriesEditParameter> parameters, MouseEventArgs e,
                                          Keys modifierKeys, out IChartInteractiveObject objectToEdit)
        {
            objectToEdit = null;
            if (channelBeingCreated == null)
            {
                return(false);
            }

            // если канал незавершен - нет точки проекции
            if (!channelBeingCreated.Point3.HasValue)
            {
                // если канал сжался в точку сингулярности - удалить его
                var lenPx = Conversion.GetSpanLenInScreenCoords(channelBeingCreated.linePoints[0],
                                                                channelBeingCreated.linePoints[1], Chart.StockPane.WorldRect, Chart.StockPane.CanvasRect);
                if (lenPx < 3)
                {
                    data.Remove(channelBeingCreated);
                    channelBeingCreated = null;
                    return(true);
                }

                // добавить третью точку
                channelBeingCreated.Point3 = new PointD(
                    (channelBeingCreated.linePoints[0].X + channelBeingCreated.linePoints[1].X) / 2,
                    (channelBeingCreated.linePoints[0].Y + channelBeingCreated.linePoints[1].Y) / 2);

                channelBeingCreated = null;
                return(true);
            }

            // канал завершен
            channelBeingCreated.IsBeingCreated = false;
            objectToEdit = channelBeingCreated;

            channelBeingCreated = null;
            return(true);
        }
Esempio n. 4
0
        protected override bool OnMouseUp(List<SeriesEditParameter> parameters, MouseEventArgs e, 
            Keys modifierKeys, out IChartInteractiveObject objectToEdit)
        {
            objectToEdit = null;
            if (channelBeingCreated == null) return false;

            // если канал незавершен - нет точки проекции
            if (!channelBeingCreated.Point3.HasValue)
            {
                // если канал сжался в точку сингулярности - удалить его
                var lenPx = Conversion.GetSpanLenInScreenCoords(channelBeingCreated.linePoints[0],
                    channelBeingCreated.linePoints[1], Chart.StockPane.WorldRect, Chart.StockPane.CanvasRect);
                if (lenPx < 3)
                {
                    data.Remove(channelBeingCreated);
                    channelBeingCreated = null;
                    return true;
                }

                // добавить третью точку
                channelBeingCreated.Point3 = new PointD(
                    (channelBeingCreated.linePoints[0].X + channelBeingCreated.linePoints[1].X) / 2,
                    (channelBeingCreated.linePoints[0].Y + channelBeingCreated.linePoints[1].Y) / 2);

                channelBeingCreated = null;
                return true;
            }

            // канал завершен
            channelBeingCreated.IsBeingCreated = false;
            objectToEdit = channelBeingCreated;

            channelBeingCreated = null;
            return true;
        }
Esempio n. 5
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)
            {
                // добавить третью точку
                incompleted.Point3 = new PointD(
                    (incompleted.linePoints[0].X + incompleted.linePoints[1].X)/2,
                    (incompleted.linePoints[0].Y + incompleted.linePoints[1].Y)/2);
                channelBeingCreated = incompleted;
                return;
            }

            // ReSharper disable UseObjectOrCollectionInitializer
            var channel = new FiboChannel { Owner = this, IsBeingCreated = true };
            // ReSharper restore UseObjectOrCollectionInitializer
            channel.DrawText = SeriesEditParameter.TryGetParamValue(parameters, "DrawLabels", false);
            channel.LineColor = SeriesEditParameter.TryGetParamValue(parameters, "Color", Color.DarkBlue);
            channel.LineStyle = SeriesEditParameter.TryGetParamValue(parameters, "LineType", TrendLine.TrendLineStyle.Отрезок);
            channel.AddPoint(pointD.X, pointD.Y);
            channel.AddPoint(pointD.X, pointD.Y);
            channelBeingCreated = channel;

            if (Owner.Owner.Owner.AdjustObjectColorsOnCreation)
                channel.AjustColorScheme(Owner.Owner.Owner);
            data.Add(channel);
        }
Esempio n. 6
0
 public override IChartInteractiveObject LoadObject(XmlElement objectNode, CandleChartControl owner, bool trimObjectsOutOfHistory = false)
 {
     var obj = new FiboChannel();
     obj.LoadFromXML(objectNode, owner);
     obj.Owner = this;
     data.Add(obj);
     return obj;
 }