public PeventEditor(Pevent pevent, SpriteBundle bundle, PeventClassBundle bundlec)
        {
            InitializeComponent();

            using (XNAUtils utils = new XNAUtils())
            {
                sBundle = bundle;
                pEvent = pevent;
                pSprite = pevent.pSprite;
                cBundle = bundlec;

                foreach (PeventClass pClass in cBundle.ListpEventClass)
                    CB_Class.Items.Add(pClass);
                CB_Class.Text = pevent.Class.ToString();
                CB_Direction.SelectedItem = pevent.Direction.ToString();
                CHK_Flying.Checked = pevent.Flying;

                if (pSprite != null)
                    PN_Graphics.BackgroundImage = utils.ConvertToImage(pevent.pSprite.SpriteImage);

                CB_MoveType.SelectedItem = pevent.MoveType.ToString();
                TB_Name.Text = pevent.Name;
                TB_Script.Text = pevent.Script;
                LB_Position.Text = pevent.Position.X + " x " + pevent.Position.Y;
                NUM_Sight.Value = new Decimal(pEvent.Sight);
                CHK_Through.Checked = pevent.Through;
                CB_TriggerType.SelectedItem = pevent.TriggerType.ToString();
                NUM_Speed.Value = new Decimal(pevent.Velocity);
                CHK_Disposable.Checked = pevent.Disposable;

                HasAccepted = false;
                this.CB_MoveType.SelectedIndexChanged += new System.EventHandler(this.CB_MoveType_SelectedIndexChanged);
            }
        }
 public CustomMouvement(Pevent pvent, string Depart, int mapWidth, int mapHeight)
 {
     InitializeComponent();
     ListePoints = pvent.ArretMouvement;
     foreach (Point point in ListePoints)
         LBMouvements.Items.Add(point);
     lblPointDepart.Text = "Point de départ: " + Depart;
     NUM_PointX.Maximum = mapWidth;
     NUM_PointY.Maximum = mapHeight;
 }
        public PopUpGraphics(Pevent pEvent,SpriteBundle psBundle)
        {
            sBundle = psBundle;
            pSprite = pEvent.pSprite;
            InitializeComponent();

            using (XNAUtils utils = new XNAUtils())
            {
                if (pSprite != null)
                    PN_Graphics.BackgroundImage = utils.ConvertToImage(pSprite.SpriteImage);
            }
        }
        public PeventEditor(Point position, SpriteBundle bundle, PeventClassBundle bundlec, Size map)
        {
            InitializeComponent();
            HasAccepted = false;

            LB_Position.Text = position.X + " x " + position.Y;

            pEvent = new Pevent();
            pEvent.Position = position;
            pEvent.ArretMouvement = new List<Point>();
            sBundle = bundle;
            cBundle = bundlec;
            Map = map;

            foreach (PeventClass pClass in cBundle.ListpEventClass)
                CB_Class.Items.Add(pClass);

            this.CB_MoveType.SelectedIndexChanged += new System.EventHandler(this.CB_MoveType_SelectedIndexChanged);
        }
 public PopUpScript(Pevent pEvent)
 {
     InitializeComponent();
     TB_Script.Text = pEvent.Script;
 }
 public void SetInfos(Pevent e)
 {
     label1.Text = e.Name == String.Empty ? "Sans nom" : e.Name;
     label2.Text = e.Class != null ? "Hors-classe" : e.Class.ToString();
 }
        private void EditEvent(Int32 X, Int32 Y)
        {
            if (!(X < PN_Map.Width - 1 && X > 0 && Y < PN_Map.Height - 1 && Y > 0)) return;

            Int32 l = CurrentLayer;
            Int32 x = X / Prefs.Map.TileSize.Width;
            Int32 y = Y / Prefs.Map.TileSize.Width;

            if (CurrentMap.Tiles[l, x, y].pEvent == null)
            {
                if (DraggingPevent != null)
                {
                    CurrentMap.Tiles[l, x, y].pEvent = DraggingPevent.Clone() as Pevent;
                    if (!((Control.ModifierKeys & Keys.Control) > 0)) CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent = null;

                    CurrentMap.Tiles[l, x, y].pEvent.Position = new System.Drawing.Point(x, y);
                }
                else
                {
                    PeventEditor dlg = new PeventEditor(new System.Drawing.Point(x, y), Project.Ressources.Sprites, Project.Ressources.Classes, new System.Drawing.Size(MapSize.Width, MapSize.Height));
                    dlg.ShowDialog();

                    if (dlg.HasAccepted)
                    {
                        CurrentMap.Tiles[l, x, y].pEvent = dlg.pEvent;
                    }
                    else if (dlg.HasDeleted)
                    {
                        CurrentMap.Tiles[l, x, y].pEvent = null;
                    }
                }
            }
            else
            {
                if (DraggingPevent != null && DraggingPevent.Position == CurrentMap.Tiles[l, x, y].pEvent.Position) DraggingPevent = null;

                if (DraggingPevent != null)
                {
                    CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent = CurrentMap.Tiles[l, x, y].pEvent.Clone() as Pevent;
                    CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent.Position = new System.Drawing.Point(DraggingPevent.Position.X, DraggingPevent.Position.Y);

                    CurrentMap.Tiles[l, x, y].pEvent = DraggingPevent.Clone() as Pevent;
                    CurrentMap.Tiles[l, x, y].pEvent.Position = new System.Drawing.Point(x, y);
                }
                else
                {
                    PeventEditor dlg = new PeventEditor(CurrentMap.Tiles[l, x, y].pEvent, Project.Ressources.Sprites, Project.Ressources.Classes);
                    dlg.ShowDialog();

                    if (dlg.HasAccepted) CurrentMap.Tiles[l, x, y].pEvent = dlg.pEvent.Clone() as Pevent;
                    else if (dlg.HasDeleted) CurrentMap.Tiles[l, x, y].pEvent = null;
                }
            }

            DraggingPevent = null;
            Refresh();
            DrawMap();
        }
        private void PN_Map_MouseLeave(object sender, EventArgs e)
        {
            LB_STATUS_Position.Text = "Hors du canvas";
            LB_STATUS_Position.ForeColor = System.Drawing.Color.Red;

            DraggingPevent = null;
        }
 private void PN_Map_MouseDown(object sender, MouseEventArgs e)
 {
     if (CurrentMap.Tiles != null && CurrentTool == DrawingTools.Event && CurrentMap.Tiles[CurrentLayer, e.X / Prefs.Map.TileSize.Width, e.Y / Prefs.Map.TileSize.Height].pEvent != null)
     {
         DraggingPevent = CurrentMap.Tiles[CurrentLayer, e.X / Prefs.Map.TileSize.Width, e.Y / Prefs.Map.TileSize.Height].pEvent.Clone() as Pevent;
     }
 }