Ejemplo n.º 1
0
        internal void ApplyConfiguration(Configuration appliedConfiguration, bool refreshPlayer, bool force)
        {
            try
            {
                bool isAudioscrobblerUpdated = false;
                bool isProxyUpdated = false;

                if (this.configuration.LastFmSubmit != appliedConfiguration.LastFmSubmit ||
                    this.configuration.LastFmUser != appliedConfiguration.LastFmUser ||
                    this.configuration.LastFmPassword != appliedConfiguration.LastFmPassword)
                {
                    isAudioscrobblerUpdated = true;
                }

                if (configuration.ProxyHost != appliedConfiguration.ProxyHost ||
                    configuration.ProxyPort != appliedConfiguration.ProxyPort ||
                    configuration.ProxyUser != appliedConfiguration.ProxyUser ||
                    configuration.ProxyPassword != appliedConfiguration.ProxyPassword)
                {
                    isProxyUpdated = true;
                }

                if (force)
                {
                    isAudioscrobblerUpdated = true;
                    isProxyUpdated = true;
                }

                //
                // Apply

                this.configuration.Apply(appliedConfiguration);

                try
                {
                    //
                    // Title buttons

                    this.btnClose.Visible = this.configuration.CloseButtonVisible;
                    this.btnMinimize.Visible = this.configuration.MinimizeButtonVisible;

                    //
                    // Window

                    this.TopMost = this.configuration.KeepOnTop;
                    settingsForm.TopMost = this.configuration.KeepOnTop;

                    //
                    // Tool tip

                    if (this.configuration.CloseButtonMinimizeToTray)
                    {
                        toolTip.SetToolTip(this.btnClose, "Close (Minimize to Tray)");
                    }
                    else
                    {
                        toolTip.SetToolTip(this.btnClose, "Close (Exit)");
                    }

                    toolTip.SetToolTip(this.btnMinimize, "Minimize");

                    //
                    // G15

                    if (configuration.SendToG15 && g15 == null)
                    {
                        Debug.WriteLine("Connecting to G15");

                        g15 = new G15();

                        // first define some delegates
                        bDelegate = new ButtonDelegate(this.ButtonDelegateImplementation);
                        cDelegate = new ConfigureDelegate(this.ConfigureDelegateImplementation);

                        g15.SetButtonDelegateImplementation(bDelegate);
                        g15.SetConfigureDelegateImplementation(cDelegate);
                        g15.OpenLCD();
                    }
                    else if (!configuration.SendToG15 && g15 != null)
                    {
                        g15.CloseLCD();
                        g15 = null;
                    }

                    //
                    // Refresh player

                    if (song.Name != string.Empty)
                    {
                        refreshMessenger = true;
                        refreshXfire = true;
                        refreshSkype = true;
                        refreshG15 = true;
                    }

                    if (refreshPlayer)
                    {
                        RefreshPlayer(false);
                    }

                    //
                    // Audioscrobbler

                    if ((isAudioscrobblerUpdated || isProxyUpdated || audioscrobbler == null) &&
                        configuration.LastFmSubmit &&
                        configuration.LastFmUser != string.Empty)
                    {
                        if (audioscrobbler != null)
                        {
                            audioscrobbler.Connected -= new EventHandler(this.AudioscrobblerConnected);
                        }

                        audioscrobbler = new Audioscrobbler("opa", "0.1", configuration.LastFmUser, configuration.LastFmPassword);

                        audioscrobbler.Connected += new EventHandler(this.AudioscrobblerConnected);
                        audioscrobbler.ConnectionFailed += new EventHandler(this.AudioscrobblerConnectionFailed);

                        audioscrobbler.Connect(
                            configuration.ProxyHost,
                            configuration.ProxyPort,
                            configuration.ProxyUser,
                            configuration.ProxyPassword);
                    }

                    if (configuration.LastFmSubmit && configuration.LastFmSubmitManual)
                    {
                        menuLastFmSubmit.Visible = true;
                    }
                    else
                    {
                        menuLastFmSubmit.Visible = false;
                    }

                    //
                    // Proxy

                    if (isProxyUpdated)
                    {
                        LoadStations();
                    }
                }
                finally
                {
                    this.configuration.Save();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        public Configuration Clone()
        {
            Configuration cloned = new Configuration();
            cloned.items = this.items.Clone();

            return cloned;
        }
Ejemplo n.º 3
0
        public Player()
        {
            User32.ShowWindow(this.Handle, 0);

            InitializeComponent();

            this.SuspendLayout();

            try
            {
                aboutForm = new About();
                aboutForm.HideOnClose = true;

                this.VScroll = false;
                this.HScroll = false;

                this.pandora16 = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType().Namespace + ".Pandora16.bmp"));
                this.pandora16.MakeTransparent(Color.Black);

                //
                // Initialize
                //

                InitializeMenus();
                InitializeTimers();
                InitializeNotifyIcon();
                InitializeTaskbarNotifier();

                //
                // Colors
                //

                btnClose.ForeColor = BACKGROUND_COLOR;
                btnMinimize.ForeColor = BACKGROUND_COLOR;

                //
                // Tool tip
                //

                toolTip.SetToolTip(this.btnMinimize, "Minimize");
                toolTip.SetToolTip(this.btnClose, "Close");

                //
                // Settings
                //

                settingsForm = new SettingsForm();
                settingsForm.HideOnClose = true;
                settingsForm.SettingsView.Player = this;

                //
                // Configuration
                //

                this.configuration = Configuration.Load();
                ApplyConfiguration(this.configuration, false, false);

                isPayingUser = this.configuration.PayingUser;

                //
                // Window
                //

                Size playerSize = new Size(640, 250);

                ResizeFromContent(playerSize);
                pictureBoxFill.Size = playerSize;
                pictureBoxFill.Location = new Point(2, 18);

                if (configuration.Location != string.Empty)
                {
                    try
                    {
                        string[] coordinates = configuration.Location.Split(new char[] {','});

                        this.Location = new Point(int.Parse(coordinates[0]), int.Parse(coordinates[1]));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                        Debug.WriteLine(ex.StackTrace);
                    }
                }

                MoveToWorkingArea();

                //
                // Browser
                //

                browser.Silent = true;

                //
                // Windows hook
                //

                try
                {
                    windowsHook = new WindowsHook();
                    windowsHook.KeyDown += new KeyEventHandler(this.GlobalKeyDown);
                    windowsHook.KeyUp += new KeyEventHandler(this.GlobalKeyUp);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }

                //
                // Stations
                //

                StationLoader.Loaded += new EventHandler(this.StationsLoaded);

                //
                // Title
                //

                title = DEFAULT_TITLE;
                this.Text = title;
                notifyIcon.Text = title;
                pictureBoxTitle.Refresh();

                //
                // Refresh browser, somehow form Load event start before ctor finishes
                //

                Debug.WriteLine("Loading radio ...");

                try
                {
                    object url2 = STARTUP_URL2;
                    browser2.Navigate2(ref url2, ref missing, ref missing, ref missing, ref missing);

                    object url = STARTUP_URL;
                    browser.Navigate2(ref url, ref missing, ref missing, ref missing, ref missing);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
            }
            finally
            {
                this.ResumeLayout(true);
                Application.DoEvents();
                User32.ShowWindow(this.Handle, 9);
            }
        }
Ejemplo n.º 4
0
 public void Apply(Configuration configuration)
 {
     this.items = configuration.items.Clone();
 }