예제 #1
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++;
            }
        }
예제 #2
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++;
            }
        }