Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!DesignMode)
            {
                DisplayHelper.AutoFitSystemCheckBox(chkPing, chkPing.Width, chkPing.Width);
                LayoutHelper.NaturalizeHeightAndDistribute(8, Controls);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            using (new AutoGrow(this, AnchorStyles.Right | AnchorStyles.Bottom, false))
            {
                // Fix up the Size group box
                using (new AutoGrow(groupBoxSize, AnchorStyles.Right, false))
                {
                    using (new AutoGrow(panelRowsAndColumns, AnchorStyles.Right, false))
                    {
                        DisplayHelper.AutoFitSystemLabel(labelRows, 0, int.MaxValue);
                        DisplayHelper.AutoFitSystemLabel(labelColumns, 0, int.MaxValue);
                        LayoutHelper.DistributeHorizontally(8, labelRows, numericTextBoxRows);
                        LayoutHelper.DistributeHorizontally(8, labelColumns, numericTextBoxColumns);
                        LayoutHelper.DistributeHorizontally(16,
                                                            new ControlGroup(labelRows, numericTextBoxRows),
                                                            new ControlGroup(labelColumns, numericTextBoxColumns));
                    }
                }

                // Fix up the Appearance group box
                using (new AutoGrow(groupBoxAppearance, AnchorStyles.Right | AnchorStyles.Bottom, false))
                {
                    DisplayHelper.AutoFitSystemCheckBox(checkBoxShowBorder, 0, int.MaxValue);
                    DisplayHelper.AutoFitSystemLabel(label1, 0, int.MaxValue);
                    DisplayHelper.AutoFitSystemLabel(label3, 0, int.MaxValue);
                    DisplayHelper.AutoFitSystemLabel(labelBorderPixels, 0, int.MaxValue);
                    DisplayHelper.AutoFitSystemLabel(labelPaddingPixels, 0, int.MaxValue);
                    DisplayHelper.AutoFitSystemLabel(labelSpacingPixels, 0, int.MaxValue);
                    LayoutHelper.DistributeHorizontally(
                        8,
                        new ControlGroup(checkBoxShowBorder, label1, label3),
                        new ControlGroup(numericTextBoxBorder, numericTextBoxCellPadding, numericTextBoxCellSpacing),
                        new ControlGroup(labelBorderPixels, labelPaddingPixels, labelSpacingPixels)
                        );
                }

                // Make the group boxes the same width
                int maxWidth = Math.Max(groupBoxAppearance.Width, groupBoxSize.Width);
                groupBoxAppearance.Width = maxWidth;
                groupBoxSize.Width       = maxWidth;
            }

            // Align the OK/Cancel
            ControlGroup okCancelGroup = new ControlGroup(buttonOK, buttonCancel);

            okCancelGroup.Left = groupBoxAppearance.Right - okCancelGroup.Width;
            LayoutHelper.FixupOKCancel(buttonOK, buttonCancel);
        }
Exemple #3
0
            public void PositionControl(Control c, int indentLevel)
            {
                int INDENT_MARGIN = ScaleX(16);

                c.Top  = _top;
                c.Left = _left + (INDENT_MARGIN * indentLevel);

                Graphics g = c.CreateGraphics();

                try
                {
                    int maxWidth = _maxWidth - SystemInformation.VerticalScrollBarWidth - c.Left - _left;
                    c.Width = maxWidth;
                    if (c is CheckBox)
                    {
                        DisplayHelper.AutoFitSystemCheckBox((CheckBox)c, 0, maxWidth);
                    }
                    else if (c is RadioButton)
                    {
                        DisplayHelper.AutoFitSystemRadioButton((RadioButton)c, 0, maxWidth);
                    }
                    else
                    {
                        Debug.Fail("Being asked to position a control that isn't a radiobutton or checkbox");
                    }
                    LayoutHelper.NaturalizeHeight(c);
                }
                finally
                {
                    g.Dispose();
                }
                _width = Math.Max(_width, c.Width);
                _controls.Add(c);

                _top = _top + c.Height + _margin;

                // enforce max height if necessary
                if (_enforcedMaxHeight == -1 && _top > _maxHeight)
                {
                    _enforcedMaxHeight = _top;
                }
            }
        protected override void OnLoad(EventArgs e)
        {
            Parent.Dock = DockStyle.Fill;

            Form form = FindForm();

            form.AcceptButton = buttonOK;
            form.CancelButton = buttonCancel;
            form.MinimumSize  = new Size(536, 320);
            form.ShowIcon     = false;
            //form.MaximizeBox = true;
            form.Closing += delegate
            {
                if (form.DialogResult == DialogResult.Cancel)
                {
                    originalState.Restore();
                    EditorContext.ApplyDecorator();
                }
                else
                {
                    // This forces the linked image to be updated as well
                    SaveSettingsAndApplyDecorator();
                }
            };

            base.OnLoad(e);

            if (EditorContext.EnforcedAspectRatio == null)
            {
                int width = cbAspectRatio.Left - lblAspectRatio.Right;

                DisplayHelper.AutoFitSystemLabel(lblAspectRatio, 0, int.MaxValue);

                DisplayHelper.AutoFitSystemCombo(cbAspectRatio, 0, int.MaxValue, false);
                buttonRotate.Width = buttonRotate.GetPreferredWidth();

                bool isButtonRotateVisible = buttonRotate.Visible;
                buttonRotate.Visible = true;
                LayoutHelper.DistributeHorizontally(width, lblAspectRatio, cbAspectRatio, buttonRotate);
                buttonRotate.Visible = isButtonRotateVisible;
                if (isButtonRotateVisible && (cbAspectRatio.Height + 2) > buttonRotate.Height)
                {
                    buttonRotate.Height = cbAspectRatio.Height + 2;
                }
            }
            else
            {
                lblAspectRatio.Visible       =
                    cbAspectRatio.Visible    =
                        buttonRotate.Visible = false;
            }

            DisplayHelper.AutoFitSystemCheckBox(chkGrid, 0, int.MaxValue);
            DisplayHelper.AutoFitSystemButton(btnRemoveCrop);
            LayoutHelper.FixupOKCancel(buttonOK, buttonCancel);
            chkGrid.Left = buttonCancel.Right - chkGrid.Width;

            panel1.Height        = Math.Max(buttonRotate.Bottom, cbAspectRatio.Bottom) + 3;
            imageCropControl.Top = panel1.Bottom;

            imageCropControl.Select();

            //int minWidth = buttonRotate.Right + width + (form.ClientSize.Width - buttonOK.Left) + SystemInformation.FrameBorderSize.Width * 2;
            //form.MinimumSize = new Size(minWidth, form.MinimumSize.Height);
        }