Beispiel #1
0
        void CreateButton(PixelLayout layout, int index, int x, int y)
        {
            var b = new SelectColourBox {
                Pad     = this,
                Size    = new Size(16, 16),
                Index   = index,
                Enabled = index < Palette.Count
            };

            colours[index] = b;
            layout.Add(b, x, y);
        }
Beispiel #2
0
        void UpdateColours()
        {
            var size   = new Size(16, ((Palette.Count + 15) / 16));
            var layout = new TableLayout(size);

            layout.Spacing = new Size(2, 2);
            layout.Padding = 4;

            int count = 0;

            for (int y = 0; y < size.Height; y++)
            {
                for (int x = 0; x < size.Width; x++)
                {
                    if (count < Palette.Count)
                    {
                        var sel = new SelectColourBox {
                            Index = count++, Editor = this
                        };
                        if (SelectedIndex == sel.Index)
                        {
                            sel.Load += delegate
                            {
                                sel.Focus();
                            }
                        }
                        ;
                        layout.Add(sel, x, y);
                    }
                    else
                    {
                        layout.Add(new Panel {
                            Size = new Size(16, 16)
                        }, x, y);
                    }
                }
            }

            coloursHolder.Content = layout;

            removeButton.Enabled = Palette.Count > 1;
        }

        Control CancelButton()
        {
            var control = new Button {
                Text = "Cancel"
            };

            control.Click += delegate
            {
                Result = false;
                Close();
            };
            AbortButton = control;

            return(control);
        }

        Control OkButton()
        {
            var control = new Button {
                Text = "Ok"
            };

            control.Click += delegate
            {
                Result = true;
                if (handler.Client != null)
                {
                    handler.Client.SendCommand(new Actions.SetPalette(handler)
                    {
                        Palette = Palette
                    });
                }
                else
                {
                    handler.CurrentPage.Palette = Palette;
                    handler.Document.IsModified = true;
                }
                Close();
            };

            DefaultButton = control;

            return(control);
        }

        Control SetDefaultButton()
        {
            var control = new Button {
                Text = "Set Defaults"
            };

            control.Click += delegate
            {
                Palette = Palette.GetDosPalette();
                UpdateColours();
                Invalidate();
            };
            return(control);
        }
    }