C# Class Paint.BaseGame

Base game - derived from the MonoGame Game class and acts as a base class for our separate 'paint' and 'playback' apps
Inheritance: Microsoft.Xna.Framework.Game
Mostrar archivo Open project: RandolphBurt/MonoGame-iOS-SimplePaint

Protected Properties

Property Type Description
BackgroundColor Color
Canvas ICanvas
CanvasTouchPoints List
DeviceScale int
GraphicsDeviceManager GraphicsDeviceManager
GraphicsDisplay IGraphicsDisplay
ImageStateData ImageStateData
InMemoryCanvasRenderTarget Microsoft.Xna.Framework.Graphics.RenderTarget2D
InMemoryToolboxRenderTarget Microsoft.Xna.Framework.Graphics.RenderTarget2D
InitialDraw bool
SpriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
ToolBox IToolBox
ToolboxLayoutDefinition Paint.ToolboxLayout.ToolboxLayoutDefinition

Public Methods

Method Description
BaseGame ( ImageStateData imageStateData, ToolboxLayoutDefinition toolboxLayoutDefinition, int deviceScale ) : System

Initializes a new instance of the Paint.BaseGame class.

Protected Methods

Method Description
BlankRenderTarget ( RenderTarget2D renderTarget ) : void

Blanks the render target.

CheckToolboxCollision ( ITouchPoint touchPoint ) : bool

Checks whether the user has touched inside the toolbox

ConvertGestureType ( GestureType gestureType ) : TouchType

Converts a MonoGame.GestureType into our TouchType representation

ConvertScreenTouchToCanvasTouch ( TouchPointSizeColour screenTouchPoint ) : TouchPointSizeColour

Converts the screen touchpoint to a canvas touchpoint - i.e. alters the position of the touch to take into account the position and size of the toolbox

CreateRenderTargets ( ) : void

Creates the canvas.

CreateToolbox ( ) : IToolBox

Creates the toolbox.

Draw ( GameTime gameTime ) : void

Called everytime we need to redraw the screen

Initialize ( ) : void

Enable the capturing of gestures on the device

LoadContent ( ) : void

We load any content we need at the beginning of the application life cycle. Also anything that needs initialising is done here

Private Methods

Method Description
DrawCanvasOnScreen ( ) : void

Draws the canvas on screen.

DrawToolboxOnScreen ( ) : void

Draws the toolbox on screen.

Method Details

BaseGame() public method

Initializes a new instance of the Paint.BaseGame class.
public BaseGame ( ImageStateData imageStateData, ToolboxLayoutDefinition toolboxLayoutDefinition, int deviceScale ) : System
imageStateData ImageStateData ImageSaveData
toolboxLayoutDefinition Paint.ToolboxLayout.ToolboxLayoutDefinition Layout of the toolbox
deviceScale int Layout of the toolbox
return System

BlankRenderTarget() protected method

Blanks the render target.
protected BlankRenderTarget ( RenderTarget2D renderTarget ) : void
renderTarget Microsoft.Xna.Framework.Graphics.RenderTarget2D /// Render target. ///
return void

CheckToolboxCollision() protected method

Checks whether the user has touched inside the toolbox
protected CheckToolboxCollision ( ITouchPoint touchPoint ) : bool
touchPoint ITouchPoint
return bool

ConvertGestureType() protected method

Converts a MonoGame.GestureType into our TouchType representation
protected ConvertGestureType ( GestureType gestureType ) : TouchType
gestureType GestureType /// The monogame gesture type. ///
return TouchType

ConvertScreenTouchToCanvasTouch() protected method

Converts the screen touchpoint to a canvas touchpoint - i.e. alters the position of the touch to take into account the position and size of the toolbox
protected ConvertScreenTouchToCanvasTouch ( TouchPointSizeColour screenTouchPoint ) : TouchPointSizeColour
screenTouchPoint TouchPointSizeColour
return TouchPointSizeColour

CreateRenderTargets() protected method

Creates the canvas.
protected CreateRenderTargets ( ) : void
return void

CreateToolbox() protected abstract method

Creates the toolbox.
protected abstract CreateToolbox ( ) : IToolBox
return IToolBox

Draw() protected method

Called everytime we need to redraw the screen
protected Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime /// Allows you to monitor time passed since last draw ///
return void

Initialize() protected method

Enable the capturing of gestures on the device
protected Initialize ( ) : void
return void

LoadContent() protected method

We load any content we need at the beginning of the application life cycle. Also anything that needs initialising is done here
protected LoadContent ( ) : void
return void

Property Details

BackgroundColor protected_oe property

Background color for our app
protected Color BackgroundColor
return Color

Canvas protected_oe property

Where we draw our picture - the canvas/paper/drawing board
protected ICanvas Canvas
return ICanvas

CanvasTouchPoints protected_oe property

Keeps track of all touch/gestures made on the canvas since the last Draw command- is then reset after handled by the Draw.
protected List CanvasTouchPoints
return List

DeviceScale protected_oe property

The device scale/resolution. 1 = normal. 2 = retina.
protected int DeviceScale
return int

GraphicsDeviceManager protected_oe property

Our monogame GrahicsDeviceManager handles all the rendering
protected GraphicsDeviceManager GraphicsDeviceManager
return GraphicsDeviceManager

GraphicsDisplay protected_oe property

The graphics texture map - contains all our graphics for buttons etc
protected IGraphicsDisplay GraphicsDisplay
return IGraphicsDisplay

ImageStateData protected_oe property

The image state data. height/width of image and details of save points (undo/redo state)
protected ImageStateData,Paint ImageStateData
return ImageStateData

InMemoryCanvasRenderTarget protected_oe property

An in memory render target - as the user draws on the canvas then so we update this rendertarget. Then each 'draw cycle' we render this to the screen.
protected RenderTarget2D,Microsoft.Xna.Framework.Graphics InMemoryCanvasRenderTarget
return Microsoft.Xna.Framework.Graphics.RenderTarget2D

InMemoryToolboxRenderTarget protected_oe property

An in memory render target for holding the toolbox Then each 'draw cycle' we render this to the screen.
protected RenderTarget2D,Microsoft.Xna.Framework.Graphics InMemoryToolboxRenderTarget
return Microsoft.Xna.Framework.Graphics.RenderTarget2D

InitialDraw protected_oe property

Simply tracks whether this is the very first time we are drawing the canvas - if so then we need to draw everything on each control/tool.
protected bool InitialDraw
return bool

SpriteBatch protected_oe property

The sprite batch handles all the drawing to the render targets / screen
protected SpriteBatch,Microsoft.Xna.Framework.Graphics SpriteBatch
return Microsoft.Xna.Framework.Graphics.SpriteBatch

ToolBox protected_oe property

The tool box - contains all our controls/buttons for the user to interact with the app
protected IToolBox ToolBox
return IToolBox

ToolboxLayoutDefinition protected_oe property

Defines the layout of all the controls in the toolbox
protected ToolboxLayoutDefinition,Paint.ToolboxLayout ToolboxLayoutDefinition
return Paint.ToolboxLayout.ToolboxLayoutDefinition