private void AddLabel(string text) { var label = new InputLabel(); label.Break = BreakType.Row; label.Text = text; label.Font = new Font("Calibri", 14F, FontStyle.Regular, GraphicsUnit.Point, 204); label.ForeColor = Color.FromArgb(0, 114, 198); c1InputPanel1.Items.Add(label); }
// ========================================= PUBLIC FUNCS ========================================= public void AddInputLabel(string labelName = "") { if (prefInputLabel) { // gen new label InputLabel label = Instantiate(prefInputLabel, transform).GetComponent <InputLabel>(); label.Init(GetParent(), labelName); lLabels.Add(label); // refresh canvas CanvasMgr.Instance.RefreshCanvas(); } }
public string send() { string toSend = InputPort.ToString() + " " + InputLabel.ToString() + " " + OutputPort.ToString() + " "; foreach (int label in OutputLabel) { toSend += label + ","; } toSend = toSend.Remove(toSend.Length - 1, 1); toSend += " " + Index; return(toSend); }
/// <summary> /// 建造一个漂亮的复选框 /// </summary> public CheckBoxBuilder(CheckBoxDto checkBoxDto) { _inputLabel = new InputLabel("checkbox", checkBoxDto.Value, "chklist", checkBoxDto.IsChecked ? " checked='checked' " : ""); _labelGroupLabel = new LabelGroupLabel("chkbox", checkBoxDto.Text, checkBoxDto.IsDisabled ? " disabled " : ""); }
private void AddInputComponent(XmlNode node) { switch (node.Name) { case "C1InputButton": InputButton button = new InputButton(); ReadCommonProperties(node, button); button.Text = XmlUtil.Read(node, "text", String.Empty); button.Image = XmlUtil.ReadImage(node, "image"); button.CheckOnClick = XmlUtil.Read(node, "toggle", false); button.Pressed = XmlUtil.Read(node, "pressed", false); c1InputPanel1.Items.Add(button); break; case "C1InputCheckBox": InputCheckBox checkBox = new InputCheckBox(); ReadCommonProperties(node, checkBox); checkBox.Checked = XmlUtil.Read(node, "checked", false); checkBox.ThreeState = XmlUtil.Read(node, "threeState", false); checkBox.Text = XmlUtil.Read(node, "text", String.Empty); c1InputPanel1.Items.Add(checkBox); break; case "C1InputComboBox": InputComboBox comboBox = new InputComboBox(); ReadCommonProperties(node, comboBox, true); comboBox.DropDownStyle = XmlUtil.Read(node, "dropDownList", false) ? InputComboBoxStyle.DropDownList : InputComboBoxStyle.DropDown; comboBox.MaxDropDownItems = XmlUtil.Read(node, "maxDropDownItems", 8); comboBox.GripHandleVisible = XmlUtil.Read(node, "gripHandle", false); comboBox.Text = XmlUtil.Read(node, "text", String.Empty); comboBox.Width = XmlUtil.Read(node, "width", 100); comboBox.MaxLength = XmlUtil.Read(node, "maxLength", 250); // parse combobox options string options = XmlUtil.Read(node, "options", String.Empty); string[] optList = options.Split(','); for (int i = 0; i < optList.Length; i++) { InputOption option = new InputOption(); option.Text = optList[i]; comboBox.Items.Add(option); } c1InputPanel1.Items.Add(comboBox); break; case "C1InputDatePicker": InputDatePicker datePicker = new InputDatePicker(); ReadCommonProperties(node, datePicker, true); datePicker.Format = XmlUtil.Read(node, "format", String.Empty); datePicker.ShowToday = XmlUtil.Read(node, "showToday", true); datePicker.Width = XmlUtil.Read(node, "width", 100); c1InputPanel1.Items.Add(datePicker); break; case "C1InputGroup": InputGroupHeader header = new InputGroupHeader(); header.Text = XmlUtil.Read(node, "text", String.Empty); header.Collapsible = XmlUtil.Read(node, "collapsible", false); header.Collapsed = XmlUtil.Read(node, "collapsed", false); header.Height = XmlUtil.Read(node, "height", 24); c1InputPanel1.Items.Add(header); break; case "C1InputImage": InputImage image = new InputImage(); ReadCommonProperties(node, image); image.Image = XmlUtil.ReadImage(node, "image"); c1InputPanel1.Items.Add(image); break; case "C1InputLabel": InputLabel label = new InputLabel(); ReadCommonProperties(node, label); label.Text = XmlUtil.Read(node, "text", String.Empty); label.WordWrap = XmlUtil.Read(node, "wordwrap", false); c1InputPanel1.Items.Add(label); break; case "C1InputRadioButton": InputRadioButton radioButton = new InputRadioButton(); ReadCommonProperties(node, radioButton); radioButton.Checked = XmlUtil.Read(node, "checked", false); radioButton.GroupName = XmlUtil.Read(node, "groupName", String.Empty); radioButton.Text = XmlUtil.Read(node, "text", String.Empty); c1InputPanel1.Items.Add(radioButton); break; case "C1InputSeparator": InputSeparator separator = new InputSeparator(); ReadCommonProperties(node, separator); c1InputPanel1.Items.Add(separator); break; case "C1InputTextBox": InputTextBox textBox = new InputTextBox(); ReadCommonProperties(node, textBox, true); textBox.Text = XmlUtil.Read(node, "text", String.Empty); textBox.Width = XmlUtil.Read(node, "width", 100); textBox.MaxLength = XmlUtil.Read(node, "maxLength", 250); c1InputPanel1.Items.Add(textBox); break; case "C1InputNumericBox": InputNumericBox numBox = new InputNumericBox(); ReadCommonProperties(node, numBox, true); numBox.Format = XmlUtil.Read(node, "format", string.Empty); numBox.Text = XmlUtil.Read(node, "value", String.Empty); numBox.Increment = Decimal.Parse(XmlUtil.Read(node, "step", "1")); numBox.Width = XmlUtil.Read(node, "width", 100); c1InputPanel1.Items.Add(numBox); break; case "C1InputControlHost": string className = XmlUtil.Read(node, "control", String.Empty); if (!String.IsNullOrEmpty(className)) { string qualifiedTypeName = typeof(Control).AssemblyQualifiedName; qualifiedTypeName = qualifiedTypeName.Replace(".Control", "." + className); Type controlType = Type.GetType(qualifiedTypeName, true); if (controlType != null) { ConstructorInfo ci = controlType.GetConstructor(new Type[0]); if (ci != null) { Control control = ci.Invoke(new object[0]) as Control; if (control != null) { InputControlHost controlHost = new InputControlHost(control); ReadCommonProperties(node, controlHost); c1InputPanel1.Items.Add(controlHost); } } } } break; case "C1InputLinkLabel": string linkText = XmlUtil.Read(node, "text", String.Empty); if (!String.IsNullOrEmpty(linkText)) { InputHtmlLabel htmlLabel = new InputHtmlLabel(); ReadCommonProperties(node, htmlLabel); string linkHRef = XmlUtil.Read(node, "href", String.Empty); htmlLabel.Text = "<a href='" + linkHRef + "'>" + linkText + "</a>"; htmlLabel.LinkClicked += new C1.Win.C1InputPanel.LinkClickedEventHandler(htmlLabel_LinkClicked); c1InputPanel1.Items.Add(htmlLabel); } break; default: InputLabel unknown = new InputLabel(); ReadCommonProperties(node, unknown); string text = XmlUtil.Read(node, "text", String.Empty); if (text.Length > 0) { unknown.Text = "< " + node.Name + ", Text = \"" + text + "\" >"; } else { unknown.Text = "< " + node.Name + " >"; } c1InputPanel1.Items.Add(unknown); break; } }
public PropertyList(ArrayList properties) { this.ChildSpacing = new Size(2, 2); this.Margin = new Padding(0); this.Padding = new Padding(0); this.SuspendLayout(); for (int i = 0; i < properties.Count; i++) { Association a = properties[i] as Association; if (a == null) { string s = properties[i] as string; if (s.ToLower().Equals("separator")) { InputSeparator sep = new InputSeparator(); this.Items.Add(sep); } else if (s.ToLower().Equals("colbreak")) { this.Items[this.Items.Count - 1].Break = BreakType.Column; } else { InputGroupHeader gh = new InputGroupHeader(); gh.Text = s; gh.Height = unitHeight; gh.BackColor = Color.Transparent; this.Items.Add(gh); } } else if (a.Descriptor.PropertyType == Type.GetType("System.Boolean")) { InputCheckBox chk = new InputCheckBox(); chk.Height = unitHeight; chk.Checked = (bool)a.Value; chk.Tag = a; if (string.IsNullOrEmpty(a.LongName)) { chk.Text = a.Descriptor.Name + " "; } else { chk.Text = a.LongName + " "; } chk.CheckedChanged += new EventHandler(chk_CheckedChanged); this.Items.Add(chk); } else { InputLabel lab = new InputLabel(); lab.VerticalAlign = InputContentAlignment.Center; lab.Height = unitHeight; lab.Width = labelWidth; if (string.IsNullOrEmpty(a.LongName)) { lab.Text = a.Descriptor.Name; } else { lab.Text = a.LongName; } this.Items.Add(lab); if (a.Descriptor.PropertyType.IsEnum) { InputComboBox box = new InputComboBox(); box.Height = unitHeight; box.DropDownStyle = InputComboBoxStyle.DropDownList; BindingFlags flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly; FieldInfo[] fields = a.Descriptor.PropertyType.GetFields(flags); box.Tag = a; box.Text = a.Value.ToString(); box.SelectedIndexChanged += new EventHandler(box_SelectedIndexChanged); for (int f = 0; f < fields.Length; f++) { var field = fields[f]; if (a.AllowedValues == null || a.AllowedValues.Contains(field.Name)) { InputOption ic = new InputOption(); ic.Text = field.GetValue(field).ToString(); ic.Tag = field; box.Items.Add(ic); } } this.Items.Add(box); } else if (a.Descriptor.PropertyType == Type.GetType("System.DateTime")) { InputDatePicker dp = new InputDatePicker(); dp.Height = unitHeight; dp.Value = (DateTime)a.Value; dp.Tag = a; dp.LostFocus += new EventHandler(date_LostFocus); this.Items.Add(dp); } else if (a.Descriptor.PropertyType == Type.GetType("System.TimeSpan")) { InputTimePicker tp = new InputTimePicker(); tp.Height = unitHeight; tp.Value = (TimeSpan)a.Value; tp.Tag = a; tp.LostFocus += new EventHandler(time_LostFocus); this.Items.Add(tp); } else if (a.Descriptor.PropertyType.ToString().Equals("System.Drawing.Color")) { ColorEditorHost ce = new ColorEditorHost(); ce.Height = unitHeight; ce.Width = 102; ce.SelectedColor = (System.Drawing.Color)a.Value; ce.Tag = a; ce.LostFocus += new EventHandler(color_LostFocus); this.Items.Add(ce); } else if (a.Descriptor.PropertyType == Type.GetType("System.Int32")) { InputNumericBox nb = new InputNumericBox(); nb.Height = unitHeight; nb.Width = 50; nb.Value = (int)a.Value; nb.Tag = a; nb.Maximum = 100000; nb.ValueChanged += new EventHandler(nb_ValueChanged); this.Items.Add(nb); } else if (a.Descriptor.PropertyType == Type.GetType("System.Int16")) { InputNumericBox nb = new InputNumericBox(); nb.Height = unitHeight; nb.Width = 50; nb.Value = (short)a.Value; nb.Tag = a; nb.Maximum = 100000; nb.ValueChanged += new EventHandler(nb_ValueChanged); this.Items.Add(nb); } else if (a.Descriptor.PropertyType == Type.GetType("System.Int64")) { InputNumericBox nb = new InputNumericBox(); nb.Value = (long)a.Value; nb.Tag = a; nb.Maximum = 100000; nb.Height = unitHeight; nb.Width = 50; nb.ValueChanged += new EventHandler(nb_ValueChanged); this.Items.Add(nb); } else if (a.Descriptor.PropertyType == Type.GetType("System.Single") || a.Descriptor.PropertyType == Type.GetType("System.Double")) { InputNumericBox nb = new InputNumericBox(); nb.Value = (decimal)Math.Floor((Single)a.Value); nb.Tag = a; nb.Maximum = 360; nb.Minimum = 0; nb.Height = unitHeight; nb.Width = 50; nb.ValueChanged += new EventHandler(nb_ValueChanged); this.Items.Add(nb); } else { InputTextBox txt = new InputTextBox(); txt.VerticalAlign = InputContentAlignment.Center; txt.Height = unitHeight; txt.Text = a.Value.ToString(); txt.Tag = a; txt.LostFocus += new EventHandler(txt_LostFocus); this.Items.Add(txt); } } } this.Dock = System.Windows.Forms.DockStyle.Fill; this.ResumeLayout(); }
public override void Initialize() { // Determine the position and size of the interface. int x = 0, y = 0, w = 50, h = 40; // Pass an empty provider to the panel (the interface will be drawn on Main.tile). object provider = null; // Although we can use as a provider, for example, FakeTileRectangle from FakeManager: //object provider = FakeManager.FakeManager.Common.Add("TestPanelProvider", x, y, w, h); // Create a panel with a wall of diamond gemspark wall with black paint. Panel root = TUI.TUI.Create(new Panel("TestPanel", x, y, w, h, null, new ContainerStyle() { Wall = WallID.DiamondGemspark, WallColor = PaintID.Black }, provider)) as Panel; // Create a Label widget (text display) with white characters. Label label1 = new Label(1, 1, 17, 2, "some text", new LabelStyle() { TextColor = PaintID.White }); // Add to panel root.Add(label1); // Create a container that occupies the lower (larger) half of our panel, painted over with white paint. // The Add function returns the newly added object in the VisualObject type, // so adding an element can be implemented as follows: VisualContainer node = root.Add( new VisualContainer(0, 15, w, 25, null, new ContainerStyle() { WallColor = PaintID.White }) ) as VisualContainer; // Add a button to this container, which, when clicked, will send the clicker to the chat. /*node.Add(new Button(5, 0, 12, 4, "lol", null, new ButtonStyle() * { Wall = 165, WallColor = PaintID.DeepGreen }, (self, touch) => * touch.Player().SendInfoMessage("You pressed lol button!")));*/ if (false) { // Set the layout configuration. node.SetupLayout(Alignment.Center, Direction.Right, Side.Center, null, 3, false); // Add the InputLabel widget to the layout that allows you to input text. node.AddToLayout(new InputLabel(0, 0, new InputLabelStyle() { TextColor = PaintID.Black, Type = InputLabelType.All, TextUnderline = LabelUnderline.None }, new Input <string>("000", "000"))); // Add to the layout one more ItemRack widget that corresponds to the Weapon rack: displaying an item // on a 3x3 rack. By clicking displays the relative and absolute coordinates of this click. node.AddToLayout(new ItemRack(0, 0, new ItemRackStyle() { Type = 200, Left = true }, (self, touch) => Console.WriteLine($"Touch: {touch.X}, {touch.Y}; absolute: {touch.AbsoluteX}, {touch.AbsoluteY}"))); ItemRack irack1 = node.AddToLayout(new ItemRack(0, 0, new ItemRackStyle() { Type = 201, Left = true })) as ItemRack; // ItemRack allows you to add text on top using a sign: irack1.SetText("lololo\nkekeke"); // Finally, add the slider to the layout. node.AddToLayout(new Slider(0, 0, 10, 2, new SliderStyle() { Wall = WallID.AmberGemsparkOff, WallColor = PaintID.White })); } if (false) { // Set up the grid configuration. Specify that it has to fill all the cells automatically. // Two columns (right size of 15, left - everything else) and two lines, occupying the same amount of space. node.SetupGrid( new ISize[] { new Relative(100), new Absolute(15) }, // Размеры колонок new ISize[] { new Relative(50), new Relative(50) }, // Размеры линий null, true); // In the top left cell (at the intersection of the first column and the first line), set the background color to orange. node[0, 0].Style.WallColor = PaintID.DeepOrange; // At the top right, we put a sapphire (blue) wall without paint. node[1, 0].Style.Wall = WallID.SapphireGemspark; node[1, 0].Style.WallColor = PaintID.None; // In the bottom left cell, you can place the Label widget with the SandStoneSlab block. // Although the coordinates and sizes are specified as 0, they will automatically be // set, since the object is in the Grid. node[0, 1] = new Label(0, 0, 0, 0, "testing", null, new LabelStyle() { Tile = TileID.SandStoneSlab, TileColor = PaintID.Red, TextColor = PaintID.Black }); } if (false) { // Install a large and complex grid. node.SetupGrid(new ISize[] { new Absolute(3), new Relative(50), new Absolute(6), new Relative(50) }, new ISize[] { new Relative(20), new Absolute(5), new Relative(80) }); // Although we set the grid on the node, we can still add objects as before. // Add a button that draws the grid by pressing, and hides it when released. node.Add(new Button(3, 3, 10, 4, "show", null, new ButtonStyle() { WallColor = PaintID.DeepBlue, BlinkStyle = ButtonBlinkStyle.Full, TriggerStyle = ButtonTriggerStyle.Both }, (self, touch) => { if (touch.State == TouchState.Begin) { node.ShowGrid(); } else { node.Apply().Draw(); } })); } if (false) { // Add a label and immediately set Alignment.DownRight with indent 3 blocks to the right and 1 below. node.Add(new Label(0, 0, 16, 6, "test", new LabelStyle() { WallColor = PaintID.DeepPink })) .SetAlignmentInParent(Alignment.DownRight, new ExternalIndent() { Right = 3, Down = 1 }); } if (false) { // Let's make our node container the size of the root in width. node.SetFullSize(true, false); } node.SetupLayout(Alignment.Center, Direction.Down, Side.Center, null, 1, false); // VisualObject VisualObject obj = node.AddToLayout(new VisualObject(5, 5, 8, 4, null, new UIStyle() { Wall = WallID.AmethystGemspark, WallColor = PaintID.DeepPurple }, (self, touch) => TSPlayer.All.SendInfoMessage($"Relative: ({touch.X}, {touch.Y}); Absolute: ({touch.AbsoluteX}, {touch.AbsoluteY})"))); // VisualContainer //VisualContainer node2 = node.Add( // new VisualContainer(5, 5, 20, 10, null, new ContainerStyle() { WallColor = PaintID.Black }) //) as VisualContainer; // Label Label label = node.AddToLayout(new Label(15, 5, 19, 4, "some text", new LabelStyle() { WallColor = PaintID.DeepLime, TextColor = PaintID.DeepRed })) as Label; // Button Button button = node.AddToLayout(new Button(15, 5, 12, 4, "lol", null, new ButtonStyle() { WallColor = PaintID.DeepGreen, BlinkColor = PaintID.Shadow, TriggerStyle = ButtonTriggerStyle.TouchEnd }, (self, touch) => touch.Player().SendInfoMessage("You released lol button!"))) as Button; // Slider Slider slider = node.AddToLayout(new Slider(15, 5, 10, 2, new SliderStyle() { Wall = WallID.EmeraldGemspark, WallColor = PaintID.White, SeparatorColor = PaintID.Black, UsedColor = PaintID.DeepOrange }, new Input <int>(0, 0, (self, value, playerIndex) => TShock.Players[playerIndex].SendInfoMessage("Slider value: " + value)))) as Slider; // Checkbox Checkbox checkbox = node.AddToLayout(new Checkbox(15, 5, 2, new CheckboxStyle() { Wall = WallID.EmeraldGemspark, WallColor = PaintID.White, CheckedColor = PaintID.DeepRed }, new Input <bool>(false, false, (self, value, playerIndex) => TSPlayer.All.SendInfoMessage("Checkbox value: " + value)))) as Checkbox; // Separator Separator separator = node.AddToLayout(new Separator(6, new UIStyle() { Wall = 156, WallColor = PaintID.DeepRed })) as Separator; // InputLabel InputLabel input = node.AddToLayout(new InputLabel(15, 5, new InputLabelStyle() { Type = InputLabelType.All, TextUnderline = LabelUnderline.Underline, TextColor = PaintID.DeepRed, TextUnderlineColor = PaintID.Black // Этот параметр из LabelStyle }, new Input <string>("12345", "12345", (self, value, playerIndex) => TSPlayer.All.SendInfoMessage("InputLabel value: " + value)))) as InputLabel; // ItemRack ItemRack irack = node.AddToLayout(new ItemRack(15, 5, new ItemRackStyle() { Type = ItemID.LargeDiamond, Size = ItemSize.Biggest, Left = true })) as ItemRack; ItemRack irack2 = node.AddToLayout(new ItemRack(20, 5, new ItemRackStyle() { Type = ItemID.SnowmanCannon, Size = ItemSize.Smallest, Left = true })) as ItemRack; irack2.SetText("This is a snowman cannon."); // VisualSign VisualSign vsign = node.AddToLayout(new VisualSign(0, 0, "lmfao sosi(te pozhaluista)")) as VisualSign; VisualSign vsign2 = node.AddToLayout(new VisualSign(0, 0, "This is an example of what can happen " + "if you use signs in TUI without FakeManager (only $399!)." + "Text above would be empty. Even tho it has to have it...")) as VisualSign; // FormField FormField ffield = node.AddToLayout(new FormField( new Checkbox(0, 0, 2, new CheckboxStyle() { Wall = WallID.AmberGemspark, WallColor = PaintID.White, CheckedColor = PaintID.DeepRed }), 15, 5, 20, 2, "check me", new LabelStyle() { TextColor = PaintID.Shadow, TextAlignment = Alignment.Left }, new ExternalIndent() { Right = 1 })) as FormField; // Image Image image = node.AddToLayout(new Image(15, 5, "Media\\Image.TEditSch")) as Image; // Video Video video = node.AddToLayout(new Video(15, 5, null, new VideoStyle() { Path = "Media\\Animation-1", Delay = 100, TileColor = PaintID.DeepTeal }, (self, touch) => (self as Video).ToggleStart())) as Video; // AlertWindow Button alertButton = node.AddToLayout(new Button(15, 10, 16, 4, "alert", null, new ButtonStyle() { Wall = WallID.AmberGemspark, WallColor = PaintID.DeepOrange }, (self, touch) => node.Root.Alert("Hello world"))) as Button; // ConfirmWindow Button confirmButton = node.AddToLayout(new Button(15, 13, 20, 4, "confirm\npls", null, new ButtonStyle() { Wall = WallID.AmberGemspark, WallColor = PaintID.DeepTeal }, (self, touch) => node.Root.Confirm("Very nice", value => TSPlayer.All.SendInfoMessage("Confirmed? " + value)))) as Button; // ScrollBackground // <Adding a lot of widgets to layout> // Specifying layer value as Int32.MinValue so that this widget would be under all other child objects, // although ScrollBackground specifies this layer by default in custructor so we don't have to do it manually. ScrollBackground scrollbg = node.Add(new ScrollBackground(true, true, true), Int32.MinValue) as ScrollBackground; // ScrollBar ScrollBar scrollbar = node.Add(new ScrollBar(Direction.Right)) as ScrollBar; // Arrow Arrow arrow = node.AddToLayout(new Arrow(15, 5, new ArrowStyle() { TileColor = PaintID.DeepBlue, Direction = Direction.Left })) as Arrow; }
public void AddInputLabel(InputLabel inputLabel) { InputLabel = inputLabel; }
public string GetResult() { return(InputLabel.GetResult() + LabelGroupLabel.GetResult()); }