예제 #1
0
파일: GaGa.cs 프로젝트: asaveliev/GaGa
        /// <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();
            }
        }
예제 #2
0
파일: GaGa.cs 프로젝트: joshimoo/GaGa
        /// <summary>
        /// GaGa implementation.
        /// </summary>
        /// <param name="filepath">Path to the streams file to use.</param>
        public GaGa(String filepath)
        {
            // gui components:
            container = new Container();

            notifyIcon = new NotifyIcon(container);
            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            notifyIcon.Icon = Util.ResourceAsIcon("GaGa.Resources.idle.ico");
            notifyIcon.MouseClick += OnIconMouseClick;
            notifyIcon.Visible = true;

            toolStripRenderer = new ToolStripAeroRenderer();

            menu = notifyIcon.ContextMenuStrip;
            menu.Opening += OnMenuOpening;
            menu.Renderer = toolStripRenderer;

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

            // streams menu:
            streamsFilepath = filepath;
            streamsFileLoader = new StreamsFileLoader(filepath, "GaGa.Resources.streams.ini");

            // streams menu constant items:
            errorOpenItem = new ToolStripMenuItem();
            errorOpenItem.Text = "Error opening streams file";
            errorOpenItem.Click += OnErrorOpenItemClick;

            errorReadItem = new ToolStripMenuItem();
            errorReadItem.Text = "Error reading streams file";
            errorReadItem.Click += OnErrorReadItemClick;

            editItem = new ToolStripMenuItem();
            editItem.Text = "Edit streams file";
            editItem.Click += OnEditItemClick;

            // audio settings:
            audioSettingsItem = new ToolStripMenuItem();
            audioSettingsItem.Text = "Audio settings";

            balanceTrackBar = new ToolStripLabeledTrackBar();
            balanceTrackBar.Label.Text = "Balance";
            balanceTrackBar.TrackBar.Minimum = -10;
            balanceTrackBar.TrackBar.Maximum = 10;
            balanceTrackBar.TrackBar.Value = 0;
            balanceTrackBar.TrackBar.ValueChanged += OnBalanceTrackBarChanged;

            volumeTrackBar = new ToolStripLabeledTrackBar();
            volumeTrackBar.Label.Text = "Volume";
            volumeTrackBar.TrackBar.Minimum = 0;
            volumeTrackBar.TrackBar.Maximum = 20;
            volumeTrackBar.TrackBar.Value = 10;
            volumeTrackBar.TrackBar.ValueChanged += OnVolumeTrackBarChanged;

            // change back color to the renderer color:
            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;

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

            // other items:
            exitItem = new ToolStripMenuItem();
            exitItem.Text = "Exit";
            exitItem.Click += OnExitItemClick;

            // update everything:
            BalanceUpdate();
            VolumeUpdate();
        }