/// <summary>
        /// Initializes a new instance of the <see cref="Paint.ToolBox"/> class.
        /// </summary>
        /// <param name='toolboxLayoutDefinition' The layout of the toolbox />
        /// <param name='graphicsDisplay' The graphics texture map - contains images for buttons and controls />
        /// <param name='scale' iPad size scale - i.e.2 for retina and 1 for normal - allows us to multiply up the layout />
        public ToolBox(ToolboxLayoutDefinition toolboxLayoutDefinition, IGraphicsDisplay graphicsDisplay, int scale)
        {
            this.BackgroundColor = this.TranslateToolboxLayoutColor(toolboxLayoutDefinition.BackgroundColor);
            this.BorderColor = this.TranslateToolboxLayoutColor(toolboxLayoutDefinition.Border.Color);
            this.GraphicsDisplay = graphicsDisplay;
            this.Scale = scale;
            this.toolboxWidth = toolboxLayoutDefinition.Width * scale;
            this.ToolboxMinimizedHeight = toolboxLayoutDefinition.MinimizedHeight * scale;
            this.toolboxMaximisedHeight = toolboxLayoutDefinition.MaximizedHeight * scale;

            int toolboxBorderWidth = toolboxLayoutDefinition.Border.Width * scale;

            // we start maximised and docked at the bottom
            this.ToolboxHeight = toolboxLayoutDefinition.MaximizedHeight * scale;
            this.DockPosition = DockPosition.Bottom;

            this.toolboxBounds = new Rectangle(0, 0, this.toolboxWidth, this.ToolboxHeight);

            this.toolbarInnerBounds = new Rectangle(
                toolboxBorderWidth,
                toolboxBorderWidth,
                this.toolboxWidth - (2 * toolboxBorderWidth),
                this.ToolboxMinimizedHeight - (2 * toolboxBorderWidth));

            this.interactiveTools = new List<IToolBoxToolTouch>();
            this.nonInteractiveTools = new List<IToolBoxTool>();

            // Add all the buttons
            this.AddStandardTools(toolboxLayoutDefinition.StandardTools);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Paint.CanvasPlaybackApp"/> class.
        /// </summary>
        /// <param name='canvasPlayback'>Canvas Playback data</param>
        /// <param name='imageStateData'>ImageSaveData</param>
        /// <param name='toolboxLayoutDefinition'>Layout of the toolbox</param>
        /// <param name='deviceScale'>The device scale/resolution. 1 = normal.  2 = retina.</param>
        public CanvasPlaybackApp(
			ICanvasPlayback canvasPlayback, 
			ImageStateData imageStateData, 
			ToolboxLayoutDefinition toolboxLayoutDefinition,
			int deviceScale)
            : base(imageStateData, toolboxLayoutDefinition, deviceScale)
        {
            this.canvasPlayback = canvasPlayback;
            this.calculatePlaybackSpeed = new CalculatePlaybackSpeed();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Paint.PaintApp"/> class.
        /// Instantiate our GraphicsDeviceManager and establish where the content folder is
        /// </summary>
        /// <param name='pictureIOManager'>Picture IO Manager</param>
        /// <param name='filenameResolver'>Filename Resolver</param>
        /// <param name='imageStateData'>ImageSaveData</param>
        /// <param name='saveBusyMessageDisplay'>Class for dsplaying the 'Busy - saving' message</param>
        /// <param name='toolboxLayoutDefinition'>Layout of the toolbox</param>
        /// <param name='deviceScale'>The device scale/resolution. 1 = normal.  2 = retina.</param>
        public PaintApp(
			IPictureIOManager pictureIOManager, 
			IFilenameResolver filenameResolver, 
			ImageStateData imageStateData,
			IUIBusyMessage saveBusyMessageDisplay,
			ToolboxLayoutDefinition toolboxLayoutDefinition,
			int deviceScale)
            : base(imageStateData, toolboxLayoutDefinition, deviceScale)
        {
            this.filenameResolver = filenameResolver;
            this.pictureIOManager = pictureIOManager;
            this.saveBusyMessageDisplay = saveBusyMessageDisplay;
        }
        /// <summary>
        /// Loads the toolbox layouts - from xml configuraiton files
        /// </summary>
        private void LoadToolboxLayouts()
        {
            this.PaintPortraitToolboxLayout =
                ObjectDeserializer.DeserialiseFromXmlFile<ToolboxLayoutDefinition>("Content/PaintToolboxPortraitLayout.xml");

            this.PaintLandscapeToolboxLayout =
                ObjectDeserializer.DeserialiseFromXmlFile<ToolboxLayoutDefinition>("Content/PaintToolboxLandscapeLayout.xml");

            this.PlaybackPortraitToolboxLayout =
                ObjectDeserializer.DeserialiseFromXmlFile<ToolboxLayoutDefinition>("Content/PlaybackToolboxPortraitLayout.xml");

            this.PlaybackLandscapeToolboxLayout =
                ObjectDeserializer.DeserialiseFromXmlFile<ToolboxLayoutDefinition>("Content/PlaybackToolboxLandscapeLayout.xml");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Paint.PlaybackToolbox"/> class.
 /// </summary>
 /// <param name='toolboxLayoutDefinition' The layout of the toolbox />
 /// <param name='graphicsDisplay' The graphics texture map - contains images for buttons and controls />
 /// <param name='scale' iPad size scale - i.e.2 for retina and 1 for normal - allows us to multiply up the layout />
 public PlaybackToolbox(ToolboxLayoutDefinition toolboxLayoutDefinition, IGraphicsDisplay graphicsDisplay, int scale)
     : base(toolboxLayoutDefinition, graphicsDisplay, scale)
 {
     this.CreateTools(toolboxLayoutDefinition);
 }
        /// <summary>
        /// Creates all our tools.
        /// </summary>
        /// <param name='toolboxLayoutDefinition' The layout of the toolbox />
        private void CreateTools(ToolboxLayoutDefinition toolboxLayoutDefinition)
        {
            this.playbackProgressBar = this.CreateProgressBar(toolboxLayoutDefinition.PlaybackTools.ProgressBar);
            this.AddTool(this.playbackProgressBar);

            this.speedGauge = this.CreateSpeedGauge(toolboxLayoutDefinition.PlaybackTools.SpeedGauge);
            this.AddTool(this.speedGauge);
        }
        /// <summary>
        /// Creates all our tools.
        /// </summary>
        /// <param name='toolboxLayoutDefinition' The layout of the toolbox />
        private void CreateTools(ToolboxLayoutDefinition toolboxLayoutDefinition)
        {
            Color startColor = new Color(
                toolboxLayoutDefinition.PaintTools.ColorSetter.Region.BackgroundColor.Red,
                toolboxLayoutDefinition.PaintTools.ColorSetter.Region.BackgroundColor.Green,
                toolboxLayoutDefinition.PaintTools.ColorSetter.Region.BackgroundColor.Blue);

            var brushSizeSelector = this.CreateBrushSizeSelector(startColor, toolboxLayoutDefinition.PaintTools.BrushSizeSelector);
            this.AddTool(brushSizeSelector);

            // ColorSetter - shows what colour the user has chosen
            this.colorSetter = this.CreateColorSetter(startColor, toolboxLayoutDefinition.PaintTools.ColorSetter);
            this.AddTool(colorSetter);

            // User defined color selector
            var colorSelector = this.CreateColorSelector(startColor, toolboxLayoutDefinition.PaintTools.ColorSelector);

            colorSelector.ColorChanged += (sender, e) => {
                this.colorSetter.Color = colorSelector.Color;
                brushSizeSelector.Color = colorSelector.Color;
            };

            this.AddTool(colorSelector);

            // Pre defined color pickers
            this.CreateColorPickers(colorSelector, toolboxLayoutDefinition.PaintTools.ColorPickers.ColorPicker);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Paint.BaseGame"/> class.
        /// </summary>
        /// <param name='imageStateData'>ImageSaveData</param>
        /// <param name='toolboxLayoutDefinition'>Layout of the toolbox</param>
        /// <param name='deviceScale'>Layout of the toolbox</param>
        /// <param name='deviceScale'>The device scale/resolution. 1 = normal.  2 = retina.</param>
        public BaseGame(ImageStateData imageStateData, ToolboxLayoutDefinition toolboxLayoutDefinition, int deviceScale)
        {
            this.ImageStateData = imageStateData;
            this.ToolboxLayoutDefinition = toolboxLayoutDefinition;
            this.DeviceScale = deviceScale;

            this.GraphicsDeviceManager = new GraphicsDeviceManager(this);
            this.GraphicsDeviceManager.IsFullScreen = true;

            if (imageStateData.Width > imageStateData.Height)
            {
                this.GraphicsDeviceManager.SupportedOrientations =
                    DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            }
            else
            {
                this.GraphicsDeviceManager.SupportedOrientations =
                    DisplayOrientation.Portrait | DisplayOrientation.PortraitUpsideDown;
            }

            this.Content.RootDirectory = "Content";
        }