Example #1
0
        /// Initialize Component
        private void InitializeItems()
        {
            //Initialize the components for the form design: add the title bar, buttons for maximized, minimized,
            //form options dropdown menu and the client area of the form*/
            components = new System.ComponentModel.Container();//initialize container

            #region -Control Instantiation

            pnlClientArea = new Panel();
            pnlTitleBar   = new Panel();
            lblCaption    = new Label();
            dragControl   = new CTDragControl(pnlTitleBar, this, components); //Drag control, add to component container
            dmFormOptions = new CTDropdownMenu(components);                   //Add to component container
            btnFormIcon   = new FontAwesome.Sharp.IconButton();
            miHelp        = new FontAwesome.Sharp.IconMenuItem();

            pnlTitleBar.SuspendLayout();
            #endregion

            #region -Form Title Bar
            //
            //  Panel: Form Title Bar
            //
            pnlTitleBar.Name     = "pnlTitleBar";
            pnlTitleBar.Location = new Point(0, 0);
            pnlTitleBar.Dock     = DockStyle.Top;
            pnlTitleBar.Size     = new Size(960, 40);
            pnlTitleBar.Controls.Add(btnFormIcon);//Add controls
            pnlTitleBar.Controls.Add(lblCaption);
            pnlTitleBar.Controls.Add(this.btnMinimize);
            pnlTitleBar.Controls.Add(this.btnMaximize);
            pnlTitleBar.Controls.Add(this.btnClose);
            //
            // Icon Button: Form Icon (FontAwesome.Sharp library)
            //
            btnFormIcon.Name      = "btnIcon";
            btnFormIcon.Cursor    = Cursors.Hand;
            btnFormIcon.FlatStyle = FlatStyle.Flat;
            btnFormIcon.FlatAppearance.BorderSize = 0;
            btnFormIcon.Flip      = FontAwesome.Sharp.FlipOrientation.Normal;
            btnFormIcon.IconChar  = FontAwesome.Sharp.IconChar.Folder;
            btnFormIcon.IconColor = Color.WhiteSmoke;
            btnFormIcon.IconSize  = 25;
            btnFormIcon.Rotation  = 0D;
            btnFormIcon.Location  = new Point(0, 0);
            btnFormIcon.Size      = new Size(40, 40);
            btnFormIcon.UseVisualStyleBackColor = false;//Events
            btnFormIcon.MouseEnter += new System.EventHandler(FormIcon_MouseEnter);
            btnFormIcon.MouseLeave += new System.EventHandler(FormIcon_MouseLeave);
            btnFormIcon.Click      += new System.EventHandler(FormIcon_Click);
            FormIcon = IconChar.Folder;
            //
            // Label: Form Caption
            //
            lblCaption.Name      = "lblCaption";
            lblCaption.AutoSize  = true;
            lblCaption.Font      = new Font("Montserrat", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            lblCaption.ForeColor = Color.WhiteSmoke;
            lblCaption.Location  = new Point(40, 10);
            //
            // Button: Control box buttons
            //
            this.btnClose.Dock    = DockStyle.Right;
            this.btnMaximize.Dock = DockStyle.Right;
            this.btnMinimize.Dock = DockStyle.Right;

            #endregion

            #region -Form Options
            //
            // Icon MenuItem: Help (FontAwesome.Sharp library)
            //
            miHelp.Name      = "miHelp";
            miHelp.Text      = "Help";
            miHelp.IconSize  = 21;
            miHelp.IconChar  = IconChar.Question;
            miHelp.IconColor = Colors.FantasyColorScheme4;
            miHelp.Click    += new System.EventHandler(HelpMessage_Click);
            //
            //  DropdownMenu: Form Options
            //
            dmFormOptions.Name = "dmFormOptions";
            dmFormOptions.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            dmFormOptions.Items.AddRange(new ToolStripItem[] { //Add menu items
                miSnapLeft,                                    //Snap Window Left
                miSnapRight,                                   //Snap Window Right
                miExitSnap,                                    //Exit Snap Window
                miHelp
            });
            dmFormOptions.OwnerIsMenuButton = false;
            dmFormOptions.VisibleChanged   += new EventHandler(FormOptions_VisibleChanged);

            #endregion

            #region -Client Area

            // Panel: Client Area (Form Body)
            pnlClientArea.Dock       = DockStyle.Fill;
            pnlClientArea.Location   = new Point(0, 40);
            pnlClientArea.Name       = "pnlClientArea";
            pnlClientArea.Size       = new Size(960, 485);
            pnlClientArea.AutoScroll = true;
            #endregion

            #region -RJ Child Form Properties
            //
            // RJChildForm
            //
            this.Name = "RJChildForm";
            this.Text = "RJ Child form";
            this.Controls.Add(pnlClientArea);
            this.Controls.Add(pnlTitleBar);
            this.AutoScaleDimensions = new SizeF(6F, 13F);
            this.AutoScaleMode       = AutoScaleMode.None;   //Disable autoscale mode, to keep the form size set in the DefaultSize property
            this.FormBorderStyle     = FormBorderStyle.None; //Borderless form
            this.MinimumSize         = new Size(400, 180);   //Minimun form size
            this.DoubleBuffered      = true;
            this.Resize     += new System.EventHandler(Form_Resize);
            this.Deactivate += new EventHandler(Form_Deactivated); //subscribe Deactivate event to change / opaque title bar color
            this.Activated  += new EventHandler(Form_Activated);   //Subscribe Activated event to retrieve title bar color
            desktopPanelSize = true;                               //Set default value
            pnlTitleBar.PerformLayout();
            pnlTitleBar.ResumeLayout();
            #endregion
        }
Example #2
0
        /// Initialize Component
        private void InitializeItems()
        {
            /// Initialize the components (object instantiation) for the form design:
            /// add the title bar, side menu, buttons for maximized, minimized, form options-user options dropdown menu
            /// and the client area(Desktop) of the form
            ///
            components = new System.ComponentModel.Container();//initialize container

            #region -Control Instantiation
            pnlSideMenu       = new Panel();
            pnlSideMenuHeader = new Panel();
            pnlTitleBar       = new Panel();
            pnlDesktop        = new Panel();
            pnlDesktopHeader  = new Panel();
            pnlMarker         = new Panel();
            pnlSide           = new Panel();
            btnMoveNewWindow  = new FontAwesome.Sharp.IconButton();///(FontAwesome.Sharp library)
            btnScreenshot     = new FontAwesome.Sharp.IconButton();
            btnPrint          = new FontAwesome.Sharp.IconButton();
            btnHelp           = new FontAwesome.Sharp.IconButton();
            biSideMenuButton  = new CTMenuIcon();
            biFormIcon        = new CTMenuIcon();
            lblCaption        = new CTLabel();
            dmFormOptions     = new CTDropdownMenu(components);                   //Add to component container
            miCloseChildForms = new FontAwesome.Sharp.IconMenuItem();             ///(FontAwesome.Sharp library)
            toolTip           = new ToolTip(components);                          //Add to component container
            dragControl       = new CTDragControl(pnlTitleBar, this, components); ///Drag Control, add to component container
            //Suspend layout
            #endregion

            #region -Form Side Menu
            //
            //  Panel: Side Panel
            //
            pnlSide.Name     = "pnlSide";
            pnlSide.Dock     = DockStyle.Left;
            pnlSide.Location = new Point(0, 0);
            pnlSide.Size     = new Size(220, 610);
            pnlSide.Controls.Add(pnlSideMenu);
            pnlSide.Controls.Add(pnlSideMenuHeader);
            //
            //  Panel: Side Menu
            //
            pnlSideMenu.Name      = "pnlSideMenu";
            pnlSideMenu.Padding   = new Padding(0, 65, 0, 0);
            pnlSideMenu.BackColor = Colors.SideMenuColor;
            pnlSideMenu.Dock      = DockStyle.Fill;
            pnlSideMenu.Location  = new Point(0, 60);
            pnlSideMenu.Size      = new Size(220, 550);
            pnlSideMenu.Controls.Add(pnlMarker);//Add controls

            //
            // Panel: Side Menu Header
            //
            pnlSideMenuHeader.Name = "pnlSideMenuHeader";
            pnlSideMenuHeader.Controls.Add(biSideMenuButton);//Add controls
            pnlSideMenuHeader.Size     = new Size(220, 60);
            pnlSideMenuHeader.Dock     = DockStyle.Top;
            pnlSideMenuHeader.Location = new Point(0, 0);
            //
            // RJ BarIcon: Side Menu Button
            //
            biSideMenuButton.Name         = "biSideMenuButton";
            biSideMenuButton.Anchor       = (AnchorStyles.Top | AnchorStyles.Right);
            biSideMenuButton.Customizable = true;
            biSideMenuButton.IconColor    = Color.White;
            biSideMenuButton.BackColor    = Color.Transparent;
            biSideMenuButton.Cursor       = Cursors.Hand;
            biSideMenuButton.IconChar     = FontAwesome.Sharp.IconChar.Bars;///(FontAwesome.Sharp library)
            biSideMenuButton.IconSize     = 25;
            biSideMenuButton.Location     = new Point(175, 20);
            biSideMenuButton.Size         = new System.Drawing.Size(25, 25);
            biSideMenuButton.Click       += new System.EventHandler(SideMenuButton_Click);//Event
            //
            // Panel: Child Form Marker
            //
            pnlMarker.Name     = "pnlChildFormMarker";
            pnlMarker.Size     = new Size(4, 55);
            pnlMarker.Location = new Point(0, 60);
            pnlMarker.Visible  = false;
            #endregion

            #region -Form Title Bar
            //
            //  Panel: TitleBar
            //
            pnlTitleBar.Name      = "pnlTitleBar";
            pnlTitleBar.BackColor = UIAppearance.StyleColor;
            pnlTitleBar.Size      = new Size(960, 60);
            pnlTitleBar.Location  = new Point(220, 0);
            pnlTitleBar.Dock      = DockStyle.Top;
            pnlTitleBar.Controls.Add(lblCaption);//Add controls
            pnlTitleBar.Controls.Add(biFormIcon);
            pnlTitleBar.Controls.Add(this.btnMinimize);
            pnlTitleBar.Controls.Add(this.btnMaximize);
            pnlTitleBar.Controls.Add(this.btnClose);
            //
            // Label: Form Caption
            //
            lblCaption.Name      = "lblCaption";
            lblCaption.AutoSize  = true;
            lblCaption.Style     = LabelStyle.BarCaption;
            lblCaption.Location  = new Point(46, 21);
            lblCaption.TextAlign = ContentAlignment.MiddleLeft;
            lblCaption.Text      = "Home";
            //
            // Button: Control box buttons
            //
            this.btnClose.Size   = new Size(35, 20);
            this.btnClose.Anchor = (AnchorStyles.Top | AnchorStyles.Right);

            this.btnMaximize.Size   = new Size(35, 20);
            this.btnMaximize.Anchor = (AnchorStyles.Top | AnchorStyles.Right);

            this.btnMinimize.Size   = new Size(35, 20);
            this.btnMinimize.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
            //
            // Bar Icon: Active Form Icon
            //
            biFormIcon.Name        = "biFormIcon";
            biFormIcon.BackColor   = Color.Transparent;
            biFormIcon.Cursor      = Cursors.Hand;
            biFormIcon.IconChar    = FontAwesome.Sharp.IconChar.Home;///(FontAwesome.Sharp library)
            biFormIcon.IconSize    = 25;
            biFormIcon.Location    = new Point(19, 20);
            biFormIcon.Size        = new Size(25, 25);
            biFormIcon.SizeMode    = PictureBoxSizeMode.AutoSize;
            biFormIcon.Click      += new System.EventHandler(this.FormIcon_Click);//Events
            biFormIcon.MouseEnter += new System.EventHandler(this.FormIcon_MouseHover);
            biFormIcon.MouseLeave += new System.EventHandler(this.FormIcon_MouseLeave);
            #endregion

            #region -Form Options
            //
            // Icon MenuItem: Close Child Forms (FontAwesome.Sharp library)
            //
            miCloseChildForms.Name      = "miCloseChildForms";
            miCloseChildForms.Text      = "Close Child Forms";
            miCloseChildForms.IconSize  = 24;
            miCloseChildForms.IconChar  = FontAwesome.Sharp.IconChar.CalendarTimes;
            miCloseChildForms.IconColor = Colors.FantasyColorScheme4;
            miCloseChildForms.Click    += new System.EventHandler(CloseAllChildForms_Click);//Event
            //
            //  DropdownMenu: Form Options -------------
            //
            dmFormOptions.Name = "dmFormOptions";
            dmFormOptions.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            dmFormOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                miSnapLeft,  //Snap Window Left
                miSnapRight, //Snap Window Right
                miExitSnap,  //Exit Snap Window
                miCloseChildForms
            });
            dmFormOptions.OwnerIsMenuButton = false;
            #endregion

            #region -Desktop Header (Child Form Options)
            //
            //  Panel: Desktop Header -------------
            //
            pnlDesktopHeader.Name      = "pnlDesktopHeader";
            pnlDesktopHeader.BackColor = Colors.LightBackground;
            pnlDesktopHeader.Dock      = DockStyle.Top;
            pnlDesktopHeader.Location  = new Point(220, 60);
            pnlDesktopHeader.Size      = new Size(960, 25);
            pnlDesktopHeader.Padding   = new Padding(14, 0, 0, 0);
            pnlDesktopHeader.Controls.Add(btnHelp);//Add controls
            pnlDesktopHeader.Controls.Add(btnMoveNewWindow);
            pnlDesktopHeader.Controls.Add(btnScreenshot);
            pnlDesktopHeader.Controls.Add(btnPrint);
            //
            // Icon Button: Print Form (FontAwesome.Sharp library)
            //
            btnPrint.Dock = DockStyle.Left;
            btnPrint.FlatAppearance.BorderSize = 0;
            btnPrint.FlatStyle = FlatStyle.Flat;
            btnPrint.IconSize  = 20;
            btnPrint.IconChar  = FontAwesome.Sharp.IconChar.Print;
            btnPrint.IconColor = Colors.FantasyColorScheme1;
            btnPrint.Location  = new Point(0, 0);
            btnPrint.Name      = "btnPrint";
            btnPrint.Size      = new Size(35, 25);
            btnPrint.UseVisualStyleBackColor = true;
            btnPrint.Cursor  = Cursors.Hand;
            btnPrint.Visible = false;
            btnPrint.Click  += new EventHandler(Print_Click);
            //
            // Icon Button: Form Screenshot (FontAwesome.Sharp library)
            //
            btnScreenshot.Dock = DockStyle.Left;
            btnScreenshot.FlatAppearance.BorderSize = 0;
            btnScreenshot.FlatStyle = FlatStyle.Flat;
            btnScreenshot.IconSize  = 20;
            btnScreenshot.IconChar  = FontAwesome.Sharp.IconChar.Camera;
            btnScreenshot.IconColor = Colors.FantasyColorScheme2;
            btnScreenshot.Location  = new Point(0, 0);
            btnScreenshot.Name      = "btnScreenShoot";
            btnScreenshot.Size      = new Size(35, 25);
            btnScreenshot.UseVisualStyleBackColor = true;
            btnScreenshot.Cursor  = Cursors.Hand;
            btnScreenshot.Visible = false;
            btnScreenshot.Click  += new EventHandler(Screenshot_Click);
            //
            // Icon Button: Move Child Form New Window (FontAwesome.Sharp library)
            //
            btnMoveNewWindow.Name = "btnOpenNewWindow";
            btnMoveNewWindow.Dock = DockStyle.Left;
            btnMoveNewWindow.FlatAppearance.BorderSize = 0;
            btnMoveNewWindow.FlatStyle = FlatStyle.Flat;
            btnMoveNewWindow.IconSize  = 20;
            btnMoveNewWindow.IconChar  = FontAwesome.Sharp.IconChar.WindowMaximize;
            btnMoveNewWindow.IconColor = Colors.FantasyColorScheme3;
            btnMoveNewWindow.Location  = new Point(15, 0);
            btnMoveNewWindow.Size      = new Size(35, 25);
            btnMoveNewWindow.UseVisualStyleBackColor = true;
            btnMoveNewWindow.Cursor  = Cursors.Hand;
            btnMoveNewWindow.Visible = false;
            btnMoveNewWindow.Click  += new EventHandler(MoveNewWindow_Click);//Event
            //
            // Icon Button: User Help (FontAwesome.Sharp library)
            //
            btnHelp.Dock = DockStyle.Left;
            btnHelp.FlatAppearance.BorderSize = 0;
            btnHelp.FlatStyle = FlatStyle.Flat;
            btnHelp.IconSize  = 20;
            btnHelp.IconChar  = FontAwesome.Sharp.IconChar.QuestionCircle;
            btnHelp.IconColor = Colors.FantasyColorScheme4;
            btnHelp.Location  = new Point(0, 0);
            btnHelp.Name      = "btnHelp";
            btnHelp.Size      = new Size(35, 25);
            btnHelp.UseVisualStyleBackColor = true;
            btnHelp.Cursor  = Cursors.Hand;
            btnHelp.Visible = false;
            btnHelp.Click  += new EventHandler(ChilFormHelp_Click);
            #endregion

            #region -Desktop (Cliente area - Child form container)
            //
            //  Panel: Desktop
            //
            pnlDesktop.Name      = "pnlDesktop";
            pnlDesktop.BackColor = Colors.LightBackground;
            pnlDesktop.Dock      = DockStyle.Fill;
            pnlDesktop.Location  = new Point(220, 85);
            pnlDesktop.Size      = new Size(960, 525);
            #endregion

            #region -Others
            //
            // ToolTip
            //
            toolTip.AutoPopDelay = 5000;
            toolTip.InitialDelay = 1000;
            toolTip.ReshowDelay  = 500;
            toolTip.ShowAlways   = true;
            toolTip.BackColor    = Color.FromArgb(236, 82, 99);
            toolTip.ForeColor    = Color.White;
            toolTip.OwnerDraw    = true;
            toolTip.Draw        += new DrawToolTipEventHandler(ToolTip_Draw);
            toolTip.SetToolTip(btnPrint, "Print child form content");
            toolTip.SetToolTip(btnScreenshot, "Take a screenshot");
            toolTip.SetToolTip(btnMoveNewWindow, "Move child form to new window");
            toolTip.SetToolTip(btnHelp, "Help message to user");
            #endregion

            #region -RJ Main Form Properties
            //
            //RJMainForm
            //
            deactivateFormEvent      = true;
            this.Resizable           = true;
            this.PrimaryForm         = true;
            this.AutoScaleDimensions = new SizeF(6F, 13F);
            this.AutoScaleMode       = AutoScaleMode.None;
            this.FormBorderStyle     = FormBorderStyle.None; //Borderless form
            this.MinimumSize         = new Size(650, 400);   //Minimun form size
            this.Controls.Add(pnlDesktop);                   //Add controls
            this.Controls.Add(pnlDesktopHeader);
            this.Controls.Add(pnlTitleBar);
            this.Controls.Add(pnlSide);
            this.Deactivate += new EventHandler(Form_Deactivated); //subscribe Deactivate event to change / opaque title bar color
            this.Activated  += new EventHandler(Form_Activated);   //Subscribe Activated event to retrieve title bar color

            #endregion
        }