using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;

namespace Mutation
{
    public partial class Analyzer : Form
    {
        List<DataBlock> Blocks = new List<DataBlock>();

        public Analyzer()
        {
            InitializeComponent();
        }

        private void Analyzer_Load(object sender, EventArgs e)
        {
            // Add all the Blocks
            for (int i = 0; i < Blocks.Count; i++)
            {
                // Create the Row
                CategoryRow row = new CategoryRow(Blocks[i].Name);
                row.ChildRows.AddRange(new EditorRow[] { new EditorRow(), new EditorRow() });
                row.ChildRows[0].Properties.Caption = "Offset";
                row.ChildRows[0].Properties.Value = Blocks[i].Offset.ToString();
                row.ChildRows[1].Properties.Caption = "Size";
                row.ChildRows[1].Properties.Value = Blocks[i].Size.ToString();

                // Add it
                if (Blocks[i].Type == DataType.SoundRaw)
                    SoundRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.ModelRaw)
                    ModelRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BSP1)
                    DetailObjects.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BSP2)
                    Permutations.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BSP3)
                    WaterDefinitions.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BSP4)
                    BSPDecorators.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.LightmapRaw)
                    LightmapPoop.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Weather)
                    WeatherRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Particle)
                    ParticleRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Decorator)
                    DecoratorRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Coconut)
                    CoconutRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Animation)
                    AnimationRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BSPMeta)
                    BSPMeta.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.LightmapMeta)
                    LightmapMeta.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.StringID)
                    StringIds.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.FileTable)
                    FileTable.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Unicode)
                    Unicode.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.BitmapRaw)
                    BitmapRaw.ChildRows.Add(row);
                else if (Blocks[i].Type == DataType.Meta)
                    Meta.ChildRows.Add(row);
            }
        }

        public void AddBlock(DataBlock block)
        {
            Blocks.Add(block);
        }
    }
}
