Ejemplo n.º 1
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        public void Initialize(XnaItems xnaItems, Control owner)
        {
            //SetStyle(ControlStyles.AllPaintingInWmPaint |
            //    ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            // Keep reference to owner form
            Owner = owner;

            drawingContext  = xnaItems.DrawingContext;
            lineBatch       = xnaItems.LineBatch;
            this.SpriteFont = xnaItems.FontManager.GetFont("SpriteFont").Font;

            // set default tool
            _activeTool = Xna2dDrawToolType.Pointer;

            // create list of graphic objects
            _graphicsList = new XnaGraphicsList();

            // create array of drawing tools
            _tools = new Tool[(int)Xna2dDrawToolType.NumberOfDrawTools];
            _tools[(int)Xna2dDrawToolType.Pointer]   = new ToolPointer();
            _tools[(int)Xna2dDrawToolType.Rectangle] = new ToolRectangle();
            _tools[(int)Xna2dDrawToolType.Ellipse]   = new ToolEllipse();
            _tools[(int)Xna2dDrawToolType.Line]      = new ToolLine();
            _tools[(int)Xna2dDrawToolType.Polygon]   = new ToolPolygon();
            _tools[(int)Xna2dDrawToolType.Text]      = new XnaToolText();
            _tools[(int)Xna2dDrawToolType.Bitmap]    = new ToolImage();
            _tools[(int)Xna2dDrawToolType.Pan]       = new ToolPan();
            _tools[(int)Xna2dDrawToolType.Path]      = new XnaToolPath();

            System.Drawing.Graphics g = Owner.CreateGraphics();
            XnaDrawObject.Dpi = new Point((int)1, (int)1);

            Create2DProjectionMatrix();
        }
Ejemplo n.º 2
0
        protected override void Initialize()
        {
            components                     = new Container();
            _contextMenuStrip              = new ContextMenuStrip(components);
            _selectAllToolStripMenuItem    = new ToolStripMenuItem();
            _toolStripSeparator1           = new ToolStripSeparator();
            _bringToFrontToolStripMenuItem = new ToolStripMenuItem();
            _sendToBackToolStripMenuItem   = new ToolStripMenuItem();
            _deleteToolStripMenuItem       = new ToolStripMenuItem();
            _toolStripSeparator2           = new ToolStripSeparator();
            _cutToolStripMenuItem          = new ToolStripMenuItem();
            _copyToolStripMenuItem         = new ToolStripMenuItem();
            _pasteToolStripMenuItem        = new ToolStripMenuItem();
            _toolStripSeparator3           = new ToolStripSeparator();
            _contextMenuStrip.SuspendLayout();
            SuspendLayout();
            //
            // contextMenuStrip
            //
            _contextMenuStrip.Items.AddRange(new ToolStripItem[] {
                _selectAllToolStripMenuItem,
                _toolStripSeparator1,
                _bringToFrontToolStripMenuItem,
                _sendToBackToolStripMenuItem,
                _toolStripSeparator3,
                _deleteToolStripMenuItem,
                _toolStripSeparator2,
                _cutToolStripMenuItem,
                _copyToolStripMenuItem,
                _pasteToolStripMenuItem
            });
            _contextMenuStrip.Name = @"_contextMenuStrip";
            _contextMenuStrip.Size = new System.Drawing.Size(153, 198);
            //
            // selectAllToolStripMenuItem
            //
            _selectAllToolStripMenuItem.Name   = "selectAllToolStripMenuItem";
            _selectAllToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _selectAllToolStripMenuItem.Text   = @"Select All";
            _selectAllToolStripMenuItem.Click += SelectAllToolStripMenuItemClick;
            //
            // toolStripSeparator1
            //
            _toolStripSeparator1.Name = "toolStripSeparator1";
            _toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
            //
            // bringToFrontToolStripMenuItem
            //
            _bringToFrontToolStripMenuItem.Name   = "bringToFrontToolStripMenuItem";
            _bringToFrontToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _bringToFrontToolStripMenuItem.Text   = @"Bring to Front";
            _bringToFrontToolStripMenuItem.Click += BringToFrontToolStripMenuItemClick;
            //
            // sendToBackToolStripMenuItem
            //
            _sendToBackToolStripMenuItem.Name   = "sendToBackToolStripMenuItem";
            _sendToBackToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _sendToBackToolStripMenuItem.Text   = @"Send to Back";
            _sendToBackToolStripMenuItem.Click += SendToBackToolStripMenuItemClick;
            //
            // deleteToolStripMenuItem
            //
            _deleteToolStripMenuItem.Name   = "deleteToolStripMenuItem";
            _deleteToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _deleteToolStripMenuItem.Text   = @"Delete";
            _deleteToolStripMenuItem.Click += DeleteToolStripMenuItemClick;
            //
            // toolStripSeparator2
            //
            _toolStripSeparator2.Name = "toolStripSeparator2";
            _toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
            //
            // cutToolStripMenuItem
            //
            _cutToolStripMenuItem.Name   = "cutToolStripMenuItem";
            _cutToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _cutToolStripMenuItem.Text   = @"Cut";
            _cutToolStripMenuItem.Click += CutToolStripMenuItemClick;
            //
            // copyToolStripMenuItem
            //
            _copyToolStripMenuItem.Name   = "copyToolStripMenuItem";
            _copyToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _copyToolStripMenuItem.Text   = @"Copy";
            _copyToolStripMenuItem.Click += CopyToolStripMenuItemClick;
            //
            // pasteToolStripMenuItem
            //
            _pasteToolStripMenuItem.Name   = "pasteToolStripMenuItem";
            _pasteToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            _pasteToolStripMenuItem.Text   = @"Paste";
            _pasteToolStripMenuItem.Click += PasteToolStripMenuItemClick;
            //
            // toolStripSeparator3
            //
            _toolStripSeparator3.Name = "toolStripSeparator3";
            _toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
            //
            // DrawArea
            //
            //AutoScroll = true;
            //AutoSize = true;
            //Name = "DrawArea";

            MouseMove += XnaToolUser_MouseMove;
            MouseDown += XnaToolUser_MouseDown;
            MouseUp   += XnaToolUser_MouseUp;
            ToolDone  += ResetToolSelection;

            _contextMenuStrip.ResumeLayout(false);

            // set default tool
            _activeTool = Xna2dDrawToolType.Pointer;

            // create list of graphic objects
            _graphicsList = new XnaGraphicsList();

            // create array of drawing tools
            _tools = new XnaTool[(int)Xna2dDrawToolType.NumberOfDrawTools];
            _tools[(int)Xna2dDrawToolType.Pointer]   = new XnaToolPointer();
            _tools[(int)Xna2dDrawToolType.Rectangle] = new ToolRectangle();
            _tools[(int)Xna2dDrawToolType.Ellipse]   = new ToolEllipse();
            _tools[(int)Xna2dDrawToolType.Line]      = new ToolLine();
            _tools[(int)Xna2dDrawToolType.Polygon]   = new ToolPolygon();
            _tools[(int)Xna2dDrawToolType.Text]      = new XnaToolText();
            _tools[(int)Xna2dDrawToolType.Bitmap]    = new ToolImage();
            _tools[(int)Xna2dDrawToolType.Pan]       = new ToolPan();
            _tools[(int)Xna2dDrawToolType.Path]      = new XnaToolPath();

            XnaDrawObject.Dpi = new Point((int)1, (int)1);
        }