예제 #1
0
 /// <summary>
 /// Instance of SpriteBatch optimised for CAD capability
 /// </summary>
 /// <param name="graphics"></param>
 public CADSpriteBatch(GraphicsDevice graphics, CADContentFactory cadContent) : base(graphics, cadContent)
 {
 }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Creates ContentFactory
            this.cadContent = new CADContentFactory(Content);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new CADSpriteBatch(GraphicsDevice, this.cadContent);

            // Create Controls
            btnXup                 = new Button();
            btnXup.Left            = 10;
            btnXup.Top             = 10;
            btnXup.Width           = 39;
            btnXup.Height          = 39;
            btnXup.TextureDisabled = this.cadContent.imgButtonArrowDisabled;
            btnXup.TextureIdle     = this.cadContent.imgButtonArrowOff;
            btnXup.TexturePressed  = this.cadContent.imgButtonArrowOn;
            btnXup.TextureHover    = this.cadContent.imgButtonArrowHover;
            btnXup.TextureOriginX  = 19;
            btnXup.TextureOriginY  = 19;
            btnXup.TextureRotation = (float)Math.PI * 2 * 0;
            btnXup.Enabled         = true;

            btnDrillPoints                 = new Button();
            btnDrillPoints.Left            = 300;
            btnDrillPoints.Top             = 10;
            btnDrillPoints.Width           = 120;
            btnDrillPoints.Height          = 40;
            btnDrillPoints.TextOffsetY     = 12;
            btnDrillPoints.Enabled         = true;
            btnDrillPoints.Text            = "Drill Points";
            btnDrillPoints.Font            = this.cadContent.fontConsolas12;
            btnDrillPoints.FontColor       = Color.LightGreen;
            btnDrillPoints.BackGroundColor = Color.DarkGreen;

            btnDrillShapes                 = new Button();
            btnDrillShapes.Left            = 720;
            btnDrillShapes.Top             = 10;
            btnDrillShapes.Width           = 120;
            btnDrillShapes.Height          = 40;
            btnDrillShapes.TextOffsetY     = 12;
            btnDrillShapes.Enabled         = true;
            btnDrillShapes.Text            = "Drill Shapes";
            btnDrillShapes.Font            = this.cadContent.fontConsolas12;
            btnDrillShapes.FontColor       = Color.LightGreen;
            btnDrillShapes.BackGroundColor = Color.DarkGreen;

            this.sbManualSpeed                       = new ScrollBar();
            this.sbManualSpeed.Top                   = 10;
            this.sbManualSpeed.Left                  = 860;
            this.sbManualSpeed.Width                 = 200;
            this.sbManualSpeed.Height                = 25;
            this.sbManualSpeed.Value                 = 0.5f;
            this.sbManualSpeed.Enabled               = true;
            this.sbManualSpeed.Range                 = 0.1f;
            this.sbManualSpeed.TextureArrowOn        = this.cadContent.scrollArrowOn;
            this.sbManualSpeed.TextureArrowOff       = this.cadContent.scrollArrowOff;
            this.sbManualSpeed.TextureArrowHover     = this.cadContent.scrollArrowHover;
            this.sbManualSpeed.TextureArrowDisabled  = this.cadContent.scrollArrowDisabled;
            this.sbManualSpeed.TextureRangeOn        = this.cadContent.scrollRangeOn;
            this.sbManualSpeed.TextureRangeDisabled  = this.cadContent.scrollRangeDisabled;
            this.sbManualSpeed.TextureBarEdgeOn      = this.cadContent.scrollBarEdgeOn;
            this.sbManualSpeed.TextureBarEdgeOff     = this.cadContent.scrollBarEdgeOff;
            this.sbManualSpeed.TextureBarEdgeHover   = this.cadContent.scrollBarEdgeHover;
            this.sbManualSpeed.TextureBarCenterOn    = this.cadContent.scrollBarCenterOn;
            this.sbManualSpeed.TextureBarCenterOff   = this.cadContent.scrollBarCenterOff;
            this.sbManualSpeed.TextureBarCenterHover = this.cadContent.scrollBarCenterHover;

            btnGoToOrigin                 = new Button();
            btnGoToOrigin.Left            = 440;
            btnGoToOrigin.Top             = 10;
            btnGoToOrigin.Width           = 120;
            btnGoToOrigin.Height          = 40;
            btnGoToOrigin.TextOffsetY     = 12;
            btnGoToOrigin.Enabled         = true;
            btnGoToOrigin.Text            = "GoTo Origin";
            btnGoToOrigin.Font            = this.cadContent.fontConsolas12;
            btnGoToOrigin.FontColor       = Color.LightGreen;
            btnGoToOrigin.BackGroundColor = Color.DarkGreen;

            btnClearPoints                 = new Button();
            btnClearPoints.Left            = 580;
            btnClearPoints.Top             = 10;
            btnClearPoints.Width           = 120;
            btnClearPoints.Height          = 40;
            btnClearPoints.TextOffsetY     = 12;
            btnClearPoints.Enabled         = true;
            btnClearPoints.Text            = "Clear Points";
            btnClearPoints.Font            = this.cadContent.fontConsolas12;
            btnClearPoints.FontColor       = Color.LightGreen;
            btnClearPoints.BackGroundColor = Color.DarkGreen;

            // Drawing Toolbox
            this.toolbox = new Toolbox();
            this.toolbox.TextureToolSelect = this.cadContent.imgToolsSelect;
            this.toolbox.TextureToolMove   = this.cadContent.imgToolsMove;
            this.toolbox.TextureToolDelete = this.cadContent.imgToolsDelete;
            this.toolbox.TextureToolPoint  = this.cadContent.imgToolsPoint;
            this.toolbox.TextureToolShape  = this.cadContent.imgToolsShape;
            this.toolbox.Left      = 10;
            this.toolbox.Top       = 60;
            this.toolbox.LayerBase = 0.1f;
            this.toolbox.Enabled   = true;
            this.toolbox.createTools();


            // Machine
            this.machine                   = new Machine();
            this.machine.Left              = 60;
            this.machine.Top               = 10;
            this.machine.Width             = 200;
            this.machine.Height            = 40;
            this.machine.Enabled           = true;
            this.machine.ComPortName       = "COM7";
            this.machine.TextureController = this.cadContent.machineController;
            this.machine.Enabled           = true;
            try {
                this.machine.connect();
                this.machine.origin();
            } catch (MachineException) {
                this.machine.SimulationMode = true;
            }

            // Drill tool
            this.drillTool = new DrillTool(this.machine);

            // CAD Panel
            cadPanel                             = new CAD2DDrawingPanel();
            cadPanel.Left                        = 10 + 46;
            cadPanel.Top                         = 60;
            cadPanel.Width                       = config.windowSizeX - 20 - 46;
            cadPanel.Height                      = config.windowSizeY - 70;
            cadPanel.BackgroundColor             = Color.Black;
            cadPanel.ScrollSize                  = 25;
            cadPanel.LayerBase                   = 0.9f;
            cadPanel.TextureScrollArrowOn        = this.cadContent.scrollArrowOn;
            cadPanel.TextureScrollArrowOff       = this.cadContent.scrollArrowOff;
            cadPanel.TextureScrollArrowHover     = this.cadContent.scrollArrowHover;
            cadPanel.TextureScrollArrowDisabled  = this.cadContent.scrollArrowDisabled;
            cadPanel.TextureScrollRangeOn        = this.cadContent.scrollRangeOn;
            cadPanel.TextureScrollRangeDisabled  = this.cadContent.scrollRangeDisabled;
            cadPanel.TextureScrollBarEdgeOn      = this.cadContent.scrollBarEdgeOn;
            cadPanel.TextureScrollBarEdgeOff     = this.cadContent.scrollBarEdgeOff;
            cadPanel.TextureScrollBarEdgeHover   = this.cadContent.scrollBarEdgeHover;
            cadPanel.TextureScrollBarCenterOn    = this.cadContent.scrollBarCenterOn;
            cadPanel.TextureScrollBarCenterOff   = this.cadContent.scrollBarCenterOff;
            cadPanel.TextureScrollBarCenterHover = this.cadContent.scrollBarCenterHover;
            cadPanel.FontCanvas                  = this.cadContent.fontConsolas12;
            cadPanel.TexturePoint                = this.cadContent.imgPoint;
            cadPanel.TextureMachineTool          = this.cadContent.machineTool;
            cadPanel.Enabled                     = true;
            cadPanel.Machine                     = this.machine;
            cadPanel.Toolbox                     = this.toolbox;
        }