static void Main(string[] args)
        {
            const int port = 1234;
            //const string address = "192.168.56.1";
            var client = new ClientListener(port);

            client.Start();
        }
        public MainWindow()
        {
            InitializeComponent();
            Common.Populate(); //Add ranks and other defaults
            SetRankImages();

            cl = new ClientListener();
        }
Example #3
0
        private void SendName_Clicked(object sender, EventArgs e)
        {
            ClientListener.Kullanici = new ClientKullanici
            {
                KullaniciAdi = Name.Text,
                Sorular      = new List <ClientKullanici.SoruOzellikleri>()
            };

            ClientListener.SendObject();


            //Bekle();
        }
Example #4
0
 private void Giris_Clicked(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Ip.Text))
     {
         //Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         ClientListener.Ip = Ip.Text;
         var result = ClientListener.Start();
         if (result)
         {
             Navigation.PushModalAsync(new NamePage());
         }
         else
         {
             Info.Text = "Ağa bağlanılamadı";
         }
         //try
         //{
         //    var result = Socket.BeginConnect(ip, 100, null, null);
         //    bool success = result.AsyncWaitHandle.WaitOne(500);
         //    if (success)
         //    {
         //        Socket.EndConnect(result);
         //        Navigation.PushModalAsync(new NamePage());
         //    }
         //    else
         //    {
         //        throw new SocketException(10060);
         //    }
         //}
         //catch (Exception)
         //{
         //    Socket.Close();
         //    Info.Text = "Ağa bağlanılamadı";
         //}
     }
 }
Example #5
0
        private void SoruYukle()
        {
            int gridRowCount    = Convert.ToInt16(Math.Ceiling((decimal)_test.CevapSayisi / 2));
            int gridColumnCount = 2;
            // Grid
            Grid mainGrid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            for (int i = 0; i < gridRowCount; i++)
            {
                mainGrid.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }

            // COLORS ADD
            #region Color
            colors.Add(Color.Red);
            colors.Add(Color.CornflowerBlue);
            colors.Add(Color.Orange);
            colors.Add(Color.MediumVioletRed);
            colors.Add(Color.ForestGreen);
            colors.Add(Color.Gold);
            colors.Add(Color.HotPink);
            colors.Add(Color.Teal);
            #endregion


            // OTHER COMPENENTS
            for (int i = 0; i < _test.CevapSayisi; i++)
            {
                buttons.Add(new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    BackgroundColor   = colors[i],
                });

                buttons[i].Clicked += new EventHandler(Button_Clicked);
            }

            // ADDING COMPENENTS TO STACKLAYOUTS
            byte btnIndex = 0;
            for (int i = 0; i < gridRowCount; i++)
            {
                for (int k = 0; k < gridColumnCount; k++)
                {
                    if (btnIndex >= _test.CevapSayisi)
                    {
                        break;
                    }
                    Grid.SetRow(buttons[btnIndex], i);
                    Grid.SetColumn(buttons[btnIndex], k);
                    btnIndex++;
                }
            }

            for (int i = 0; i < _test.CevapSayisi; i++)
            {
                mainGrid.Children.Add(buttons[i]);
            }

            Content = mainGrid;

            Device.StartTimer(TimeSpan.FromSeconds(0.1), () =>
            {
                sure += 0.1f;
                if (sure >= _test.Sure)
                {
                    if (sonuc == -1)
                    {
                        ClientListener.Kullanici.Sorular.Add(new ClientKullanici.SoruOzellikleri
                        {
                            Cevap       = 99,
                            CevapSuresi = sure,
                        });
                        ClientListener.SendObject();
                        Navigation.PushModalAsync(new SoruSonuc(sonuc, totalPuan));
                        sure = 0;
                        IndexArtır();
                        sureBitti = true;
                        return(false);
                    }
                }
                return(true); // True = Repeat again, False = Stop the timer
            });
        }
Example #6
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            // Soruya Ait Cevapları Bul
            List <Cevap> cevaplar = new List <Cevap>();
            int          soruId   = _sorular[ClientListener.SoruIndex].SoruId;

            foreach (Cevap cevap in _cevaplar)
            {
                if (cevap.SoruId == soruId)
                {
                    cevaplar.Add(cevap);
                }
            }

            Button button = (Button)sender;

            // Tıklanılan butonun indexini bul ve Hangi Cevabın verildiğini tespit et.
            int cevapIndex = buttons.IndexOf(button);

            if (Convert.ToBoolean(cevaplar[cevapIndex].Dogru))
            {
                sonuc = 1;
            }
            else
            {
                sonuc = 0;
            }

            float puan;

            if (!sureBitti && sonuc == 1)
            {
                puan = 250 / sure;
            }
            else
            {
                puan = 0;
            }


            ClientListener.Kullanici.Sorular.Add(new ClientKullanici.SoruOzellikleri
            {
                Puan        = puan,
                CevapSuresi = sure,
            });

            if (ClientListener.Kullanici.Sorular.Count > 0)
            {
                foreach (var item in ClientListener.Kullanici.Sorular)
                {
                    totalPuan += item.Puan;
                }
            }

            ClientListener.Kullanici.TotalPuan = totalPuan;

            // Cevabı Gönder
            ClientListener.SendObject();

            IndexArtır();
            // Bekleme Ekranını AÇ
            Navigation.PushModalAsync(new SoruSonuc(sonuc, totalPuan));
        }