示例#1
0
        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);
        }
示例#2
0
        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++;
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        private static void addCommentLine(ref PanelReplacement PU)
        {
            var TB = new TextBox();

            TB.Width = 600;
            PU.AddControl(TB, true);
        }
示例#7
0
        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
            });
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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;
        }
示例#11
0
        private static void addMoveLine(ref PanelReplacement PU)
        {
            addLabel("move", ref PU);

            //source
            addvariablesCB(ref PU);

            addLabel("to", ref PU);

            //destination
            addvariablesCB(ref PU);
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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;
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }
示例#18
0
        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);
        }
示例#19
0
        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);
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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);
        }
示例#23
0
        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);
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        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);
        }
示例#27
0
        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);
        }
示例#28
0
        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);
        }
示例#29
0
        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);
            }
        }
示例#30
0
        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);
        }