public void OnDraw(Graphics g, float x, int position) // position == 0 -> middle of screen, selected item ;; position < 0 -> above middle ;; position > 0 -> below middle { float middleY = Game.Resolution.Height / 2 - ItemHeight / 2; float offsetY = (ItemHeight + 3.0f) * position; float y = middleY + offsetY; if (y < -ItemHeight || y > Game.Resolution.Height) // if item isn't on screen don't draw it { return; } RectangleF rect = new RectangleF(x, y, ItemWidth, ItemHeight); g.DrawRectangle(rect, position == 0 ? Color.FromArgb(200, 200, 200) : Color.FromArgb(100, 5, 5, 5)); string text = DisplayText; SizeF textSize = Graphics.MeasureText(text, ItenFontName, ItemFontSize); float textX = rect.X + rect.Width * 0.5f - textSize.Width * 0.5f; float textY = rect.Y + rect.Height * 0.5f - textSize.Height * 0.8f; g.DrawText(text, ItenFontName, ItemFontSize, new PointF(textX, textY), position == 0 ? Color.FromArgb(0, 0, 0) : Color.FromArgb(100, 240, 240, 240), rect); }
private Notification(string title, string subtitle, double seconds) { EasingStartValue = Game.Resolution.Width - Width; EasingChangeInValue = Width; Title = title; Subtitle = subtitle; DisplaySeconds = seconds; TitleWrapped = AdvancedUI.Util.WrapText(title, Font, TitleFontSize, Width - 10); SubtitleWrapped = AdvancedUI.Util.WrapText(subtitle, Font, SubtitleFontSize, Width - 10); TitleColor = Color.FromArgb(200, 0, 0); SubtitleColor = Color.FromArgb(230, 230, 230); SubtitleYCoordinate = Graphics.MeasureText(TitleWrapped, Font, TitleFontSize).Height; NotificationHeight = SubtitleYCoordinate + Graphics.MeasureText(SubtitleWrapped, Font, SubtitleFontSize).Height + 35; easing = true; easingInverse = false; easingCurrentTime = EaseDuration; location.X = Game.Resolution.Width; }