Example #1
0
        public ContentArea(Game game, string routeName, TrackContent trackContent, EnumArray <string, ColorSetting> colorPreferences, TrackViewerViewSettings viewSettings) :
            base(game)
        {
            if (null == game)
            {
                throw new ArgumentNullException(nameof(game));
            }
            if (null == colorPreferences)
            {
                throw new ArgumentNullException(nameof(colorPreferences));
            }

            Enabled        = false;
            RouteName      = routeName;
            TrackContent   = trackContent ?? throw new ArgumentNullException(nameof(trackContent));
            bounds         = trackContent.Bounds;
            spriteBatch    = new SpriteBatch(GraphicsDevice);
            fontManager    = FontManager.Exact("Segoe UI", System.Drawing.FontStyle.Regular);
            inputComponent = game.Components.OfType <MouseInputGameComponent>().Single();
            inputComponent.AddMouseEvent(MouseMovedEventType.MouseMoved, MouseMove);

            foreach (ColorSetting setting in EnumExtension.GetValues <ColorSetting>())
            {
                UpdateColor(setting, ColorExtension.FromName(colorPreferences[setting]));
            }
            this.viewSettings              = viewSettings;
            game.Window.ClientSizeChanged += Window_ClientSizeChanged;
        }
 private static void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
 {
     if (e.Index > -1)
     {
         string colorName = (sender as ComboBox).Items[e.Index].ToString();
         Color  color     = ColorExtension.FromName(colorName);
         backgroundBrush.Color = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
         e.Graphics.FillRectangle(backgroundBrush, e.Bounds);
         fontBrush.Color = color.ToComplementSystemDrawingColor();
         e.Graphics.DrawString(colorName, e.Font, fontBrush, e.Bounds, System.Drawing.StringFormat.GenericDefault);
         // If the ListBox has focus, draw a focus rectangle around the selected item.
         e.DrawFocusRectangle();
     }
 }