예제 #1
0
        Control CreateDrawCharacter()
        {
            var layout = new DynamicLayout {
                Padding = Padding.Empty
            };

            layout.BeginHorizontal();

            characterPanel = layout;

            layout.Add(new Label {
                Text = "C&haracter:"
            });

            charTextBox          = new FontTextBox(Handler, new Size(1, 1));
            charTextBox.ReadOnly = false;
            charTextBox.SetAttribute(this.Attribute);

            layout.Add(charTextBox);
            layout.Add(null);

            layout.EndHorizontal();


            return(layout);
        }
예제 #2
0
 Control ColoursControl()
 {
     colours           = new ColourSelection(Handler.CurrentPage.Palette, Handler.DrawAttribute);
     colours.Size      = new Size(250, 220);
     colours.Selected += delegate
     {
         if (colours.HasFocus && characterPanel.Visible)
         {
             // now set character
             charTextBox.Focus();
         }
         else
         {
             Result = true;
             Close();
         }
     };
     colours.Changed += delegate
     {
         charTextBox.SetAttribute(this.Attribute);
     };
     return(colours);
 }
예제 #3
0
        Control Characters()
        {
            var font    = CharacterHandler.CurrentPage.Font;
            int width   = 64;           //font.NumChars > 256 ? 64 : 32;
            var size    = new Size(width, (font.NumChars + width - 1) / width);
            var control = new FontTextBox(CharacterHandler, size);

            control.Bordered = true;
            control.SetAttribute(CharacterHandler.DrawAttribute);
            control.MouseDown += (sender, e) =>
            {
                if (lastSet != null)
                {
                    lastSet.Insert(control.CursorElement);
                    lastSet.Invalidate();
                    lastSet.Focus();
                }
                e.Handled = true;
            };
            control.ReadOnly = true;
            control.CanFocus = false;
            int character = 0;

            for (int y = 0; y < control.Canvas.Height; y++)
            {
                for (int x = 0; x < control.Canvas.Width; x++)
                {
                    if (character < font.NumChars)
                    {
                        var ce = control.Canvas[x, y];
                        ce.Character         = character++;
                        control.Canvas[x, y] = ce;
                    }
                }
            }

            return(control);
        }
예제 #4
0
        Control CharacterSelection()
        {
            var layout = new DynamicLayout {
                Spacing = new Size(10, 5)
            };

            RadioButton master = null;

            for (int i = 0; i < CharacterDocumentInfo.MAX_CHARACTER_SETS; i++)
            {
                var characterSet = CharacterHandler.Info.GetCharacterSet(i).ToArray();
                var control      = new FontTextBox(CharacterHandler, new Size(characterSet.Length, 1));
                control.ReadOnly = false;
                control.SetAttribute(CharacterHandler.DrawAttribute);
                sets.Add(control.Canvas);
                for (int c = 0; c < characterSet.Length; c++)
                {
                    var ce = control.Canvas[c, 0];
                    ce.Character         = characterSet[c];
                    control.Canvas[c, 0] = ce;
                }
                control.GotFocus += delegate
                {
                    lastSet = control;
                };
                var radio = new RadioButton(master)
                {
                    Text = "Set " + (i + 1), Tag = i
                };
                if (i == CharacterHandler.CharacterSet)
                {
                    radio.Checked = true;
                    radio.Focus();
                }
                radio.CheckedChanged += delegate(object sender, EventArgs e)
                {
                    var c = (RadioButton)sender;
                    selected = (int)c.Tag;
                };
                radio.MouseDoubleClick += (sender, e) =>
                {
                    e.Handled = true;
                    Save();
                    Result = DialogResult.Ok;
                    Close();
                };
                if (master == null)
                {
                    master = radio;
                }
                if (i % 2 == 0)
                {
                    layout.BeginHorizontal();
                }
                layout.Add(radio);
                layout.Add(control);
                if (i % 2 == 1)
                {
                    layout.EndHorizontal();
                }
            }

            return(new GroupBox {
                Content = layout
            });
        }
예제 #5
0
        Control Brushes()
        {
            var layout = new TableLayout(6, 5);

            layout.Spacing = new Size(10, 5);
            layout.SetColumnScale(0);
            layout.SetColumnScale(5);

            RadioButton master  = null;
            var         brushes = CharacterHandler.Info.Brushes;

            for (int i = 0; i < CharacterDocumentInfo.MAX_BRUSHES; i++)
            {
                var brush   = (i < brushes.Length) ? brushes[i] : new BrushInfo();
                var control = new FontTextBox(CharacterHandler, new Size(CharacterDocumentInfo.MAX_BRUSH_SIZE, 1));
                control.ReadOnly = false;
                control.SetAttribute(CharacterHandler.DrawAttribute);
                brushCanvases.Add(control.Canvas);

                if (brush != null)
                {
                    var characters = brush.GetCharacters(CharacterHandler.CurrentPage.Font.Encoding) ?? new Character[0];
                    for (int c = 0; c < characters.Length; c++)
                    {
                        var ce = control.Canvas[c, 0];
                        ce.Character         = characters[c];
                        control.Canvas[c, 0] = ce;
                    }
                }
                control.GotFocus += delegate
                {
                    lastSet = control;
                };
                var x     = (i / 5) * 2;
                var y     = i % 5;
                var radio = new RadioButton(master)
                {
                    Text = "Brush " + (i + 1), Tag = i
                };
                if (i == SelectedBrush)
                {
                    radio.Checked = true;
                    radio.Focus();
                }
                radio.MouseDoubleClick += (sender, e) =>
                {
                    e.Handled = true;
                    var c = (RadioButton)sender;
                    SelectedBrush = (int)c.Tag;
                    Result        = DialogResult.Ok;
                    Save();
                    Close();
                };
                radio.CheckedChanged += delegate(object sender, EventArgs e)
                {
                    var c = (RadioButton)sender;
                    SelectedBrush = (int)c.Tag;
                };
                if (master == null)
                {
                    master = radio;
                }
                layout.Add(radio, x + 1, y);
                layout.Add(control, x + 2, y);
            }

            /**
             * var scroll = new Scrollable{  };
             * var pl = new PixelLayout(scroll);
             * pl.Add(layout.Container, 0, 0);
             * return scroll;
             * /**/
            return(new GroupBox {
                Content = layout
            });
            /**/
        }