using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace DarkWynter.App { public partial class CutSceneMain : UserControl { // Holds the temp item before adding to permanent list public CSObjects tempObj; // Holds the objects of created items public List CSObjecList = new List(); WayPointPopUp waypointPopUp; ActorPopUp actorPopUp; PropPopUp propPopUp; public CutSceneMain() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.terrain.AllowDrop = true; this.terrain.DragEnter += new DragEventHandler(terrain_DragEnter); this.terrain.DragDrop += new DragEventHandler(terrain_DragDrop); this.waypoint.MouseDown += new MouseEventHandler(waypoint_MouseDown); } #region Terrain /// /// Copy the new image /// /// /// void terrain_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Bitmap)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } /// /// Create the new bitmap onto the terrain and add the csobject to the list /// /// /// void terrain_DragDrop(object sender, DragEventArgs e) { Bitmap bmp = (Bitmap)e.Data.GetData(DataFormats.Bitmap); //Get graphics from the Image in the PictureBox1 which is the drop destination. Graphics g = Graphics.FromImage(this.terrain.Image); Point location = this.terrain.PointToClient(new Point(e.X, e.Y)); //Draw the draged image onto the destinational image g.DrawImage(bmp, location); //Force the PictureBox to redraw himself this.terrain.Invalidate(); // Create the objects as perment if (tempObj != null) { if (tempObj is Waypoint) { tempObj = new Waypoint(bmp, location.X, location.Y, (this.waypoint.Name + CSObjecList.Count)); CSObjecList.Add(tempObj); tempObj = null; } if (tempObj is Actor) { tempObj = new Actor(bmp, location.X, location.Y, (this.actor.Name + CSObjecList.Count)); CSObjecList.Add(tempObj); tempObj = null; } if (tempObj is Prop) { tempObj = new Prop(bmp, location.X, location.Y, (this.prop.Name + CSObjecList.Count)); CSObjecList.Add(tempObj); tempObj = null; } } } /// /// If clicked on csobject location, launch properties window /// /// /// void terrain_DoubleClick(object sender, EventArgs e) { Button ThisButton = sender as Button;//or Button ThisButton = (Button)sender; MouseEventArgs me = e as MouseEventArgs;//or MouseEventArgs em = (MouseEventArgs)e; Point newPoint = new Point(me.X, me.Y); for (int i = 0; i < CSObjecList.Count; i++) { if (CSObjecList[i] is Waypoint && newPoint.X < (CSObjecList[i].imageLocation.X + 20) && newPoint.X > (CSObjecList[i].imageLocation.X - 20) && newPoint.Y < (CSObjecList[i].imageLocation.Y + 20) && newPoint.Y > (CSObjecList[i].imageLocation.Y - 20)) { // Create waypoint popup waypointPopUp = new WayPointPopUp(CSObjecList[i]); waypointPopUp.Show(); CSObjecList[i] = WayPointPopUp.tempObject; } else if (CSObjecList[i] is Actor && newPoint.X < (CSObjecList[i].imageLocation.X + 20) && newPoint.X > (CSObjecList[i].imageLocation.X - 30) && newPoint.Y < (CSObjecList[i].imageLocation.Y + 30) && newPoint.Y > (CSObjecList[i].imageLocation.Y - 30)) { // Create Actor popup actorPopUp = new ActorPopUp(CSObjecList[i]); actorPopUp.Show(); CSObjecList[i] = ActorPopUp.tempObject; } else if (CSObjecList[i] is Prop && newPoint.X < (CSObjecList[i].imageLocation.X + 20) && newPoint.X > (CSObjecList[i].imageLocation.X - 30) && newPoint.Y < (CSObjecList[i].imageLocation.Y + 30) && newPoint.Y > (CSObjecList[i].imageLocation.Y - 30)) { // Create Prop popup propPopUp = new PropPopUp(CSObjecList[i]); propPopUp.Show(); CSObjecList[i] = PropPopUp.tempObject; } } } #endregion #region WayPoint /// /// If image selected, prepare it for drag /// /// /// void waypoint_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { tempObj = new Waypoint(""); this.waypoint.DoDragDrop(this.waypoint.Image, DragDropEffects.All); } if (e.Button == MouseButtons.Right) { // this is where we needtodothe arrow change direction thing } } /// /// Put name out to side /// /// /// void waypoint_MouseHover(object sender, EventArgs e) { if (this.waypointLabel.Visible == false) { this.waypointLabel.Visible = true; } } /// /// Remove name /// /// /// void waypoint_MouseLeave(object sender, EventArgs e) { this.waypointLabel.Visible = false; } #endregion #region Actor /// /// If image selected, prepare it for drag /// /// /// void actor_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { tempObj = new Actor(""); this.actor.DoDragDrop(this.actor.Image, DragDropEffects.All); } if (e.Button == MouseButtons.Right) { // this is where we needtodothe arrow change direction thing } } /// /// Put name out to side /// /// /// void actor_MouseHover(object sender, EventArgs e) { if (this.actorLabel.Visible == false) { this.actorLabel.Visible = true; } } /// /// Remove name /// /// /// void actor_MouseLeave(object sender, EventArgs e) { this.actorLabel.Visible = false; } #endregion #region Prop /// /// If image selected, prepare it for drag /// /// /// void prop_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { tempObj = new Prop(""); this.prop.DoDragDrop(this.prop.Image, DragDropEffects.All); } if (e.Button == MouseButtons.Right) { // this is where we needtodothe arrow change direction thing } } /// /// Put name out to side /// /// /// void prop_MouseHover(object sender, EventArgs e) { if (this.propLabel.Visible == false) { this.propLabel.Visible = true; } } /// /// Remove name /// /// /// void prop_MouseLeave(object sender, EventArgs e) { this.propLabel.Visible = false; } #endregion } }