Exemple #1
0
        void ElementClickEvent(object sender, EventArgs e)
        {
            Button button = sender as Button;

            curBrush   = button.Text;
            curBrushUI = Util.GetUIInformation(curBrush);
        }
Exemple #2
0
        void BuildButtons(Control obj, int category)
        {
            int left = buttonMargin;

            foreach (string name in brushes)
            {
                UIInformation uiinformation = Util.GetUIInformation(name);
                if (uiinformation.category == category &&
                    uiinformation.visibleInMenu == true)
                {
                    Button button = new Button();
                    button.UseCompatibleTextRendering = true;
                    button.BackColor = uiinformation.color;
                    button.Click    += new EventHandler(ElementClickEvent);
                    if (uiinformation.color.GetBrightness() <= 0.5)
                    {
                        button.ForeColor = Color.White;
                    }
                    else
                    {
                        button.ForeColor = Color.Black;
                    }
                    button.Location = new Point(left, obj.Location.Y + buttonMargin);
                    button.Size     = new Size(buttonWidth, buttonHeight);
                    button.FlatAppearance.BorderSize = 0;
                    button.FlatStyle = FlatStyle.Flat;
                    button.Text      = uiinformation.name;
                    button.TextAlign = ContentAlignment.MiddleCenter;
                    obj.Controls.Add(button);
                    left += buttonMargin + buttonWidth;
                }
            }
        }
Exemple #3
0
        public GameForm()
        {
            InitializeComponent();

            this.DoubleBuffered  = true;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.KeyPreview      = true;
            this.MaximizeBox     = false;

            renderer            = new Renderer();
            targetFPS           = 60;
            targetFrameInterval = 10000000 / targetFPS;
            lastUpdate          = DateTime.Now.Ticks;
            frameTicks          = new Queue <long>();

            simHeight = 110;
            simWidth  = 180;
            pixelSize = 5;

            InitializeSimulation();
            GetBrushes();
            BuildUI();

            mousePosition = this.PointToClient(Cursor.Position);

            brushSize  = 7;
            curBrush   = "SAND";
            curBrushUI = Util.GetUIInformation(curBrush);

            tabControl.SelectedIndex = 2;

            gameTimer          = new Timer();
            gameTimer.Interval = (int)((double)1000 / targetFPS / 1.1);
            gameTimer.Tick    += Update;
            gameTimer.Start();
        }