Beispiel #1
0
        //-------------------------------------------------------------
        public KobberLan()
        //-------------------------------------------------------------
        {
            suggestForm    = null;
            broadcast      = null;
            communication  = null;
            countBroadcast = 2;
            suggestedGames = new List <SuggestedGame>();

            InitializeComponent();

            Torrent.Get().SetGuiReference(this);
            Log.Get().SetGuiReference(this);
        }
Beispiel #2
0
 //-------------------------------------------------------------
 private void button_SuggestInternetGame_Click(object sender, EventArgs e)
 //-------------------------------------------------------------
 {
     //Show Internet form
     if (suggestForm == null || suggestForm.GetClosedStatus() == true)
     {
         suggestForm = new SuggestInternetGame(this);
         suggestForm.Show(this);
     } //Focus on Internet form
     else
     {
         suggestForm.BringToFront();
         suggestForm.Focus();
     }
 }
Beispiel #3
0
        //-------------------------------------------------------------
        public void SuggestInternetGame(SuggestInternetGame suggestForm)
        //-------------------------------------------------------------
        {
            DTO_Suggestion game = new DTO_Suggestion()
            {
                type       = Code.SuggestionType.Internet,
                title      = "Unknown",
                author     = Helper.GetHostIP().ToString(),
                imageCover = Properties.Resources.no_cover //Default image
            };

            game.description = suggestForm.GetDescription();
            game.title       = suggestForm.GetTitle(); //Key / title is the same
            game.key         = suggestForm.GetTitle(); //Key / title is the same
            game.version     = suggestForm.GetVersion();
            game.startGame   = suggestForm.GetStartLocation();
            game.maxPlayers  = suggestForm.GetMaxPlayers();

            //Get images
            var imageBigUrl   = suggestForm.GetImageBig();
            var imageCoverUrl = suggestForm.GetImageCover();

            //Get images from Internet
            WebClient client = new WebClient();
            Stream    stream = client.OpenRead(imageCoverUrl);

            game.imageCover = Bitmap.FromStream(stream);
            stream.Close();
            stream        = client.OpenRead(imageBigUrl);
            game.imageBig = Bitmap.FromStream(stream);
            stream.Close();
            client.Dispose();

            //Send suggestion to LAN
            Log.Get().Write("Communication client prepare to send Internet suggested");
            communication.ClientSend(game);

            //Update own GUI with suggested game
            AddSuggestedGame(game);

            //Destroy InternetForm
            suggestForm.Dispose();
            suggestForm = null;
        }