/// <summary>
 /// Overridden. Inherited from <see cref="ControlDesigner.Initialize( IComponent )"/>.
 /// </summary>
 /// <param name="component">
 /// The <see cref="IComponent"/> hosted by the designer.
 /// </param>
 public override void Initialize(IComponent component)
 {
     _page = component as MultiPanelPage;
     if (_page == null)
         DisplayError(new Exception("You attempted to use a MultiPanelPageDesigner with a class that does not inherit from MultiPanelPage."));
     base.Initialize(component);
 }
Esempio n. 2
0
            /// <summary>
            /// </summary>
            public ControlCollection(Control owner)
                : base(owner)
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner", "Tried to create a MultiPanelPage.ControlCollection with a null owner.");
                }
                MultiPanelPage c = owner as MultiPanelPage;

                if (c == null)
                {
                    throw new ArgumentException("Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.", "owner");
                }
            }
Esempio n. 3
0
            /// <summary>
            /// </summary>
            public override void Add(Control value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("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);
            }
Esempio n. 4
0
        public override void Add(Control value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("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);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes the component.
        /// </summary>
        private void InitializeComponent(bool fillMode)
        {
            // Some fill must initialize before begin
            _colorTable = new[]
            {
                Color.FromArgb(0xff, 0, 0), Color.FromArgb(0xff, 0x80, 0x17),
                Color.FromArgb(0xff, 0xf7, 0x0), Color.FromArgb(0, 0xe8, 0),
                Color.FromArgb(0x19, 0x77, 0xff), Color.FromArgb(0xfc, 0x0c, 0x59),
                Color.FromArgb(0xff, 0xff, 0xff), Color.FromArgb(0, 0, 0)
            };

            _isBasic = true;

            _mpnMain = new MultiPanel();
            // Basic initialize
            _pgeBasic           = new MultiPanelPage();
            _tlpBasic           = new TableLayoutPanel();
            _llbSwitchAdvance   = new LinkLabel();
            _tlpBasicColorTable = new TableLayoutPanel();

            _csbColor = new ColorSelectorButton[8];

            _tlpBasicSizeBar = new TableLayoutPanel();
            _tkbBasicSize    = new MetroTrackBar();
            _lbBasicSize     = new Label();
            _btnNoFillBasic  = new MetroButton();
            // Advance initialize
            _pgeAdvance         = new MultiPanelPage();
            _tlpAdvance         = new TableLayoutPanel();
            _llbSwitchBasic     = new LinkLabel();
            _tlpColorSelector   = new TableLayoutPanel();
            _clrWheel           = new ColorWheel();
            _colorEditor        = new ColorEditor();
            _colorEditorManager = new ColorEditorManager();
            _cbxPenStyle        = new ComboBox();
            _tlpAdvanceSizeBar  = new TableLayoutPanel();
            _tkbAdvanceSize     = new MetroTrackBar();
            _txtSize            = new TextBox();
            _btnNoFillAdvance   = new MetroButton();

            _mpnMain.SuspendLayout();
            // Basic suspend layout
            _pgeBasic.SuspendLayout();
            _tlpBasic.SuspendLayout();
            _tlpBasicColorTable.SuspendLayout();
            if (!fillMode)
            {
                _tlpBasicSizeBar.SuspendLayout();
            }
            // Advance suspend layout
            _pgeAdvance.SuspendLayout();
            _tlpAdvance.SuspendLayout();
            _tlpColorSelector.SuspendLayout();

            if (!fillMode)
            {
                _tlpAdvanceSizeBar.SuspendLayout();
            }

            SuspendLayout();
            //
            // mpnMain
            //
            _mpnMain.BackColor = Color.Transparent;
            _mpnMain.Controls.Add(_pgeBasic);
            _mpnMain.Controls.Add(_pgeAdvance);
            _mpnMain.Dock         = DockStyle.Fill;
            _mpnMain.Location     = new Point(0, 0);
            _mpnMain.Margin       = new Padding(3, 4, 3, 4);
            _mpnMain.Name         = "_mpnMain";
            _mpnMain.SelectedPage = _pgeBasic;
            _mpnMain.Size         = new Size(210, 198);
            _mpnMain.TabIndex     = 0;
            //
            // pgeBasic
            //
            _pgeBasic.BackColor = Color.Transparent;
            _pgeBasic.Controls.Add(_tlpBasic);
            _pgeBasic.Dock     = DockStyle.Fill;
            _pgeBasic.Location = new Point(0, 0);
            _pgeBasic.Margin   = new Padding(3, 4, 3, 4);
            _pgeBasic.Name     = "_pgeBasic";
            _pgeBasic.Size     = new Size(210, 198);
            _pgeBasic.TabIndex = 0;
            _pgeBasic.Text     = @"Basic";
            //
            // tlpBasic
            //
            _tlpBasic.BackColor   = Color.Transparent;
            _tlpBasic.ColumnCount = 1;
            _tlpBasic.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            _tlpBasic.Controls.Add(_llbSwitchAdvance, 0, 0);
            _tlpBasic.Controls.Add(_tlpBasicColorTable, 0, 1);
            if (fillMode)
            {
                _tlpBasic.Controls.Add(_btnNoFillBasic, 0, 2);
            }
            else
            {
                _tlpBasic.Controls.Add(_tlpBasicSizeBar, 0, 2);
            }
            _tlpBasic.Dock     = DockStyle.Fill;
            _tlpBasic.Location = new Point(0, 0);
            _tlpBasic.Margin   = new Padding(3, 4, 3, 4);
            _tlpBasic.Name     = "_tlpBasic";
            _tlpBasic.RowCount = 3;
            _tlpBasic.RowStyles.Add(new RowStyle());
            _tlpBasic.RowStyles.Add(new RowStyle(SizeType.Absolute, 120F));
            _tlpBasic.RowStyles.Add(new RowStyle(SizeType.Absolute, 26F));
            _tlpBasic.Size     = new Size(210, 198);
            _tlpBasic.TabIndex = 0;
            //
            // llbSwitchAdvance
            //
            _llbSwitchAdvance.LinkColor = Color.FromArgb(1, 123, 205);
            _llbSwitchAdvance.Location  = new Point(3, 0);
            _llbSwitchAdvance.Name      = @"_llbSwitchAdvance";
            _llbSwitchAdvance.Size      = new Size(204, 24);
            _llbSwitchAdvance.TabIndex  = 0;
            _llbSwitchAdvance.TabStop   = true;
            _llbSwitchAdvance.Text      = @"Advance";
            _llbSwitchAdvance.TextAlign = ContentAlignment.MiddleCenter;
            _llbSwitchAdvance.Click    += _llbSwitchAdvance_Click;
            //
            // tlpBasicColorTable
            //
            _tlpBasicColorTable.ColumnCount = 4;
            _tlpBasicColorTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
            _tlpBasicColorTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
            _tlpBasicColorTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
            _tlpBasicColorTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
            _tlpBasicColorTable.Dock     = DockStyle.Fill;
            _tlpBasicColorTable.Location = new Point(10, 34);
            _tlpBasicColorTable.Margin   = new Padding(10);
            _tlpBasicColorTable.Name     = "_tlpBasicColorTable";
            _tlpBasicColorTable.RowCount = 2;
            _tlpBasicColorTable.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
            _tlpBasicColorTable.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
            _tlpBasicColorTable.Size     = new Size(190, 100);
            _tlpBasicColorTable.TabIndex = 1;


            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    //
                    // colorSelectorButton
                    //
                    int id = i * 4 + j;

                    _csbColor[id] = new ColorSelectorButton
                    {
                        BackColor = _colorTable[id],
                        Dock      = DockStyle.Fill,
                        Location  = new Point(10, 10),
                        Margin    = new Padding(10),
                        Name      = string.Format("csbColor{0}", id),
                        Size      = new Size(27, 30),
                        TabIndex  = id,
                        Text      = string.Format("Color{0}", id),
                        UseVisualStyleBackColor = true,
                    };
                    _csbColor[id].Click += ColorSizeControl_Click;

                    _tlpBasicColorTable.Controls.Add(_csbColor[id], j, i);
                }
            }
            if (fillMode)
            {
                //
                // btnNoFillBasic
                //
                _btnNoFillBasic.BackColor  = Color.White;
                _btnNoFillBasic.Dock       = DockStyle.Fill;
                _btnNoFillBasic.HoverColor = Color.FromArgb(230, 230, 230);
                _btnNoFillBasic.Location   = new Point(15, 230);
                _btnNoFillBasic.Margin     = new Padding(15);
                _btnNoFillBasic.Name       = "_btnNoFillBasic";
                _btnNoFillBasic.PressColor = Color.FromArgb(77, 77, 77);
                _btnNoFillBasic.Size       = new Size(180, 30);
                _btnNoFillBasic.TabIndex   = 4;
                _btnNoFillBasic.Text       = @"No Fill";
                _btnNoFillBasic.UseVisualStyleBackColor = false;
                _btnNoFillBasic.Click += NoFillButton_Click;
            }
            else
            {
                //
                // tlpBasicSizeBar
                //
                _tlpBasicSizeBar.ColumnCount = 2;
                _tlpBasicSizeBar.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                _tlpBasicSizeBar.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
                _tlpBasicSizeBar.Controls.Add(_tkbBasicSize, 0, 0);
                _tlpBasicSizeBar.Controls.Add(_lbBasicSize, 1, 0);
                _tlpBasicSizeBar.Dock     = DockStyle.Fill;
                _tlpBasicSizeBar.Location = new Point(15, 159);
                _tlpBasicSizeBar.Margin   = new Padding(15);
                _tlpBasicSizeBar.Name     = "_tlpBasicSizeBar";
                _tlpBasicSizeBar.RowCount = 1;
                _tlpBasicSizeBar.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
                _tlpBasicSizeBar.Size     = new Size(180, 24);
                _tlpBasicSizeBar.TabIndex = 2;
                //
                // tkbSize
                //
                _tkbBasicSize.Dock     = DockStyle.Fill;
                _tkbBasicSize.Location = new Point(3, 3);
                _tkbBasicSize.Name     = @"_tkbBasicSize";
                _tkbBasicSize.Size     = new Size(124, 18);
                _tkbBasicSize.TabIndex = 0;
                _tkbBasicSize.Text     = @"metroTrackBar1";
                // synchronize trackbar mutualy
                var synTrkBasic = new TrackBarSync(_tkbBasicSize, _lbBasicSize);
                synTrkBasic.Add(_tkbAdvanceSize);
                synTrkBasic.ValueChanged += synTrackBar_ValueChanged;

                _tkbBasicSize.Value = (int)_selectedWidth;

                //
                // lbSize
                //
                _lbBasicSize.Dock      = DockStyle.Fill;
                _lbBasicSize.Location  = new Point(133, 0);
                _lbBasicSize.Name      = @"_lbBasicSize";
                _lbBasicSize.Size      = new Size(44, 24);
                _lbBasicSize.TabIndex  = 1;
                _lbBasicSize.Text      = ConvertWidthToString(_selectedWidth);
                _lbBasicSize.TextAlign = ContentAlignment.MiddleCenter;
            }
            //
            // _pgeAdvance
            //
            _pgeAdvance.Controls.Add(_tlpAdvance);
            _pgeAdvance.Dock     = DockStyle.Fill;
            _pgeAdvance.Location = new Point(0, 0);
            _pgeAdvance.Margin   = new Padding(3, 4, 3, 4);
            _pgeAdvance.Name     = "_pgeAdvance";
            _pgeAdvance.Size     = new Size(210, 275 + 26);
            _pgeAdvance.TabIndex = 1;
            _pgeAdvance.Text     = @"_pgeAdvance";
            //
            // _tlpAdvance
            //
            _tlpAdvance.BackColor   = Color.Transparent;
            _tlpAdvance.ColumnCount = 1;
            _tlpAdvance.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            _tlpAdvance.Controls.Add(_llbSwitchBasic, 0, 0);
            _tlpAdvance.Controls.Add(_tlpColorSelector, 0, 1);
            if (fillMode)
            {
                _tlpAdvance.Controls.Add(_btnNoFillAdvance, 0, 2);
            }
            else
            {
                _tlpAdvance.Controls.Add(_tlpAdvanceSizeBar, 0, 2);
                _tlpAdvance.Controls.Add(_cbxPenStyle, 0, 3);
            }
            _tlpAdvance.Dock     = DockStyle.Fill;
            _tlpAdvance.Location = new Point(0, 0);
            _tlpAdvance.Margin   = new Padding(3, 4, 3, 4);
            _tlpAdvance.Name     = "_tlpAdvance";
            _tlpAdvance.RowCount = 4;
            _tlpAdvance.RowStyles.Add(new RowStyle(SizeType.Absolute, 25F));
            _tlpAdvance.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
            _tlpAdvance.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
            if (!fillMode)
            {
                _tlpAdvance.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F));
            }

            _tlpAdvance.Size     = new Size(210, 275 + 26);
            _tlpAdvance.TabIndex = 1;
            //
            // _llbSwitchBasic
            //
            _llbSwitchBasic.Dock      = DockStyle.Fill;
            _llbSwitchBasic.LinkColor = Color.FromArgb(1, 123, 205);
            _llbSwitchBasic.Location  = new Point(3, 0);
            _llbSwitchBasic.Name      = "_llbSwitchBasic";
            _llbSwitchBasic.Size      = new Size(204, 25);
            _llbSwitchBasic.TabIndex  = 0;
            _llbSwitchBasic.TabStop   = true;
            _llbSwitchBasic.Text      = @"Basic";
            _llbSwitchBasic.TextAlign = ContentAlignment.MiddleCenter;
            _llbSwitchBasic.Click    += _llbSwitchBasic_Click;
            //
            // _tlpColorSelector
            //
            _tlpColorSelector.ColumnCount = 1;
            _tlpColorSelector.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            _tlpColorSelector.Controls.Add(_clrWheel, 0, 0);
            _tlpColorSelector.Controls.Add(_colorEditor, 0, 1);
            _tlpColorSelector.Dock     = DockStyle.Fill;
            _tlpColorSelector.Location = new Point(3, 28);
            _tlpColorSelector.Name     = "_tlpColorSelector";
            _tlpColorSelector.RowCount = 2;
            _tlpColorSelector.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
            _tlpColorSelector.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));
            _tlpColorSelector.Size     = new Size(204, 184);
            _tlpColorSelector.TabIndex = 3;
            //
            // _clrWheel
            //
            _clrWheel.Color    = _selectedColor;
            _clrWheel.Dock     = DockStyle.Fill;
            _clrWheel.Location = new Point(3, 3);
            _clrWheel.Name     = "_clrWheel";
            _clrWheel.Size     = new Size(198, 138);
            _clrWheel.TabIndex = 0;

            //
            // _colorEditor
            //
            _colorEditor.Color    = _selectedColor;
            _colorEditor.Dock     = DockStyle.Fill;
            _colorEditor.TabIndex = 1;

            //
            // colorEditorManager
            //
            _colorEditorManager.ColorEditor   = _colorEditor;
            _colorEditorManager.ColorWheel    = _clrWheel;
            _colorEditorManager.ColorChanged += ColorEditorManager_ColorChanged;

            if (fillMode)
            {
                //
                // btnNoFillAdvance
                //
                _btnNoFillAdvance.BackColor  = Color.White;
                _btnNoFillAdvance.Dock       = DockStyle.Fill;
                _btnNoFillAdvance.HoverColor = Color.FromArgb(230, 230, 230);
                _btnNoFillAdvance.Location   = new Point(15, 230);
                _btnNoFillAdvance.Margin     = new Padding(15);
                _btnNoFillAdvance.Name       = "_btnNoFillAdvance";
                _btnNoFillAdvance.PressColor = Color.FromArgb(77, 77, 77);
                _btnNoFillAdvance.Size       = new Size(180, 30);
                _btnNoFillAdvance.TabIndex   = 4;
                _btnNoFillAdvance.Text       = @"No Fill";
                _btnNoFillAdvance.UseVisualStyleBackColor = false;
                _btnNoFillAdvance.Click += NoFillButton_Click;
            }
            else
            {
                //
                // _tlpAdvanceSizeBar
                //
                _tlpAdvanceSizeBar.ColumnCount = 2;
                _tlpAdvanceSizeBar.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                _tlpAdvanceSizeBar.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
                _tlpAdvanceSizeBar.Controls.Add(_tkbAdvanceSize, 0, 0);
                _tlpAdvanceSizeBar.Controls.Add(_txtSize, 1, 0);
                _tlpAdvanceSizeBar.Dock     = DockStyle.Fill;
                _tlpAdvanceSizeBar.Location = new Point(15, 230);
                _tlpAdvanceSizeBar.Margin   = new Padding(15);
                _tlpAdvanceSizeBar.Name     = "_tlpAdvanceSizeBar";
                _tlpAdvanceSizeBar.RowCount = 1;
                _tlpAdvanceSizeBar.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
                _tlpAdvanceSizeBar.Size     = new Size(180, 30);
                _tlpAdvanceSizeBar.TabIndex = 2;
                //
                // _tkbAdvanceSize
                //
                _tkbAdvanceSize.Dock     = DockStyle.Fill;
                _tkbAdvanceSize.Location = new Point(3, 3);
                _tkbAdvanceSize.Name     = "_tkbAdvanceSize";
                _tkbAdvanceSize.Size     = new Size(124, 24);
                _tkbAdvanceSize.TabIndex = 0;
                _tkbAdvanceSize.Text     = @"tkbAdvanceSize";
                // synchronize trackbar mutualy
                var synTrkAdvance = new TrackBarSync(_tkbAdvanceSize, _txtSize);
                synTrkAdvance.Add(_tkbBasicSize);
                synTrkAdvance.ValueChanged += synTrackBar_ValueChanged;

                _tkbAdvanceSize.Value = (int)_selectedWidth;

                //
                // _txtSize
                //
                _txtSize.Dock             = DockStyle.Fill;
                _txtSize.Location         = new Point(133, 3);
                _txtSize.Name             = "_txtSize";
                _txtSize.Text             = ConvertWidthToString(_selectedWidth);
                _txtSize.Size             = new Size(44, 25);
                _txtSize.TabIndex         = 1;
                _txtSize.CausesValidation = true;
                _txtSize.Validating      += _txtSize_Validating;
                //
                // _cbxPenStyle
                //
                _cbxPenStyle.Dock = DockStyle.Fill;
                _cbxPenStyle.FormattingEnabled = true;
                _cbxPenStyle.DataSource        = Enum.GetValues(typeof(DashStyle));
                _cbxPenStyle.Location          = new Point(3, 4);
                _cbxPenStyle.Margin            = new Padding(15, 0, 15, 0);
                _cbxPenStyle.Name                  = "_cbxPenStyle";
                _cbxPenStyle.Size                  = new Size(172, 25);
                _cbxPenStyle.TabIndex              = 2;
                _cbxPenStyle.SelectedIndex         = 0;
                _cbxPenStyle.SelectedIndexChanged += PenStyle_SelectedIndexChanged;
            }
            //
            // This Control
            //
            BackColor = Color.White;
            Controls.Add(_mpnMain);
            Font   = new Font("Segoe UI Light", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 0);
            Margin = new Padding(3, 4, 3, 4);
            Name   = "ColorToolControl";
            Size   = new Size(210, 198);
            _mpnMain.ResumeLayout(false);
            // Basic Resume Layout
            _pgeBasic.ResumeLayout(false);
            _tlpBasic.ResumeLayout(false);
            _tlpBasicColorTable.ResumeLayout(false);
            if (!fillMode)
            {
                _tlpBasicSizeBar.ResumeLayout(false);
            }
            // Advance Resume Layout
            _pgeAdvance.ResumeLayout(false);
            _tlpAdvance.ResumeLayout(false);
            _tlpColorSelector.ResumeLayout(false);
            if (!fillMode)
            {
                _tlpAdvanceSizeBar.ResumeLayout(false);
                _tlpAdvanceSizeBar.PerformLayout();
            }
            ResumeLayout(false);
        }