Пример #1
0
        private void SetFirstColumnWidth(float width, int level)
        {
            if (clientControl != null)
            {
                foreach (Control control in clientControl.Controls)
                {
                    DialogSectionControl sec = control as DialogSectionControl;
                    if (sec != null)
                    {
                        sec.SetFirstColumnWidth(width, 0);
                    }
                }
//        float oldwidth = clientControl.GetColumnWidths()[0];
                ColumnStyle style = new ColumnStyle(SizeType.Absolute);
                style.Width = width - level;
                //if(enclosure != null) {
                //  enclosure.Width += (int)(width - oldwidth);
                //}
                clientControl.ColumnStyles.Add(style);
                clientControl.Width = clientControl.PreferredSize.Width;
                if (enclosure != null)
                {
                    enclosure.Width = enclosure.PreferredSize.Width;
                    minWidth        = this.Width = enclosure.Width;
                }
                else
                {
                    minWidth = this.Width = clientControl.Width;
                }
                ColumnStyle style2 = new ColumnStyle(SizeType.Percent);
                style2.Width = 100;
//        clientControl.ColumnStyles.Add(style2);
            }
        }
Пример #2
0
 private float GetFirstColumnWidth()
 {
     if (clientControl != null)
     {
         float width = clientControl.GetColumnWidths()[0];
         foreach (Control control in clientControl.Controls)
         {
             DialogSectionControl sec = control as DialogSectionControl;
             if (sec != null)
             {
                 width = Math.Max(width, sec.GetFirstColumnWidth());
             }
         }
         return(width);
     }
     return(0);
 }
Пример #3
0
        public DialogSectionControl(DialogSectionControl parent,
                                    PropertyDescriptorCollection descriptors, PropertyDescriptor parentDesc, bool drawBox)
        {
            nested           = true;
            this.descriptors = descriptors;
            this.drawBox     = drawBox;
            this.title       = parentDesc.DisplayName;
            _registeredProxies.Add(new DescriptorProxy(descriptors));
            bindingSource         = _registeredProxies;
            this.parent           = parent;
            parent.StatusChanged += view_StatusChanged;
            itemFactory           = new ItemFactory(this);
            InitializeComponent();
//      if (clientControl != null) {
//        clientControl.Dock = DockStyle.Fill;
//      }
//
//      if (enclosure != null) {
//        enclosure.Dock = DockStyle.Fill;
//      }
//      this.PerformLayout();
        }
Пример #4
0
        private void CreateEditors()
        {
            SuspendLayout();
            PropertyModelView propertyModelView = _registeredViews[0];
            int nonemptyGroups = 0;

            foreach (PropertyDescriptor property in propertyModelView.GetProperties())
            {
                if (property.GetChildProperties().Count > 0)
                {
                    ++nonemptyGroups;
                }
            }

            if (nonemptyGroups < 2 || propertyModelView.SectionCount < 2)
            {
                bool drawBox = false;
                PropertyDescriptorCollection properties    = propertyModelView.GetProperties();
                DialogSectionControl         clientControl =
                    new DialogSectionControl(this, properties, drawBox, this.Title);
                topLevelControlMap[View.Handler.ID] = clientControl;
                this.Controls.Add(clientControl);
                sectionControl = clientControl;
                minHeight      = clientControl.PreferredSize.Height;
                minWidth       = clientControl.PreferredSize.Width;
                topControl     = clientControl;
            }
            else
            {
                TabControl multipleCategoryTabControl = new TabControl()
                {
                    Multiline = multiLine
                };
                if (multiLine)
                {
                    multipleCategoryTabControl.SizeMode = TabSizeMode.FillToRight;
                }
                Controls.Add(multipleCategoryTabControl);
                sectionControl = multipleCategoryTabControl;
                PropertyDescriptorCollection properties = propertyModelView.GetProperties();
                foreach (PropertyDescriptor property in properties)
                {
                    if (property.GetChildProperties().Count == 0)
                    {
                        continue;
                    }
                    string  category = property.Category;
                    string  name     = category.TrimStart('\r');
                    TabPage page     = new TabPage(name);
                    page.Name = name;
                    DialogSectionControl clientControl =
                        new DialogSectionControl(this, property.GetChildProperties(), property, false);
                    page.Controls.Add(clientControl);
                    topLevelControlMap[
                        ((PropertyModelView.OptionItemPropertyDescriptor)
                             ((PropertyModelView.OptionItemPropertyDescriptor)property).Owner).ID] = clientControl;
                    page.Dock = DockStyle.Fill;
                    multipleCategoryTabControl.TabPages.Add(page);
                    minHeight = Math.Max(minHeight, clientControl.Height);
                    minWidth  = Math.Max(minWidth, clientControl.PreferredSize.Width);
                }

                minWidth += 3;
                int tabSize = 0;
                if (multiLine)
                {
                    for (int i = 0; i < multipleCategoryTabControl.TabCount; ++i)
                    {
                        var rect = multipleCategoryTabControl.GetTabRect(i);
                        tabSize = Math.Max(tabSize, rect.Location.Y);
                    }
                }
                else
                {
                    tabSize = multipleCategoryTabControl.ItemSize.Height;
                }
                minHeight += tabSize + multipleCategoryTabControl.Margin.Vertical;

                multipleCategoryTabControl.Width  = minWidth;
                multipleCategoryTabControl.Height = minHeight;
                topControl = multipleCategoryTabControl;
                multipleCategoryTabControl.Dock = DockStyle.Fill;
            }

            ResumeLayout(false);
        }
Пример #5
0
            public Control AddItemControl(PropertyModelView.OptionItemPropertyDescriptor prop,
                                          TableLayoutPanel clientControl, int count)
            {
                System.Windows.Forms.Binding viewBinding;
                bool   span          = false;
                string bindingTarget = "Value";

                Control inputControl = prop.GetAttribute(OptionItem.CUSTOM_DIALOGITEM_EDITOR) as Control;

                if (inputControl != null && inputControl is IDialogItemControl)
                {
                    span = true;
                }
                else
                {
                    Type editorType = prop.GetAttribute(OptionItem.CUSTOM_DIALOGITEM_EDITOR) as Type;
                    if (editorType != null)
                    {
                        Control c = System.Activator.CreateInstance(editorType) as Control;
                        if (c != null && c is IDialogItemControl)
                        {
                            inputControl = c;
                            span         = true;
                        }
                    }
                    else
                    {
                        //now build default editors
                        if (prop is PropertyModelView.OptionGroupPropertyDescriptor)
                        {
                            inputControl =
                                new DialogSectionControl(_enclosingInstance, prop.GetChildProperties(), prop, true);
                            span = true;
                            //don't bind...
                            bindingTarget = null;
                        }
                        else if (prop.Type == typeof(bool))
                        {
                            //checkbox for bools
                            inputControl = new CheckBoxWrapper();
                            bool supportUndefined =
                                (bool)prop.GetAttribute(OptionItem.SUPPORT_UNDEFINED_VALUE_ATTRIBUTE);
                            ((CheckBoxWrapper)inputControl).ThreeState = supportUndefined &&
                                                                         prop.GetValue(this) ==
                                                                         OptionItem.VALUE_UNDEFINED;
                        }
                        else
                        {
                            inputControl = new GenericValueEditor(prop);
                        }
                    }
                }
                inputControl.Size = inputControl.GetPreferredSize(new Size());

                clientControl.Controls.Add(inputControl, 1, count);
                _enclosingInstance.inputControls.Add(inputControl);
                inputControl.Anchor  = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top;
                inputControl.Enabled = prop.Enabled;


                if (span)
                {
                    clientControl.SetColumnSpan(inputControl, 2);
                }
                else
                {
                    Label inputLabel = new Label();
                    inputLabel.AutoSize  = true;
                    inputLabel.TextAlign = ContentAlignment.MiddleLeft;
                    inputLabel.Text      = prop.DisplayName + ":";

                    //todo: needs serious overhaul...
                    inputLabel.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
                    clientControl.Controls.Add(inputLabel, 0, count);
                }
                if (bindingTarget != null)
                {
                    viewBinding =
                        new System.Windows.Forms.Binding(bindingTarget,
                                                         _enclosingInstance.bindingSource, prop.Name, true,
                                                         DataSourceUpdateMode.OnPropertyChanged);

                    inputControl.DataBindings.Add(viewBinding);
                }
                return(inputControl);
            }
Пример #6
0
 public ItemFactory(DialogSectionControl _enclosingInstance)
 {
     this._enclosingInstance = _enclosingInstance;
 }