コード例 #1
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 Point(5, pos);
                    newEntry.LabelName.DrawBorder = true;
                    newEntry.LabelName.BorderColor = Color.Honeydew;
                    newEntry.LabelName.BackgroundColor = Color.Gray;
                    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 Point(15, pos);
                        newEntry.LabelName.DrawBorder = true;
                        newEntry.LabelName.BorderColor = Color.DeepSkyBlue;
                        newEntry.LabelName.BackgroundColor = Color.Gray;
                        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 Point(5, pos);
                    newEntry.LabelName.DrawBorder = true;
                    newEntry.LabelName.BorderColor = newEntry.CanEdit ? Color.Chartreuse : Color.IndianRed;
                    newEntry.LabelName.BackgroundColor = Color.Gray;
                    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 Point(newEntry.LabelName.ClientArea.Right + 5,
                                                  newEntry.LabelName.ClientArea.Y);
                        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);
                }
            }
        }
コード例 #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);
                }
            }
        }