/// <summary> /// Construct the CCToolbar by initializing and adding all the buttons. /// Its default orientation is HorizontalTop. /// </summary> /// <param name="ccMainForm"></param> public CCToolbar(Form sourceForm) { InitializeComponent(); this.ccMainForm = sourceForm; morePrevBtn = new PrevCCButton(this); //morePrevBtn.SetIcon("Icons/MoreLeft.png"); morePrevBtn.FlashOn(); moreNextBtn = new NextCCButton(this); //moreNextBtn.SetIcon("Icons/MoreRight.png"); moreNextBtn.FlashOn(); this.BackColor = this.toolbarColor;//Color.DarkBlue; //this.BackColor = Color.MidnightBlue; this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.BringToFront(); // Re-center the toolbar (reset the button scrolling) when its size changes this.SizeChanged += new EventHandler(OnResizeCenterToolbar); SetToolbarDockLocation(); InitializeAllToolbarItems(); ShowMoreArrows(); // Initialize auto slide slideTimer autoSlideTimer = new Timer(); autoSlideTimer.Interval = autoSlideInterval; autoSlideTimer.Tick += new EventHandler(autoSlideTimer_Tick); autoSlideTimer.Stop(); }
/// <summary> /// Set a button to have Cancel icon and behavior. /// </summary> public void SetButtonToCancel(CCButton button) { button.Text = "Cancel"; //ref icon: http://www.openclipart.org/detail/19676 button.SetIcon("Icons/Cancel.png"); button.actionEvent += new CCButton.actionEventHandler(closeBtn_actionEvent); }
public MovementForm(CCToolbar ccToolbar) : this() { this.ccToolbar = ccToolbar; //this.orientation = orientation; this.orientation = ccToolbar.Orientation; prevBtn = new PrevCCButton(this.ccToolbar); nextBtn = new NextCCButton(this.ccToolbar); selectionBtn = new SelectionCCButton(this.ccToolbar); if (orientation == CCToolbar.ToolbarOrientation.HorizontalTop || orientation == CCToolbar.ToolbarOrientation.HorizontalBottom) { tableLayoutPanel.Controls.Add(prevBtn, 0, 1); tableLayoutPanel.Controls.Add(selectionBtn, 1, 1); tableLayoutPanel.Controls.Add(nextBtn, 2, 1); } else if (orientation == CCToolbar.ToolbarOrientation.VerticalLeft || orientation == CCToolbar.ToolbarOrientation.VerticalRight) { tableLayoutPanel.Controls.Add(prevBtn, 1, 0); tableLayoutPanel.Controls.Add(selectionBtn, 1, 1); tableLayoutPanel.Controls.Add(nextBtn, 1, 2); } }
/// <summary> /// Add the MainMenu buttons to the toolbar. /// </summary> private void AddMainMenuButtons() { List <CCButton> mainMenuButtons = new List <CCButton>(); fileCCButton = new Toolbox.FileCCButton(this); imageCCButton = new Toolbox.ImageCCButton(this); drawingCCButton = new Toolbox.DrawingCCButton(this); settingsCCButton = new Toolbar.SettingsCCButton(this); aboutCCButton = new Toolbox.AboutCCButton(this); mainMenuButtons.Add(fileCCButton); mainMenuButtons.Add(imageCCButton); mainMenuButtons.Add(drawingCCButton); mainMenuButtons.Add(settingsCCButton); mainMenuButtons.Add(aboutCCButton); AddNewToolbarButtons(mainMenuButtons, "Main Menu"); }
/// <summary> /// Helper method: Add a navigation button to the toolbar at a given index. /// </summary> /// <param name="btn"></param> /// <param name="index"></param> private void AddNavButtonToPanelAtIndex(CCButton navButton, int index) { int x = 0; int y = 0; if (orientation == ToolbarOrientation.HorizontalTop || orientation == ToolbarOrientation.HorizontalBottom) { x = index * (buttonWidth + SPACE_BTWN_BTNS); y = 0; } else if (orientation == ToolbarOrientation.VerticalLeft || orientation == ToolbarOrientation.VerticalRight) { x = 0; y = index * (buttonHeight + SPACE_BTWN_BTNS); } navButton.Location = new Point(x, y); navButtonsPanel.Controls.Add(navButton); }
/// <summary> /// Set a button's icon to the Apply icon. You must implement the behavior yourself. /// </summary> public void SetButtonIconToApply(CCButton button) { button.Text = "Apply"; //ref icon: http://www.openclipart.org/detail/26557 button.SetIcon("Icons/Apply.png"); }
/// <summary> /// Add a list of buttons to the toolbar. /// </summary> /// <param name="buttons"></param> private void AddButtonsToToolbar(List <CCButton> buttons) { // Use a double-buffering like method // to reduce screen twitch when changing buttons // - create a copy of the toolbar panel to put the new buttons on DoubleBufferPanel tempPanel = new DoubleBufferPanel(); tempPanel.Location = toolbarButtonsPanel.Location; tempPanel.Size = toolbarButtonsPanel.Size; tempPanel.AutoSize = toolbarButtonsPanel.AutoSize; tempPanel.AutoSizeMode = toolbarButtonsPanel.AutoSizeMode; tempPanel.BackColor = toolbarButtonsPanel.BackColor; // Add new buttons to the copy panel for (int i = 0; i < buttons.Count; i++) { CCButton currentButton = buttons[i]; // Make sure button is the current desired size currentButton.Width = buttonWidth; currentButton.Height = buttonHeight; int x = 0; int y = 0; switch (this.orientation) { case ToolbarOrientation.HorizontalTop: x = i * (currentButton.Width + SPACE_BTWN_BTNS); y = 0; break; case ToolbarOrientation.HorizontalBottom: goto case ToolbarOrientation.HorizontalTop; case ToolbarOrientation.VerticalLeft: x = 0; y = i * (currentButton.Height + SPACE_BTWN_BTNS); break; case ToolbarOrientation.VerticalRight: goto case ToolbarOrientation.VerticalLeft; default: break; } currentButton.Location = new Point(x, y); tempPanel.Controls.Add(currentButton); } // Swap the toolbar panel and the copy // -- the order of operations is very important this.Controls.Add(tempPanel); toolbarButtonsPanel.Hide(); toolbarButtonsPanel.Controls.Clear(); toolbarButtonsPanel = tempPanel; // Reset toolbar panel with starting settings // since this is a new set of buttons SetToolbarButtonsPanelLocation(); toolbarButtonsIndex = 0; lastSlideDirection = SlideDirection.Next; CenterizeToolbar(); }