コード例 #1
0
        public void DrawPointArray(int id, Color color)
        {
            Vector2 point, point2;

            DrawTools.LineColor = color;
            IEnumerator <PriceFluctuation> it = visibleFluctuations.GetEnumerator();

            while (it.MoveNext() && (!it.Current.ExtraData.ContainsKey(id) || !(it.Current.ExtraData[id] is float)))
            {
                ;
            }

            if (!it.Current.ExtraData.ContainsKey(id))
            {
                return;
            }

            point = cam.WorldToScreenPoint(new Vector2(CoordGrid.FromDateToXAxis(it.Current.PeriodBegin), CoordGrid.FromPriceToYAxis((float)it.Current.ExtraData[id])));

            while (it.MoveNext())
            {
                if (it.Current.ExtraData[id] is float)
                {
                    point2 = cam.WorldToScreenPoint(new Vector2(CoordGrid.FromDateToXAxis(it.Current.PeriodBegin), CoordGrid.FromPriceToYAxis((float)it.Current.ExtraData[id])));
                    DrawTools.DrawLine(point, point2, false);
                    point = point2;
                }
            }
        }
コード例 #2
0
        public void DrawGrid(IEnumerable <DateTime> dateList, IEnumerable <decimal> pricesList)
        {
            if (!IsSettingsSet)
            {
                return;
            }


            DrawTools.LineColor  = gridColor;
            DrawTools.dashLength = 0.05f;
            DrawTools.gap        = 0.07f;

            priceTextPool.CleanPool();

            float yPoint;

            foreach (var price in pricesList)
            {
                yPoint = CoordGrid.FromPriceToYAxis((float)price);
                yPoint = cam.WorldToScreenPoint(new Vector2(0, yPoint)).y;
                priceTextPool.SetText(
                    price.ToString("F8"),
                    yPoint,
                    TextPoolManager.ShiftBy.Vertical
                    );

                Vector2 pricePoint1 = new Vector2(cam.WorldToScreenPoint(worldPointInLeftDownCorner).x, yPoint);
                Vector2 pricePoint2 = new Vector2(cam.WorldToScreenPoint(worldPointInRightUpCorner).x, yPoint);

                DrawTools.DrawOnePixelLine(pricePoint1, pricePoint2, true);
            }

            dateTextPool.CleanPool();
            foreach (var date in dateList)
            {
                float dateLine = CoordGrid.FromDateToXAxis(date);
                dateLine = cam.WorldToScreenPoint(new Vector2(dateLine, 0)).x;
                dateTextPool.SetText(
                    date.ChartStringFormat(),
                    dateLine,
                    TextPoolManager.ShiftBy.Horizontal
                    );


                Vector2 datePoint1 = new Vector2(dateLine, cam.pixelRect.min.y);
                Vector2 datePoint2 = new Vector2(dateLine, cam.pixelRect.max.y);

                DrawTools.DrawOnePixelLine(datePoint1, datePoint2, true);
            }
        }
コード例 #3
0
            public bool CanMoveFurther(Vector3 fromPoint, Vector3 byStep)
            {
                float x0 = CoordGrid.FromDateToXAxis(ChartDataManager.WorkBeginTime);
                float x1 = CoordGrid.FromDateToXAxis(ChartDataManager.WorkEndTime);

                Vector3 nextpoint = fromPoint + byStep;

                if ((nextpoint.x > x0 && nextpoint.x < x1) ||
                    (nextpoint.x <= x0 && byStep.x >= 0) ||
                    (nextpoint.x >= x1 && byStep.x <= 0))
                {
                    return(true);
                }
                return(false);
            }
コード例 #4
0
            internal Vector3 GetLastPoint()
            {
                if (!IsSettingsSet)
                {
                    return(Vector3.zero);
                }


                float x = CoordGrid.FromDateToXAxis(chartDataManager.WorkEndTime);
                float y;

                if (ChartDrawer.Instance.Autoscale)
                {
                    y = cameraTransform.position.y;
                }
                else
                {
                    y = CoordGrid.FromPriceToYAxis((float)chartDataManager.GetPriceFluctuation(chartDataManager.WorkEndTime).Close);
                }

                return(new Vector3(x, y));
            }
コード例 #5
0
        public void DrawVolume(Rect camRect)
        {
            if (!IsSettingsSet)
            {
                return;
            }

            float worldRealToScreen = (CoordGrid.FromDateToXAxis(visibleEndDate) - CoordGrid.FromDateToXAxis(visibleStartDate)) / (worldPointInRightUpCorner.x - worldPointInLeftDownCorner.x);


            int   count            = DateTimeTools.CountFramesInPeriod(chartDataManager.TFrame, visibleStartDate, visibleEndDate, TimeSpan.Zero);
            float pixelLenghtFrame = camRect.width * worldRealToScreen / count;
            float maxVolume        = (float)visibleFluctuations.Max(x => x.Volume);

            //Если свечка видна только частично, то необходимо смещать отрисовку объёма на равную долю видимости
            float   diff = (worldPointInLeftDownCorner.x - CoordGrid.FromDateToXAxis(visibleStartDate)) * camRect.width / (worldPointInRightUpCorner.x - worldPointInLeftDownCorner.x);
            Vector2 barLeftDownCorner = camRect.min - new Vector2(diff + pixelLenghtFrame / 2, 0);
            Vector2 barRightUpCorner;
            Vector2 bordersOffset = new Vector2((20 / count < 1 ? 1 : 20 / count), 0);

            if (chartDataManager.WorkBeginTime > visibleStartDate)
            {
                int shift = DateTimeTools.CountFramesInPeriod(chartDataManager.TFrame, visibleStartDate, chartDataManager.WorkBeginTime, TimeSpan.Zero);
                barLeftDownCorner += new Vector2(shift * pixelLenghtFrame, 0);
            }

            foreach (var fluctuation in visibleFluctuations)
            {
                float pixelHeightFrame = (float)fluctuation.Volume / maxVolume * camRect.height;
                barRightUpCorner = barLeftDownCorner + new Vector2(pixelLenghtFrame, pixelHeightFrame);

                DrawTools.DrawRectangle(barLeftDownCorner + bordersOffset, barRightUpCorner - bordersOffset, fluctuation.Close - fluctuation.Open > 0 ? volumeUpColor : volumeDownColor);

                barLeftDownCorner = new Vector2(barRightUpCorner.x, camRect.min.y);
            }
        }