コード例 #1
0
        private void onMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.selection.Region = Rectangle.Empty;
                this.selectedRegion   = this.selection.Region;

                foreach (MapEntity entity in EntitiesToSelect)
                {
                    if (!SelectedEntities.Contains <MapEntity>(entity))
                    {
                        if (!ShiftDown)
                        {
                            SelectedEntities.Add(entity);
                        }
                    }
                    if (ShiftDown)
                    {
                        SelectedEntities.Remove(entity);
                    }
                }

                EntitiesToSelect.Clear();
            }
        }
コード例 #2
0
        private void onMouseChange(object sender, MouseEventArgs e)
        {
            this.EditorForm.Focus();
            if (e.Button == MouseButtons.Left)
            {
                int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale);
                int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale);

                this.selection.End(new Vector2(xt, yt));
                this.selectedRegion = this.selection.Region;

                IEnumerable <Entity> enumeration = EditorEngine.Instance.CurrentMap.Entities;

                foreach (MapEntity worldEntity in enumeration)
                {
                    if (selectedRegion.Intersects(worldEntity.Bounds))
                    {
                        if (!EntitiesToSelect.Contains(worldEntity))
                        {
                            EntitiesToSelect.Add(worldEntity);
                        }
                    }
                    else
                    {
                        EntitiesToSelect.Remove(worldEntity);
                    }
                }
            }
        }