Пример #1
0
        public override void RenderNote(GraphicsWrapper g, EventData eventData, Rectangle eventRectangle, int centerX, int centerY)
        {
            int rectangleX      = centerX - (RECTANGLE_WIDTH / 2);
            int rectangleY      = centerY - (RECTANGLE_HEIGHT / 2);
            int rectangleWidth  = RECTANGLE_WIDTH + (eventData.Duration > 6 ? eventData.VirtualDuration : 0);
            int rectangleHeight = RECTANGLE_HEIGHT;

            g.FillRectangle(CustomBrushes.NoteBackground, rectangleX, rectangleY, rectangleWidth, rectangleHeight);
            g.DrawRectangle(Pens.Black, rectangleX, rectangleY, rectangleWidth, rectangleHeight);

            string text = String.Empty;

            switch (EventDisplayMode)
            {
            case EventDisplayMode.Attribute:
                byte attribute = eventData.Attribute;
                text = String.Format("Attr {0,3:000}", attribute);
                break;

            case EventDisplayMode.Instrument:
                var instrument = eventData.Instrument;
                int insNo      = instrument != null ? instrument.InsNum : 0;
                text = String.Format("Ins {0,3:000}", insNo);
                break;

            case EventDisplayMode.Duration:
                ushort duration = eventData.Duration;
                text = String.Format("Dur {0,3:000}", duration);
                break;

            case EventDisplayMode.Pan:
                byte pan = eventData.Pan;
                text = String.Format("Pan {0,3:000}", pan);
                break;

            case EventDisplayMode.Velocity:
                byte vel = eventData.Vel;
                text = String.Format("Vel {0,3:000}", vel);
                break;
            }


            g.DrawString(text, this.m_textFont, Brushes.Black, centerX + SHADOW_DISTANCE, centerY + SHADOW_DISTANCE, _stringFormat);
            g.DrawString(text, this.m_textFont, Brushes.White, centerX, centerY, _stringFormat);
        }
Пример #2
0
 protected void DrawString(GraphicsWrapper g, string s, Font font, Brush brush, float x, float y)
 {
     g.DrawString(s, font, brush, x, y);
 }
Пример #3
0
        public override PointF DrawCustomMessages(ChartPane managingPane, GraphicsWrapper g, PointF drawingLocation)
        {
            if (Visible == false)
            {
                return(drawingLocation);
            }

            // Draw any standard messages first (if any).
            drawingLocation = base.DrawCustomMessages(managingPane, g, drawingLocation);

            Font font = managingPane.TitleFont;

            if (CustomMessagesFont != null)
            {
                font = CustomMessagesFont;
            }

            foreach (FFNewsCustom.NewsEvent eventItem in Indicator.VisibleNewsEvents)
            {
                TimeSpan span  = (eventItem.DateTime - DateTime.UtcNow);
                int      hours = (int)Math.Abs(Math.Floor(span.TotalHours));

                string message;
                if (span.TotalSeconds < 0)
                {
                    message = hours.ToString() + " hrs " + Math.Abs(span.Minutes).ToString() + " mins since " + eventItem.Country + ": " + eventItem.Title;
                }
                else
                {
                    message = hours.ToString() + " hrs " + span.Minutes.ToString() + " mins until " + eventItem.Country + ": " + eventItem.Title;
                }
                drawingLocation = DrawCustomMessage(g, font, Indicator.TitleBrush, message, drawingLocation);

                float drawingLocationOriginalX = drawingLocation.X;
                SizeF size = new SizeF();
                if (font != null && Indicator.ImpactBrush != null)
                {
                    // Draw impact part.
                    string impactString = "Impact: " + eventItem.Impact.ToString();
                    size = g.MeasureString(impactString, font);
                    g.DrawString(impactString, font, Indicator.ImpactBrush, drawingLocation);
                    drawingLocation.X += size.Width;
                }

                // Draw previous part.
                if (string.IsNullOrEmpty(eventItem.Previous) == false)
                {
                    if (font != null && Indicator.PreviousBrush != null)
                    {
                        string previousString = "Previous: " + eventItem.Previous;
                        size = g.MeasureString(previousString, font);
                        g.DrawString(previousString, font, Indicator.PreviousBrush, drawingLocation);
                        drawingLocation.X += size.Width;
                    }
                }

                if (string.IsNullOrEmpty(eventItem.Forecast) == false)
                {
                    if (font != null && Indicator.ForecastBrush != null)
                    {
                        string forecastString = "Forecast: " + eventItem.Forecast;
                        size = g.MeasureString(forecastString, font);
                        g.DrawString(forecastString, font, Indicator.ForecastBrush, drawingLocation);
                        drawingLocation.X += size.Width;
                    }
                }

                drawingLocation.X  = drawingLocationOriginalX;
                drawingLocation.Y += size.Height;
            }

            return(drawingLocation);
        }