public void InputCount_ValueChanged(object sender) { int count = int.Parse("0" + ComponentValueInputCount.value); rootcomp.valuebox_length = count; for (int i = 0; i < labellist.Count; i++) { Features.ui_elements.Remove(labellist[i]); Features.ui_elements.Remove(inputlist[i]); } rootcomp.parameters.Clear(); inputlist.Clear(); labellist.Clear(); if (count > 0) { labellist.Add(new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, InputCount_Label), new Point(size.X / 2, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, "Input 0:")); inputlist.Add(new UI_ValueInput(new Pos(5, 0, ORIGIN.TR, ORIGIN.DEFAULT, labellist[0]), new Point(size.X / 2, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, 3, 12)); inputlist[0].ValueChanged += SetParameterLabels; rootcomp.parameters.Add(""); Features.Add_UI_Elements(labellist[0]); Features.Add_UI_Elements(inputlist[0]); for (int i = 1; i < count; i++) { UI_String newlabel = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, labellist[i - 1]), new Point(size.X / 2, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, "Input " + i.ToString() + ":"); labellist.Add(newlabel); UI_ValueInput newbox = new UI_ValueInput(new Pos(5, 0, ORIGIN.TR, ORIGIN.DEFAULT, labellist[i]), new Point(size.X / 2, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, 3, 12); inputlist.Add(newbox); inputlist[i].ValueChanged += SetParameterLabels; rootcomp.parameters.Add(""); Features.Add_UI_Elements(newlabel); Features.Add_UI_Elements(newbox); } } }
public UI_EditComp_Window(Pos pos, Point size, string title, Point minsize, Generic_Conf conf, bool IsResizeable) : base(pos, size, title, minsize, conf, IsResizeable) { UI_String spooky = new UI_String(new Pos(0), Point.Zero, conf, ""); UI_String Box_Name_Label = new UI_String(new Pos(bezelsize, bezelsize + headheight), Point.Zero, UI_Handler.genbutconf, "Name:"); UI_String Box_Category_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, Box_Name_Label), Point.Zero, UI_Handler.genbutconf, "Category: "); int longestLabelX = (int)(UI_Handler.genbutconf.font.MeasureString("Category: ").X); Box_Name = new UI_ValueInput(new Pos(longestLabelX, 0, ORIGIN.DEFAULT, ORIGIN.DEFAULT, Box_Name_Label), new Point(size.X / 3, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, 3, 24); Box_Name.ValueChanged += BoxName_ValueChange; Box_Category = new UI_ValueInput(new Pos(longestLabelX, 0, ORIGIN.DEFAULT, ORIGIN.DEFAULT, Box_Category_Label), new Point(size.X / 3, (int)(UI_Handler.genbutconf.font.MeasureString("Test").Y)), UI_Handler.genbutconf, 3, 24); Box_Category.ValueChanged += BoxCategory_ValueChange; Features = new UI_Scrollable <UI_Element>(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, Box_Category_Label), Point.Zero); UI_String SimCode_FuncName_Label = new UI_String(new Pos(5, 5), Point.Zero, UI_Handler.genbutconf, "SC Func. Name: "); //UI_String AfterSimCode_FuncName_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, SimCode_FuncName_Label), Point.Zero, UI_Handler.genbutconf, "PSC Func. Name: "); UI_String InternalState_Length_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, SimCode_FuncName_Label), Point.Zero, UI_Handler.genbutconf, "Int. State Length: "); UI_String ClickType_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, InternalState_Length_Label), Point.Zero, UI_Handler.genbutconf, "Click Type: "); int longestLabelX2 = (int)(UI_Handler.genbutconf.font.MeasureString("Int. State Length: ").X); Box_SimCode_FuncName = new UI_ValueInput(new Pos(longestLabelX2, 0, ORIGIN.DEFAULT, ORIGIN.DEFAULT, SimCode_FuncName_Label), new Point(size.X / 3, SimCode_FuncName_Label.size.Y), UI_Handler.genbutconf, 3, 24); //Box_AfterSimCode_FuncName = new UI_ValueInput(new Pos(longestLabelX2, 0, ORIGIN.DEFAULT, ORIGIN.DEFAULT, AfterSimCode_FuncName_Label), new Point(size.X / 3, AfterSimCode_FuncName_Label.size.Y), UI_Handler.genbutconf, 3, 24); Box_InternalState_Length = new UI_ValueInput(new Pos(longestLabelX2, 0, ORIGIN.DEFAULT, ORIGIN.DEFAULT, InternalState_Length_Label), new Point(size.X / 3, InternalState_Length_Label.size.Y), UI_Handler.genbutconf, 1, 24); Box_ClickType = new UI_ValueInput(new Pos(0, 0, ORIGIN.TR, ORIGIN.DEFAULT, ClickType_Label), new Point((int)(UI_Handler.genbutconf.font.MeasureString("00").X), InternalState_Length_Label.size.Y), UI_Handler.genbutconf, 1, 1); Code_Sim_Button = new UI_StringButton(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, ClickType_Label), new Point((int)(UI_Handler.buttonwidth * 1.8), UI_Handler.buttonheight), "Edit Sim Code", true, UI_Handler.genbutconf); //Code_AfterSim_Button = new UI_StringButton(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, Code_Sim_Button), new Point((int)(UI_Handler.buttonwidth * 2.4), UI_Handler.buttonheight), "Edit After-Sim Code", true, UI_Handler.genbutconf); rotbuttons = new UI_StringButton[8]; for (int i = 0; i < 8; ++i) { if (i == 0) { rotbuttons[i] = new UI_StringButton(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, Code_Sim_Button), new Point(25, 25), i.ToString(), true, UI_Handler.behave1conf); } else { rotbuttons[i] = new UI_StringButton(new Pos(5, 0, ORIGIN.TR, ORIGIN.DEFAULT, rotbuttons[i - 1]), new Point(25, 25), i.ToString(), true, UI_Handler.behave1conf); } rotbuttons[i].GotToggledLeft += RotButtonPressed; } rotbuttons[0].IsActivated = true; gridpaint = new UI_GridPaint(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, rotbuttons[0]), new Point(450), 300, new Point(150), new Point(-2, 6), UI_Handler.gridpaintbuttonconf); gridpaint.UpdateFunctions.Add(delegate() { if (new Rectangle(gridpaint.absolutpos, gridpaint.size).Contains(App.mo_states.New.Position)) { Features.DenyScroll = true; } }); gridpaint.PixelChanged += PixelChanged; paintbuttons = new UI_TexButton[5]; for (int i = 0; i < 5; ++i) { Generic_Conf curconf = new Generic_Conf(UI_Handler.gridpaintbuttonconf); curconf.tex_color = paintbuttoncols[i]; if (i == 0) { paintbuttons[i] = new UI_TexButton(new Pos(5, 0, ORIGIN.TR, ORIGIN.DEFAULT, gridpaint), new Point(25, 25), new Point(364, 0), UI_Handler.Button_tex, curconf); } else { paintbuttons[i] = new UI_TexButton(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, paintbuttons[i - 1]), new Point(25, 25), new Point(364, 0), UI_Handler.Button_tex, curconf); } paintbuttons[i].GotToggledLeft += PaintButtonPressed; } paintbuttons[0].IsActivated = true; overlaybutton = new UI_TexButton(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, paintbuttons[4]), new Point(25, 25), new Point(364, 0), UI_Handler.Button_tex, UI_Handler.gridpaintbuttonconf); overlaybutton.GotToggledLeft += OverlayButtonPressed; gridpaint.curplacetype = 1; UI_String OverlayTextBox_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, gridpaint), Point.Zero, UI_Handler.genbutconf, "Text for Overlay: "); OverlayTextBox = new UI_ValueInput(new Pos(0, ORIGIN.TR, ORIGIN.DEFAULT, OverlayTextBox_Label), new Point(size.X / 3, SimCode_FuncName_Label.size.Y), UI_Handler.genbutconf, 3, 24); InputCount_Label = new UI_String(new Pos(0, 5, ORIGIN.BL, ORIGIN.DEFAULT, OverlayTextBox_Label), Point.Zero, UI_Handler.genbutconf, "ParameterCount: "); ComponentValueInputCount = new UI_ValueInput(new Pos(0, ORIGIN.TR, ORIGIN.DEFAULT, InputCount_Label), new Point(size.X / 8, SimCode_FuncName_Label.size.Y), UI_Handler.genbutconf, 1, 2); parameterlabels = new List <string>(); Features.Add_UI_Elements(spooky, SimCode_FuncName_Label, Box_SimCode_FuncName, InternalState_Length_Label, Box_InternalState_Length, ClickType_Label, Box_ClickType, Code_Sim_Button); Features.Add_UI_Elements(rotbuttons); Features.Add_UI_Elements(gridpaint, OverlayTextBox_Label, OverlayTextBox); Features.Add_UI_Elements(paintbuttons); Features.Add_UI_Elements(overlaybutton); Features.Add_UI_Elements(InputCount_Label); Features.Add_UI_Elements(ComponentValueInputCount); Add_UI_Elements(Box_Name_Label, Box_Name, Box_Category_Label, Box_Category, Features); Code_Sim_Button.GotActivatedLeft += Code_Sim_Button_Pressed; //Code_AfterSim_Button.GotActivatedLeft += Code_AfterSim_Button_Pressed; Box_SimCode_FuncName.ValueChanged += Box_SimCode_FuncName_ValueChange; //Box_AfterSimCode_FuncName.ValueChanged += Box_AfterSimCode_FuncName_ValueChange; Box_InternalState_Length.ValueChanged += Box_InternalState_Length_ValueChange; Box_ClickType.ValueChanged += Box_ClickType_ValueChanged; OverlayTextBox.ValueChanged += Box_Overlay_ValueChanged; ComponentValueInputCount.ValueChanged += InputCount_ValueChanged; // Code Boxes CodeBox_Sim = new UI_TextBox(new Pos(0), new Point(250, 400), UI_Handler.gen_conf); //CodeBox_AfterSim = new UI_TextBox(new Pos(0), new Point(250, 400), UI_Handler.gen_conf); CodeBox_Sim.LostFocus += Code_Sim_LostFocus; //CodeBox_AfterSim.LostFocus += Code_AfterSim_LostFocus; UpdatePos(); Resize(); GetsUpdated = GetsDrawn = false; overlayCalc = new byte[300, 300]; }