Exemple #1
0
        /// <summary>
        /// Returns true if the server configuration is valid, or the user wants to keep it
        /// </summary>
        /// <returns>true if valid and should be saved, false if dialog should stay open</returns>
        private bool ValidateServerConfiguration()
        {
            if (!TunerName.Equals(VideoInputDeviceList.NetworkDeviceName))
            {
                return(true);
            }

            ServerConfig server = null;

            try
            {
                server = new ServerConfig(ServerAddress);

                ServerInfo info = server.GetServerInfo();

                bool foundSource = false;

                foreach (StreamSourceInfo i in info.StreamSources.Items)
                {
                    foundSource = (i.SourceName == ServerSource);
                    if (foundSource)
                    {
                        break;
                    }
                }

                if (!foundSource)
                {
                    throw new Exception("The server specified does not have any source called \"" + ServerSource + "\"!");
                }

                return(true);
            }
            catch (Exception ex)
            {
                DialogResult r = FCYesNoMsgBox.ShowDialog("Problem with Network TV configuration",
                                                          "Your Network TV configuration could not be verified. Would you like ignore this problem and keep these network settings anyway?" +
                                                          Environment.NewLine +
                                                          Environment.NewLine +
                                                          ex.Message,
                                                          this);

                return(r == DialogResult.Yes);
            }
            finally
            {
                if (server != null)
                {
                    server.Dispose();
                    server = null;
                }
            }
        }