Beispiel #1
0
        public MediaPlayerWindow(bool aEnabled, IRefreshHandler aRefreshHandler)
        {
            InitializeComponent();

            iRefreshHandler = aRefreshHandler;

            buttonRefresh.Click += new RoutedEventHandler(EventButtonRefreshClick);

            iReceiverList = new ReceiverList(this.Dispatcher);

            iReceiverList.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(EventReceiverListCollectionChanged);

            iMediaPlayerConfiguration = MediaPlayerConfiguration.Load(aEnabled);

            listBoxReceivers.ItemsSource = iMediaPlayerConfiguration.MediaPlayerList;
        }
Beispiel #2
0
        public static MediaPlayerConfiguration Load(bool aEnabled)
        {
            MediaPlayerConfiguration configuration;

            XmlSerializer xml = new XmlSerializer(typeof(MediaPlayerConfiguration));

            string common = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string folder = Path.Combine(common, "ohSongcast");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            string path = Path.Combine(folder, "MediaPlayerConfiguration.xml");

            if (!File.Exists(path))
            {
                configuration = new MediaPlayerConfiguration();
                configuration.SetPath(path);
                configuration.Save();
            }
            else
            {
                try
                {
                    using (TextReader reader = new StreamReader(path))
                    {
                        configuration = (MediaPlayerConfiguration)xml.Deserialize(reader);
                        configuration.SetPath(path);
                    }
                }
                catch (Exception)
                {
                    configuration = new MediaPlayerConfiguration();
                    configuration.SetPath(path);
                    configuration.Save();
                }
            }

            configuration.Initialise(aEnabled);

            return(configuration);
        }
        public static MediaPlayerConfiguration Load(bool aEnabled)
        {
            MediaPlayerConfiguration configuration;

            XmlSerializer xml = new XmlSerializer(typeof(MediaPlayerConfiguration));

            string common = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string folder = Path.Combine(common, "ohSongcast");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            string path = Path.Combine(folder, "MediaPlayerConfiguration.xml");

            if (!File.Exists(path))
            {
                configuration = new MediaPlayerConfiguration();
                configuration.SetPath(path);
                configuration.Save();
            }
            else
            {
                try
                {
                    using (TextReader reader = new StreamReader(path))
                    {
                        configuration = (MediaPlayerConfiguration)xml.Deserialize(reader);
                        configuration.SetPath(path);
                    }
                }
                catch (Exception)
                {
                    configuration = new MediaPlayerConfiguration();
                    configuration.SetPath(path);
                    configuration.Save();
                }
            }

            configuration.Initialise(aEnabled);

            return (configuration);
        }