public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path.PointCount > 0)
            {
                GraphicsPath fill = new GraphicsPath();
                RectangleF rect = m_Param.Path.GetBounds();
                PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
                // this will draw beyond the shape's location
                for (double i = -rect.Height; i < rect.Height; i++)
                {
                    PointD pt1 = refPt + PointD.Orthogonal(m_Param.V) * i * drawMethods.Spacing(m_Param.C);
                    PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
                    PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;

                    fill.StartFigure();
                    fill.AddLine((Point)pt2, (Point)pt3);

                }

                GraphicsContainer c = gc.BeginContainer();
                gc.SetClip((Tools.Model.VectorPath)m_Param.Path);
                gc.DrawPath(r.RegionGuides, fill);
                gc.EndContainer(c);

            }
        }
        public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
        {
            this.chart = chart;
            scriptActivatedCoords = worldCoords;

            // найти робота / роботов на данный тикер / ТФ
            var robots = MainForm.Instance.RobotFarm.GetRobotCopies();
            robots = robots.Where(r => r.Graphics.Any(g => g.a == chart.chart.Symbol && g.b == chart.chart.Timeframe))
                      .ToList();
            if (robots.Count == 0) return "Нет роботов для " + chart.Symbol + ":" + chart.Timeframe;
            selectedBot = robots[0];
            // если роботов несколько - предложить пользователю выбрать интересующего
            if (robots.Count > 1)
            {
                object selectedRobot;
                string inputText;

                if (!Dialogs.ShowComboDialog("Укажите робота",
                                                             robots.Cast<object>().ToList(), out selectedRobot,
                                                             out inputText))
                    return "робот не выбран из списка";
                selectedBot = (BaseRobot) selectedRobot;
            }

            ShowRobotDataOnChart();

            return "";
        }
Exemple #3
0
 public SunMoon_Type(string imagelocation,double initialangle)
     : base(BITMAP.FromFile(imagelocation), default(Point), ImagePasteMode.Transparent, EffectDock.Screen)
 {
     REVOLVE_RADIUS = new PointD(Background.Size.Half());
     REVOLVE_PERIOD = CONST.OneDay;
     INITIAL_ANGLE = initialangle;
 }
Exemple #4
0
        private string CandleData(PointD chartPoint, out int trend)
        {
            trend = 0;
            int index = (int)(chartPoint.X + 0.5);
            if (index < 0 || index >= Owner.Owner.StockSeries.Data.Count)
                return "";

            float open = Owner.Owner.StockSeries.Data[index].open;
            float close = Owner.Owner.StockSeries.Data[index].close;
            if (chartPoint.Y > Math.Max(open, close) || chartPoint.Y < Math.Min(open, close))
                return "";

            float high = Owner.Owner.StockSeries.Data[index].high;
            float low = Owner.Owner.StockSeries.Data[index].low;
            DateTime date = Owner.Owner.StockSeries.Data[index].timeOpen;
            trend = open < close ? 1 : -1;
            string dateStr = date.ToString("dd.MM.yyyy HH:mm");
            var sb = new StringBuilder();
            sb.AppendLine(string.Format("O: {0}", open.ToStringUniformPriceFormat(true)));
            sb.AppendLine(string.Format("H: {0}", high.ToStringUniformPriceFormat(true)));
            sb.AppendLine(string.Format("L: {0}", low.ToStringUniformPriceFormat(true)));
            sb.AppendLine(string.Format("C: {0}", close.ToStringUniformPriceFormat(true)));
            sb.AppendLine(dateStr);
            return sb.ToString();
        }
        public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
        {
            var dlg = new OpenFileDialog
            {
                Filter = "*.csv|*.csv|*.*|*.*",
                FilterIndex = 0,
                DefaultExt = "csv",
                Title = "Открыть файл сделок"
            };
            if (dlg.ShowDialog() != DialogResult.OK) return "";

            // прочитать ордера
            var allOrders = ReadOrdersFromCsv(dlg.FileName);
            var chartOrders = allOrders.Where(o => o.Symbol.Contains(chart.Symbol)).ToList();
            if (chartOrders.Count == 0)
            {
                var msg = string.Format("{0} ордеров прочитано, ни один не относится к графику {1}",
                    allOrders.Count, chart.Symbol);
                return msg;
            }

            if (allOrders.Count > 1000)
            {
                //var msg = string.Format("Прочитано {0} ордеров. Отобразить ордера на выбранном временном отрезке?",
                //    chartOrders.Count);
                var ordersDlg = new Mt4ImportDlg(chartOrders);
                if (ordersDlg.ShowDialog() == DialogResult.OK)
                    chartOrders = ordersDlg.selectedOrders;
            }

            ShowOrders(chartOrders, chart);
            return string.Empty;
        }
Exemple #6
0
 public RectangleD(PointD point, SizeD size)
 {
     _x = point.X;
     _y = point.Y;
     _width = size.Width;
     _height = size.Height;
 }
Exemple #7
0
 protected override Rectangle GetREGION()
 {
     PointD pd1 = new PointD(0, Sky.MaxHeight);
     PointD pd2 = new PointD(Block.Width, 0);
     Point p1 = Background.WorldToClient(pd1);
     Point p2 = Background.WorldToClient(pd2);
     return p1.GetRectangle(p2);
 }
Exemple #8
0
 internal static double GetSpanLenInScreenCoords(PointD worldPtA, PointD worldPtB,
     RectangleD worldRect, RectangleD canvasRect)
 {
     var scrA = WorldToScreen(new PointD(worldPtA.X, worldPtA.Y), worldRect, canvasRect);
     var scrB = WorldToScreen(new PointD(worldPtB.X, worldPtB.Y), worldRect, canvasRect);
     return Math.Sqrt((scrA.X - scrB.X) * (scrA.X - scrB.X) +
                           (scrA.Y - scrB.Y) * (scrA.Y - scrB.Y));
 }
        /// <summary>
        /// Moves shape to specified position (in world units) relative to the diagram.
        /// </summary>
        public static void MoveTo(this NodeShape shape, PointD position)
        {
            var newBounds = new RectangleD(PointD.Empty, shape.AbsoluteBounds.Size);
            newBounds.X = position.X;
            newBounds.Y = position.Y;

            shape.AbsoluteBounds = newBounds;
        }
 public override void Process()
 {
     SPEED *= 0.995;
     LOC += SPEED;
     RADIUS += RADIUS_SPEED;
     TIME += 1.0 / CONST.UpdateFrequency;
     if (TIME >= PERIOD) DISPOSED = true;
 }
 public override bool HitTest(PointD point)
 {
     if (m_Param.Path != m_path)
     {
         m_Param.Path = m_path;
     }
     return base.HitTest(point);
 }
 public LevelImageFragment(byte[] yComponents, int imageWidth, int imageHeight, int xOffset, int yOffset, int width, int height)
 {
     Offset = new PointD((double)xOffset / imageWidth, (double)yOffset / imageHeight);
     YComponents = new byte[width * height];
     for (int i = 0; i < height; i++)
         for (int j = 0; j < width; j++)
             YComponents[i * width + j] = yComponents[(yOffset + i) * imageWidth + (xOffset + j)];
 }
        public override void Draw(System.Drawing.Graphics gc, Render.RenderParameter r, Render.RenderHint editState, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path != null)
            {
                /*if (editState.GetAttributes() == States.StateAttributes.Start)
                {
                    if (r.StrokeFill != null)
                        gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath) m_Param.Path);
                    gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);
                }
                else*/ if (editState == Render.RenderHint.Start)
                {
                    Pen dashPen = (Pen)r.StrokeOutline.Clone();
                    dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    if (m_Param.Path.PointCount > 0)
                    {
                        PointD firstPoint = (PointD)m_Param.Path.GetFirstPoint();
                        gc.DrawEllipse(dashPen, (float)firstPoint.X - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)firstPoint.Y - Tools.Render.DrawHelper.TARGET_SIZE / 2.0f, (float)Tools.Render.DrawHelper.TARGET_SIZE, (float)Tools.Render.DrawHelper.TARGET_SIZE);

                        if (r.StrokeFill != null)
                            gc.FillPath(r.StrokeFill, (Tools.Model.VectorPath)m_Param.Path);
                        gc.DrawPath(r.StrokeOutline, (Tools.Model.VectorPath)m_Param.Path);

                        DrawRegionRepresentation(gc, r, drawMethods, mousePosition);
                    }
                }
                /*else if (editState.GetAttributes() == States.StateAttributes.Change)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param, r);
                    if (editState is States.RegionChange)
                    {
                        DrawRegionRepresentation(gc, r, mousePosition);

                        ((States.RegionChange)editState).Handles.DrawHandles(gc, m_Param, r);
                    }
                }*/
                else if (editState == Render.RenderHint.Feedback)
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    if (!(this is ConveyorBeltFilter))
                        DrawRegionRepresentation(gc, r,drawMethods, mousePosition);

                }
                else
                {
                    drawMethods.DrawNegativeSpace(gc, m_Param.Path.InternalPath, r);
                    drawMethods.DrawPositiveSpace(gc, m_Param.Path.InternalPath, r);
                    DrawRegionRepresentation(gc, r, drawMethods, mousePosition);

                        // TODO ((States.IFilterHandles)editState).Handles.DrawHandles(gc, m_Param, r);

                }
                drawMethods.DrawHandles(gc, this, r);
            }
        }
 protected override void Draw_PANEL_Image(BitmapData data_bac)
 {
     base.Draw_PANEL_Image(data_bac);
     PointD p = new PointD(225, 225);
     Bitmap bmp; ProduceGearImage(out bmp);
     data_bac.Paste(bmp, p - bmp.Half(), ImagePasteMode.Transparent);
     bmp = ProducePercentImage();
     data_bac.Paste(bmp, p - bmp.Half(), ImagePasteMode.Gradient);
 }
        public PriceProbForm(CandleChartControl chart, PointD worldCoords)
            : this()
        {
            this.chart = chart;
            tbPrice.Text = worldCoords.Y.ToStringUniform(5);

            var candles = chart.chart.StockSeries.Data.Candles;
            if (candles.Count == 0) return;
            dtEnd.Value = candles[candles.Count - 1].timeClose;
        }
        public void MouseDown(Position.VirtualMousePosition mouseMove)
        {
            m_startPt = (PointD) mouseMove.GetPhysicalPoint();
            m_virtualDelta = new List<PointD>();
            m_realDelta = new List<PointD>();

            // initial movement is nothing
            m_virtualDelta.Add(PointD.Empty);
            m_realDelta.Add(PointD.Empty);
        }
Exemple #17
0
 public Bullet(Planet planet,Weapon parent,Bitmap image, int explodecnt,double explodeperiod)
     : base(image, parent.Reveal_GetLOC(), ImagePasteMode.Transparent, EffectDock.World)
 {
     PLANET = planet;
     PARENT = parent;
     SPEED = new PointD(Math.Sin(parent.ANGLE), -Math.Cos(parent.ANGLE)) * parent.BULLET_SPEED;
     ENDURANCE = parent.ENDURANCE + DISAPPEAR_PERIOD;
     EXPLODE_CNT = explodecnt;
     EXPLODE_PERIOD = explodeperiod;
 }
Exemple #18
0
 public static PointD getCursorLocation(bool fijacion, PointD deltaCursor, PointD gaze)
 {
     if (fijacion)
     {
         PointD headPlusEyes = gaze + deltaCursor;
         return headPlusEyes;
     }
     else
         return gaze;
 }
 public override string ActivateScript(CandleChartControl chart, PointD worldCoords)
 {
     this.chart = chart;
     var dlg = new CaymanDivergenceSetupDlg();
     if (dlg.ShowDialog() == DialogResult.Cancel) return "";
     skippedCandles = dlg.SkipCandles;
     checkedPrices = dlg.CheckedPrices;
     removeOldSigns = dlg.RemoveOldSigns;
     return BuildSeries();
 }
 /// <summary>
 /// Retrieves a mouse action that should be made active on the next
 /// MouseDown event if the mouse is over the specified point.
 /// </summary>
 /// <param name="mouseButtons">The current mouse button state.</param>
 /// <param name="point">The mouse position relative to the diagram's top-left in world units.</param>
 /// <param name="hitTestInfo">Information detailing the results of the hit testing.</param>
 /// <returns>A mouse action that should be made active on the next MouseDown event if the mouse is over the specified point.</returns>
 public override MouseAction GetPotentialMouseAction(MouseButtons mouseButtons, PointD point, DiagramHitTestInfo hitTestInfo)
 {
     DiagramItem hitDiagramItem = hitTestInfo.HitDiagramItem;
     Diagram diagram = (hitDiagramItem != null) ? hitDiagramItem.Diagram : null;
     if (diagram == null)
     {
         return null;
     }
     return diagram.SelectAction;
 }
Exemple #21
0
        public CGMRestrictedText(Command c, CGMImage parent)
        {
            deltaWidth = BinaryUtil.makeVdc(c, parent.VDCtype, parent.VDCRealType, parent.IntPrecision);
            deltaHeight = BinaryUtil.makeVdc(c, parent.VDCtype, parent.VDCRealType, parent.IntPrecision);
            position = BinaryUtil.makePoint(c, parent.VDCtype, parent.VDCRealType, parent.IntPrecision);

            finalNotFinal = BinaryUtil.makeEnum(c);
            Text = BinaryUtil.getString(c);

            type = parent.RestrictedTextType;
        }
        public HandCalibratedModifierStrategy(CaptureConfig captureConfig, Point target)
            : base(captureConfig, target)
        {
            _regressorPair = new LinearRegressorFactory().GetHandMeasured320x240();

            // calibration was done in 320x240. If capture settings different need to scale the calibration
            decimal xDiffScale = captureConfig.Resolution.Width / 320m;
            decimal yDiffScale = captureConfig.Resolution.Height / 240m;

            Scale = new PointD(xDiffScale, yDiffScale);
        }
        public void AddFilter(KinTemplates.Cursor.Tools.IToolFilter filter, FeedbackParameter r)
        {
            // forces
            if (filter is Tools.ConveyorBeltFilter
                || filter is Tools.ConveyorBeltFilter2
                || filter is Tools.OrbitFilter
                || filter is Tools.OrbitFilter2
                || filter is Tools.OrbitFilter3
                || filter is Tools.MagneticLineAttractionFilter
                || filter is Tools.MagneticPointAttractionFilter
                || filter is Tools.RubberBandFilter
                // || filter is Tools.TunnelLineFilter
                )
            {
                if (m_forces == null)
                {
                    Rectangle screenBounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
                    m_forces = new PointD[screenBounds.Width / FORCE_GRID][];
                    for (int i = 0; i < m_forces.Length; i++)
                    {
                        m_forces[i] = new PointD[screenBounds.Height / FORCE_GRID];
                    }

                    //m_renderedForces = new Bitmap(screenBounds.Width, screenBounds.Height);
                }

                for (int i = 0; i < m_forces.Length; i++)
                {
                    for (int j = 0; j < m_forces[i].Length; j++)
                    {
                        Point thePoint = new Point(i * FORCE_GRID, j * FORCE_GRID);
                        if (filter.HitTest((PointD)thePoint))
                        {
                            // test all points with the filter
                            Position.VirtualMousePosition mouse = new Position.VirtualMousePosition(thePoint);
                            Position.ParameterizedMousePosition fakeMouse = new Position.ParameterizedMousePosition(mouse, 20);// TODO: instrument from the computer
                            m_forces[i][j] += filter.GetVelocity(fakeMouse) * Render.DrawHelper.SPEED_AMPLIFIER;
                        }
                    }
                }
            }

            /*
            // we have rendered something, let's cache this picture
            if (m_forces != null)
            {
                Graphics fromBitmap = Graphics.FromImage(m_renderedForces);
                InternalRenderForces(fromBitmap, r);
                fromBitmap.Dispose();
            }
            */
        }
 static void Draw_Info(Block b, BitmapData data_bac)
 {
     int column = 125;
     PointD p = new PointD(BLOCK_SIZE.Width, 0);
     data_bac.Paste(b.NAME, p, Color.Yellow);
     p.X += column;
     data_bac.Paste("$" + b.PRICE.ToString(), p);
     p.X += column;
     int v = OreStorage.Get(b.NAME);
     data_bac.Paste(v.ToString() + (v == 1 ? " pc" : " pcs"), p);
     p.X += column;
     data_bac.Paste("$" + (b.PRICE * v).ToString(), p);
 }
 public override void DrawRegionRepresentation(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
 {
     if (m_Param.Path != null)
     {
         if (m_Param.Path.IsVisible((Point)mousePosition))
         {
             gc.DrawString("+ speed", r.FontType, new SolidBrush(r.RegionGuides.Color), new PointF((float)mousePosition.X, (float)mousePosition.Y - 15));
         }
     }
     else
     {
         gc.DrawString("+ speed", r.FontType, new SolidBrush(r.RegionGuides.Color), new PointF((float)mousePosition.X, (float)mousePosition.Y - 15));
     }
 }
 public Missile_Flame(PointD loc, PointD jetspeed,double initialradius,double finalradius, double period, double yellowperiod = 1.0/3.0, double redperiod = 2.0/3.0)
     : base(null, loc, ImagePasteMode.Gradient, EffectDock.World)
 {
     SPEED = jetspeed + RANDOM.NextDouble(Math.PI).AsAngle() * jetspeed.Abs() * 0.2;
     RADIUS_SPEED = (finalradius - initialradius) / (CONST.UpdateFrequency * period);
     RADIUS = initialradius;
     TIME = 0.0;
     PERIOD = period;
     YELLOW_PERIOD = yellowperiod;
     RED_PERIOD = redperiod;
     YELLOW_COLOR = Color.FromArgb(64, 255, 255, 0);
     RED_COLOR = Color.FromArgb(64, 255, 0, 0);
     BLACK_COLOR = Color.FromArgb(64, 0, 0, 0);
 }
 public override PointD GetVelocity(Position.IVirtualMousePosition m)
 {
     // velocity restriction
     double speed = m.GetSpeed();
     double speedLimit = m_Param.C  * 10 * GetStrength(m.GetVirtualPointD());
     if (speed > speedLimit)
     {
         PointD maxParts = new PointD(speedLimit * m.GetUnitDirection().X, speedLimit * m.GetUnitDirection().Y);
         return -1 * m.GetVelocity() + maxParts;
     }
     else
     {
         return PointD.Empty;
     }
 }
        protected PointD m_TrackingVPos; // virtual position

        #endregion Fields

        #region Constructors

        public VirtualMousePosition(System.Drawing.Point startPosition)
        {
            m_StartPos = startPosition;

            // real position
            m_LastPhysicalPos = startPosition;
            m_CurPhysicalPos = startPosition;

            // virtual position
            m_TrackingVPos = new PointD( startPosition.X, startPosition.Y );
            m_LastVPos = new PointD(startPosition.X, startPosition.Y);

            m_LastTime = Environment.TickCount;
            m_Timer = new HiPerfTimer();
            m_Timer.Start();
        }
Exemple #29
0
 /// <summary>
 ///     Determines whether the current <see cref="PolygonD"/> contains the specified point. If the point lies exactly
 ///     on one of the polygon edges, it is considered to be contained in the polygon.</summary>
 /// <param name="point">
 ///     Point to check.</param>
 /// <returns>
 ///     True if the specified point lies inside the current <see cref="PolygonD"/>.</returns>
 public bool ContainsPoint(PointD point)
 {
     foreach (var edge in ToEdges())
         if (edge.ContainsPoint(point))
             return true;
     bool c = false;
     PointD p = _vertices[_vertices.Count - 1];
     foreach (PointD q in _vertices)
     {
         if ((((q.Y <= point.Y) && (point.Y < p.Y)) ||
              ((p.Y <= point.Y) && (point.Y < q.Y))) &&
             (point.X < (p.X - q.X) * (point.Y - q.Y) / (p.Y - q.Y) + q.X))
             c = !c;
         p = q;
     }
     return c;
 }
Exemple #30
0
 internal static PointD ScreenToWorld(PointD screenPt, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(screenRect.Width) > double.Epsilon) && (Math.Abs(screenRect.Height) > double.Epsilon))
     {
         var td = new PointD(0.0, 0.0)
                      {
                          X =
                              ((((screenPt.X - screenRect.Left)/screenRect.Width)*worldRect.Width) +
                               worldRect.Left),
                          Y =
                              ((((screenRect.Height - (screenPt.Y - screenRect.Top))/screenRect.Height)*
                                worldRect.Height) +
                               worldRect.Top)
                      };
         return td;
     }
     return PointD.Empty;
 }
Exemple #31
0
 /// <summary>
 ///    Adjusts the location of this rectangle by the specified amount.
 /// </summary>
 public void Offset(PointD pos) => Offset(pos.X, pos.Y);
Exemple #32
0
 /**
  * Create a new SizeD object from a point
  */
 /// <summary>
 ///    <para>
 ///       Initializes a new instance of the <see cref='System.Drawing.SizeD'/> class from
 ///       the specified <see cref='System.Drawing.PointD'/>.
 ///    </para>
 /// </summary>
 public SizeD(PointD pt)
 {
     width  = pt.X;
     height = pt.Y;
 }
Exemple #33
0
 /// <summary>
 ///    <para>
 ///       Determines if the specified point is contained within the
 ///       rectangular region defined by this <see cref='System.Drawing.Rectangle'/> .
 ///    </para>
 /// </summary>
 public bool Contains(PointD pt) => Contains(pt.X, pt.Y);