Ejemplo n.º 1
0
        public static void saveGameListConfig(ListGames list)
        {
            XmlTextWriter xw      = null;
            Game          tmpGame = null;

            try
            {
                xw            = new XmlTextWriter(GameXMLFile, Encoding.UTF8);
                xw.Formatting = Formatting.Indented;

                xw.WriteStartDocument(true);

                xw.WriteStartElement("DesktopLiveStreamer");

                // Le parametre du jeu par défaut
                xw.WriteElementString("DefaultGame", DefaultGame);


                for (int i = 0; i < list.getSize(); i++)
                {
                    tmpGame = list[i];

                    xw.WriteStartElement("Game");
                    xw.WriteElementString("Caption", tmpGame.Caption);
                    xw.WriteElementString("Twitch_ID", tmpGame.TwitchGameID);
                    xw.WriteElementString("Own3D_ID", tmpGame.Own3DGameID);
                    xw.WriteEndElement();
                }

                xw.WriteEndElement();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xw != null)
                {
                    xw.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void FrmStreams_Load(object sender, EventArgs e)
        {
            listGames = new ListGames();
            listFavoriteStreams = new ListStreams();
            listLiveStreams = new ListStreams();

            XMLPersist.StreamXMLFile = "streamlist.xml";
            XMLPersist.GameXMLFile = "gamelist.xml";

            try
            {
                XMLPersist.loadStreamListConfig(listFavoriteStreams);
            }
            catch (FileNotFoundException)
            {
                // critical problem, the file needs to exist
                MessageBox.Show(this, "Error: Unable to load configuration file 'streamlist.xml'. Check if it " +
                            "exists in the directory of the application and is readable.",
                            "Configuration file not found", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }

            try
            {

                XMLPersist.loadGameListConfig(listGames);
            }
            catch (FileNotFoundException)
            {
                // Not very serious, the config file will be created later
                Console.WriteLine("An XML configuration file wasn't found");
            }

            // Check if VLC executable is found
            if (XMLPersist.VLCExecutable != null && !File.Exists(XMLPersist.VLCExecutable.Replace("\\\" --file-caching=5000", "").Replace("\\\"", "")))
            {
                // Try to get VLC directory from registry
                String path = ReadVLCExecutable();
                if (path != null && File.Exists(path))
                {
                    XMLPersist.VLCExecutable = "\\\"" + path + "\\\" --file-caching=5000"; ;
                    try
                    {
                        XMLPersist.saveStreamListConfig(listFavoriteStreams);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        MessageBox.Show(this, "Error: Unable to save the configuration. Check if you have write " +
                                    "permissions on the directory of the application.\n" +
                                    "Desktop Live Streamer may require administrative rights on some systems.", "Write permission required", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    DialogResult r = MessageBox.Show(this,
                        "VLC player doesn't appear to be installed or has been put in a different directory. Would you like to specify its path now ?",
                        "VLC Player not found",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    if (r == DialogResult.Yes)
                        btnChangeVLC_Click(this, EventArgs.Empty);
                }
            }

            // Check if LiveStreamer executable is found
            if (XMLPersist.LiveStreamerExecutable != null && !File.Exists(XMLPersist.LiveStreamerExecutable))
            {
                DialogResult r = MessageBox.Show(this,
                    "LiveStreamer doesn't appear to be installed or has been put in a different directory. Would you like to specify its path now ?",
                    "LiveStreamer not found",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                if (r == DialogResult.Yes)
                    btnChangeStreamer_Click(this, EventArgs.Empty);
            }

            updateComboGames();

            if (listGames.getSize() == 0)
            {
                btnChangeGame.Visible = false;
                btnValidateGame.Visible = true;

                loadAllGames = false;
                updateGamesThread = new Thread(new ThreadStart(updateGames));
                updateGamesThread.Start();
            }
            else
            {
                imgCmbGames.Enabled = false;
                btnUpdateGames.Enabled = false;
                btnUpdateGameMenu.Enabled = false;
                btnValidateGame.Visible = false;
                btnChangeGame.Visible = true;

                updateLiveStreamsThread = new Thread(new ThreadStart(updateLiveStreams));
                updateLiveStreamsThread.Start();
            }

            updateComboStreams();

            playing = false;
            btnStop.Enabled = false;
            btnPlay.Enabled = false;
            btnOpenBrowser.Enabled = false;

            radioList2.Checked = true;

            groupFavorites.Enabled = false;
            groupLive.Enabled = true;

            cmbQualities.Enabled = false;
            btnAddLiveStream.Enabled = false;

            imgCmbStreams_SelectedIndexChanged(this, EventArgs.Empty);
        }
Ejemplo n.º 3
0
        public static void loadGameListConfig(ListGames list)
        {
            XmlTextReader xr = null;
            int attributs_lus;
            Game tmpGame = null;
            try
            {
                xr = new XmlTextReader(GameXMLFile);

                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "Game")
                    {
                        tmpGame = new Game();
                        attributs_lus = 0;
                        while (xr.Read())
                        {
                            // Lecture des attributs d'une game
                            if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption")
                            {
                                xr.Read();
                                tmpGame.Caption = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Twitch_ID")
                            {
                                xr.Read();
                                tmpGame.TwitchGameID = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Own3D_ID")
                            {
                                xr.Read();
                                tmpGame.Own3DGameID = xr.Value.Trim();
                                attributs_lus++;
                            }

                            // Sortie de while quand tous les attributs on été lu
                            if (attributs_lus == 3)
                            {
                                list.add(tmpGame);
                                break;
                            }

                        }
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "DefaultGame")
                    {
                        xr.Read();
                        DefaultGame = xr.Value.Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xr != null)
                    xr.Close();
            }
        }
Ejemplo n.º 4
0
        public static void saveGameListConfig(ListGames list)
        {
            XmlTextWriter xw = null;
            Game tmpGame = null;
            try
            {
                xw = new XmlTextWriter(GameXMLFile, Encoding.UTF8);
                xw.Formatting = Formatting.Indented;

                xw.WriteStartDocument(true);

                xw.WriteStartElement("DesktopLiveStreamer");

                // Le parametre du jeu par défaut
                xw.WriteElementString("DefaultGame", DefaultGame);

                for (int i = 0; i < list.getSize(); i++)
                {
                    tmpGame = list[i];

                    xw.WriteStartElement("Game");
                    xw.WriteElementString("Caption", tmpGame.Caption);
                    xw.WriteElementString("Twitch_ID", tmpGame.TwitchGameID);
                    xw.WriteElementString("Own3D_ID", tmpGame.Own3DGameID);
                    xw.WriteEndElement();
                }

                xw.WriteEndElement();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xw != null)
                    xw.Close();
            }
        }
Ejemplo n.º 5
0
        public static void loadGameListConfig(ListGames list)
        {
            XmlTextReader xr = null;
            int           attributs_lus;
            Game          tmpGame = null;

            try
            {
                xr = new XmlTextReader(GameXMLFile);

                while (xr.Read())
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "Game")
                    {
                        tmpGame       = new Game();
                        attributs_lus = 0;
                        while (xr.Read())
                        {
                            // Lecture des attributs d'une game
                            if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption")
                            {
                                xr.Read();
                                tmpGame.Caption = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Twitch_ID")
                            {
                                xr.Read();
                                tmpGame.TwitchGameID = xr.Value.Trim();
                                attributs_lus++;
                            }
                            else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Own3D_ID")
                            {
                                xr.Read();
                                tmpGame.Own3DGameID = xr.Value.Trim();
                                attributs_lus++;
                            }

                            // Sortie de while quand tous les attributs on été lu
                            if (attributs_lus == 3)
                            {
                                list.add(tmpGame);
                                break;
                            }
                        }
                    }
                    else if (xr.NodeType == XmlNodeType.Element && xr.Name == "DefaultGame")
                    {
                        xr.Read();
                        DefaultGame = xr.Value.Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (xr != null)
                {
                    xr.Close();
                }
            }
        }