Exemplo n.º 1
0
        private void DrawGraphClose(Graphics g, TradeTracker.TradeData cp)
        {
            long  currTimestamp  = chartEndTime;
            float posXChartOpen  = (currTimestamp - cp.buyTimestamp) * ((float)rightDivider / chartTimespan);
            float posXChartClose = (currTimestamp - cp.sellTimestamp) * ((float)rightDivider / chartTimespan);

            posXChartOpen  = rightDivider - posXChartOpen;
            posXChartClose = rightDivider - posXChartClose;

            if (posXChartClose < 0)
            {
                return;
            }

            // find the yPos of the current price

            float ySize    = bottomDivider - topDivider;
            float yPosCurr = ((float)cp.percentGain / 30f) * -ySize + centerDivider;

            if (yPosCurr < topDivider + 5)
            {
                yPosCurr = topDivider + 5;
            }
            if (yPosCurr > bottomDivider - 5)
            {
                yPosCurr = bottomDivider - 5;
            }

            using (Pen pen = new Pen(Style.Colors.Primary.Dark1, 2)) {
                pen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dash;
                pen.DashPattern = new float[] { 3, 4 };

                g.DrawLine(pen, posXChartOpen, centerDivider, posXChartClose, yPosCurr);
            }

            using (Brush brush = new SolidBrush(Style.Colors.Primary.Main)) {
                g.FillEllipse(brush, posXChartOpen - 7, centerDivider - 7, 14, 14);
                g.FillEllipse(brush, posXChartClose - 5, yPosCurr - 5, 10, 10);

                string text = cp.pair.QuoteCurrency == "BTC" ? cp.pair.BaseCurrency : cp.pair.QuoteCurrency;

                float width = g.MeasureString(text, Style.Fonts.Tiny).Width;
                g.DrawString(text, Style.Fonts.Tiny, brush, new PointF(posXChartOpen - (width / 2) + 2, centerDivider + 10));
            }

            using (Brush brush = new SolidBrush(Style.Colors.Background)) {
                g.FillEllipse(brush, posXChartOpen - 5, centerDivider - 5, 10, 10);
            }
        }
Exemplo n.º 2
0
        private void DrawGraphOpen(Graphics g, TradeTracker.TradeData op)
        {
            long  currTimestamp = chartEndTime;
            float posXChart     = (currTimestamp - op.buyTimestamp) * ((float)rightDivider / chartTimespan);

            posXChart = rightDivider - posXChart;

            if (posXChart < 15)
            {
                posXChart = 15;
            }

            // find the yPos of the current price

            float ySize    = bottomDivider - topDivider;
            float yPosCurr = ((float)op.percentGain / 30f) * -ySize + centerDivider;

            if (yPosCurr < topDivider + 5)
            {
                yPosCurr = topDivider + 5;
            }
            if (yPosCurr > bottomDivider - 5)
            {
                yPosCurr = bottomDivider - 5;
            }

            using (Pen pen = new Pen(Style.Colors.Terciary.Dark2, 2)) {
                pen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dash;
                pen.DashPattern = new float[] { 3, 4 };

                g.DrawLine(pen, posXChart, centerDivider, rightDivider, yPosCurr);
            }

            // draw stop loss icons
            if (op.stopLossPercent > 0.875)
            {
                float posYStopLoss = (((float)(op.stopLossPercent - 1) * 100) / 30) * -ySize + centerDivider;
                using (Pen pen = new Pen(Style.Colors.Secondary.Dark2)) {
                    pen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dash;
                    pen.DashPattern = new float[] { 3, 4 };

                    g.DrawLine(pen, posXChart, posYStopLoss, rightDivider, posYStopLoss);
                    g.DrawLine(pen, posXChart, centerDivider, posXChart, posYStopLoss);
                }
                using (Brush brush = new SolidBrush(Style.Colors.Secondary.Dark1)) {
                    g.FillEllipse(brush, posXChart - 3, posYStopLoss - 3, 6, 6);
                    g.FillEllipse(brush, rightDivider - 3, posYStopLoss - 3, 6, 6);
                }
            }

            // draw the icons and currency name

            using (Brush brush = new SolidBrush(Style.Colors.Terciary.Main)) {
                g.FillEllipse(brush, posXChart - 7, centerDivider - 7, 14, 14);
                g.FillEllipse(brush, rightDivider - 4, yPosCurr - 4, 8, 8);

                string text = op.pair.QuoteCurrency == "BTC" ? op.pair.BaseCurrency : op.pair.QuoteCurrency;

                float width = g.MeasureString(text, Style.Fonts.Tiny).Width;
                g.DrawString(text, Style.Fonts.Tiny, brush, new PointF(posXChart - (width / 2) + 2, centerDivider + 10));
            }
            using (Brush brush = new SolidBrush(Style.Colors.Background)) {
                g.FillEllipse(brush, posXChart - 5, centerDivider - 5, 10, 10);
                g.FillEllipse(brush, rightDivider - 2, yPosCurr - 2, 4, 4);
            }
        }
Exemplo n.º 3
0
        private void DrawOpenPosition(Graphics g, TradeTracker.TradeData op, float posX, float posWidth)
        {
            string text    = "";
            float  width   = 0;
            float  textPos = 0;

            string[] partsOpen = Helper.SplitLeadingZeros(op.buyPrice.ToString("F" + op.displayDigits));
            string[] partsCurr = Helper.SplitLeadingZeros(op.openPrice.ToString("F" + op.displayDigits));

            float posXOpen  = 0;
            float posXClose = 0;

            using (Brush brush = new SolidBrush(Style.Colors.Primary.Dark2)) {
                // Draw open price (leading zeros)
                text     = op.buyPrice.ToString("F" + op.displayDigits);
                width    = g.MeasureString(text, Style.Fonts.Tiny).Width;
                textPos  = (posWidth / 2) - (width / 2) + posX - 3;
                posXOpen = textPos;

                g.DrawString(partsOpen[0], Style.Fonts.Tiny, brush, new PointF(textPos, 10));
                posXOpen += g.MeasureString(partsOpen[0], Style.Fonts.Tiny).Width;
            }

            using (Brush brush = new SolidBrush(Style.Colors.Terciary.Dark2)) {
                // Draw current price (leading zeros)
                text      = op.openPrice.ToString("F" + op.displayDigits);
                width     = g.MeasureString(text, Style.Fonts.Tiny).Width;
                textPos   = (posWidth / 2) - (width / 2) + posX - 3;
                posXClose = textPos;

                g.DrawString(partsCurr[0], Style.Fonts.Tiny, brush, new PointF(textPos, 25));
                posXClose += g.MeasureString(partsCurr[0], Style.Fonts.Tiny).Width;
            }

            using (Brush brush = new SolidBrush(Style.Colors.Primary.Main)) {
                // Draw open price (remainder)
                g.DrawString(partsOpen[1], Style.Fonts.Tiny, brush, new PointF(posXOpen - 2, 10));

                // Draw currency name
                text    = op.pair.QuoteCurrency == "BTC" ? op.pair.BaseCurrency : op.pair.QuoteCurrency;
                width   = g.MeasureString(text, Style.Fonts.Tiny).Width;
                textPos = (posWidth / 4) - (width / 2) - 4;
                g.DrawString(text, Style.Fonts.Tiny, brush, new PointF(posX + textPos, 40));
            }

            using (Brush brush = new SolidBrush(Style.Colors.Terciary.Main)) {
                // Draw current price (remainder)
                g.DrawString(partsCurr[1], Style.Fonts.Tiny, brush, new PointF(posXClose - 2, 25));
            }

            // Draw percent change

            Color percentColor = Helper.LerpColor((float)op.percentGain, -5f, 5, Style.Colors.Negative, Style.Colors.Positive);

            using (Brush brush = new SolidBrush(percentColor)) {
                text    = (op.percentGain > 0 ? "+" : "") + op.percentGain.ToString("F3") + "%";
                width   = g.MeasureString(text, Style.Fonts.Tiny).Width;
                textPos = (posWidth * 0.67f) - (width / 2) - 3;
                g.DrawString(text, Style.Fonts.Tiny, brush, new PointF(posX + textPos, 40));
            }

            using (Pen pen = new Pen(Style.Colors.Terciary.Dark2)) {
                g.DrawRectangle(pen, posX, positionBoxMargin, posWidth, topDivider - (2 * positionBoxMargin));
            }

            DrawGraphPosition(g, op.buyTimestamp, posX + (posWidth / 2), Style.Colors.Terciary.Dark2, true);
        }