Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapScreenControl"/> class.
        /// </summary>
        public MapScreenControl()
        {
            if (!DesignMode && LicenseManager.UsageMode != LicenseUsageMode.Runtime)
            {
                return;
            }

            _drawingManager  = new DrawingManager();
            _transBoxManager = new TransBoxManager();
            _camera          = new Camera2D(ClientSize.ToVector2())
            {
                KeepInMap = true
            };

            if (DrawingManager.LightManager.DefaultSprite == null)
            {
                DrawingManager.LightManager.DefaultSprite = new Grh(GrhInfo.GetData("Effect", "light"));
            }

            GlobalState.Instance.Map.SelectedObjsManager.SelectedChanged += SelectedObjsManager_SelectedChanged;

            lock (_instancesSync)
            {
                _instances.Add(this);
            }
        }
Пример #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Resize"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            if (DesignMode)
            {
                return;
            }

            Camera.Size = ClientSize.ToVector2() * Camera.Scale;
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapScreenControl"/> class.
 /// </summary>
 public GrhAtlasView()
 {
     TilesetConfiguration = null;
     if (!DesignMode && LicenseManager.UsageMode != LicenseUsageMode.Runtime)
     {
         return;
     }
     _transBoxManager = new TransBoxManager();
     _camera          = new Camera2D(ClientSize.ToVector2())
     {
         KeepInMap = false
     };
 }
Пример #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Resize"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            if (DesignMode)
            {
                return;
            }

            var oldCenter = Camera.Center;

            Camera.Size = ClientSize.ToVector2();
            Camera.CenterOn(oldCenter);
        }
Пример #5
0
        /// <summary>
        /// Allows derived classes to handle when the <see cref="RenderWindow"/> is created or re-created.
        /// </summary>
        /// <param name="newRenderWindow">The current <see cref="RenderWindow"/>.</param>
        protected override void OnRenderWindowCreated(RenderWindow newRenderWindow)
        {
            base.OnRenderWindowCreated(newRenderWindow);

            if (DesignMode)
            {
                return;
            }

            DrawingManager.RenderWindow = newRenderWindow;

            var oldCenter = Camera.Center;

            Camera.Size = ClientSize.ToVector2();
            Camera.CenterOn(oldCenter);
        }
Пример #6
0
        /// <summary>
        /// Derived classes override this to initialize their drawing code.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (DesignMode)
            {
                return;
            }

            Camera.Size = ClientSize.ToVector2();
            Camera.CenterOn(Vector2.Zero);

            var t = new Timer {
                Interval = 1000 / 60
            };

            t.Tick += (EventHandler)((x, y) => InvokeDrawing(this, EventArgsHelper.Create(TickCount.Now)));
            t.Start();
        }