Example #1
0
        public async Task Process(SetRectangle rect)
        {
            if (!IsLoggedIn)
            {
                return;
            }

            var bat = MyBattle;

            if (bat == null || (bat.Founder != User && !User.IsAdmin))
            {
                await Respond("No rights to set rectangle");

                return;
            }

            if (rect.Rectangle == null)
            {
                BattleRect org;
                bat.Rectangles.TryRemove(rect.Number, out org);
            }
            else
            {
                bat.Rectangles[rect.Number] = rect.Rectangle;
            }
            await state.Broadcast(bat.Users.Keys, rect);
        }
        private void PB_Preview_MouseUp(object sender, MouseEventArgs e)
        {
            m_MouseIsDown = false;
            Point end = (sender as PictureBox).PointToScreen(e.Location);

            DrawRectangle();
            if (m_MouseRect.X == 0 || m_MouseRect.Y == 0 || m_MouseRect.Width == 0 || m_MouseRect.Height == 0)
            {
            }
            else
            {
                SetRectangle?.Invoke(PB_Preview, m_MouseRect);
            }
            DrawRectangle();
        }