using OverlayFormObj;
namespace DualScreenDemo
{
    public partial class PrimaryForm : Form
    {
        public Panel primaryScreenPanel;
        public Button syncServiceBellButton;
        public Button syncCutSongButton;
        public Button syncReplayButton;
        public Button syncOriginalSongButton;
        public Button syncMuteButton;
        public Button syncPauseButton;
        public Button syncPlayButton;
        public Button syncVolumeUpButton;
        public Button syncVolumeDownButton;
        public Button syncMicUpButton;
        public Button syncMicDownButton;
        public Button syncCloseButton;
        
        private void InitializeSyncScreen()
        {
            this.primaryScreenPanel = new System.Windows.Forms.Panel();
            this.syncServiceBellButton = new System.Windows.Forms.Button();
            this.syncCutSongButton = new System.Windows.Forms.Button();
            this.syncReplayButton = new System.Windows.Forms.Button();
            this.syncOriginalSongButton = new System.Windows.Forms.Button();
            this.syncMuteButton = new System.Windows.Forms.Button();
            this.syncPauseButton = new System.Windows.Forms.Button();
            this.syncPlayButton = new System.Windows.Forms.Button();
            this.syncVolumeUpButton = new System.Windows.Forms.Button();
            this.syncVolumeDownButton = new System.Windows.Forms.Button();
            this.syncMicUpButton = new System.Windows.Forms.Button();
            this.syncMicDownButton = new System.Windows.Forms.Button();
            this.syncCloseButton = new System.Windows.Forms.Button();
            this.SuspendLayout();

            ResizeAndPositionControl(this.primaryScreenPanel, 0, 0, 1440, 900);
            this.primaryScreenPanel.TabIndex = 0;
            this.primaryScreenPanel.BorderStyle = BorderStyle.FixedSingle;
            this.primaryScreenPanel.BackColor = System.Drawing.Color.Black; 
            
            // 同步畫面 服務鈴
            ConfigureButton(this.syncServiceBellButton, 1240, 17, 161, 161, 
                resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, 
                //(sender, e) => SendCommandThroughSerialPort("a2 53 a4"));
                (sender,e)=>OnServiceBellButtonClick(sender,e));
                        
            ConfigureButton(this.syncCutSongButton, 1218, 195, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, (sender, e) => videoPlayerForm.PlayNextSong());
            ConfigureButton(this.syncReplayButton, 1218, 265, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, ReplayButton_Click);
            // 有人聲入口位置
            ConfigureButton(this.syncOriginalSongButton, 1218, 335, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, (sender,e) => videoPlayerForm.ToggleVocalRemoval());
            ConfigureButton(this.syncMuteButton, 1218, 406, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, MuteUnmuteButton_Click);
            ConfigureButton(this.syncPauseButton, 1218, 475, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncPauseButton_Click);
            ConfigureButton(this.syncPlayButton, 1218, 475, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncPlayButton_Click);
            ConfigureButton(this.syncVolumeUpButton, 1218, 546, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
            this.syncVolumeUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↑ ","a2 b3 a4"); };
            this.syncVolumeUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); };
            ConfigureButton(this.syncVolumeDownButton, 1218, 616, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
            this.syncVolumeDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↓ ","a2 b4 a4");};
            this.syncVolumeDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel();};
            ConfigureButton(this.syncMicUpButton, 1218, 686, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
            this.syncMicUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↑ ","a2 b5 a4");};
            this.syncMicUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); };
            ConfigureButton(this.syncMicDownButton, 1218, 756, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
            this.syncMicDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↓ ","a2 b6 a4");};
            this.syncMicDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); };

            
            
            
            ConfigureButton(this.syncCloseButton, 1218, 826, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncCloseButton_Click);

            
            
            
            this.ClientSize = new System.Drawing.Size(1440, 900); 
            this.Controls.Add(this.primaryScreenPanel);
            this.Controls.Add(this.syncCloseButton);
            this.Name = "PrimaryForm";
            this.ResumeLayout(false);
        }

        private void SyncPauseButton_Click(object sender, EventArgs e)
        {
            videoPlayerForm.Pause();

            
            syncPauseButton.Visible = false;
            syncPlayButton.Visible = true;
            syncPlayButton.BringToFront();
            pauseButton.Visible = false;
            playButton.Visible = true;
        }
        
        private void SyncPlayButton_Click(object sender, EventArgs e)
        {
            videoPlayerForm.Play();

            
            syncPauseButton.Visible = true;
            syncPauseButton.BringToFront();
            syncPlayButton.Visible = false;
            pauseButton.Visible = true;
            playButton.Visible = false;
        }
        
        private void SyncCloseButton_Click(object sender, EventArgs e)
        {
            VideoPlayerForm.Instance.ClosePrimaryScreenPanel();
        }
        
        private void SyncScreenButton_Click(object sender, EventArgs e)
        {
            videoPlayerForm.IsSyncToPrimaryMonitor = true;
            videoPlayerForm.SyncToPrimaryMonitor();  
        }
    }
}