Beispiel #1
0
        /// <summary>
        /// GaGa implementation.
        /// </summary>
        /// <param name="settingsFilepath">
        /// Path to the settings file to use.
        /// </param>
        /// <param name="streamsFilepath">
        /// Path to the streams file to use.
        /// </param>
        public GaGa(String settingsFilepath, String streamsFilepath)
        {
            // gui components:
            container = new Container();
            toolStripRenderer = new ToolStripAeroRenderer();

            notifyIcon = new NotifyIcon(container);
            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            notifyIcon.ContextMenuStrip.Renderer = toolStripRenderer;
            notifyIcon.Visible = true;

            // settings:
            this.settingsFilepath = settingsFilepath;
            settings = SettingsLoad();

            // streams:
            this.streamsFilepath = streamsFilepath;
            streamsFileLoader = new StreamsFileLoader(streamsFilepath);

            // player:
            player = new Player(notifyIcon);

            // constant menu items:
            dynamicMenuMarker = new ToolStripMenuItem();
            dynamicMenuMarker.Visible = false;

            errorOpenItem = new ToolStripMenuItem();
            errorOpenItem.Text = "Error opening streams file (click for details)";

            errorReadItem = new ToolStripMenuItem();
            errorReadItem.Text = "Error reading streams file (click for details)";

            editItem = new ToolStripMenuItem();
            editItem.Text = "&Edit streams file";

            exitItem = new ToolStripMenuItem();
            exitItem.Text = "E&xit";

            // audio submenu:
            audioMenuItem = new ToolStripMenuItem();
            audioMenuItem.Text = "Audio";

            balanceTrackBar = new ToolStripLabeledTrackBar();
            balanceTrackBar.Label.Text = "Balance";
            balanceTrackBar.TrackBar.Minimum = -10;
            balanceTrackBar.TrackBar.Maximum = 10;

            volumeTrackBar = new ToolStripLabeledTrackBar();
            volumeTrackBar.Label.Text = "Volume";
            volumeTrackBar.TrackBar.Minimum = 0;
            volumeTrackBar.TrackBar.Maximum = 20;

            // adjust the backcolor to the renderer:
            Color back = toolStripRenderer.ColorTable.ToolStripDropDownBackground;

            balanceTrackBar.BackColor = back;
            balanceTrackBar.Label.BackColor = back;
            balanceTrackBar.TrackBar.BackColor = back;
            volumeTrackBar.BackColor = back;
            volumeTrackBar.Label.BackColor = back;
            volumeTrackBar.TrackBar.BackColor = back;

            audioMenuItem.DropDownItems.Add(balanceTrackBar);
            audioMenuItem.DropDownItems.Add(volumeTrackBar);

            // options submenu:
            optionsMenuItem = new ToolStripMenuItem();
            optionsMenuItem.Text = "Options";

            optionsEnableAutoPlayItem = new ToolStripMenuItem();
            optionsEnableAutoPlayItem.Text = "Enable auto play on startup";

            optionsEnableMultimediaKeysItem = new ToolStripMenuItem();
            optionsEnableMultimediaKeysItem.Text = "Enable multimedia keys";

            optionsMenuItem.DropDownItems.Add(optionsEnableAutoPlayItem);
            optionsMenuItem.DropDownItems.Add(optionsEnableMultimediaKeysItem);

            // add multimedia keys:
            KeyboardHook.Hooker.Add("Toggle Play", Keys.MediaPlayPause);
            KeyboardHook.Hooker.Add("Stop", Keys.MediaStop);
            KeyboardHook.Hooker.Add("Toggle Mute", Keys.VolumeMute);
            KeyboardHook.Hooker.Add("Volume Up", Keys.VolumeUp);
            KeyboardHook.Hooker.Add("Volume Down", Keys.VolumeDown);

            // apply settings before wiring events:
            balanceTrackBar.TrackBar.Value = settings.LastBalanceTrackBarValue;
            volumeTrackBar.TrackBar.Value = settings.LastVolumeTrackBarValue;

            BalanceUpdate();
            VolumeUpdate();

            player.Select(settings.LastPlayerStream);

            optionsEnableAutoPlayItem.Checked = settings.OptionsEnableAutoPlayChecked;
            optionsEnableMultimediaKeysItem.Checked = settings.OptionsEnableMultimediaKeysChecked;

            // wire events:
            notifyIcon.ContextMenuStrip.Opening += OnMenuOpening;
            notifyIcon.MouseClick += OnIconMouseClick;

            errorOpenItem.Click += OnErrorOpenItemClick;
            errorReadItem.Click += OnErrorReadItemClick;
            editItem.Click += OnEditItemClick;
            exitItem.Click += OnExitItemClick;

            balanceTrackBar.TrackBar.ValueChanged += OnBalanceTrackBarChanged;
            volumeTrackBar.TrackBar.ValueChanged += OnVolumeTrackBarChanged;

            optionsEnableAutoPlayItem.CheckOnClick = true;
            optionsEnableMultimediaKeysItem.Click += OnEnableMultimediaKeysItemClicked;

            KeyboardHook.Hooker.HotkeyDown += OnHotkeyDown;

            // handle options:
            if (optionsEnableAutoPlayItem.Checked)
            {
                player.Play();
            }

            if (optionsEnableMultimediaKeysItem.Checked)
            {
                MultimediaKeysHook();
            }
        }
Beispiel #2
0
        /// <summary>
        /// GaGa implementation.
        /// </summary>
        /// <param name="settingsFilepath">
        /// Path to the settings file to use.
        /// </param>
        /// <param name="streamsFilepath">
        /// Path to the streams file to use.
        /// </param>
        public GaGa(String settingsFilepath, String streamsFilepath)
        {
            // gui components:
            container         = new Container();
            toolStripRenderer = new ToolStripAeroRenderer();

            notifyIcon = new NotifyIcon(container);
            notifyIcon.ContextMenuStrip          = new ContextMenuStrip();
            notifyIcon.ContextMenuStrip.Renderer = toolStripRenderer;
            notifyIcon.Visible = true;

            // settings:
            this.settingsFilepath = settingsFilepath;
            settings = SettingsLoad();

            // streams:
            this.streamsFilepath = streamsFilepath;
            streamsFileLoader    = new StreamsFileLoader(streamsFilepath);

            // player:
            player = new Player(notifyIcon);

            // constant menu items:
            dynamicMenuMarker         = new ToolStripMenuItem();
            dynamicMenuMarker.Visible = false;

            errorOpenItem      = new ToolStripMenuItem();
            errorOpenItem.Text = "Error opening streams file (click for details)";

            errorReadItem      = new ToolStripMenuItem();
            errorReadItem.Text = "Error reading streams file (click for details)";

            editItem      = new ToolStripMenuItem();
            editItem.Text = "&Edit streams file";

            exitItem      = new ToolStripMenuItem();
            exitItem.Text = "E&xit";

            // audio submenu:
            audioMenuItem      = new ToolStripMenuItem();
            audioMenuItem.Text = "Audio";

            balanceTrackBar                  = new ToolStripLabeledTrackBar();
            balanceTrackBar.Label.Text       = "Balance";
            balanceTrackBar.TrackBar.Minimum = -10;
            balanceTrackBar.TrackBar.Maximum = 10;

            volumeTrackBar                  = new ToolStripLabeledTrackBar();
            volumeTrackBar.Label.Text       = "Volume";
            volumeTrackBar.TrackBar.Minimum = 0;
            volumeTrackBar.TrackBar.Maximum = 20;

            // adjust the backcolor to the renderer:
            Color back = toolStripRenderer.ColorTable.ToolStripDropDownBackground;

            balanceTrackBar.BackColor          = back;
            balanceTrackBar.Label.BackColor    = back;
            balanceTrackBar.TrackBar.BackColor = back;
            volumeTrackBar.BackColor           = back;
            volumeTrackBar.Label.BackColor     = back;
            volumeTrackBar.TrackBar.BackColor  = back;

            audioMenuItem.DropDownItems.Add(balanceTrackBar);
            audioMenuItem.DropDownItems.Add(volumeTrackBar);

            // options submenu:
            optionsMenuItem      = new ToolStripMenuItem();
            optionsMenuItem.Text = "Options";

            optionsEnableAutoPlayItem      = new ToolStripMenuItem();
            optionsEnableAutoPlayItem.Text = "Enable auto play on startup";

            optionsEnableMultimediaKeysItem      = new ToolStripMenuItem();
            optionsEnableMultimediaKeysItem.Text = "Enable multimedia keys";

            optionsMenuItem.DropDownItems.Add(optionsEnableAutoPlayItem);
            optionsMenuItem.DropDownItems.Add(optionsEnableMultimediaKeysItem);

            // add multimedia keys:
            KeyboardHook.Hooker.Add("Toggle Play", Keys.MediaPlayPause);
            KeyboardHook.Hooker.Add("Stop", Keys.MediaStop);
            KeyboardHook.Hooker.Add("Toggle Mute", Keys.VolumeMute);
            KeyboardHook.Hooker.Add("Volume Up", Keys.VolumeUp);
            KeyboardHook.Hooker.Add("Volume Down", Keys.VolumeDown);

            // apply settings before wiring events:
            balanceTrackBar.TrackBar.Value = settings.LastBalanceTrackBarValue;
            volumeTrackBar.TrackBar.Value  = settings.LastVolumeTrackBarValue;

            BalanceUpdate();
            VolumeUpdate();

            player.Select(settings.LastPlayerStream);

            optionsEnableAutoPlayItem.Checked       = settings.OptionsEnableAutoPlayChecked;
            optionsEnableMultimediaKeysItem.Checked = settings.OptionsEnableMultimediaKeysChecked;

            // wire events:
            notifyIcon.ContextMenuStrip.Opening += OnMenuOpening;
            notifyIcon.MouseClick += OnIconMouseClick;

            errorOpenItem.Click += OnErrorOpenItemClick;
            errorReadItem.Click += OnErrorReadItemClick;
            editItem.Click      += OnEditItemClick;
            exitItem.Click      += OnExitItemClick;

            balanceTrackBar.TrackBar.ValueChanged += OnBalanceTrackBarChanged;
            volumeTrackBar.TrackBar.ValueChanged  += OnVolumeTrackBarChanged;

            optionsEnableAutoPlayItem.CheckOnClick = true;
            optionsEnableMultimediaKeysItem.Click += OnEnableMultimediaKeysItemClicked;

            KeyboardHook.Hooker.HotkeyDown += OnHotkeyDown;

            // handle options:
            if (optionsEnableAutoPlayItem.Checked)
            {
                player.Play();
            }

            if (optionsEnableMultimediaKeysItem.Checked)
            {
                MultimediaKeysHook();
            }
        }