Exemple #1
0
        protected virtual void OnContentsResized(ContentsResizedEventArgs e)
        {
            ContentsResizedEventHandler eh = (ContentsResizedEventHandler)(Events[ContentsResizedEvent]);

            if (eh != null)
            {
                eh(this, e);
            }
        }
Exemple #2
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// contentsresizedeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this ContentsResizedEventHandler contentsresizedeventhandler, Object sender, ContentsResizedEventArgs e, AsyncCallback callback)
        {
            if (contentsresizedeventhandler == null)
            {
                throw new ArgumentNullException("contentsresizedeventhandler");
            }

            return(contentsresizedeventhandler.BeginInvoke(sender, e, callback, null));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MLifterTextBox"/> class.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-09-19</remarks>
        public MLifterTextBox()
        {
            AllowAnswerSubmit = true;
            BorderStyle = BorderStyle.None;
            Font = new System.Drawing.Font("MS Sans Serif", 14, System.Drawing.FontStyle.Bold);
            SelectionAlignment = HorizontalAlignment.Center;

            //ScrollBars = RichTextBoxScrollBars.ForcedVertical;

            AllowDrop = true;
            DragEnter += new DragEventHandler(MLifterTextBox_DragEnter);
            DragDrop += new DragEventHandler(MLifterTextBox_DragDrop);
            MouseDown += new MouseEventHandler(MLifterTextBox_MouseDown);
            Leave += new EventHandler(MLifterTextBox_Leave);
            ContentsResized += new ContentsResizedEventHandler(MLifterTextBox_ContentsResized);

            caseSensitive = false;
            correctOnTheFly = false;

            StripChars.Add("\n\r");
            StripChars.Add("\r\n");
            StripChars.Add("\n");
            //StripChars.Add(",");

            allowedControlChars.Clear();
            allowedControlChars.Add((char)Keys.Enter);
            allowedControlChars.Add((char)Keys.Back);
            allowedControlChars.Add((char)Keys.Space);
            allowedControlChars.Add((char)Keys.LineFeed);

            IgnoreChars = ".!?;,";
        }
Exemple #4
0
        /// <summary>
        /// Layouts sub-components
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void RecomputeSizes(object sender, EventArgs args)
        {
            rootPanel.HorizontalScroll.Maximum = 0;
            //exactly so (strange winform behaviour)
            rootPanel.AutoScroll = false;
            rootPanel.AutoScroll = true;

            //change splitPanel Sizes
            foreach (Control control in rootPanel.Controls)
            {
                SplitContainer split;
                if (control is SplitContainer)
                {
                    split = (SplitContainer)control;
                }
                else if (control is Panel)
                {
                    Panel panel = (Panel)control;
                    panel.Width = rootPanel.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight);
                    RecomputeComponentSize(panel);
                    continue;
                }
                else
                {
                    continue;
                }

                // change children of main level
                foreach (Control optionControl in split.Panel2.Controls)
                {
                    if (optionControl is GroupBox)
                    {
                        GroupBox groupBox = (GroupBox)optionControl;
                        groupBox.Width = split.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight);
                        foreach (Control groupControl in groupBox.Controls)
                        {
                            if (groupControl is Panel)
                            {
                                Panel panel = (Panel)groupControl;
                                panel.Width = groupBox.Width - (gbPaddingLeft + gbPaddingRight);
                                RecomputeComponentSize(panel);
                            }
                        }
                    }
                    else if (optionControl is RichTextBox)
                    {
                        // rtf boxes can be isolated
                        RichTextBox text = (RichTextBox)optionControl;
                        text.Width       = split.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight);
                        text.BorderStyle = BorderStyle.None;
                        text.ScrollBars  = RichTextBoxScrollBars.None;
                        var content = text.Rtf;
                        text.Text = String.Empty;
                        ContentsResizedEventHandler text_OnContentsResized = null;
                        text_OnContentsResized = delegate(object o, ContentsResizedEventArgs e) {
                            text.Height           = e.NewRectangle.Height;
                            text.ContentsResized -= text_OnContentsResized;
                        };
                        text.ContentsResized += text_OnContentsResized;
                        text.Rtf              = content;
                    }
                    else if (optionControl is Panel)
                    {
                        Panel panel = (Panel)optionControl;
                        panel.Width = split.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight);
                        RecomputeComponentSize(panel);
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Creates a foldable top-level grouping and it's children
        /// </summary>
        /// <param name="optionGroup"></param>
        private SplitContainer AddTopLevelOptionGroup(OptionGroup optionGroup)
        {
            SplitContainer splitContainer = new SplitContainer();

            splitContainer.Orientation = Orientation.Horizontal;
            splitContainer.BackColor   = Color.LightGray;
            splitContainer.Width       =
                rootPanel.Width - (rootPanel.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight + 100));
            splitContainer.IsSplitterFixed = true;

            var groupLabelButton =
                new Label()
            {
                Text = "▶ " + optionGroup.Label, BackColor = Color.Gray, ForeColor = Color.White, Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleLeft, AutoSize = false
            };

            groupLabelButton.Click += (sender, args) => {
                toggleHeaderCollapse(splitContainer);
            };
            splitContainer.Panel1.Click += (sender, args) => {
                toggleHeaderCollapse(splitContainer);
            };

            splitContainer.Panel1.Controls.Add(groupLabelButton);
            splitContainer.Panel1.BackColor = Color.Gray;
            splitContainer.Panel1.Size      = new Size(rootPanel.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight), 30);
            splitContainer.Panel1.AutoSize  = true;


            var Y = topLevelGroupPaddingTop;

            foreach (var option in (optionGroup).ChildOptions)
            {
                // a group containing more elements
                if (option.ComponentType == ComponentTypes.OptionGroup)
                {
                    var optionControl = CreateGroupBox(option as OptionGroup);
                    optionControl.Location = new Point(topLevelGroupPaddingLeft, Y);
                    splitContainer.Panel2.Controls.Add(optionControl);
                    Y += optionControl.Height;
                }
                else
                {
                    // single elements
                    var optionControl = CreateControl(option);
                    splitContainer.Panel2.Controls.Add(optionControl);
                    optionControl.Location = new Point(topLevelGroupPaddingLeft, Y);
                    Y += optionControl.Height;
                }
            }

            splitContainer.Panel2.BackColor = Color.White;
            splitContainer.Panel1MinSize    = 30;
            splitContainer.Panel2MinSize    = 1;
            splitContainer.Panel2.AutoSize  = true;

            splitContainer.FixedPanel       = FixedPanel.Panel1;
            splitContainer.SplitterDistance = 10;
            splitContainer.MinimumSize      = new Size(rootPanel.Width, 10);
            splitContainer.Size             = new Size(rootPanel.Width, 10);
            splitContainer.Panel2Collapsed  = true;

            if (optionGroup.Label == "Description")
            {
                if (splitContainer.Panel2.Controls[0] is RichTextBox)
                {
                    // rtf boxes can be isolated
                    RichTextBox text = (RichTextBox)splitContainer.Panel2.Controls[0];
                    text.Width       = rootPanel.Width - (topLevelGroupPaddingLeft + topLevelGroupPaddingRight);
                    text.BorderStyle = BorderStyle.None;
                    text.ScrollBars  = RichTextBoxScrollBars.None;
                    var content = text.Rtf;
                    text.Text = String.Empty;
                    ContentsResizedEventHandler text_OnContentsResized = null;
                    text_OnContentsResized = delegate(object o, ContentsResizedEventArgs args) {
                        text.Height           = args.NewRectangle.Height;
                        splitContainer.Height = topLevelGroupPaddingBottom + topLevelGroupPaddingTop + args.NewRectangle.Height;
                        text.ContentsResized -= text_OnContentsResized;
                    };
                    text.ContentsResized += text_OnContentsResized;
                    text.Rtf              = content;

                    toggleHeaderCollapse(splitContainer);
                }
            }
            return(splitContainer);
        }