Пример #1
0
        public static void Open(Control parent, WordChoice wordChoice, EventHandler <WordChoosenEventArgs> wordChoosen)
        {
            // disable the page control
            foreach (Control control in parent.Controls)
            {
                if (control is Page)
                {
                    control.Enabled = false;
                }
            }

            var msg = new MessageWordChoice();

            msg.btnFirstWord.Text  = wordChoice.Words[0];
            msg.btnSecondWord.Text = wordChoice.Words[1];
            msg.btnThirdWord.Text  = wordChoice.Words[2];
            msg.WordChoosen       += wordChoosen;
            parent.SizeChanged    += msg.OnSizeChanged;
            parent.Controls.Add(msg);
            msg.Disposed += (s, e) => Msg_Disposed(parent, EventArgs.Empty);
            msg.OnSizeChanged(parent, EventArgs.Empty);
            msg.Show();
            msg.BringToFront();
        }
Пример #2
0
        private void Client_ObjectReceived(object sender, AdvancedNetworkLib.ObjectReceivedEventArgs e)
        {
            Console.WriteLine($"Received obj '{e.Object.GetType().Name}'");

            var obj = e.Object;

            if (obj is RankList)
            {
                this.updateRankListControl(obj as RankList);
            }
            else if (obj is ChatMessage)
            {
                var chatMessage = obj as ChatMessage;
                this.chatControl.AddMessage(chatMessage.PlayerName, chatMessage.Text);
            }
            else if (obj is ChoosingWordInfo)
            {
                var choosingWordInfo = obj as ChoosingWordInfo;
                this.chatControl.AddInfo($"{choosingWordInfo.PlayerName} wählt ein Wort!");
            }
            else if (obj is FoundWordInfo)
            {
                var foundWordInfo = obj as FoundWordInfo;
                this.chatControl.AddInfo($"{foundWordInfo.PlayerName} hat das Wort erraten!");
            }
            else if (obj is WhatDoYouWantInfo)
            {
                this.chatControl.AddInfo("Was willst du damit erreichen?");
            }
            else if (obj is WordChoice)
            {
                var wordChoice = obj as WordChoice;
                MessageWordChoice.Open(this.Parent, wordChoice, this.wordChoosen);
            }
            else if (obj is Drawing)
            {
                using (var ms = new MemoryStream((obj as Drawing).Data))
                {
                    this.drawField.updateBitmap((Bitmap)Image.FromStream(ms));
                }
            }
            else if (obj is DrawingRequest)
            {
                // send latest drawing
                this.DrawField_BitmapChanged(null, EventArgs.Empty);
            }
            else if (obj is ChoosedWordInfo)
            {
                var choosedWord = obj as ChoosedWordInfo;
                this.lblWord.Text = choosedWord.Word;
            }
            else if (obj is FinalEvaluation)
            {
                this.chatControl.AddInfo("Ende im Gelände");
            }
            else if (obj is SimpleRoundInfo)
            {
                var sri = obj as SimpleRoundInfo;
                this.lblRoundInfo.Text = $"Runde {sri.Current} von {sri.Total}";
            }
            else if (obj is KickedNoMorePlayer)
            {
                this.Parent.closeCurrentPage();
                MessageBox.Show("Alle Spieler haben das Spiel verlassen");
            }
            else if (obj is KickedByHost)
            {
                this.Parent.closeCurrentPage();
                MessageBox.Show("Du wurdest aus dem Spiel geworfen!");
            }
        }