Ejemplo n.º 1
0
            /// <summary>
            /// Handles the Move event of the picModify control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
            public void picModify_Move(object sender, MouseEventArgs e)
            {
                if (isMouseDown)
                {
                    PictureBox pictureBox = (PictureBox)sender;
                    System.Drawing.Point position = view.pnlDraw.PointToClient(Cursor.Position);
                    int pictureBoxX = (position.X - view.pnlDraw.AutoScrollPosition.X) / PICTURE_BOX_SIZE;
                    int pictureBoxY = (position.Y - view.pnlDraw.AutoScrollPosition.Y) / PICTURE_BOX_SIZE;
                    if (pictureBoxX >= 0 && pictureBoxX < CurrentModel.selectedFloor.width &&
                        pictureBoxY >= 0 && pictureBoxY < CurrentModel.selectedFloor.height)
                    {
                        if (e.Button == MouseButtons.Left)
                        {
                            selectedTile = CurrentModel.selectedFloor.GetTile(pictureBoxX, pictureBoxY);
                            if (selectedTilePictureBox != null)
                            {
                                selectedTile.SetTile(selectedTilePictureBox.ImageLocation);
                            }
                            if (selectedObjectPictureBox != null)
                            {
                                selectedTile.objectOnTile.SetObject(selectedObjectPictureBox.ImageLocation);
                            }
                        }
                        else if (e.Button == MouseButtons.Right)
                        {
                            view.draggedPictureBox.Visible = true;
                            if (pictureBox.Parent != null && pictureBox.Parent is PictureBox)
                            {
                                view.draggedPictureBox.Image = (pictureBox.Parent as PictureBox).Image;
                            }
                            else
                            {
                                view.draggedPictureBox.Image = pictureBox.Image;
                            }
                            view.draggedPictureBox.Location = view.pnlDraw.PointToClient(Control.MousePosition);
                        }
                    }

                }
            }