Example #1
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            leftPanel = new Panel();
            leftPanel.Initialize();
            AddDrawBox(leftPanel);

            rightPanel = new Panel();
            rightPanel.Initialize();
            AddDrawBox(rightPanel);

            var builder = new FieldBuilder();

            builder.BuildSessionStart(leftPanel);

            entitiesWithPainters = builder.AddColumnListBox("Entities being drawn:", 400, 2);
            entitiesWithPainters.SetColumnName(0, "Entity-Type");
            entitiesWithPainters.SetColumnName(1, "Painter-Type");

            builder.BuildSessionEnd();

            builder.BuildSessionStart(rightPanel);

            entityPainters = builder.AddColumnListBox("Entity-painters:", 400, 1);
            entityPainters.SetColumnName(0, "Painter-Type");

            builder.AddResizableButtonField("Add Painter", delegate(object sender)
            {
                AddEntityPainterForm.ShowDialogue(Parent, simulation, delegate(object _sender)
                {
                    var form = (AddEntityPainterForm)_sender;

                    form.Result.Initialize(DrawBox.DefaultSkinFile);
                    simulation.EntityPainters.Add(form.Result);

                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                });
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.AddResizableButtonField("Remove Painter", delegate(object sender)
            {
                if (entityPainters.SelectedRow != null)
                {
                    simulation.EntityPainters.Remove((IEntityPainter)entityPainters.SelectedRow.ExtraValues[0]);
                    reloadEntitiesWithPaintersList();
                    reloadPainterList();
                }
            }, FieldBuilder.ResizableButtonOrientation.FillWidth);

            builder.BuildSessionEnd();

            leftPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            leftPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            rightPanel.X      = leftPanel.Width + panelMargin;
            rightPanel.Width  = Math.Max(leftPanel.Width, rightPanel.Width);
            rightPanel.Height = Math.Max(leftPanel.Height, rightPanel.Height);

            Wrap();

            reloadEntitiesWithPaintersList();
            reloadPainterList();

            leftPanel.Alignment  = DrawBoxAlignment.GetTopBottom();
            rightPanel.Alignment = DrawBoxAlignment.GetTopBottom();

            SizeChanged += new SizeChangedEvent(EntityDrawingOptionsForm_SizeChanged);

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }