diff --git a/src/Forms/Main.Designer.cs b/src/Forms/Main.Designer.cs index 2fb204fb1..5b601d14c 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/Forms/Main.Designer.cs @@ -122,6 +122,9 @@ this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.showhideWaveFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showhideVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator19 = new System.Windows.Forms.ToolStripSeparator(); + this.undockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.redockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemSpellCheckMain = new System.Windows.Forms.ToolStripMenuItem(); this.spellCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.findDoubleWordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -1132,7 +1135,10 @@ this.openVideoToolStripMenuItem, this.toolStripSeparator5, this.showhideWaveFormToolStripMenuItem, - this.showhideVideoToolStripMenuItem}); + this.showhideVideoToolStripMenuItem, + this.toolStripSeparator19, + this.undockVideoControlsToolStripMenuItem, + this.redockVideoControlsToolStripMenuItem}); this.toolStripMenuItemVideo.Name = "toolStripMenuItemVideo"; this.toolStripMenuItemVideo.Size = new System.Drawing.Size(50, 20); this.toolStripMenuItemVideo.Text = "Video"; @@ -1140,29 +1146,49 @@ // openVideoToolStripMenuItem // this.openVideoToolStripMenuItem.Name = "openVideoToolStripMenuItem"; - this.openVideoToolStripMenuItem.Size = new System.Drawing.Size(195, 22); + this.openVideoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); this.openVideoToolStripMenuItem.Text = "Open video..."; this.openVideoToolStripMenuItem.Click += new System.EventHandler(this.buttonOpenVideo_Click); // // toolStripSeparator5 // this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(192, 6); + this.toolStripSeparator5.Size = new System.Drawing.Size(196, 6); // // showhideWaveFormToolStripMenuItem // this.showhideWaveFormToolStripMenuItem.Name = "showhideWaveFormToolStripMenuItem"; - this.showhideWaveFormToolStripMenuItem.Size = new System.Drawing.Size(195, 22); + this.showhideWaveFormToolStripMenuItem.Size = new System.Drawing.Size(199, 22); this.showhideWaveFormToolStripMenuItem.Text = "Show/hide wave form"; this.showhideWaveFormToolStripMenuItem.Click += new System.EventHandler(this.showhideWaveFormToolStripMenuItem_Click); // // showhideVideoToolStripMenuItem // this.showhideVideoToolStripMenuItem.Name = "showhideVideoToolStripMenuItem"; - this.showhideVideoToolStripMenuItem.Size = new System.Drawing.Size(195, 22); + this.showhideVideoToolStripMenuItem.Size = new System.Drawing.Size(199, 22); this.showhideVideoToolStripMenuItem.Text = "Show/hide video"; this.showhideVideoToolStripMenuItem.Click += new System.EventHandler(this.toolStripButtonToogleVideo_Click); // + // toolStripSeparator19 + // + this.toolStripSeparator19.Name = "toolStripSeparator19"; + this.toolStripSeparator19.Size = new System.Drawing.Size(196, 6); + // + // undockVideoControlsToolStripMenuItem + // + this.undockVideoControlsToolStripMenuItem.Name = "undockVideoControlsToolStripMenuItem"; + this.undockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.undockVideoControlsToolStripMenuItem.Text = "Un-dock video controls"; + this.undockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.undockVideoControlsToolStripMenuItem_Click); + // + // redockVideoControlsToolStripMenuItem + // + this.redockVideoControlsToolStripMenuItem.Name = "redockVideoControlsToolStripMenuItem"; + this.redockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.redockVideoControlsToolStripMenuItem.Text = "Re-dock video controls"; + this.redockVideoControlsToolStripMenuItem.Visible = false; + this.redockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.redockVideoControlsToolStripMenuItem_Click); + // // toolStripMenuItemSpellCheckMain // this.toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -2040,19 +2066,17 @@ // // groupBoxVideo // - this.groupBoxVideo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxVideo.Controls.Add(this.checkBoxSyncListViewWithVideoWhilePlaying); this.groupBoxVideo.Controls.Add(this.labelVideoInfo); this.groupBoxVideo.Controls.Add(this.trackBarWaveFormPosition); this.groupBoxVideo.Controls.Add(this.panelWaveFormControls); this.groupBoxVideo.Controls.Add(this.AudioWaveForm); this.groupBoxVideo.Controls.Add(this.tabControlButtons); + this.groupBoxVideo.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBoxVideo.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBoxVideo.Location = new System.Drawing.Point(3, 3); + this.groupBoxVideo.Location = new System.Drawing.Point(0, 0); this.groupBoxVideo.Name = "groupBoxVideo"; - this.groupBoxVideo.Size = new System.Drawing.Size(1238, 299); + this.groupBoxVideo.Size = new System.Drawing.Size(1244, 305); this.groupBoxVideo.TabIndex = 1; this.groupBoxVideo.TabStop = false; // @@ -2069,7 +2093,7 @@ // labelVideoInfo // this.labelVideoInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelVideoInfo.Location = new System.Drawing.Point(863, 12); + this.labelVideoInfo.Location = new System.Drawing.Point(869, 12); this.labelVideoInfo.Name = "labelVideoInfo"; this.labelVideoInfo.Size = new System.Drawing.Size(369, 13); this.labelVideoInfo.TabIndex = 12; @@ -2081,10 +2105,10 @@ this.trackBarWaveFormPosition.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.trackBarWaveFormPosition.AutoSize = false; - this.trackBarWaveFormPosition.Location = new System.Drawing.Point(645, 258); + this.trackBarWaveFormPosition.Location = new System.Drawing.Point(645, 264); this.trackBarWaveFormPosition.Maximum = 1000; this.trackBarWaveFormPosition.Name = "trackBarWaveFormPosition"; - this.trackBarWaveFormPosition.Size = new System.Drawing.Size(586, 20); + this.trackBarWaveFormPosition.Size = new System.Drawing.Size(592, 20); this.trackBarWaveFormPosition.TabIndex = 11; this.trackBarWaveFormPosition.TickStyle = System.Windows.Forms.TickStyle.None; this.trackBarWaveFormPosition.ValueChanged += new System.EventHandler(this.trackBarWaveFormPosition_ValueChanged); @@ -2093,7 +2117,7 @@ // this.panelWaveFormControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.panelWaveFormControls.Controls.Add(this.toolStrip2); - this.panelWaveFormControls.Location = new System.Drawing.Point(478, 263); + this.panelWaveFormControls.Location = new System.Drawing.Point(478, 269); this.panelWaveFormControls.Name = "panelWaveFormControls"; this.panelWaveFormControls.Size = new System.Drawing.Size(161, 29); this.panelWaveFormControls.TabIndex = 10; @@ -2184,11 +2208,11 @@ this.AudioWaveForm.DrawGridLines = true; this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); this.AudioWaveForm.Location = new System.Drawing.Point(475, 30); - this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(4); + this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0); this.AudioWaveForm.Name = "AudioWaveForm"; this.AudioWaveForm.NewSelectionParagraph = null; this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red; - this.AudioWaveForm.Size = new System.Drawing.Size(756, 222); + this.AudioWaveForm.Size = new System.Drawing.Size(762, 228); this.AudioWaveForm.StartPositionSeconds = 0D; this.AudioWaveForm.TabIndex = 6; this.AudioWaveForm.TextColor = System.Drawing.Color.Gray; @@ -2941,9 +2965,9 @@ this.labelSubtitle.BackColor = System.Drawing.Color.Black; this.labelSubtitle.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelSubtitle.ForeColor = System.Drawing.Color.White; - this.labelSubtitle.Location = new System.Drawing.Point(0, 248); + this.labelSubtitle.Location = new System.Drawing.Point(0, 246); this.labelSubtitle.Name = "labelSubtitle"; - this.labelSubtitle.Size = new System.Drawing.Size(280, 32); + this.labelSubtitle.Size = new System.Drawing.Size(281, 33); this.labelSubtitle.TabIndex = 3; this.labelSubtitle.Text = "labelSubtitle"; this.labelSubtitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -2955,10 +2979,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); this.mediaPlayer.CurrentPosition = 0D; - this.mediaPlayer.Location = new System.Drawing.Point(0, 2); + this.mediaPlayer.Location = new System.Drawing.Point(0, 0); + this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); this.mediaPlayer.Name = "mediaPlayer"; this.mediaPlayer.ShowStopButton = true; - this.mediaPlayer.Size = new System.Drawing.Size(280, 246); + this.mediaPlayer.Size = new System.Drawing.Size(281, 246); this.mediaPlayer.TabIndex = 5; this.mediaPlayer.VideoPlayer = null; this.mediaPlayer.Volume = 0D; @@ -3440,6 +3465,9 @@ private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainerMain; + private System.Windows.Forms.ToolStripMenuItem undockVideoControlsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem redockVideoControlsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator19; } } diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 8a2db4675..c42751be6 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -78,6 +78,11 @@ namespace Nikse.SubtitleEdit.Forms ShowEarlierLater _showEarlierOrLater = null; + bool _isVideoControlsUnDocked = false; + VideoPlayerUnDocked _videoPlayerUnDocked = null; + WaveFormUnDocked _waveFormUnDocked = null; + VideoControlsUndocked _videoControlsUnDocked = null; + private bool AutoRepeatContinueOn { get @@ -4029,7 +4034,7 @@ namespace Nikse.SubtitleEdit.Forms { MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); _subtitleListViewIndex = -1; - + FileNew(); _subtitle.Paragraphs.Clear(); if (isSsa) @@ -4074,10 +4079,18 @@ namespace Nikse.SubtitleEdit.Forms ShowStatus(_language.SubtitleImportedFromMatroskaFile); _subtitle.Renumber(1); _subtitle.WasLoadedWithFrameNumbers = false; - _fileName = string.Empty; + if (fileName.ToLower().EndsWith(".mkv")) + { + _fileName = fileName.Substring(0, fileName.Length - 4); + Text = Title + " - " + _fileName; + } + else + { + Text = Title; + } _fileDateTime = new DateTime(); - Text = Title; - _converted = false; + + _converted = true; SubtitleListview1.Fill(_subtitle, _subtitleAlternate); if (_subtitle.Paragraphs.Count > 0) @@ -4521,7 +4534,7 @@ namespace Nikse.SubtitleEdit.Forms if (vobSubOcr.ShowDialog(this) == DialogResult.OK) { MakeHistoryForUndo(_language.BeforeImportingVobSubFile); - + FileNew(); _subtitle.Paragraphs.Clear(); SetCurrentFormat(new SubRip().FriendlyName); _subtitle.WasLoadedWithFrameNumbers = false; @@ -5284,7 +5297,7 @@ namespace Nikse.SubtitleEdit.Forms if (formSubOcr.ShowDialog(this) == DialogResult.OK) { MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); - + FileNew(); _subtitle.Paragraphs.Clear(); SetCurrentFormat(new SubRip().FriendlyName); _subtitle.WasLoadedWithFrameNumbers = false; @@ -5774,42 +5787,86 @@ namespace Nikse.SubtitleEdit.Forms private void ShowVideoPlayer() { - if (toolStripButtonToogleVideo.Checked && toolStripButtonToogleWaveForm.Checked) + if (_isVideoControlsUnDocked) { - splitContainer1.Panel2Collapsed = false; - MoveVideoUp(); + ShowHideUnDockedVideoControls(); } else { - splitContainer1.Panel2Collapsed = true; - MoveVideoDown(); - } - - splitContainerMain.Panel2Collapsed = false; - if (toolStripButtonToogleVideo.Checked) - { - if (AudioWaveForm.Visible) + if (toolStripButtonToogleVideo.Checked && toolStripButtonToogleWaveForm.Checked) { - AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + splitContainer1.Panel2Collapsed = false; + MoveVideoUp(); } else { - panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + splitContainer1.Panel2Collapsed = true; + MoveVideoDown(); } - } - else if (AudioWaveForm.Visible) - { - AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - } - AudioWaveForm.Width = groupBoxVideo.Width - (AudioWaveForm.Left + 10); - checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - panelWaveFormControls.Left = AudioWaveForm.Left; - trackBarWaveFormPosition.Left = panelWaveFormControls.Left + panelWaveFormControls.Width + 5; - trackBarWaveFormPosition.Width = AudioWaveForm.Left + AudioWaveForm.Width - trackBarWaveFormPosition.Left + 5; + splitContainerMain.Panel2Collapsed = false; + if (toolStripButtonToogleVideo.Checked) + { + if (AudioWaveForm.Visible) + { + AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + else + { + panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + } + else if (AudioWaveForm.Visible) + { + AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + AudioWaveForm.Width = groupBoxVideo.Width - (AudioWaveForm.Left + 10); + + checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + panelWaveFormControls.Left = AudioWaveForm.Left; + trackBarWaveFormPosition.Left = panelWaveFormControls.Left + panelWaveFormControls.Width + 5; + trackBarWaveFormPosition.Width = AudioWaveForm.Left + AudioWaveForm.Width - trackBarWaveFormPosition.Left + 5; + } if (mediaPlayer.VideoPlayer == null && !string.IsNullOrEmpty(_fileName)) TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(_fileName), Path.GetFileNameWithoutExtension(_fileName))); + + } + + private void ShowHideUnDockedVideoControls() + { + if (_videoPlayerUnDocked == null || _videoPlayerUnDocked.IsDisposed) + UnDockVideoPlayer(); + _videoPlayerUnDocked.Visible = false; + if (toolStripButtonToogleVideo.Checked) + { + _videoPlayerUnDocked.Show(this); + if (_videoPlayerUnDocked.WindowState == FormWindowState.Minimized) + _videoPlayerUnDocked.WindowState = FormWindowState.Normal; + } + + if (_waveFormUnDocked == null || _waveFormUnDocked.IsDisposed) + UnDockWaveForm(); + _waveFormUnDocked.Visible = false; + if (toolStripButtonToogleWaveForm.Checked) + { + _waveFormUnDocked.Show(this); + if (_waveFormUnDocked.WindowState == FormWindowState.Minimized) + _waveFormUnDocked.WindowState = FormWindowState.Normal; + } + + if (toolStripButtonToogleVideo.Checked || toolStripButtonToogleWaveForm.Checked) + { + if (_videoControlsUnDocked == null || _videoControlsUnDocked.IsDisposed) + UnDockVideoButtons(); + _videoControlsUnDocked.Visible = false; + _videoControlsUnDocked.Show(this); + } + else + { + if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed) + _videoControlsUnDocked.Visible = false; + } } private void MoveVideoUp() @@ -5834,7 +5891,7 @@ namespace Nikse.SubtitleEdit.Forms splitContainer1.Panel2.Controls.Clear(); groupBoxVideo.Controls.Add(control); } - panelVideoPlayer.Top = 26; + panelVideoPlayer.Top = 27; panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; panelVideoPlayer.Height = groupBoxVideo.Height - (panelVideoPlayer.Top + 5); panelVideoPlayer.Width = groupBoxVideo.Width - (panelVideoPlayer.Left + 5); @@ -6156,7 +6213,10 @@ namespace Nikse.SubtitleEdit.Forms labelSubtitle.BringToFront(); if (!toolStripButtonToogleVideo.Checked && !toolStripButtonToogleWaveForm.Checked) { - HideVideoPlayer(); + if (_isVideoControlsUnDocked) + ShowHideUnDockedVideoControls(); + else + HideVideoPlayer(); } else { @@ -6174,7 +6234,10 @@ namespace Nikse.SubtitleEdit.Forms panelWaveFormControls.Visible = toolStripButtonToogleWaveForm.Checked; if (!toolStripButtonToogleWaveForm.Checked && !toolStripButtonToogleVideo.Checked) { - HideVideoPlayer(); + if (_isVideoControlsUnDocked) + ShowHideUnDockedVideoControls(); + else + HideVideoPlayer(); } else { @@ -6462,15 +6525,23 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.VideoControls.LastActiveTab = "Adjust"; } - if (toolStripButtonToogleWaveForm.Checked ) - AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - AudioWaveForm.Width = groupBoxVideo.Width - (AudioWaveForm.Left + 10); - panelWaveFormControls.Left = AudioWaveForm.Left; - trackBarWaveFormPosition.Left = panelWaveFormControls.Left + panelWaveFormControls.Width + 5; - trackBarWaveFormPosition.Width = groupBoxVideo.Width - (trackBarWaveFormPosition.Left + 10); - this.Main_Resize(null, null); - checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - Refresh(); + if (!_isVideoControlsUnDocked) + { + if (toolStripButtonToogleWaveForm.Checked) + AudioWaveForm.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + AudioWaveForm.Width = groupBoxVideo.Width - (AudioWaveForm.Left + 10); + panelWaveFormControls.Left = AudioWaveForm.Left; + trackBarWaveFormPosition.Left = panelWaveFormControls.Left + panelWaveFormControls.Width + 5; + trackBarWaveFormPosition.Width = groupBoxVideo.Width - (trackBarWaveFormPosition.Left + 10); + this.Main_Resize(null, null); + checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + Refresh(); + } + else if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed) + { + _videoControlsUnDocked.Width = tabControlButtons.Width + 20; + _videoControlsUnDocked.Height = tabControlButtons.Height + 40; + } } private void buttonSecBack1_Click(object sender, EventArgs e) @@ -6988,7 +7059,7 @@ namespace Nikse.SubtitleEdit.Forms if (vobSubOcr.ShowDialog(this) == DialogResult.OK) { MakeHistoryForUndo(_language.BeforeImportingBluRaySupFile); - + FileNew(); _subtitle.Paragraphs.Clear(); SetCurrentFormat(new SubRip().FriendlyName); _subtitle.WasLoadedWithFrameNumbers = false; @@ -7293,8 +7364,29 @@ namespace Nikse.SubtitleEdit.Forms bool doReFill = false; bool updateListViewStatus = false; SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - string message; - var updates = _networkSession.GetUpdates(out message); + string message = string.Empty; + + List updates = null; + try + { + updates = (List)_networkSession.GetUpdates(out message); + } + catch (Exception exception) + { + MessageBox.Show("Unable to connect to server: " + exception.Message); + _networkSession.TimerStop(); + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.Close(); + _networkChat = null; + } + _networkSession = null; + EnableDisableControlsNotWorkingInNetworkMode(true); + toolStripStatusNetworking.Visible = false; + SubtitleListview1.HideExtraColumn(); + _networkChat = null; + return; + } int currentSelectedIndex = -1; if (SubtitleListview1.SelectedItems.Count > 0) currentSelectedIndex = SubtitleListview1.SelectedItems[0].Index; @@ -7461,8 +7553,9 @@ namespace Nikse.SubtitleEdit.Forms _networkSession.InsertLine(insertIndex, insertParagraph); doReFill = true; } - _networkSession.CheckForAndSubmitUpdates(updates); // updates only (no inserts/deletes) + + //TODO: do some compare lines count... and reload if no match! } else { @@ -7573,5 +7666,177 @@ namespace Nikse.SubtitleEdit.Forms } #endregion - } + private void UnDockVideoPlayer() + { + _videoPlayerUnDocked = new VideoPlayerUnDocked(this, labelVideoInfo.Text, _formPositionsAndSizes, mediaPlayer); + _formPositionsAndSizes.SetPositionAndSize(_videoPlayerUnDocked); + + Control control = null; + if (splitContainer1.Panel2.Controls.Count == 0) + { + control = panelVideoPlayer; + groupBoxVideo.Controls.Remove(control); + } + else if (splitContainer1.Panel2.Controls.Count > 0) + { + control = panelVideoPlayer; + splitContainer1.Panel2.Controls.Clear(); + } + if (control != null) + { + control.Top = 0; + control.Left = 0; + control.Width = _videoPlayerUnDocked.PanelContainer.Width; + control.Height = _videoPlayerUnDocked.PanelContainer.Height; + _videoPlayerUnDocked.PanelContainer.Controls.Add(control); + } + } + + public void ReDockVideoPlayer(Control control) + { + groupBoxVideo.Controls.Add(control); + } + + private void UnDockWaveForm() + { + _waveFormUnDocked = new WaveFormUnDocked(this, labelVideoInfo.Text, _formPositionsAndSizes); + _formPositionsAndSizes.SetPositionAndSize(_waveFormUnDocked); + + var control = AudioWaveForm; + groupBoxVideo.Controls.Remove(control); + control.Top = 0; + control.Left = 0; + control.Width = _waveFormUnDocked.PanelContainer.Width; + control.Height = _waveFormUnDocked.PanelContainer.Height - panelWaveFormControls.Height; + _waveFormUnDocked.PanelContainer.Controls.Add(control); + + var control2 = (Control)panelWaveFormControls; + groupBoxVideo.Controls.Remove(control2); + control2.Top = control.Height; + control2.Left = 0; + _waveFormUnDocked.PanelContainer.Controls.Add(control2); + + var control3 = (Control)trackBarWaveFormPosition; + groupBoxVideo.Controls.Remove(control3); + control3.Top = control.Height; + control3.Left = control2.Width +2; + control3.Width = _waveFormUnDocked.PanelContainer.Width - control3.Left; + _waveFormUnDocked.PanelContainer.Controls.Add(control3); + } + + public void ReDockWaveForm(Control waveForm, Control buttons, Control trackBar) + { + groupBoxVideo.Controls.Add(waveForm); + waveForm.Top = 30; + waveForm.Height = groupBoxVideo.Height - (waveForm.Top + buttons.Height + 10); + + groupBoxVideo.Controls.Add(buttons); + buttons.Top = waveForm.Top + waveForm.Height + 5; + + groupBoxVideo.Controls.Add(trackBar); + trackBar.Top = buttons.Top; + } + + private void UnDockVideoButtons() + { + _videoControlsUnDocked = new VideoControlsUndocked(this, labelVideoInfo.Text, _formPositionsAndSizes); + _formPositionsAndSizes.SetPositionAndSize(_videoControlsUnDocked); + var control = tabControlButtons; + groupBoxVideo.Controls.Remove(control); + control.Top = 0; + control.Left = 0; + _videoControlsUnDocked.PanelContainer.Controls.Add(control); + splitContainerMain.Panel2Collapsed = true; + splitContainer1.Panel2Collapsed = true; + } + + public void ReDockVideoButtons(Control videoButtons) + { + groupBoxVideo.Controls.Add(videoButtons); + videoButtons.Top = 12; + videoButtons.Left = 5; + } + + private void undockVideoControlsToolStripMenuItem_Click(object sender, EventArgs e) + { + UnDockVideoPlayer(); + if (toolStripButtonToogleVideo.Checked) + _videoPlayerUnDocked.Show(this); + + UnDockWaveForm(); + if (toolStripButtonToogleWaveForm.Checked) + _waveFormUnDocked.Show(this); + + UnDockVideoButtons(); + _videoControlsUnDocked.Show(this); + + _isVideoControlsUnDocked = true; + + undockVideoControlsToolStripMenuItem.Visible = false; + redockVideoControlsToolStripMenuItem.Visible = true; + + tabControl1_SelectedIndexChanged(null, null); + } + + private void redockVideoControlsToolStripMenuItem_Click(object sender, EventArgs e) + { + + if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed) + { + var control = _videoControlsUnDocked.PanelContainer.Controls[0]; + _videoControlsUnDocked.PanelContainer.Controls.Clear(); + ReDockVideoButtons(control); + _videoControlsUnDocked.Close(); + _videoControlsUnDocked = null; + } + + if (_waveFormUnDocked != null && !_waveFormUnDocked.IsDisposed) + { + var controlWaveForm = _waveFormUnDocked.PanelContainer.Controls[0]; + var controlButtons = _waveFormUnDocked.PanelContainer.Controls[1]; + var controlTrackBar = _waveFormUnDocked.PanelContainer.Controls[2]; + _waveFormUnDocked.PanelContainer.Controls.Clear(); + ReDockWaveForm(controlWaveForm, controlButtons, controlTrackBar); + _waveFormUnDocked.Close(); + _waveFormUnDocked = null; + } + + if (_videoPlayerUnDocked != null && !_videoPlayerUnDocked.IsDisposed) + { + var control = _videoPlayerUnDocked.PanelContainer.Controls[0]; + _videoPlayerUnDocked.PanelContainer.Controls.Remove(control); + ReDockVideoPlayer(control); + _videoPlayerUnDocked.Close(); + _videoPlayerUnDocked = null; + } + + _isVideoControlsUnDocked = false; + _videoPlayerUnDocked = null; + _waveFormUnDocked = null; + _videoControlsUnDocked = null; + ShowVideoPlayer(); + + AudioWaveForm.Visible = toolStripButtonToogleWaveForm.Checked; + trackBarWaveFormPosition.Visible = toolStripButtonToogleWaveForm.Checked; + panelWaveFormControls.Visible = toolStripButtonToogleWaveForm.Checked; + if (!toolStripButtonToogleVideo.Checked) + HideVideoPlayer(); + + mediaPlayer.Invalidate(); + this.Refresh(); + + undockVideoControlsToolStripMenuItem.Visible = true; + redockVideoControlsToolStripMenuItem.Visible = false; + } + + internal void SetWaveFormToogleOff() + { + toolStripButtonToogleWaveForm.Checked = false; + } + + internal void SetVideoPlayerToogleOff() + { + toolStripButtonToogleVideo.Checked = false; + } + } } \ No newline at end of file diff --git a/src/Forms/VideoControlsUndocked.Designer.cs b/src/Forms/VideoControlsUndocked.Designer.cs new file mode 100644 index 000000000..eec424859 --- /dev/null +++ b/src/Forms/VideoControlsUndocked.Designer.cs @@ -0,0 +1,61 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class VideoControlsUndocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelContainer = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(458, 307); + this.panelContainer.TabIndex = 2; + // + // VideoControlsUndocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(458, 307); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.Name = "VideoControlsUndocked"; + this.Text = "VideoControlsUndocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoControlsUndocked_FormClosing); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + } +} \ No newline at end of file diff --git a/src/Forms/VideoControlsUndocked.cs b/src/Forms/VideoControlsUndocked.cs new file mode 100644 index 000000000..6dcfbad9e --- /dev/null +++ b/src/Forms/VideoControlsUndocked.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class VideoControlsUndocked : Form + { + Main _mainForm = null; + PositionsAndSizes _positionsAndSizes = null; + + public Panel PanelContainer + { + get + { + return panelContainer; + } + } + + public VideoControlsUndocked(Main mainForm, string title, PositionsAndSizes positionsAndSizes) + { + InitializeComponent(); + _mainForm = mainForm; + _positionsAndSizes = positionsAndSizes; + Text = title; + } + + private void VideoControlsUndocked_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + var control = panelContainer.Controls[0]; + panelContainer.Controls.Clear(); + _mainForm.ReDockVideoButtons(control); + } + _positionsAndSizes.SavePositionAndSize(this); + } + } +} diff --git a/src/Forms/VideoControlsUndocked.resx b/src/Forms/VideoControlsUndocked.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/VideoControlsUndocked.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/VideoPlayerUnDocked.Designer.cs b/src/Forms/VideoPlayerUnDocked.Designer.cs new file mode 100644 index 000000000..a69324d6e --- /dev/null +++ b/src/Forms/VideoPlayerUnDocked.Designer.cs @@ -0,0 +1,63 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class VideoPlayerUnDocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelContainer = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Margin = new System.Windows.Forms.Padding(0); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(614, 323); + this.panelContainer.TabIndex = 0; + // + // VideoPlayerUnDocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(614, 323); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.KeyPreview = true; + this.Name = "VideoPlayerUnDocked"; + this.Text = "VideoPlayerUnDocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoPlayerUnDocked_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoPlayerUnDocked_KeyDown_1); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + } +} \ No newline at end of file diff --git a/src/Forms/VideoPlayerUnDocked.cs b/src/Forms/VideoPlayerUnDocked.cs new file mode 100644 index 000000000..7d601211e --- /dev/null +++ b/src/Forms/VideoPlayerUnDocked.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class VideoPlayerUnDocked : Form + { + Main _mainForm = null; + PositionsAndSizes _positionsAndSizes = null; + Controls.VideoPlayerContainer _videoPlayerContainer; + + public Panel PanelContainer + { + get + { + return panelContainer; + } + } + + public VideoPlayerUnDocked(Main main, string title, PositionsAndSizes positionsAndSizes, Controls.VideoPlayerContainer videoPlayerContainer) + { + InitializeComponent(); + _mainForm = main; + _positionsAndSizes = positionsAndSizes; + _videoPlayerContainer = videoPlayerContainer; + Text = title; + } + + private void VideoPlayerUnDocked_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + var control = panelContainer.Controls[0]; + panelContainer.Controls.Clear(); + _mainForm.ReDockVideoPlayer(control); + _mainForm.SetVideoPlayerToogleOff(); + } + _positionsAndSizes.SavePositionAndSize(this); + } + + private void VideoPlayerUnDocked_KeyDown_1(object sender, KeyEventArgs e) + { + if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Enter) + { + if (WindowState == FormWindowState.Maximized) + WindowState = FormWindowState.Normal; + else if (WindowState == FormWindowState.Normal) + WindowState = FormWindowState.Maximized; + e.SuppressKeyPress = true; + } + else if (_videoPlayerContainer.VideoPlayer != null) + { + if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) + { + if (_videoPlayerContainer.VideoPlayer.IsPlaying) + _videoPlayerContainer.VideoPlayer.Pause(); + else + _videoPlayerContainer.VideoPlayer.Play(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Right && e.Modifiers == Keys.Control) + { + _videoPlayerContainer.CurrentPosition += 0.10; + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Left && e.Modifiers == Keys.Control) + { + _videoPlayerContainer.CurrentPosition -= 0.10; + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Right && e.Modifiers == Keys.Alt) + { + _videoPlayerContainer.CurrentPosition += 0.5; + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Left && e.Modifiers == Keys.Alt) + { + _videoPlayerContainer.CurrentPosition -= 0.5; + e.SuppressKeyPress = true; + } + } + } + } +} diff --git a/src/Forms/VideoPlayerUnDocked.resx b/src/Forms/VideoPlayerUnDocked.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/VideoPlayerUnDocked.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/WaveFormUnDocked.Designer.cs b/src/Forms/WaveFormUnDocked.Designer.cs new file mode 100644 index 000000000..96c09d716 --- /dev/null +++ b/src/Forms/WaveFormUnDocked.Designer.cs @@ -0,0 +1,60 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class WaveFormUnDocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelContainer = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(632, 203); + this.panelContainer.TabIndex = 1; + // + // WaveFormUnDocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(632, 203); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.Name = "WaveFormUnDocked"; + this.Text = "WaveFormUnDocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WaveFormUnDocked_FormClosing); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + } +} \ No newline at end of file diff --git a/src/Forms/WaveFormUnDocked.cs b/src/Forms/WaveFormUnDocked.cs new file mode 100644 index 000000000..d3b6d221e --- /dev/null +++ b/src/Forms/WaveFormUnDocked.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class WaveFormUnDocked : Form + { + Main _mainForm = null; + PositionsAndSizes _positionsAndSizes = null; + + public Panel PanelContainer + { + get + { + return panelContainer; + } + } + + public WaveFormUnDocked(Main mainForm, string title, PositionsAndSizes positionsAndSizes) + { + InitializeComponent(); + _mainForm = mainForm; + _positionsAndSizes = positionsAndSizes; + Text = title; + } + + private void WaveFormUnDocked_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + var controlWaveForm = panelContainer.Controls[0]; + var controlButtons = panelContainer.Controls[1]; + var controlTrackBar = panelContainer.Controls[2]; + panelContainer.Controls.Clear(); + _mainForm.ReDockWaveForm(controlWaveForm, controlButtons, controlTrackBar); + _mainForm.SetWaveFormToogleOff(); + } + _positionsAndSizes.SavePositionAndSize(this); + } + } +} diff --git a/src/Forms/WaveFormUnDocked.resx b/src/Forms/WaveFormUnDocked.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/WaveFormUnDocked.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Logic/PositionsAndSizes.cs b/src/Logic/PositionsAndSizes.cs index 77730c9f5..21deadf40 100644 --- a/src/Logic/PositionsAndSizes.cs +++ b/src/Logic/PositionsAndSizes.cs @@ -3,7 +3,7 @@ using System.Windows.Forms; namespace Nikse.SubtitleEdit.Logic { - class PositionsAndSizes + public class PositionsAndSizes { List _positionsAndSizes = new List(); diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 0b67e5574..4ddd0a463 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.1.*")] +[assembly: AssemblyVersion("3.1.0.*")] diff --git a/src/SubtitleEdit.csproj b/src/SubtitleEdit.csproj index ac7831357..1ea055d12 100644 --- a/src/SubtitleEdit.csproj +++ b/src/SubtitleEdit.csproj @@ -361,12 +361,24 @@ UnknownSubtitle.cs + + Form + + + VideoControlsUndocked.cs + Form VideoError.cs + + Form + + + VideoPlayerUnDocked.cs + Form @@ -403,6 +415,12 @@ Watermark.cs + + Form + + + WaveFormUnDocked.cs + @@ -696,6 +714,12 @@ UnknownSubtitle.cs Designer + + VideoControlsUndocked.cs + + + VideoPlayerUnDocked.cs + VisualSync.cs Designer @@ -715,6 +739,9 @@ Watermark.cs + + WaveFormUnDocked.cs + PublicResXFileCodeGenerator Resources.Designer.cs