Example #1
0
        private void UserPixelOperation(Formula f)
        {
            //op 0 is from variable
            var from = GetFrom(f.Operations[0]);

            //op1 is the subsub operation
            var op = f.Operations[1];

            //op2 is the amount

            //op3 is R/G/B/ALL
            var vartype = f.Operations[3];

            //op4 is the dest
            PixelOperation(from, float.Parse(f.Operations[2]), op, vartype, f.Operations[4]);
        }
Example #2
0
        private void VarPixelOperation(Formula f)
        {
            //op 0 is from variable
            var from = GetFrom(f.Operations[0]);

            //op1 is the subsub operation
            var op = f.Operations[1];

            //op2 is the amount
            var from2 = GetFrom(f.Operations[2]);

            //op3 is R/G/B/ALL
            var vartype = f.Operations[3];

            //op4 is the dest
            PixelOperation(from, from2.R,from2.G,from2.B, op, vartype, f.Operations[4]);
        }
Example #3
0
        private void PresetNHoperation(Formula f)
        {
            //op 0 is the diameter
            var diam = int.Parse(f.Operations[0]);

            //op 1 is the subsub op (eg mean)
            var mean = false;
            var median = false;
            if (f.Operations[1].Equals(MeanAverage))
                mean = true;
            else if (f.Operations[1].Equals(MedianAverage))
                median = true;

            //op 2 is from
            var fromS = f.Operations[2];

            //op 3 is the var type/r/g/b/all
            var vartype = f.Operations[3];

            //op 4 is the dest
            var toS = f.Operations[4];
            if (mean)
                PerformMeanAverage(diam, fromS, vartype, toS);
            if (median)
                PerformMedianAverage(diam, fromS, vartype, toS);
        }
Example #4
0
        private void SwapOperation(Formula f)
        {
            //param 0 is from loc
            var from = GetFrom(f.Operations[0]);

            //param 1 is from var
            var op = f.Operations[1];
            var tot = 0;
            if (op.Equals(Calculations.RedOP))
                tot += from.R;
            else if (op.Equals(Calculations.GreenOP))
                tot += from.G;
            else if (op.Equals(Calculations.BlueOP))
                tot += from.B;
            else if (op.Equals(Calculations.AllOP))
                tot += from.R + from.G + from.B;

            //param 2 is to loc

            //param 3 is to var
            var op2 = f.Operations[3];
            var to = GetFrom(f.Operations[2]);
            if (op2.Equals(Calculations.RedOP))
                to = Color.FromArgb(tot, to.G, to.B);
            else if (op2.Equals(Calculations.GreenOP))
                to = Color.FromArgb(to.R,tot,to.B);
            else if (op2.Equals(Calculations.BlueOP))
                to = Color.FromArgb(to.R, to.G,tot);
            else if (op2.Equals(Calculations.AllOP))
                to = Color.FromArgb(tot,tot,tot);

            SetTo(f.Operations[2], to);
        }
Example #5
0
        private void MoveOperation(Formula f)
        {
            //param 0 is FROM

            //param 1 is TO

            var from = GetFrom(f.Operations[0]);
            SetTo(f.Operations[1], from);
        }
Example #6
0
 private int passOperation(Formula f)
 {
     return int.Parse(f.Operations[0]);
 }
Example #7
0
        private void IfPosCondition(Formula f)
        {
            //op 0 = position type 1

            //op 1 = position type 2
            var loc = 0;
            var locstr = f.Operations[0];
            var locstr2 = f.Operations[1];
            if (locstr.Equals(XPOS)&&locstr2.Equals(PosPixels))
                loc = x;
            else if (locstr.Equals(YPOS)&&locstr2.Equals(PosPixels))
                loc = y;
            else if (locstr.Equals(XPOS)&&locstr2.Equals(PosPercent))
                loc = (int)(((float)x / (float)I.maxw) * 100.0);
            else if (locstr.Equals(YPOS)&&locstr2.Equals(PosPercent))
                loc = (int)(((float)y / (float)I.maxh) * 100.0);

            //op 2 = comparison type

            //op 3 = value

            var am = int.Parse(f.Operations[3]);

            ifstack.Add(DoIfComparison(loc, f.Operations[2], am));
        }
Example #8
0
        private void IfCondition(Formula f)
        {
            //op 0 is variable
            var from = GetFrom(f.Operations[0]);

            //op 1 is  R/G/B/ALL

            //op 2 is the operation

            //op 3 is the value
            var am = int.Parse(f.Operations[3]);

            ifstack.Add(DoIfColComparison(from, f.Operations[1], f.Operations[2], am));
        }
Example #9
0
        private void CustNHoperation(Formula f)
        {
            //apply matrix [12321] [?] from [ALL]  from [cOUT] to [cOUT]
            //op 0 is the matrix
            //var custform = storedCustomFormulas[f.ID];

            //op 1 is the from loc

            //op 2 is the var type

            //op 3 is the to loc

            PerformCustomMatrixOP(f.ID, f.Operations[2], f.Operations[1], f.Operations[3]);
        }
Example #10
0
        public static List<Formula> Deserialise(String filename)
        {
            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 = st.ToList();

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

            Formula f = null;
            var listf = new List<Formula>();
            var count2 = 0;
            while (count < ops.Count)
            {
                //FSTART = new formula
                if (ops[count].Equals("FSTART"))
                {
                    infunc = true;
                    count2 = 0;
                }
                else if (ops[count].Equals("FEND"))
                {
                    infunc = false;
                    listf.Add(f);
                }

                else if (infunc)
                {
                    if (count2 == 1)
                    {
                        f = new Formula(ops[count], ops[count + 1]);
                    }
                    else if (count2 > 2)
                        f.Operations.Add(ops[count]);
                }
                count++;
                count2++;
            }
            return listf;
        }
Example #11
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;
        }