Ejemplo n.º 1
0
        public void GetSVarsCallback(object sender, GetSVarsEventArgs args)
        {
            _sVars = args.SVars;

            int off_y = 5;

            components.Clear();

            foreach (MarshalComponentParameter svar in _sVars)
            {
                var newLabel = new Label(svar.Family.ToString() + " : " + svar.Parameter.MemberName + " =  ", "CALIBRI",
                                         _resourceManager);
                newLabel.Update(0);

                newLabel.Position       = new Point(5, off_y);
                newLabel.DrawBorder     = true;
                newLabel.DrawBackground = true;

                GuiComponent newComp = CreateEditField(svar);
                newComp.Update(0);
                newComp.Position = new Point(newLabel.ClientArea.Right + 8, off_y);

                off_y += newLabel.ClientArea.Height + 5;

                components.Add(newLabel);
                components.Add(newComp);
            }
        }
Ejemplo n.º 2
0
        private void BuildPropList()
        {
            Type entType = assigned.GetType();

            fields =
                entType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                  BindingFlags.Static);
            int pos = 25;

            foreach (FieldInfo field in fields)
            {
                var    newEntry = new PropWindowStruct();
                object fieldVal = field.GetValue(assigned);

                if (fieldVal != null && fieldVal is ICollection)
                {
                    newEntry.VarName   = field.Name;
                    newEntry.LabelName = new Label(field.Name + " = " + (fieldVal == null ? "null" : ""), "CALIBRI",
                                                   _resourceManager);
                    newEntry.CanEdit    = false;
                    newEntry.IsListItem = false;

                    newEntry.LabelName.Position        = new Vector2i(5, pos);
                    newEntry.LabelName.DrawBorder      = true;
                    newEntry.LabelName.BorderColor     = new SFML.Graphics.Color(240, 255, 240);
                    newEntry.LabelName.BackgroundColor = new SFML.Graphics.Color(128, 128, 128);
                    newEntry.LabelName.DrawBackground  = true;
                    newEntry.LabelName.Update(0);

                    pos += 5 + newEntry.LabelName.ClientArea.Height;

                    components.Add(newEntry.LabelName);
                    ObjPropList.Add(newEntry);

                    newEntry = new PropWindowStruct();

                    foreach (object item in (ICollection)fieldVal)
                    {
                        newEntry.VarName = item.ToString();

                        newEntry.CanEdit    = true;
                        newEntry.IsListItem = true;
                        newEntry.ListItem   = item;

                        newEntry.LabelName                 = new Label(item.ToString(), "CALIBRI", _resourceManager);
                        newEntry.LabelName.Position        = new Vector2i(15, pos);
                        newEntry.LabelName.DrawBorder      = true;
                        newEntry.LabelName.BorderColor     = new SFML.Graphics.Color(0, 191, 255);
                        newEntry.LabelName.BackgroundColor = new SFML.Graphics.Color(128, 128, 128);
                        newEntry.LabelName.DrawBackground  = true;
                        newEntry.LabelName.Clicked        += LabelName_Clicked;
                        newEntry.LabelName.Update(0);

                        newEntry.LabelName.Text.Text = item.ToString();
                        newEntry.LabelName.Update(0);
                        pos += 5 + newEntry.LabelName.ClientArea.Height;

                        components.Add(newEntry.LabelName);
                        ObjPropList.Add(newEntry);
                    }
                }
                else
                {
                    newEntry.VarName = field.Name;

                    newEntry.CanEdit    = !(field.IsInitOnly || field.IsLiteral);
                    newEntry.IsListItem = false;

                    newEntry.LabelName = new Label(field.Name + " = " + (fieldVal == null ? "null" : ""), "CALIBRI",
                                                   _resourceManager);
                    newEntry.LabelName.Position        = new Vector2i(5, pos);
                    newEntry.LabelName.DrawBorder      = true;
                    newEntry.LabelName.BorderColor     = newEntry.CanEdit ? new SFML.Graphics.Color(127, 255, 0) : new SFML.Graphics.Color(205, 92, 92);
                    newEntry.LabelName.BackgroundColor = new SFML.Graphics.Color(128, 128, 128);
                    newEntry.LabelName.DrawBackground  = true;
                    newEntry.LabelName.Clicked        += LabelName_Clicked;
                    newEntry.LabelName.Update(0);

                    GuiComponent edit = CreateEditField(fieldVal, field);
                    if (edit != null && newEntry.CanEdit)
                    {
                        edit.Position = new Vector2i(newEntry.LabelName.ClientArea.Right() + 5,
                                                     newEntry.LabelName.ClientArea.Top);
                        components.Add(edit);
                        edit.Update(0);
                        pos += newEntry.LabelName.ClientArea.Height > edit.ClientArea.Height
                                   ? 5 + newEntry.LabelName.ClientArea.Height
                                   : 5 + edit.ClientArea.Height;
                    }
                    else
                    {
                        newEntry.LabelName.Text.Text = field.Name + " = " +
                                                       (fieldVal == null ? "null" : fieldVal.ToString());
                        newEntry.LabelName.Update(0);
                        pos += 5 + newEntry.LabelName.ClientArea.Height;
                    }

                    components.Add(newEntry.LabelName);
                    ObjPropList.Add(newEntry);
                }
            }
        }