/// <summary> /// Creates a button and adds it. /// </summary> /// <returns> /// The button. /// </returns> /// <param name='buttonLayout'> /// Button layout. /// </param> protected virtual void AddButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { List<ImageType> imageList = new List<ImageType>(); switch (buttonLayout.ButtonType) { case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.Exit: imageList.Add(ImageType.ExitButton); break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.ToggleDock: imageList.Add(ImageType.DockTopButton); imageList.Add(ImageType.DockBottomButton); break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.ToggleMaxMin: imageList.Add(ImageType.MinimizeToolbar); imageList.Add(ImageType.MaximizeToolbar); break; } var button = new Button( this.GraphicsDisplay, new ButtonDefinition(buttonLayout, this.Scale, imageList.ToArray(), null)); switch (buttonLayout.ButtonType) { case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.Exit: button.ButtonPressed += (sender, e) => (this.OnExitButtonPressed(EventArgs.Empty)); break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.ToggleDock: button.ButtonPressed += (sender, e) => { if (button.State == 0) { this.DockPosition = DockPosition.Bottom; } else { this.DockPosition = DockPosition.Top; } }; break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.ToggleMaxMin: button.ButtonPressed += (sender, e) => { if (button.State == 0) { this.ToolboxHeight = this.toolboxMaximisedHeight; } else { this.ToolboxHeight = this.ToolboxMinimizedHeight; } }; break; } this.AddTool(button); }
/// <summary> /// Creates all the buttons and adds them to our list of controls /// </summary> /// <param name='buttons' All the buttons we need to display on screen /> protected void AddButtons(ToolboxLayoutDefinitionStandardToolsButtonsButton[] buttons) { foreach (var buttonLayout in buttons) { this.AddButton(buttonLayout); } }
/// <summary> /// Adds the restart button. /// </summary> /// <param name='buttonLayout'> /// Button layout. /// </param> private void AddRestartButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { var restartButton = new Button( this.GraphicsDisplay, new ButtonDefinition(buttonLayout, this.Scale, new ImageType[] { ImageType.RestartButton }, null)); restartButton.ButtonPressed += (sender, e) => { // we are restarting so we if we were previosly paused or disabled then reset to playing... this.playButton.State = 1; this.playButton.Enabled = true; this.OnRestartSelected(EventArgs.Empty); }; this.AddTool(restartButton); }
/// <summary> /// Adds the play pause button. /// </summary> /// <param name='buttonLayout'> /// Button layout. /// </param> private void AddPlayPauseButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { this.playButton = new Button( this.GraphicsDisplay, new ButtonDefinition(buttonLayout, this.Scale, new ImageType[] { ImageType.PlayButton, ImageType.PauseButton }, ImageType.PlayButtonDisabled)); this.playButton.ButtonPressed += (sender, e) => { if (this.playButton.State == 0) { this.OnPauseSelected(EventArgs.Empty); } else { this.OnPlaySelected(EventArgs.Empty); } }; this.AddTool(this.playButton); }
/// <summary> /// Creates all the buttons and adds them to our list of controls /// </summary> /// <param name='buttons' All the buttons we need to display on screen /> protected override void AddButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { switch (buttonLayout.ButtonType) { case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.PlayPausePlayback: this.AddPlayPauseButton(buttonLayout); break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.Restart: this.AddRestartButton(buttonLayout); break; default: base.AddButton(buttonLayout); break; } }
/// <summary> /// Adds the undo button. /// </summary> /// <param name='buttonLayout'> /// Button layout. /// </param> private void AddUndoButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { this.undoButton = new Button( this.GraphicsDisplay, new ButtonDefinition(buttonLayout, this.Scale, new ImageType[] { ImageType.UndoButton }, ImageType.UndoButtonDisabled)); this.undoButton.Enabled = false; this.undoButton.ButtonPressed += (sender, e) => { this.OnUndoSelected(EventArgs.Empty); }; this.AddTool(this.undoButton); }
/// <summary> /// Creates all the buttons and adds them to our list of controls /// </summary> /// <param name='buttons' All the buttons we need to display on screen /> protected override void AddButton(ToolboxLayoutDefinitionStandardToolsButtonsButton buttonLayout) { switch (buttonLayout.ButtonType) { case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.Undo: this.AddUndoButton(buttonLayout); break; case ToolboxLayoutDefinitionStandardToolsButtonsButtonButtonType.Redo: this.AddRedoButton(buttonLayout); break; default: base.AddButton(buttonLayout); break; } }