private void PopulateTypes(Type[] types)
 {
     listBoxType.Items.Clear();
     listBoxType.Items.AddRange(types.Select(
                                    type => DataObjectEditor.GetHumanReadableField(type.Name))
                                .ToArray());
 }
        public DataObjectEditor(DataObjectEditor parent)
        {
            InitializeComponent();
            this.parent = parent;
            this.tableLayoutPanelFields.HorizontalScroll.Enabled = false;
            this.tableLayoutPanelFields.HorizontalScroll.Visible = false;
            this.classSelector = new ClassSelector();
            this.Collapsed     = false;

            OnObjectEdited += RefreshEditors;
        }
        private IWritableContext CreateRootContext()
        {
            DataObjectEditor parent = this;

            while (parent.parent != null)
            {
                parent = parent.parent;
            }
            Json.DataObject  root    = parent.DataObject;
            IWritableContext context = JsonSerializer.createContext(root);

            return(context);
        }
        private void UpdateSelectedListItem()
        {
            int  index   = listBoxList.SelectedIndex;
            bool enabled = index >= 0;

            this.buttonDelete.Enabled = this.buttonUp.Enabled = this.buttonDown.Enabled = enabled;
            if (!enabled)
            {
                Controls.Remove(nextEditor);
                return;
            }

            if (index == 0)
            {
                this.buttonUp.Enabled = false;
            }
            if (index == CurrentList.Count - 1)
            {
                this.buttonDown.Enabled = false;
            }
            if (listBoxList.SelectedIndices.Count > 1)
            {
                this.buttonUp.Enabled   = false;
                this.buttonDown.Enabled = false;
            }

            ObjectEditor.Json.DataObject obj = CurrentItem;
            if (nextEditor == null)
            {
                nextEditor                 = new DataObjectEditor(this);
                nextEditor.Anchor          = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
                nextEditor.Height          = Height;
                nextEditor.Holder          = this;
                nextEditor.OnObjectEdited += (sender, e) => OnItemEdited(e);
                nextEditor.Location        = new Point(groupBox.Width + 5, 0);
            }
            if (nextEditor.Parent == null)
            {
                this.Collapsed = true;
                Controls.Add(nextEditor);
            }
            if (AutoCollapse)
            {
                if (nextEditor.nextEditor == null || nextEditor.nextEditor.Parent == null)
                {
                    nextEditor.Collapsed = false;
                }
            }
            nextEditor.DataObject = obj;

            //Console.WriteLine(ParentForm.HorizontalScroll.Value);
            //Console.WriteLine(ParentForm.HorizontalScroll.Minimum + ", " + ParentForm.HorizontalScroll.Maximum);
            //int relX = listBoxList.FindForm().PointToClient(
            //    listBoxList.Parent.PointToScreen(listBoxList.Location)).X;
            //Console.WriteLine(relX);
            //Console.WriteLine(ParentForm.HorizontalScroll.Value);
            //int value = ParentForm.HorizontalScroll.Value + relX - 75;
            //ParentForm.HorizontalScroll.Value = Math.Max(ParentForm.HorizontalScroll.Minimum, Math.Min(ParentForm.HorizontalScroll.Maximum, value));
            //Console.WriteLine(value + " / " + ParentForm.HorizontalScroll.Value);
            //ParentForm.Refresh();
        }
 public NoScrollListBox(DataObjectEditor parentEditor)
 {
     this.parentEditor = parentEditor;
     this.DrawMode     = System.Windows.Forms.DrawMode.OwnerDrawVariable;
 }