public InfoBarBuilderControl(InfoBarItem item) { infoLabel = new StbTextBox(0xFF, 10, 80) { X = 5, Y = 0, Width = 130, Height = 26 }; infoLabel.SetText(item.label); string[] dataVars = InfoBarManager.GetVars(); varStat = new Combobox(200, 0, 170, dataVars, (int)item.var); uint color = 0xFF7F7F7F; if (item.hue != 0xFFFF) { color = HuesLoader.Instance.GetPolygoneColor(12, item.hue); } labelColor = new ClickableColorBox(150, 0, 13, 14, item.hue, color); NiceButton deleteButton = new NiceButton(390, 0, 60, 25, ButtonAction.Activate, ResGumps.Delete) { ButtonParameter = 999 }; deleteButton.MouseUp += (sender, e) => { Dispose(); ((DataBox)Parent)?.ReArrangeChildren(); }; Add ( new ResizePic(0x0BB8) { X = infoLabel.X - 5, Y = 0, Width = infoLabel.Width + 10, Height = infoLabel.Height } ); Add(infoLabel); Add(varStat); Add(labelColor); Add(deleteButton); Width = infoLabel.Width + 10; Height = infoLabel.Height; }
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; } } }
private void AddSubMacro(MacroObject obj) { if (obj == null || obj.Code == 0) { return; } switch (obj.SubMenuType) { case 1: int count = 0; int offset = 0; Macro.GetBoundByCode(obj.Code, ref count, ref offset); string[] names = new string[count]; for (int i = 0; i < count; i++) { names[i] = _allSubHotkeysNames[i + offset]; } Combobox sub = new Combobox(20, Height, 180, names, (int)obj.SubCode - offset, 300); sub.OnOptionSelected += (senderr, ee) => { Macro.GetBoundByCode(obj.Code, ref count, ref offset); MacroSubType subType = (MacroSubType)(offset + ee); obj.SubCode = subType; }; Add(sub); Height += sub.Height; break; case 2: ResizePic background = new ResizePic(0x0BB8) { X = 16, Y = Height, Width = 240, Height = 60 }; Add(background); StbTextBox textbox = new StbTextBox(0xFF, 80, 236, true, FontStyle.BlackBorder) { X = background.X + 4, Y = background.Y + 4, Width = background.Width - 4, Height = background.Height - 4 }; textbox.SetText(obj.HasString() ? ((MacroObjectString)obj).Text : string.Empty); textbox.TextChanged += (sss, eee) => { if (obj.HasString()) { ((MacroObjectString)obj).Text = ((StbTextBox)sss).Text; } }; Add(textbox); WantUpdateSize = true; Height += background.Height; break; } _control._databox.ReArrangeChildren(); }
private void ValidateValue(int val) { Tag = val = Math.Max(_Min, Math.Min(_Max, val)); _textBox.SetText(val.ToString()); }