private static bool SwitchControls(PanelReplacement control, bool up) { var U2 = ((PanelReplacement)control.Parent); var F = ((FormulaEditor)U2.Parent); if (F == null) { return(false); } //get index of this item var index = getI(U2, control.Name); if ((index == 0 && up) || (index == U2.Controls.Count - 1 && up == false)) { return(false); } var newindex = index; if (up) { newindex--; } else { newindex++; } ListExtras.Swap(ref F.formulas, index, newindex); U2.SwitchControlLocations(index, newindex); return(true); }
public static void Deserialise(List <Formula> fl, ref PanelReplacement PU) { PU.ClearControls(); var F = ((FormulaEditor)PU.Parent); F.formulas.Clear(); var controlcount = 0; foreach (var f in fl) { var f2 = FormulaEditor.addline(ref PU, f.type, f.subtype); //set the last panel formulas name to match var subcontrolcount = 0; foreach (var s in f.Operations) { var X = PU.GetControlStack()[controlcount].Controls[subcontrolcount]; while (FormulaEditor.isUsableControl(X) == false) { subcontrolcount++; X = PU.GetControlStack()[controlcount].Controls[subcontrolcount]; } //we need to manually add the item to the combo box item list, or it wont be loaded - wtf lel if (X is ComboBox && ((ComboBox)X).Items.Contains(s) == false) { ((ComboBox)X).Items.Add(s); } PU.GetControlStack()[controlcount].Controls[subcontrolcount].Text = s; subcontrolcount++; } F.formulas.Add(f2); controlcount++; } }
private static void AddPresetNHOperation(ref PanelReplacement PU) { addLabel("from current pixel diameter:", ref PU); addNumbers(ref PU, new List <int> { 1, 2, 5 }); addLabel("take the", ref PU); var cb = new ComboBox(); cb.Items.Add(Calculations.MeanAverage); cb.Items.Add(Calculations.MedianAverage); cb.DropDownStyle = ComboBoxStyle.DropDownList; cb.SelectedIndex = 0; PU.AddControl(cb, true); addLabel("from", ref PU); addvariablesCB(ref PU, true); addLabel("from", ref PU); varlocation(ref PU); addLabel("to", ref PU); addvariablesCB(ref PU); }
public static void createGamePanel(gamepanel gp) { PanelReplacement p = gp.gamep; game g = game.games[game.games.Count - 1]; gp.Name = game.games.Count.ToString(); //store these so we can hide solo squares surrounded by hidden areas var blacksquares = new List <PanelReplacement>(); p.Controls.Clear(); int width = g.width; int height = g.height; int count = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { //black square blacksquares.Add(addSquare(p, false)); addLine(g.boxes[y][x].lineup, p, count++, true, false); if (x == (width - 1)) { blacksquares.Add(addSquare(p, true)); } } for (int x = 0; x < width; x++) { addLine(g.boxes[y][x].lineleft, p, count++, false, false); addSquareArea(g.boxes[y][x].thisBox, p); if (x == (width - 1)) { addLine(g.boxes[y][x].lineright, p, count++, false, true); } } if (y == (height - 1)) { for (int x = 0; x < width; x++) { //black square blacksquares.Add(addSquare(p, false)); addLine(g.boxes[y][x].linedown, p, count++, true, false); if (x == (width - 1)) { blacksquares.Add(addSquare(p, true)); } } } } PanelReplacement.FitPanel(p, p, 40, 0); gp.panel1.Location = new Point(0, gp.gamep.Location.Y + gp.gamep.Height + 5); PanelReplacement.FitPanel(gp.gameboardresize, gp.gameboardresize); }
private static void addIfPosConditionLine(ref PanelReplacement PU) { addLabel(Calculations.Ifposcondition, ref PU); var CB = new ComboBox(); CB.Items.Add(Calculations.XPOS); CB.Items.Add(Calculations.YPOS); CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); CB = new ComboBox(); CB.Items.Add(Calculations.PosPercent); CB.Items.Add(Calculations.PosPixels); CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); addLabel("is", ref PU); addComparisons(ref PU); var TB = new TextBox(); TB.KeyPress += handlenumbersinput; PU.AddControl(TB, true); addLabel("then...", ref PU); }
private static void addCommentLine(ref PanelReplacement PU) { var TB = new TextBox(); TB.Width = 600; PU.AddControl(TB, true); }
private static void addPassLine(ref PanelReplacement PU) { addLabel("The following will only be executed on pass number:", ref PU); addNumbers(ref PU, new List <int> { 1, 2, 3 }); }
private static void addEndIfConditionLine(ref PanelReplacement PU) { var CB = new ComboBox(); CB.Items.Add(Calculations.Endifcondition); CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); }
private static PanelReplacement addSquare(PanelReplacement p, bool last) { var P = new PanelReplacement(); P.Width = horizh; P.Height = horizh; P.BackColor = inbetweensquare; p.AddControl(P, !last); return(P); }
public static void PanelMD(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } dragging = ((PanelReplacement)((Panel)sender).Parent); dragparent = dragging.Parent as PanelReplacement; IsDragging = true; }
private static void addMoveLine(ref PanelReplacement PU) { addLabel("move", ref PU); //source addvariablesCB(ref PU); addLabel("to", ref PU); //destination addvariablesCB(ref PU); }
private static void addclosebutton(ref PanelReplacement PU) { var B = new Button(); ObjectExtras.AddToolTip(B, "Click here to remove this formula"); B.Click += B_Click; B.Text = "X"; B.Size = new Size(20, 20); B.BackColor = Color.Red; B.ForeColor = Color.White; PU.AddControl(B, true); }
private static void addMoveArrows(ref PanelReplacement PU) { var P = new Panel(); P.Size = new Size(PU.Height, PU.Height); P.BackgroundImageLayout = ImageLayout.Center; P.BackgroundImage = gripimage; P.Cursor = Cursors.SizeAll; P.MouseDown += PanelMD; P.MouseUp += PanelMU; P.MouseMove += P_MouseMove; PU.AddControl(P, true); }
public void setoperations(ref PanelReplacement PU) { var retop = new List <string>(); foreach (Control C in PU.Controls) { if (FormulaEditor.isUsableControl(C)) { retop.Add(C.Text); } } Operations = retop; }
private static void addComparisons(ref PanelReplacement PU) { var CB = new ComboBox(); CB.Items.Add(Calculations.LTop); CB.Items.Add(Calculations.LEop); CB.Items.Add(Calculations.EQop); CB.Items.Add(Calculations.GEop); CB.Items.Add(Calculations.GTop); CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); }
private static void addOperations(ref PanelReplacement PU) { //pixel operations var CB = new ComboBox(); CB.Items.Add(Calculations.Subtractop); CB.Items.Add(Calculations.Addop); CB.Items.Add(Calculations.Multiplyop); CB.Items.Add(Calculations.Divideop); CB.Items.Add(Calculations.Modulusop); CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); }
private static void varlocation(ref PanelReplacement PU, bool addall = true) { var CB = new ComboBox(); CB.Items.Add(Calculations.RedOP); CB.Items.Add(Calculations.GreenOP); CB.Items.Add(Calculations.BlueOP); if (addall) { CB.Items.Add(Calculations.AllOP); } CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); }
private static void addvariablesCB(ref PanelReplacement PU, bool noVariables = false) { var add = Calculations.GetVarList(noVariables); var CB = new ComboBox(); foreach (var s in add) { CB.Items.Add(s); } CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.SelectedIndex = 0; PU.AddControl(CB, true); }
private static void addNumbers(ref PanelReplacement PU, List <int> possibilities) { var CB = new ComboBox(); foreach (var i in possibilities) { CB.Items.Add(i.ToString()); } if (CB.Items.Count > 0) { CB.SelectedIndex = 0; } PU.AddControl(CB, true); }
private static void addMatrixEditorButton(ref PanelReplacement PU, Control textField = null) { var B = new Button(); //ObjectUpdates.addToolTip(B, "Click here to edit matrix using editor"); B.Click += B_Click2; B.Text = "?"; B.Size = new Size(20, 20); //B.BackColor = Color.; //B.ForeColor = Color.White; if (textField != null) { B.Tag = textField.Name; } PU.AddControl(B, true); }
private static int getI(PanelReplacement U2, String name) { var index = -1; var count = 0; foreach (Control C in U2.Controls) { if (C.Name.Equals(name)) { index = count; break; } count++; } return(index); }
private static void AddVarPixelOperationline(ref PanelReplacement PU) { addLabel("from", ref PU); addvariablesCB(ref PU); addOperations(ref PU); addvariablesCB(ref PU); varlocation(ref PU); addLabel("to", ref PU); addvariablesCB(ref PU); }
private static void addSwapLine(ref PanelReplacement PU) { addLabel("move", ref PU); //source addvariablesCB(ref PU); varlocation(ref PU, false); addLabel("to", ref PU); //destination addvariablesCB(ref PU); varlocation(ref PU); }
private static Control addStrings(ref PanelReplacement PU, List <String> possibilities) { var CB = new ComboBox(); foreach (var i in possibilities) { CB.Items.Add(i); } if (CB.Items.Count > 0) { CB.SelectedIndex = 0; } PU.AddControl(CB, true); return(CB); }
private static void addLabel(String textl, ref PanelReplacement PU) { var L = new Label(); L.Text = textl; //L.Size = new System.Drawing.Size(10, 10); if (L.Text.Length < 10) { L.Size = new Size(7 * L.Text.Length, 20); } else { L.Size = new Size(5 * L.Text.Length, 20); } L.AutoSize = true; PU.AddControl(L, true); }
private static void addIfConditionLine(ref PanelReplacement PU) { addLabel(Calculations.Ifcolcondition, ref PU); addvariablesCB(ref PU); addLabel("value", ref PU); varlocation(ref PU); addLabel("is", ref PU); addComparisons(ref PU); var TB = new TextBox(); TB.KeyPress += handlenumbersinput; PU.AddControl(TB, true); addLabel("then...", ref PU); }
private static void AddUserPixelOperationline(ref PanelReplacement PU) { addLabel("from", ref PU); addvariablesCB(ref PU); addOperations(ref PU); var TB = new TextBox(); TB.KeyPress += handlefloatinput; PU.AddControl(TB, true); addLabel("from", ref PU); varlocation(ref PU); addLabel("to", ref PU); addvariablesCB(ref PU); }
private static void AddCustomNHOperation(ref PanelReplacement PU) { addLabel("Apply Matrix:", ref PU); //serialised matrix, rows separated by . var C = addStrings(ref PU, new List <String> { "", Calculations.Custom1, Calculations.Custom2, Calculations.Custom3 }); //matrix editor button addMatrixEditorButton(ref PU, C); addLabel("from", ref PU); addvariablesCB(ref PU, true); addLabel("from", ref PU); varlocation(ref PU); addLabel("to", ref PU); addvariablesCB(ref PU); }
private static void addLine(area a, PanelReplacement p, int count, bool horiz, bool last) { var P = new PanelReplacement(); P.Tag = a; if (a.isAreaUsedInGame) { P.BorderWidth = 1; P.BorderColour = defaultcolourline; P.BackColor = Color.White; } else { P.BackColor = defaultcolorlinedisabled; } P.MouseClick += P_MouseClick; if (horiz) { P.Width = horizw; P.Height = horizh; a.refpanel = P; p.AddControl(P, !last); } else { P.Width = horizh; P.Height = horizw; a.refpanel = P; p.AddControl(P, !last); } if (a.isAreaUsedInGame) { a.parents[0].parent.lines.Add(a); } }
private static void addSquareArea(area a, PanelReplacement p) { var P = new PanelReplacement(); P.Tag = a; if (a.isAreaUsedInGame) { P.BorderWidth = 1; P.BorderColour = defaultcolourbox; P.BackColor = Color.White; } else { P.BackColor = defaultcolorboxdisabled; } P.MouseClick += P_MouseClick; P.Width = horizw; P.Height = horizw; a.refpanel = P; p.AddControl(P, true); }