public void Move(int deltaX, int deltaY)
 {
     if (DoMove(ref _viewPort, deltaX, deltaY))
     {
         AreaChanged?.Invoke(this, EventArgs.Empty);
     }
 }
        public void Select(Wip.ZoneArea area)
        {
            AreaList.SelectedItem = area;
            CurrentArea           = area;

            DeleteButton.Enabled = area != null;
            RenameButton.Enabled = area != null;

            AreaChanged?.Invoke(this, null);
        }
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);

            var rect = new Rectangle(this.Location, this.Size);

            if (DebugMode)
            {
                this.labelInfo.Text = rect.ToString();
            }

            AreaChanged?.Invoke(rect);
        }
Exemple #4
0
        public void scale(double c)
        {
            Console.WriteLine(this + "My area was " + area);
            var v = Math.Sqrt(c);

            points[0].X = points[0].X * v;
            points[1].Y = points[2].Y * v;
            points[2].X = points[3].X * v;
            points[3].Y = points[3].Y * v;
            area        = area * c;
            Console.WriteLine("Now I'm ");

            AreaChanged?.Invoke(this, area);
        }
Exemple #5
0
 void DisplayInfo()
 {
     if (Enabled == true)
     {
         StringBuilder b = new StringBuilder();
         b.Append("Zoom: ").AppendLine();
         b.Append(_viewPort.UserZoomFactor * 100 + "%").AppendLine();
         string informations = b.ToString();
         AreaChanged?.Invoke(this, informations);
         StringBuilder b2 = new StringBuilder();
         b2.Append("ViewPort: ").Append(_viewPort.Area).AppendLine();
         b2.Append("ClientScaleFactor: ").Append(_viewPort.ClientScaleFactor).AppendLine();
         b2.Append("Client size : ").Append(this.ClientSize);
         string engineinfos = b2.ToString();
         EngineInformationsChanged?.Invoke(this, engineinfos);
         ViewPortHeightChanged?.Invoke(this, _viewPort.Area.Height);
     }
 }
        bool SetActualZoomFactor(double value)
        {
            Debug.Assert(_map.Area.Contains(_viewPort));
            if (value > 1.0)
            {
                value = 1.0;
            }
            else if (value < MinActualZoomFactor)
            {
                value = MinActualZoomFactor;
            }
            if (Math.Abs(value - ActualZoomFactor) <= double.Epsilon)
            {
                return(false);
            }

            double grow     = value / ActualZoomFactor;
            int    newWidth = (int)Math.Round(_viewPort.Width * grow);

            if (newWidth < _minDisplayWidth)
            {
                newWidth = _minDisplayWidth;
            }
            int newHeight = (int)Math.Round(_viewPort.Height * grow);

            if (newHeight < _minDisplayWidth)
            {
                newHeight = _minDisplayWidth;
            }
            int deltaW = (newWidth - _viewPort.Width) / 2;
            int deltaH = (newHeight - _viewPort.Height) / 2;

            if (deltaW == 0 && deltaH == 0)
            {
                return(false);
            }
            _viewPort.Width  = newWidth;
            _viewPort.Height = newHeight;
            DoMove(ref _viewPort, -deltaW, -deltaW);
            Debug.Assert(_map.Area.Contains(_viewPort));
            _clientScaleFactor = _maxClientSize / (float)Math.Max(_viewPort.Width, _viewPort.Height);
            AreaChanged?.Invoke(this, EventArgs.Empty);
            return(true);
        }
Exemple #7
0
        public static void FireEventsFromMessage(Message message)
        {
            switch (message.Id)
            {
            case Messages.IngameBotStart:
                IngameBotStart?.Invoke();
                return;

            case Messages.AreaChanged:
                AreaChanged?.Invoke(null, new AreaChangedArgs(message));
                return;

            case Messages.CombatAreaChanged:
                CombatAreaChanged?.Invoke(null, new AreaChangedArgs(message));
                return;

            case Messages.PlayerDied:
                PlayerDied?.Invoke(message.GetInput <int>());
                return;

            case Messages.PlayerResurrected:
                PlayerResurrected?.Invoke();
                return;

            case Messages.PlayerLeveled:
                PlayerLeveled?.Invoke(message.GetInput <int>());
                return;

            case Messages.ItemLootedEvent:
                ItemLootedEvent?.Invoke(message.GetInput <CachedItem>());
                return;

            case Messages.ItemStashedEvent:
                ItemStashedEvent?.Invoke(message.GetInput <CachedItem>());
                return;

            case Messages.ItemsSoldEvent:
                ItemsSoldEvent?.Invoke(null, new ItemsSoldArgs(message));
                return;
            }
        }
Exemple #8
0
        internal void SetClientSize(Size client)
        {
            Debug.Assert(_map.Area.Contains(_viewPort));
            _maxClientSize = Math.Max(client.Width, client.Height);
            Rectangle newViewPort = _viewPort;
            bool      keepH       = _viewPort.Height > _viewPort.Width || (_viewPort.Height == _viewPort.Width && client.Height > client.Width);

            if (keepH)
            {
                _clientScaleFactor = (float)_maxClientSize / _viewPort.Height;
                newViewPort.Width  = (int)Math.Ceiling(_viewPort.Height * client.Width / (double)_maxClientSize);
                if (newViewPort.Width < _minDisplayWidth)
                {
                    newViewPort.Width = _minDisplayWidth;
                }
                if (newViewPort.Right > _map.MapWidth)
                {
                    DoMove(ref newViewPort, _map.MapWidth - newViewPort.Right, 0);
                }
            }
            else
            {
                _clientScaleFactor = (float)_maxClientSize / _viewPort.Width;
                newViewPort.Height = (int)Math.Ceiling(_viewPort.Width * client.Height / (double)_maxClientSize);
                if (newViewPort.Height < _minDisplayWidth)
                {
                    newViewPort.Height = _minDisplayWidth;
                }
                if (newViewPort.Bottom > _map.Area.Height)
                {
                    DoMove(ref newViewPort, 0, _map.Area.Height - newViewPort.Bottom);
                }
            }
            Debug.Assert(_map.Area.Contains(newViewPort));
            _viewPort          = newViewPort;
            _clientScaleFactor = (float)_maxClientSize / Math.Max(_viewPort.Width, _viewPort.Height);
            AreaChanged?.Invoke(this, EventArgs.Empty);
        }
Exemple #9
0
 protected virtual void OnAreaChanged() => AreaChanged?.Invoke(this, new EventArgs());
Exemple #10
0
 protected virtual void OnAreaChanged() => AreaChanged?.Invoke(this, EventArgs.Empty);