예제 #1
0
        public static void CreateMatrix(int width, int height,Pieceboard.Chesstypes CT,PanelReplacement Grid)
        {
            if (Main!=null)
            {
                Main.clear();
                Main = null;
            }

            grid = Grid;
            Main= new Pieceboard(width, height) { Thistype = CT };
            Main.GridBlocked = new short[height][];
            for (var y = 0; y < height; y++)
            {
                Main.GridBlocked[y] = new short[width];
                for (var x = 0; x < width; x++)
                {
                    var TB = new Button();
                    TB.Size = new Size(20, 20);
                    TB.Click += piecechange;
                    TB.Name = GetName(x, y);
                    TB.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((0)));
                    grid.AddControl(TB, x != (width - 1));
                }
            }
            Main.GridPieces = MatrixOps.CreateMatrix<Pieceboard.Chesstypes>(width, height);
            ApplyColour();
        }
예제 #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
        public static Formula addline(ref PanelReplacement formulapanel, string type, string subtype)
        {
            var newPanel = new PanelReplacement();
            newPanel.BackColor = Color.FromArgb(200, 200, 200);
            newPanel.Size = new Size(formulapanel.Width, 25);

            //add move arrows
            addMoveArrows(ref newPanel);

            //operation
            if (type.Equals(Calculations.Moveoperation))
            {
                if (subtype.Equals(Calculations.Moveop))
                    addMoveLine(ref newPanel);
                else if (subtype.Equals(Calculations.Swapop))
                    addSwapLine(ref newPanel);
            }
            else if (type.Equals(Calculations.Operation))
            {
                if (subtype.Equals(Calculations.UserInputPixelOperation))
                    AddUserPixelOperationline(ref newPanel);
                else if (subtype.Equals(Calculations.VarInputPixelOperation))
                    AddVarPixelOperationline(ref newPanel);
                else if (subtype.Equals(Calculations.PresetNeighbourhoodOperations))
                    AddPresetNHOperation(ref newPanel);
                else if (subtype.Equals(Calculations.CustomNeighbourhoodOperations))
                    AddCustomNHOperation(ref newPanel);
            }
            else if (type.Equals(Calculations.Conditionoperation))
            {
                if (subtype.Equals(Calculations.Ifcolcondition))
                    addIfConditionLine(ref newPanel);
                else if (subtype.Equals(Calculations.Endifcondition))
                    addEndIfConditionLine(ref newPanel);
                else if (subtype.Equals(Calculations.Ifposcondition))
                    addIfPosConditionLine(ref newPanel);
            }
            else if (type.Equals(Calculations.Passoperation))
            {
                addPassLine(ref newPanel);
            }
            else if (type.Equals(Calculations.Commentop))
            {
                addCommentLine(ref newPanel);
            }
            //add remove button
            addclosebutton(ref newPanel);

            var C = formulapanel.AddControl(newPanel, false);
            var f = new Formula();
            f.type = type;
            f.subtype = subtype;
            f.ID = C.Name;

            //reset width here
            var last = newPanel.Controls[newPanel.Controls.Count - 1];
            newPanel.Size = new Size(last.Location.X + last.Width + 1, 25);
            return f;
        }
예제 #4
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public PanelReplacement Clone()
        {
            var O = new PanelReplacement();

            O.Width     = Width;
            O.Height    = Height;
            O.BackColor = BackColor;
            return(O);
        }
예제 #5
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 });
        }
예제 #6
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;
        }
예제 #7
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;
 }
예제 #8
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);
        }
예제 #9
0
 public static void InitPanel(PanelReplacement pu)
 {
     Grid.pu = pu;
 }
예제 #10
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;
 }
예제 #11
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);
        }
예제 #12
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;
        }
예제 #13
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);
 }
예제 #14
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);
 }
예제 #15
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);
        }
예제 #16
0
        private static void addMoveLine(ref PanelReplacement PU)
        {
            addLabel("move", ref PU);

            //source
            addvariablesCB(ref PU);

            addLabel("to", ref PU);

            //destination
            addvariablesCB(ref PU);
        }
예제 #17
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);
 }
예제 #18
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);
 }
예제 #19
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);
        }
예제 #20
0
 private static void ClearColours(PanelReplacement grid)
 {
     for (var y = 0; y < Main.Height; y++)
     {
         for (var x = 0; x < Main.Width; x++)
         {
             ApplyColourCell(x, y, false);
         }
     }
 }
예제 #21
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);
        }
예제 #22
0
        public static void Deserialise(String filename, ref PanelReplacement PU)
        {
            var FS = new FileStream(filename, FileMode.Open);
            var SR = new StreamReader(FS);
            var s = SR.ReadToEnd();
            SR.Close();
            FS.Close();

            var chs = new string[2];
            chs[0] = "\r\n";
            chs[1] = "\n";
            var st = s.Split(chs, StringSplitOptions.None);
            var ops = new List<string>();
            foreach (var str in st)
            {
                //if (String.IsNullOrEmpty(str) == false&&str.Equals("\r")==false&&str.Equals("\n")==false)
                ops.Add(str);
            }

            PU.ClearControls();
            var F = ((FormulaEditor) PU.Parent);
            F.formulas.Clear();

            //the input operation count
            var count = 0;
            var infunc = false;

            var controlcount = 0;
            var subcontrolcount = 0;
            Formula f = null;

            while (count < ops.Count)
            {
                //FSTART = new formula
                if (ops[count].Equals("FSTART"))
                {
                    subcontrolcount = 0;
                    f = FormulaEditor.addline(ref PU, ops[count + 1], ops[count + 2]);
                    infunc = true;
                    count += 2;
                }
                else if (ops[count].Equals("FEND"))
                {
                    infunc = false;
                    controlcount++;
                    F.formulas.Add(f);
                }

                else if (infunc)
                {
                    var X = PU.GetControlStack()[controlcount].Controls[subcontrolcount];
                    while (FormulaEditor.isUsableControl(X)==false)
                    {
                        subcontrolcount++;
                        X = PU.GetControlStack()[controlcount].Controls[subcontrolcount];
                    }
                    PU.GetControlStack()[controlcount].Controls[subcontrolcount].Text = ops[count];
                    subcontrolcount++;
                }
                count++;
            }
        }
예제 #23
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;
        }
예제 #24
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);
        }
예제 #25
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);
        }
예제 #26
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);
        }
예제 #27
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);
        }
예제 #28
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);
        }
예제 #29
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);
        }
예제 #30
0
 /// <summary>
 /// Clones this instance.
 /// </summary>
 /// <returns></returns>
 public PanelReplacement Clone()
 {
     var O = new PanelReplacement();
     O.Width = Width;
     O.Height = Height;
     O.BackColor = BackColor;
     return O;
 }
예제 #31
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);
 }