Esempio n. 1
0
        public void ParseObjects()
        {
            Objects.Clear();
            CustomFields.Clear();

            List <String> Lines = new List <string>(File.ReadAllLines(".\\Custom.cfg", Encoding.UTF8));

            Lines.Add("");

            for (int i = 0; i < Lines.Count; i++)
            {
                String Line = Lines[i];
                if (SkipLine(Line))
                {
                    continue;
                }

                if (Line == "[Field]")
                {
                    FieldObject Obj = ParseFieldObject(Lines, ref i);
                    CustomFields.Add(Obj.CustomFieldName, new FOCommon.Items.ItemProtoCustomField(Obj.CustomFieldName,
                                                                                                  FOCommon.Utils.GetTypeFromString(Obj.DataType)));
                    AddObject(Obj);
                }
                else if (Line == "[Label]")
                {
                    AddObject(ParseLabelObject(Lines, ref i));
                }
                else if (Line == "[Common]")
                {
                    AddObject(ParseCommonObject(Lines, ref i));
                }
                else if (Line == "[CreateTab]")
                {
                    CreateTabPage(Lines, ref i);
                }
            }

            CustomInterpreter Interpreter = new CustomInterpreter();

            Interpreter.ProcessFields(Main, TabControlMain, CustomTabPages, Objects, g);
        }
Esempio n. 2
0
        public void ProcessFields(frmMain Main, TabControl MainTabControl, Dictionary <string, List <TabPage> > CustomTabPages, Dictionary <string, List <CustomUIObject> > Objects, Graphics g)
        {
            foreach (KeyValuePair <string, List <CustomUIObject> > kvp in Objects)
            {
                // This is the TabPage where these objects go to
                TabPage Page = GetCustomTabPage(Main, MainTabControl, CustomTabPages, kvp.Key);
                if (Page == null)
                {
                    continue;
                }

                InitEnvironment();

                foreach (CustomUIObject CObj in kvp.Value)
                {
                    int PosX = GetObjectValue(CObj.PosX, CommonPosX);
                    int PosY = GetObjectValue(CObj.PosY, CommonPosY);

                    Point Position = new Point(PosX, PosY);

                    if (CObj is LabelObject)
                    {
                        Page.Controls.Add(CreateLabelControl((LabelObject)CObj, Position));
                    }
                    else if (CObj is FieldObject)
                    {
                        FieldObject FObj = (FieldObject)CObj;
                        if (FObj.DataType == "bool")
                        {
                            Page.Controls.Add(CreateCheckBoxControl((FieldObject)CObj, Position));
                        }
                        else
                        {
                            // Label-->[Space]-->NumericControl
                            Page.Controls.Add(CreateLabelControl(CObj.Text, new Point(PosX, PosY), 0));
                            int Space = GetObjectValue(FObj.Space, CommonSpace);
                            Page.Controls.Add(CreateNumericControl(FObj, new Point(PosX + Space, PosY - 2)));
                        }
                    }
                    else if (CObj is CommonObject)
                    {
                        CommonObject IObj = (CommonObject)CObj;
                        IfNonZeroSet(IObj.Space, ref CommonSpace.Value);
                        IfNonZeroSet(IObj.IncX, ref IncX);
                        IfNonZeroSet(IObj.IncY, ref IncY);
                        IfNonZeroSet(IObj.Min, ref CommonMin.Value);
                        IfNonZeroSet(IObj.Max, ref CommonMax.Value);
                        IfNonZeroSet(IObj.Width, ref CommonWidth.Value);
                        IfNonZeroSet(IObj.PosX, ref CommonPosX);
                        IfNonZeroSet(IObj.PosY, ref CommonPosY);
                        IfNonZeroSet(IObj.ItemTab, ref CommonItemTab);
                    }

                    if (!(CObj is CommonObject))
                    {
                        CommonPosX += IncX;
                        CommonPosY += IncY;
                    }
                }
            }
        }
Esempio n. 3
0
        public FieldObject ParseFieldObject(List<String> Lines, ref int i)
        {
            FieldObject Obj = new FieldObject();
            do
            {
                ParseLine(Lines[i++]);
                Obj = (FieldObject)ParseCommonData(Obj);
                ParseData("FieldName", ref Obj.CustomFieldName);
                ParseData("DataType", ref Obj.DataType);

            } while (Lines[i] != "");
            return Obj;
        }
Esempio n. 4
0
 private NumericUpDown CreateNumericControl(FieldObject UIObject, Point Position)
 {
     NumericUpDown Num = new NumericUpDown();
     Num.Location = Position;
     Num.Minimum = GetObjectValue(UIObject.Min,   CommonMin);
     Num.Maximum = GetObjectValue(UIObject.Max,   CommonMax);
     Num.Width   = GetObjectValue(UIObject.Width, CommonWidth);
     Num.Tag = UIObject;
     return Num;
 }
Esempio n. 5
0
 private CheckBox CreateCheckBoxControl(FieldObject UIObject, Point Position)
 {
     CheckBox Chk = new CheckBox();
     Chk.Text = UIObject.Text;
     Chk.Location = new Point(Position.X, Position.Y);
     Chk.Tag = UIObject;
     return Chk;
 }