Example #1
0
        private void MoveDrag(MouseEventArgs e)
        {
            GetAcreCoordinates(e, out var nhX, out var nhY);

            if (DragX == -1)
            {
                DragX = nhX;
                DragY = nhY;
                return;
            }

            var dX = DragX - nhX;
            var dY = DragY - nhY;

            if (ModifierKeys == Keys.Control)
            {
                dX *= 2;
                dY *= 2;
            }

            if ((dX & 1) == 1)
            {
                dX ^= 1;
            }
            if ((dY & 1) == 1)
            {
                dY ^= 1;
            }

            var aX = Math.Abs(dX);
            var aY = Math.Abs(dY);

            if (aX < 2 && aY < 2)
            {
                return;
            }

            DragX = nhX;
            DragY = nhY;
            if (!View.SetViewTo(View.X + dX, View.Y + dY))
            {
                return;
            }

            Dragging = true;
            LoadItemGridAcre();
        }
Example #2
0
        private void ClickMapAt(MouseEventArgs e, bool skipLagCheck)
        {
            var  layer         = Map.Items.Layer1;
            int  mX            = e.X;
            int  mY            = e.Y;
            bool centerReticle = CHK_SnapToAcre.Checked;

            View.GetViewAnchorCoordinates(mX, mY, out var x, out var y, centerReticle);
            x &= 0xFFFE;
            y &= 0xFFFE;

            var  acre     = layer.GetAcre(x, y);
            bool sameAcre = AcreIndex == acre;

            if (!skipLagCheck)
            {
                if (CHK_SnapToAcre.Checked)
                {
                    if (sameAcre)
                    {
                        return;
                    }
                }
                else
                {
                    const int delta = 0; // disabled = 0
                    var       dx    = Math.Abs(View.X - x);
                    var       dy    = Math.Abs(View.Y - y);
                    if (dx <= delta && dy <= delta && !sameAcre)
                    {
                        return;
                    }
                }
            }

            if (!CHK_SnapToAcre.Checked)
            {
                View.SetViewTo(x, y);
                LoadItemGridAcre();
                return;
            }

            if (!sameAcre)
            {
                CB_Acre.SelectedIndex = acre;
            }
        }