Beispiel #1
0
        /*
         * StoreFormState
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="formToStore"/> is <see langword="null"/>.
        /// </exception>
        public void StoreFormState(Form formToStore)
        {
            if (formToStore == null)
            {
                throw new ArgumentNullException("formToStore");
            }

            NuGenFormStateDescriptor stateDescriptor = new NuGenFormStateDescriptor();

            stateDescriptor.BackColor = formToStore.BackColor;
            stateDescriptor.Padding   = formToStore.Padding;

            ControlStyles[] formControlStyles = NuGenEnum.ToArray <ControlStyles>();
            Debug.Assert(formControlStyles != null, "formControlStyles != null");

            for (int i = 0; i < formControlStyles.Length; i++)
            {
                stateDescriptor.Styles.Add(
                    formControlStyles[i],
                    NuGenControlPaint.GetStyle(formToStore, formControlStyles[i])
                    );
            }

            Debug.Assert(this.StoredForms != null, "this.StoredForms != null");

            if (this.StoredForms.ContainsKey(formToStore))
            {
                this.StoredForms[formToStore] = stateDescriptor;
            }
            else
            {
                this.StoredForms.Add(formToStore, stateDescriptor);
            }
        }
Beispiel #2
0
        /*
         * RestoreFormState
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="formToRestore"/> is <see langword="null"/>.
        /// </exception>
        public void RestoreFormState(Form formToRestore)
        {
            if (formToRestore == null)
            {
                throw new ArgumentNullException("formToRestore");
            }

            Debug.Assert(this.StoredForms != null, "this.StoredForms != null");

            if (this.StoredForms.ContainsKey(formToRestore))
            {
                NuGenFormStateDescriptor stateDescriptor   = this.StoredForms[formToRestore];
                ControlStyles[]          formControlStyles = NuGenEnum.ToArray <ControlStyles>();

                for (int i = 0; i < formControlStyles.Length; i++)
                {
                    NuGenControlPaint.SetStyle(
                        formToRestore,
                        formControlStyles[i],
                        stateDescriptor.Styles[formControlStyles[i]]
                        );

                    formToRestore.BackColor = stateDescriptor.BackColor;
                    formToRestore.Padding   = stateDescriptor.Padding;
                }
            }
        }
 public void ToArrayTest()
 {
     DummyEnum[] elements = NuGenEnum.ToArray <DummyEnum>();
     Assert.AreEqual(3, elements.Length);
     Assert.AreEqual(DummyEnum.DummyElement, elements[0]);
     Assert.AreEqual(DummyEnum.DummyElement2, elements[1]);
     Assert.AreEqual(DummyEnum.DummyElement3, elements[2]);
 }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenAlignSelector"/> class.
        /// </summary>
        /// <param name="serviceProvider"><para>Requires:</para>
        ///		<para><see cref="INuGenButtonStateService"/></para>
        ///		<para><see cref="INuGenControlStateService"/></para>
        ///		<para><see cref="INuGenRadioButtonLayoutManager"/></para>
        ///		<para><see cref="INuGenRadioButtonRenderer"/></para>
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception>
        public NuGenAlignSelector(INuGenServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.SetStyle(ControlStyles.UserPaint, true);

            this.BackColor = Color.Transparent;

            _switchers = new List <Switcher>();

            _layoutPanel = new TableLayoutPanel();
            _layoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;

            for (int i = 0; i < 3; i++)
            {
                _layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.33f));
                _layoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 33.33f));
            }

            _layoutPanel.Dock   = DockStyle.Fill;
            _layoutPanel.Parent = this;

            ContentAlignment[] alignStyleCollection = NuGenEnum.ToArray <ContentAlignment>();

            int column = 0;
            int row    = 0;

            foreach (ContentAlignment alignStyle in alignStyleCollection)
            {
                Switcher switcher = new Switcher(serviceProvider, alignStyle);
                _switchers.Add(switcher);
                switcher.CheckedChanged += _switcher_CheckedChanged;
                _layoutPanel.Controls.Add(switcher, column, row);

                column++;

                if (column == 3)
                {
                    column = 0;
                    row++;
                }
            }

            this.SetAlignment(ContentAlignment.MiddleCenter);
        }
 public void ToArrayNullTest()
 {
     int[] elements = NuGenEnum.ToArray <int>();
 }
 public void ToArrayNullTest()
 {
     Int32[] elements = NuGenEnum.ToArray <Int32>();
 }