public static SnakeSettingsGUI ConvertSettingsLogicToGUI(SnakeSettings snakeSettings)
        {
            SnakeSettingsGUI snakeSettingsGUI = new SnakeSettingsGUI(snakeSettings.RowCount,
                                                                     snakeSettings.ColumnCount,
                                                                     snakeSettings.SideLengthGUI);

            return(snakeSettingsGUI);
        }
        public static SnakeSettings ConvertSettingsGUIToLogic(SnakeSettingsGUI snakeSettings)
        {
            SnakeSettings snakeSettingsLogic = new SnakeSettings(snakeSettings.RowCount,
                                                                 snakeSettings.ColumnCount,
                                                                 snakeSettings.SideLength,
                                                                 1,
                                                                 new RandomNumberGenerator());

            return(snakeSettingsLogic);
        }
Example #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SnakeSettingsGUI snakeSettings = new SnakeSettingsGUI(20, 30, 20);
            SnakeLevelEditor levelEditor   = new SnakeLevelEditor(snakeSettings);

            Application.Run(levelEditor);
            Console.ReadKey();
        }
        public SnakeLevelEditor(SnakeSettingsGUI snakeSettings)
        {
            this.snakeSettings = snakeSettings;
            fields             = new FieldGUI[snakeSettings.RowCount, snakeSettings.ColumnCount];

            StartPosition = FormStartPosition.CenterScreen;

            storageManager = new StorageManager();

            CreateMenu();

            Text = "Snake Level Editor";

            FormBorderStyle = FormBorderStyle.FixedSingle;
            MaximizeBox     = false;

            mouseTimer          = new System.Timers.Timer();
            mouseTimer.Interval = 1;
            mouseTimer.Enabled  = false;

            // Graphical area to draw the grid.
            bitmap   = new Bitmap(snakeSettings.ColumnCount * snakeSettings.SideLength, snakeSettings.RowCount * snakeSettings.SideLength);
            graphics = Graphics.FromImage(bitmap);

            Width  = bitmap.Width + snakeSettings.SideLength;
            Height = bitmap.Height + (snakeSettings.SideLength * 2) + fileMenu.Height - 1;

            EnableDoubleBuffering();

            InitializeLevel();

            Paint              += OnPaint;
            MouseMove          += OnMouseMove;
            MouseDown          += OnMouseDown;
            MouseUp            += OnMouseUp;
            mouseTimer.Elapsed += mouseTimerEvent;

            fileMenu.ItemClicked += FileMenuOnClick;
        }