using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;
using ChtiCanon;

namespace Canon
{
    public partial class frmChtiCanon : Form
    {
        Program.GameThread gt;
        public frmChtiCanon(Program.GameThread gt)
        {
            this.gt = gt;
            Graphics g = CreateGraphics();
            InitializeComponent();
            ClientSize = new Size(Game.screenWidth, Game.screenHeight);
            game.Location = new Point(0, 0);
            game.ClientSize = new Size(Game.screenWidth, Game.screenHeight);
            game.init(gt);
        }

        public void handle()
        {
            game.handle();
        }

        public void render()
        {
            game.render();
        }

        private void frmChtiCanon_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (gt.Connection != null)
                gt.Connection.Close();
                //gt.Connection.send(new Shared.Close());
            game.close();
            System.Environment.Exit(0);
        }

        private void frmChtiCanon_Resize(object sender, EventArgs e)
        {
            game.Rendering = !ClientSize.IsEmpty;
            if (!game.Rendering)
                return;
            game.Location = new Point(0, 0);
            game.ClientSize = ClientSize;
        }
    }
}
