Exemple #1
0
        private void CMain_OnLoaded(object sender, RoutedEventArgs e)
        {
            DrawLine(CMain);
            _gs.X          = Properties.Settings.Default.FieldW;
            _gs.Y          = Properties.Settings.Default.FieldH;
            User.UserName  = Properties.Settings.Default.UserName;
            User.UserColor = Properties.Settings.Default.UserColor;
            User.UserForm  = (Form)Properties.Settings.Default.UserForm;
            if (User.UserColor == Colors.Yellow)
            {
                CbColor.SelectedIndex = 3;
            }
            else if (User.UserColor == Colors.Blue)
            {
                CbColor.SelectedIndex = 2;
            }
            else if (User.UserColor == Colors.Green)
            {
                CbColor.SelectedIndex = 1;
            }
            else if (User.UserColor == Colors.Red)
            {
                CbColor.SelectedIndex = 0;
            }
            TbName.Text = User.UserName;
            switch (User.UserForm)
            {
            case Form.Circle:
                _dot = new Circle(User.UserColor);
                CbForm.SelectedIndex = 0;
                break;

            case Form.Star:
                _dot = new Star(User.UserColor);
                CbForm.SelectedIndex = 1;
                break;

            case Form.Triangle:
                _dot = new Triangle(User.UserColor);
                CbForm.SelectedIndex = 2;
                break;

            default:
                //Todo Error!!!
                break;
            }
            TbConnectionIp.Text = Properties.Settings.Default.ServerIp;
        }
Exemple #2
0
        private async void Start_Click(object sender, RoutedEventArgs e)
        {
            while (!Connected)
            {
            }

            User.UserName = TbName.Text;
            switch (CbColor.SelectedIndex)
            {
            case 0:
                User.UserColor = Colors.Red;
                _dot.Color     = Colors.Red;
                break;

            case 1:
                User.UserColor = Colors.Green;
                _dot.Color     = Colors.Green;
                break;

            case 2:
                User.UserColor = Colors.Blue;
                _dot.Color     = Colors.Blue;
                break;

            case 3:
                User.UserColor = Colors.Yellow;
                _dot.Color     = Colors.Yellow;
                break;

            default:
                //Todo Error!!!
                break;
            }
            User.UserForm = (Form)CbForm.SelectedIndex;
            switch (User.UserForm)
            {
            case Form.Circle:
                _dot = new Circle(User.UserColor);
                break;

            case Form.Star:
                _dot = new Star(User.UserColor);
                break;

            case Form.Triangle:
                _dot = new Triangle(User.UserColor);
                break;

            default:
                //Todo Error!!!
                break;
            }
            if (!RoomSeted)
            {
                if ((LvRooms.SelectedIndex == -1) || (LvRooms.Items[0] is ListViewItem))
                {
                    MessageBox.Show("Wrong Room!!");
                    return;
                }
            }
            if (!LogIn)
            {
                await HubProxy.Invoke("join", User);

                while (!LogIn)
                {
                }
            }
            if (!RoomSeted)
            {
                var res = await HubProxy.Invoke <bool>("setRoom", ((ChatRoom)LvRooms.SelectedItem).Name);

                if (res)
                {
                    while (!RoomSeted)
                    {
                    }
                }
                else
                {
                    MessageBox.Show("Cant Set Room");
                    return;
                }
            }

            BForm.Visibility = Visibility.Collapsed;
            CMain.Children.Clear();
            CMain.Children.Add(_dot.Obj);
            DrawLine(CMain, _gs.Y, _gs.X);
            _matrix     = new byte[FieldH + 1, FieldW + 1];
            _boolMatrix = new bool[FieldH + 1, FieldW + 1];
            for (var i = 0; i < FieldH + 1; i++)
            {
                for (var j = 0; j < FieldW + 1; j++)
                {
                    _matrix[i, j]     = MatrixDefolt;
                    _boolMatrix[i, j] = false;
                }
            }
            CloseField(new List <Dot>
            {
                new Dot(1, 1, User.UserColor, User.UserForm),
                new Dot(2, 2, User.UserColor, User.UserForm),
                new Dot(3, 1, User.UserColor, User.UserForm),
                new Dot(2, 0, User.UserColor, User.UserForm)
            });
        }