Exemple #1
0
        public void SetTabControlComparer(Control control, TabControlComparer tabControlComparer)
        {
            control.ThrowIfNull("control");
            tabControlComparer.ThrowIfNull("tabControlComparer");

            _controlOverrides[control] = tabControlComparer;
        }
Exemple #2
0
        /// <summary>
        /// Invokes asynchronously the specified action for this control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="action">The action.</param>
        public static void BeginInvoke(Control control, Action action)
        {
            control.ThrowIfNull("control");
            action.ThrowIfNull("action");
            if (!control.Created || control.IsDisposed || !control.IsHandleCreated) return;

            control.BeginInvoke(action);
        }
Exemple #3
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="owner">A <see cref="T:System.Windows.Forms.Control" /> representing the control that owns the control collection.</param>
            /// <exception cref="System.ArgumentException">Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.;owner</exception>
            /// <exception cref="System.ArgumentNullException">owner</exception>
            public PageControlCollection(Control owner)
                : base(owner)
            {
                // Should not happen
                owner.ThrowIfNull(nameof(owner), "Tried to create a MultiPanelPage.ControlCollection with a null owner.");

                // Should not happen
                MultiPanelPage c = owner as MultiPanelPage;
                if (c == null)
                {
                    throw new ArgumentException(
                        @"Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.", nameof(owner));
                }
            }
Exemple #4
0
        /// <summary>
        /// Invokes the specified action for this control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="action">The action.</param>
        public static void Invoke(Control control, Action action)
        {
            control.ThrowIfNull("control");
            action.ThrowIfNull("action");
            if (!control.Created || control.IsDisposed || !control.IsHandleCreated) return;

            try
            {
                control.Invoke(action);
            }
            catch (ObjectDisposedException ex)
            {
                logger.LogError("Control {0} disposed while trying to process an Invoke on it".InvariantFormat(control.Name));
                logger.LogException(ex);
            }
            catch (InvalidOperationException ioe)
            {
                logger.LogError("Invalid operation exception triggered by {0} control while trying to invoke".InvariantFormat(control.Name));
                logger.LogException(ioe);
            }
        }
Exemple #5
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="owner">A <see cref="T:System.Windows.Forms.Control" /> representing the control that owns the control collection.</param>
            /// <exception cref="System.ArgumentException">Tried to create a MultiPanelPagesCollection with a non-MultiPanel owner.;owner</exception>
            /// <exception cref="System.ArgumentNullException">owner</exception>
            public MultiPanelPagesCollection(Control owner)
                : base(owner)
            {
                owner.ThrowIfNull(nameof(owner), "Tried to create a MultiPanelPagesCollection with a null owner.");

                m_owner = owner as MultiPanel;
                if (m_owner == null)
                {
                    throw new ArgumentException("Tried to create a MultiPanelPagesCollection with a non-MultiPanel owner.",
                        "owner");
                }
            }
Exemple #6
0
            /// <summary>
            /// Adds an array of pages
            /// </summary>
            /// <param name="controls"></param>
            /// <exception cref="System.ArgumentNullException">controls</exception>
            public override void AddRange(Control[] controls)
            {
                controls.ThrowIfNull(nameof(controls));

                foreach (MultiPanelPage p in controls)
                {
                    Add(p);
                }
            }
Exemple #7
0
            /// <summary>
            /// Adds a page.
            /// </summary>
            /// <param name="value">The <see cref="T:System.Windows.Forms.Control" /> to add to the control collection.</param>
            /// <exception cref="System.ArgumentNullException">value</exception>
            /// <exception cref="System.ArgumentException">Tried to add a non-MultiPanelPage control to the MultiPanelPagesCollection;value</exception>
            public override void Add(Control value)
            {
                value.ThrowIfNull(nameof(value), "Tried to add a null value to the MultiPanelPagesCollection.");

                MultiPanelPage p = value as MultiPanelPage;
                if (p == null)
                {
                    throw new ArgumentException("Tried to add a non-MultiPanelPage control to the MultiPanelPagesCollection",
                        "value");
                }

                p.SendToBack();
                base.Add(p);
            }
Exemple #8
0
        /// <summary>
        /// Sets the extended style.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="exStyle">The ex style.</param>
        /// <exception cref="System.ArgumentNullException">control</exception>
        public static void SetExtendedStyle(Control control, ListViewExtendedStyles exStyle)
        {
            control.ThrowIfNull(nameof(control));

            ListViewExtendedStyles styles =
                (ListViewExtendedStyles)NativeMethods.SendMessage(control.Handle, (int)ListViewMessages.GetExtendedStyle,
                                                                  IntPtr.Zero, IntPtr.Zero);
            styles |= exStyle;
            NativeMethods.SendMessage(control.Handle, (int)ListViewMessages.SetExtendedStyle, IntPtr.Zero, (IntPtr)styles);
        }
Exemple #9
0
        /// <summary>
        /// Enables the double buffer.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <exception cref="System.ArgumentNullException">control</exception>
        public static void EnableDoubleBuffer(Control control)
        {
            control.ThrowIfNull(nameof(control));

            // read current style
            ListViewExtendedStyles styles =
                (ListViewExtendedStyles)NativeMethods.SendMessage(control.Handle, (int)ListViewMessages.GetExtendedStyle,
                                                                  IntPtr.Zero, IntPtr.Zero);

            // enable double buffer and border select
            styles |= ListViewExtendedStyles.DoubleBuffer | ListViewExtendedStyles.BorderSelect;
            // write new style
            NativeMethods.SendMessage(control.Handle, (int)ListViewMessages.SetExtendedStyle, IntPtr.Zero, (IntPtr)styles);
        }
Exemple #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="container">The container whose tab order we manage.</param>
        public TabOrderManager(Control container)
        {
            container.ThrowIfNull("container");

            _mainContainer = container;
        }
Exemple #11
0
            /// <summary>
            /// Adds an item to the control. Ensures it is a <see cref="MultiPanelPage" />.
            /// </summary>
            /// <param name="value">The <see cref="T:System.Windows.Forms.Control" /> to add to the control collection.</param>
            /// <exception cref="System.ArgumentException">Tried to add a MultiPanelPage control to the MultiPanelPage.ControlCollection.;value</exception>
            /// <exception cref="System.ArgumentNullException">value</exception>
            public override void Add(Control value)
            {
                value.ThrowIfNull(nameof(value), "Tried to add a null value to the MultiPanelPage.ControlCollection.");

                MultiPanelPage p = value as MultiPanelPage;
                if (p != null)
                {
                    throw new ArgumentException("Tried to add a MultiPanelPage control to the MultiPanelPage.ControlCollection.",
                        "value");
                }

                base.Add(value);
            }