Now remembers undocked controls pos/size

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@423 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-05-06 18:12:48 +00:00
parent 9c17615918
commit d082d7454a
8 changed files with 87 additions and 4 deletions

View File

@ -419,6 +419,10 @@ namespace Nikse.SubtitleEdit.Forms
if (File.Exists(outputFileName))
outputFileName = Path.GetFileNameWithoutExtension(fileName) + "_" + Guid.NewGuid().ToString() + sf.Extension;
Console.Write(string.Format("{0}: {1} -> {2}...", count, Path.GetFileName(fileName), outputFileName));
if (sf.IsFrameBased && !sub.WasLoadedWithFrameNumbers)
sub.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.DefaultFrameRate);
else if (sf.IsTimeBased && sub.WasLoadedWithFrameNumbers)
sub.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.DefaultFrameRate);
System.IO.File.WriteAllText(outputFileName, sub.ToText(sf));
Console.WriteLine(" done.");
}
@ -4657,6 +4661,14 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.General.SyncListViewWithVideoWhilePlaying = checkBoxSyncListViewWithVideoWhilePlaying.Checked;
if (!string.IsNullOrEmpty(_fileName))
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName);
if (_videoPlayerUnDocked != null && !_videoPlayerUnDocked.IsDisposed)
Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUnDocked.Left.ToString() + ";" + _videoPlayerUnDocked.Top.ToString() + ";" + _videoPlayerUnDocked.Width + ";" + _videoPlayerUnDocked.Height;
if (_waveFormUnDocked != null && !_waveFormUnDocked.IsDisposed)
Configuration.Settings.General.UndockedWaveformPosition = _waveFormUnDocked.Left.ToString() + ";" + _waveFormUnDocked.Top.ToString() + ";" + _waveFormUnDocked.Width + ";" + _waveFormUnDocked.Height;
if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed)
Configuration.Settings.General.UndockedVideoControlsPosition = _videoControlsUnDocked.Left.ToString() + ";" + _videoControlsUnDocked.Top.ToString() + ";" + _videoControlsUnDocked.Width + ";" + _videoControlsUnDocked.Height;
Configuration.Settings.Save();
if (mediaPlayer.VideoPlayer != null)
@ -7951,11 +7963,38 @@ namespace Nikse.SubtitleEdit.Forms
else
SubtitleListview1.Focus();
SetShortcuts();
if (Configuration.Settings.General.Undocked)
{
SetPositionFromXYString(Configuration.Settings.General.UndockedVideoPosition, "VideoPlayerUnDocked");
SetPositionFromXYString(Configuration.Settings.General.UndockedWaveformPosition, "WaveFormUnDocked");
SetPositionFromXYString(Configuration.Settings.General.UndockedVideoControlsPosition, "VideoControlsUndocked");
undockVideoControlsToolStripMenuItem_Click(null, null);
}
SetShortcuts();
LoadPlugins();
}
private void SetPositionFromXYString(string positionAndSize, string name)
{
string[] parts = positionAndSize.Split(';');
if (parts.Length == 4)
{
try
{
int x = int.Parse(parts[0]);
int y = int.Parse(parts[1]);
int w = int.Parse(parts[2]);
int h = int.Parse(parts[3]);
_formPositionsAndSizes.AddPositionAndSize(new PositionAndSize() { Left = x, Top = y, Size = new Size(w, h), Name = name });
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
}
}
}
private void SetShortcuts()
{
newToolStripMenuItem.ShortcutKeys = GetKeys(Configuration.Settings.Shortcuts.MainFileNew);
@ -9324,6 +9363,8 @@ namespace Nikse.SubtitleEdit.Forms
private void undockVideoControlsToolStripMenuItem_Click(object sender, EventArgs e)
{
Configuration.Settings.General.Undocked = true;
UnDockVideoPlayer();
if (toolStripButtonToggleVideo.Checked)
_videoPlayerUnDocked.Show(this);
@ -9345,6 +9386,7 @@ namespace Nikse.SubtitleEdit.Forms
private void redockVideoControlsToolStripMenuItem_Click(object sender, EventArgs e)
{
Configuration.Settings.General.Undocked = false;
if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed)
{

View File

@ -684,7 +684,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAeABBAHgAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAegBBAHoAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -30,6 +30,11 @@ namespace Nikse.SubtitleEdit.Forms
Text = title;
}
public VideoControlsUndocked()
{
// TODO: Complete member initialization
}
private void VideoControlsUndocked_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0)

View File

@ -26,6 +26,11 @@ namespace Nikse.SubtitleEdit.Forms
Text = title;
}
public VideoPlayerUnDocked()
{
// TODO: Complete member initialization
}
private void VideoPlayerUnDocked_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0)

View File

@ -30,6 +30,11 @@ namespace Nikse.SubtitleEdit.Forms
Text = title;
}
public WaveFormUnDocked()
{
// TODO: Complete member initialization
}
private void WaveFormUnDocked_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0)

View File

@ -5,7 +5,7 @@ using System.Drawing;
namespace Nikse.SubtitleEdit.Logic
{
class PositionAndSize
public class PositionAndSize
{
public string Name { get; set; }
public int Left { get; set; }

View File

@ -7,6 +7,11 @@ namespace Nikse.SubtitleEdit.Logic
{
List<PositionAndSize> _positionsAndSizes = new List<PositionAndSize>();
public void AddPositionAndSize(PositionAndSize pAndS)
{
_positionsAndSizes.Add(pAndS);
}
public bool SetPositionAndSize(Form form)
{
if (form == null)

View File

@ -249,6 +249,10 @@ namespace Nikse.SubtitleEdit.Logic
public int AutoBackupSeconds { get; set; }
public string SpellChecker { get; set; }
public bool AllowEditOfOriginalSubtitle { get; set; }
public bool Undocked { get; set; }
public string UndockedVideoPosition { get; set; }
public string UndockedWaveformPosition { get; set; }
public string UndockedVideoControlsPosition { get; set; }
public GeneralSettings()
{
@ -300,6 +304,7 @@ namespace Nikse.SubtitleEdit.Logic
AutoBackupSeconds = 0;
SpellChecker = "hunspell";
AllowEditOfOriginalSubtitle = false;
Undocked = false;
}
}
@ -715,6 +720,18 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("AllowEditOfOriginalSubtitle");
if (subNode != null)
settings.General.AllowEditOfOriginalSubtitle = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("Undocked");
if (subNode != null)
settings.General.Undocked = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("UndockedVideoPosition");
if (subNode != null)
settings.General.UndockedVideoPosition = subNode.InnerText;
subNode = node.SelectSingleNode("UndockedWaveformPosition");
if (subNode != null)
settings.General.UndockedWaveformPosition = subNode.InnerText;
subNode = node.SelectSingleNode("UndockedVideoControlsPosition");
if (subNode != null)
settings.General.UndockedVideoControlsPosition = subNode.InnerText;
settings.Tools = new Nikse.SubtitleEdit.Logic.ToolsSettings();
node = doc.DocumentElement.SelectSingleNode("Tools");
@ -1094,6 +1111,10 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("AutoBackupSeconds", settings.General.AutoBackupSeconds.ToString());
textWriter.WriteElementString("SpellChecker", settings.General.SpellChecker);
textWriter.WriteElementString("AllowEditOfOriginalSubtitle", settings.General.AllowEditOfOriginalSubtitle.ToString());
textWriter.WriteElementString("Undocked", settings.General.Undocked.ToString());
textWriter.WriteElementString("UndockedVideoPosition", settings.General.UndockedVideoPosition);
textWriter.WriteElementString("UndockedWaveformPosition", settings.General.UndockedWaveformPosition);
textWriter.WriteElementString("UndockedVideoControlsPosition", settings.General.UndockedVideoControlsPosition);
textWriter.WriteEndElement();
textWriter.WriteStartElement("Tools", "");