public ArrowNumbersTextBox
        (
            int x,
            int y,
            int width,
            int raiseamount,
            int minvalue,
            int maxvalue,
            byte font         = 0,
            int maxcharlength = -1,
            bool isunicode    = true,
            FontStyle style   = FontStyle.None,
            ushort hue        = 0
        )
        {
            int height = 20;

            X      = x;
            Y      = y;
            Width  = width;
            Height = height;
            _Min   = minvalue;
            _Max   = maxvalue;

            Add
            (
                new ResizePic(0x0BB8)
            {
                Width  = width,
                Height = height + 4
            }
            );

            _up = new Button(raiseamount, 0x983, 0x984)
            {
                X            = width - 12,
                ButtonAction = ButtonAction.Activate
            };

            _up.MouseDown += (sender, e) =>
            {
                if (_up.IsClicked)
                {
                    UpdateValue();
                    _timeUntilNextClick = TIME_BETWEEN_CLICKS * 2;
                }
            };

            Add(_up);

            _down = new Button(-raiseamount, 0x985, 0x986)
            {
                X            = width - 12,
                Y            = height - 7,
                ButtonAction = ButtonAction.Activate
            };

            _down.MouseDown += (sender, e) =>
            {
                if (_down.IsClicked)
                {
                    UpdateValue();
                    _timeUntilNextClick = TIME_BETWEEN_CLICKS * 2;
                }
            };

            Add(_down);

            Add
            (
                _textBox = new StbTextBox
                           (
                    font,
                    maxcharlength,
                    width,
                    isunicode,
                    style,
                    hue
                           )
            {
                X           = 2,
                Y           = 2,
                Height      = height,
                Width       = width - 17,
                NumbersOnly = true
            }
            );
        }
Пример #2
0
        private void CreateCombobox(MacroObject obj)
        {
            Combobox box = new Combobox(0, 0, 200, Enum.GetNames(typeof(MacroType)), (int)obj.Code, 300);

            box.OnOptionSelected += (sender, e) =>
            {
                Combobox b = (Combobox)sender;

                if (b.SelectedIndex == 0) // MacroType.None
                {
                    MacroObject m = (MacroObject)b.Tag;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = m.Right;
                    }

                    if (m.Right != null)
                    {
                        m.Right.Left = m.Left;
                    }

                    if (m.Left != null)
                    {
                        m.Left.Right = m.Right;
                    }

                    m.Left  = null;
                    m.Right = null;

                    b.Tag = null;

                    b.Parent.Dispose();
                    _comboboxes.Remove(b);

                    if (_comboboxes.Count == 0 || _comboboxes.All(s => s.IsDisposed))
                    {
                        Macro.FirstNode = Macro.Create(MacroType.None);
                        CreateCombobox(Macro.FirstNode);
                    }
                }
                else
                {
                    MacroType t = (MacroType)b.SelectedIndex;

                    MacroObject m        = (MacroObject)b.Tag;
                    MacroObject newmacro = Macro.Create(t);

                    MacroObject left  = m.Left;
                    MacroObject right = m.Right;

                    if (left != null)
                    {
                        left.Right = newmacro;
                    }

                    if (right != null)
                    {
                        right.Left = newmacro;
                    }

                    newmacro.Left  = left;
                    newmacro.Right = right;

                    b.Tag = newmacro;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = newmacro;
                    }


                    b.Parent.Children
                    .Where(s => s != b)
                    .ToList()
                    .ForEach(s => s.Dispose());

                    switch (newmacro.SubMenuType)
                    {
                    case 1:     // another combo
                        int count  = 0;
                        int offset = 0;

                        Macro.GetBoundByCode(t, ref count, ref offset);

                        Combobox subBox = new Combobox
                                          (
                            20, b.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                            .Skip(offset)
                            .Take(count)
                            .ToArray(), 0, 300
                                          );


                        subBox.OnOptionSelected += (ss, ee) =>
                        {
                            Macro.GetBoundByCode(newmacro.Code, ref count, ref offset);
                            MacroSubType subType = (MacroSubType)(offset + ee);
                            newmacro.SubCode = subType;
                        };

                        b.Parent.Add(subBox);
                        b.Parent.WantUpdateSize = true;

                        break;

                    case 2:     // string

                        b.Parent.Add
                        (
                            new ResizePic(0x0BB8)
                        {
                            X      = 18,
                            Y      = b.Height + 2,
                            Width  = 240,
                            Height = b.Height * 2 + 4
                        }
                        );

                        StbTextBox textbox = new StbTextBox(0xFF, 80, 236, true, FontStyle.BlackBorder)
                        {
                            X      = 20,
                            Y      = b.Height + 5,
                            Width  = 236,
                            Height = b.Height * 2
                        };

                        textbox.TextChanged += (sss, eee) =>
                        {
                            if (newmacro.HasString())
                            {
                                ((MacroObjectString)newmacro).Text = ((StbTextBox)sss).Text;
                            }
                        };

                        b.Parent.Add(textbox);
                        b.Parent.WantUpdateSize = true;

                        break;
                    }
                }
            };

            box.Tag = obj;
            _scrollArea.Add(box);
            _comboboxes.Add(box);


            if (obj.Code != MacroType.None)
            {
                switch (obj.SubMenuType)
                {
                case 1:
                    int count  = 0;
                    int offset = 0;

                    Macro.GetBoundByCode(obj.Code, ref count, ref offset);

                    Combobox subBox = new Combobox
                                      (
                        20, box.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                        .Skip(offset)
                        .Take(count)
                        .ToArray(), (int)(obj.SubCode - offset), 300
                                      );


                    subBox.OnOptionSelected += (ss, ee) =>
                    {
                        Macro.GetBoundByCode(obj.Code, ref count, ref offset);
                        MacroSubType subType = (MacroSubType)(offset + ee);
                        obj.SubCode = subType;
                    };

                    box.Parent.Add(subBox);
                    box.Parent.WantUpdateSize = true;

                    break;

                case 2:

                    box.Parent.Add
                    (
                        new ResizePic(0x0BB8)
                    {
                        X      = 18,
                        Y      = box.Height + 2,
                        Width  = 240,
                        Height = box.Height * 2 + 4
                    }
                    );

                    StbTextBox textbox = new StbTextBox(0xFF, 80, 236, true, FontStyle.BlackBorder)
                    {
                        X      = 20,
                        Y      = box.Height + 5,
                        Width  = 236,
                        Height = box.Height * 2
                    };

                    textbox.SetText(obj.HasString() ? ((MacroObjectString)obj).Text : string.Empty);

                    textbox.TextChanged += (sss, eee) =>
                    {
                        if (obj.HasString())
                        {
                            ((MacroObjectString)obj).Text = ((StbTextBox)sss).Text;
                        }
                    };

                    box.Parent.Add(textbox);
                    box.Parent.WantUpdateSize = true;

                    break;
                }
            }
        }