Merge pull request #884 from xylographe/xrfmt

Minor refact (Forms/Main)
This commit is contained in:
Nikolaj Olsson 2015-06-19 22:12:21 +02:00
commit 5c4f6a4067
8 changed files with 156 additions and 237 deletions

View File

@ -634,7 +634,6 @@ namespace Nikse.SubtitleEdit.Controls
stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
e.Graphics.DrawString(WaveformNotLoadedText, textFont, textBrush, new PointF(1, 10), stringFormat);
}
}
textBrush.Dispose();
textFont.Dispose();
@ -806,7 +805,6 @@ namespace Nikse.SubtitleEdit.Controls
e.Graphics.DrawString(text, font, textBrush, new PointF(currentRegionLeft + 3, top));
}
}
}
else if (n > 51)
e.Graphics.DrawString("#" + paragraph.Number + " " + paragraph.StartTime.ToShortString(), Font, textBrush, new PointF(currentRegionLeft + 3, Height - 32));
@ -1165,7 +1163,6 @@ namespace Nikse.SubtitleEdit.Controls
private void WaveformMouseMove(object sender, MouseEventArgs e)
{
if (_wavePeaks == null)
return;
@ -1393,7 +1390,6 @@ namespace Nikse.SubtitleEdit.Controls
}
NewSelectionParagraph.StartTime.TotalSeconds = startTotalSeconds;
NewSelectionParagraph.EndTime.TotalSeconds = endTotalSeconds;
}
}
Invalidate();
@ -1482,7 +1478,6 @@ namespace Nikse.SubtitleEdit.Controls
_mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - StartPositionSeconds);
_mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - StartPositionSeconds);
}
}
private void WaveformMouseDoubleClick(object sender, MouseEventArgs e)
@ -1556,7 +1551,6 @@ namespace Nikse.SubtitleEdit.Controls
int diff = Math.Abs(_mouseMoveStartX - e.X);
if (_mouseMoveStartX == -1 || _mouseMoveEndX == -1 || diff < 10 && TimeSpan.FromTicks(DateTime.Now.Ticks - _buttonDownTimeTicks).TotalSeconds < 0.25)
{
if (ModifierKeys == Keys.Shift && _selectedParagraph != null)
{
double seconds = XPositionToSeconds(e.X);
@ -1689,7 +1683,6 @@ namespace Nikse.SubtitleEdit.Controls
double seconds = ((i - (length / 2)) / (double)_wavePeaks.Header.SampleRate) / _zoomFactor;
if (seconds >= 0)
{
StartPositionSeconds = seconds;
if (StartPositionSeconds > 1)
StartPositionSeconds -= 1;
@ -1719,7 +1712,6 @@ namespace Nikse.SubtitleEdit.Controls
double seconds = (i + (length / 2)) / (double)_wavePeaks.Header.SampleRate / _zoomFactor;
if (seconds >= 0)
{
StartPositionSeconds = seconds;
if (StartPositionSeconds > 1)
StartPositionSeconds -= 1;

View File

@ -864,7 +864,6 @@ namespace Nikse.SubtitleEdit.Controls
Items[index].UseItemStyleForSubItems = false;
Items[index].SubItems[ColumnIndexExtra].BackColor = Color.AntiqueWhite;
Items[index].SubItems[ColumnIndexExtra].ForeColor = color;
}
}

View File

@ -915,7 +915,6 @@ namespace Nikse.SubtitleEdit.Controls
{
HideAllPauseImages();
_pictureBoxPauseDown.Visible = true;
}
if (OnButtonClicked != null)
OnButtonClicked.Invoke(sender, e);

View File

@ -76,7 +76,6 @@ namespace Nikse.SubtitleEdit.Forms.DCinema
numericUpDownTopBottomMargin.Value = ss.DCinemaBottomMargin;
else
numericUpDownTopBottomMargin.Value = 8;
}
Utilities.FixLargeFonts(this, buttonCancel);
}

View File

@ -19,13 +19,11 @@ using System.Xml;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class ExportPngXml : PositionAndSizeForm
{
private class MakeBitmapParameter
{
public Bitmap Bitmap { get; set; }
public Paragraph P { get; set; }
public string Type { get; set; }
@ -64,7 +62,6 @@ namespace Nikse.SubtitleEdit.Forms
{
BackgroundColor = Color.Transparent;
}
}
private Subtitle _subtitle;
@ -1072,7 +1069,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
{
if (!param.Saved)
{
string numberString = string.Format(Path.GetFileNameWithoutExtension(Path.GetFileName(param.SavDialogFileName)) + "{0:0000}", i);
string fileName = numberString + "." + comboBoxImageFormat.Text.ToLower();
string fileNameNoPath = Path.GetFileName(fileName);
@ -1326,7 +1322,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
{
param.Bitmap.Save(fileName, ImageFormat.Png);
}
imagesSavedCount++;
//<Event InTC="00:00:24:07" OutTC="00:00:31:13" Forced="False">
@ -2166,7 +2162,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
surface.DrawString(text, font, brush, new PointF { X = x - 1, Y = y - 1 - j }, sf);
surface.DrawString(text, font, brush, new PointF { X = x - 1, Y = y - 0 - j }, sf);
surface.DrawString(text, font, brush, new PointF { X = x - 1, Y = y + 1 - j }, sf);
}
brush.Dispose();
brush = new SolidBrush(parameter.SubtitleColor);
@ -3819,7 +3814,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
}
return;
}
}
catch
{
@ -3839,7 +3833,6 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
br.RotateTransform(0);
g.FillRectangle(br, rect);
}
}
private void linkLabelPreview_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

File diff suppressed because it is too large Load Diff

View File

@ -275,7 +275,8 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
string tempArr0QuoteTrimmed = arr[0].TrimEnd('"');
if (arr0.Length > 0 && arr1.Length > 1 && !(tempArr0QuoteTrimmed.EndsWith('.') || tempArr0QuoteTrimmed.EndsWith('!') || tempArr0QuoteTrimmed.EndsWith('?') || tempArr0QuoteTrimmed.EndsWith("</i>", StringComparison.Ordinal)) &&
if (arr0.Length > 0 && arr1.Length > 1 &&
!(tempArr0QuoteTrimmed.EndsWith('.') || tempArr0QuoteTrimmed.EndsWith('!') || tempArr0QuoteTrimmed.EndsWith('?') || tempArr0QuoteTrimmed.EndsWith("</i>", StringComparison.Ordinal)) &&
!(new StripableText(arr[1]).Pre.Contains('-')))
{
insertDash = false;
@ -505,28 +506,43 @@ namespace Nikse.SubtitleEdit.Logic.Forms
text = st.Pre + text + st.Post;
if (oldText.TrimStart().StartsWith("- ", StringComparison.Ordinal) && text != null && !text.Contains(Environment.NewLine) &&
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
{
text = text.TrimStart().TrimStart('-').TrimStart();
}
if (oldText.TrimStart().StartsWith("-", StringComparison.Ordinal) &&
!oldText.TrimStart().StartsWith("--", StringComparison.Ordinal) &&
text != null && !text.Contains(Environment.NewLine) &&
(oldText.Contains(Environment.NewLine + "-", StringComparison.Ordinal) && !(oldText.Contains(Environment.NewLine + "--", StringComparison.Ordinal)) ||
oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
(oldText.Contains(Environment.NewLine + "-", StringComparison.Ordinal) && !oldText.Contains(Environment.NewLine + "--", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
{
text = text.TrimStart().TrimStart('-').TrimStart();
}
if (oldText.TrimStart().StartsWith("<i>- ", StringComparison.Ordinal) && text != null && text.StartsWith("<i>- ", StringComparison.Ordinal) && !text.Contains(Environment.NewLine, StringComparison.Ordinal) &&
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
if (oldText.TrimStart().StartsWith("<i>- ", StringComparison.Ordinal) &&
text != null && text.StartsWith("<i>- ", StringComparison.Ordinal) && !text.Contains(Environment.NewLine, StringComparison.Ordinal) &&
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
{
text = text.Remove(3, 2);
}
if (text != null && !text.Contains(Environment.NewLine, StringComparison.Ordinal) &&
(oldText.Contains(':') && !text.Contains(':') || oldText.Contains('[') && !text.Contains('[') || oldText.Contains('(') && !text.Contains('(') || oldText.Contains('{') && !text.Contains('{')) &&
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) || oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
(oldText.Contains(':') && !text.Contains(':') ||
oldText.Contains('[') && !text.Contains('[') ||
oldText.Contains('(') && !text.Contains('(') ||
oldText.Contains('{') && !text.Contains('{')) &&
(oldText.Contains(Environment.NewLine + "- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + " - ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i>- ", StringComparison.Ordinal) ||
oldText.Contains(Environment.NewLine + "<i> - ", StringComparison.Ordinal)))
{
text = text.TrimStart().TrimStart('-').TrimStart();
}
@ -1074,4 +1090,4 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
}
}
}

View File

@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// Add the event handler for handling non-UI thread exceptions to the event.
// Add the event handler for handling non-UI thread exceptions to the event.
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.EnableVisualStyles();
@ -36,11 +36,11 @@ namespace Nikse.SubtitleEdit
}
}
// Handle the UI exceptions by showing a dialog box, and asking the user whether
// or not they wish to abort execution.
// NOTE: This exception cannot be kept from terminating the application - it can only
// log the event, and inform the user about it.
// Handle the UI exceptions by showing a dialog box, and asking the user whether
// or not they wish to abort execution.
// NOTE: This exception cannot be kept from terminating the application - it can only
// log the event, and inform the user about it.
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
@ -48,7 +48,7 @@ namespace Nikse.SubtitleEdit
var ex = (Exception)e.ExceptionObject;
const string errorMsg = "An error occurred in Subtitle Edit. Please contact the adminstrator with the following information:\n\n";
// Since we can't prevent the app from terminating, log this to the event log.
// Since we can't prevent the app from terminating, log this to the event log.
if (!EventLog.SourceExists("ThreadException"))
{
EventLog.CreateEventSource("ThreadException", "Application");