misc code formatting improvements in random files in EmuHawk
This commit is contained in:
parent
1679c1b565
commit
28da1e215f
|
@ -58,7 +58,7 @@
|
|||
this.OK.TabIndex = 1;
|
||||
this.OK.Text = "&OK";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||
//
|
||||
// CommentGrid
|
||||
//
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
private void Ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
Save();
|
||||
Close();
|
||||
|
@ -88,24 +88,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SortColumn(DataGridViewColumn e)
|
||||
{
|
||||
ListSortDirection _direction;
|
||||
DataGridViewColumn _column = e;
|
||||
if (_lastHeaderClicked != _column.Name)
|
||||
DataGridViewColumn column = e;
|
||||
if (_lastHeaderClicked != column.Name)
|
||||
{
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
if (!_sortReverse)
|
||||
{
|
||||
_direction = ListSortDirection.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
_direction = ListSortDirection.Descending;
|
||||
}
|
||||
var direction = !_sortReverse
|
||||
? ListSortDirection.Ascending
|
||||
: ListSortDirection.Descending;
|
||||
|
||||
CommentGrid.Sort(_column, _direction);
|
||||
_lastHeaderClicked = _column.Name;
|
||||
CommentGrid.Sort(column, direction);
|
||||
_lastHeaderClicked = column.Name;
|
||||
_sortReverse = !_sortReverse;
|
||||
CommentGrid.Refresh();
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
this.OK.TabIndex = 1;
|
||||
this.OK.Text = "&OK";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||
//
|
||||
// SubGrid
|
||||
//
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class EditSubtitlesForm : Form
|
||||
{
|
||||
public bool ReadOnly;
|
||||
public bool ReadOnly { get; set; }
|
||||
private IMovie _selectedMovie;
|
||||
|
||||
public EditSubtitlesForm()
|
||||
|
@ -23,9 +22,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (ReadOnly)
|
||||
{
|
||||
//Set all columns to read only
|
||||
for (int x = 0; x < SubGrid.Columns.Count; x++)
|
||||
SubGrid.Columns[x].ReadOnly = true;
|
||||
// Set all columns to read only
|
||||
for (int i = 0; i < SubGrid.Columns.Count; i++)
|
||||
{
|
||||
SubGrid.Columns[i].ReadOnly = true;
|
||||
}
|
||||
|
||||
Text = "View Subtitles";
|
||||
}
|
||||
|
||||
|
@ -49,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
private void Ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ReadOnly)
|
||||
{
|
||||
|
@ -102,7 +104,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
c = SubGrid.Rows[x].Cells[3];
|
||||
c.Value = s.Duration;
|
||||
c = SubGrid.Rows[x].Cells[4];
|
||||
c.Value = String.Format("{0:X8}", s.Color);
|
||||
c.Value = string.Format("{0:X8}", s.Color);
|
||||
c.Style.BackColor = Color.FromArgb((int)s.Color);
|
||||
c = SubGrid.Rows[x].Cells[5];
|
||||
c.Value = s.Message;
|
||||
|
@ -111,7 +113,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ChangeRow(Subtitle s, int index)
|
||||
{
|
||||
if (index >= SubGrid.Rows.Count) return;
|
||||
if (index >= SubGrid.Rows.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var c = SubGrid.Rows[index].Cells[0];
|
||||
c.Value = s.Frame;
|
||||
c = SubGrid.Rows[index].Cells[1];
|
||||
|
@ -121,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
c = SubGrid.Rows[index].Cells[3];
|
||||
c.Value = s.Duration;
|
||||
c = SubGrid.Rows[index].Cells[4];
|
||||
c.Value = String.Format("{0:X8}", s.Color);
|
||||
c.Value = string.Format("{0:X8}", s.Color);
|
||||
c.Style.BackColor = Color.FromArgb((int)s.Color);
|
||||
c = SubGrid.Rows[index].Cells[5];
|
||||
c.Value = s.Message;
|
||||
|
@ -134,7 +140,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var s = new Subtitle();
|
||||
var c = SubGrid.Rows[index].Cells[0];
|
||||
|
||||
//Empty catch because it should default to subtitle default value
|
||||
// Empty catch because it should default to subtitle default value
|
||||
try { s.Frame = int.Parse(c.Value.ToString()); }
|
||||
catch { }
|
||||
c = SubGrid.Rows[index].Cells[1];
|
||||
|
@ -159,9 +165,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SubGrid_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
if (ReadOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var c = SubGrid.SelectedRows;
|
||||
if (c.Count == 0) return;
|
||||
if (c.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var s = new SubtitleMaker {Sub = GetRow(c[0].Index)};
|
||||
if (s.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
@ -172,17 +186,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void Export_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Get file to save as
|
||||
var form = new SaveFileDialog();
|
||||
form.AddExtension = true;
|
||||
form.Filter = "SubRip Files (*.srt)|*.srt|All files (*.*)|*.*";
|
||||
var form = new SaveFileDialog
|
||||
{
|
||||
AddExtension = true,
|
||||
Filter = "SubRip Files (*.srt)|*.srt|All files (*.*)|*.*"
|
||||
};
|
||||
|
||||
var result = form.ShowDialog();
|
||||
var fileName = form.FileName;
|
||||
|
||||
form.Dispose();
|
||||
|
||||
if (result != System.Windows.Forms.DialogResult.OK)
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch fps
|
||||
var system = _selectedMovie.HeaderEntries[HeaderKeys.PLATFORM];
|
||||
|
@ -201,8 +219,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
"Could not determine movie fps, export failed.",
|
||||
"Error",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -214,8 +231,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Display success
|
||||
MessageBox.Show(
|
||||
string.Format("Subtitles succesfully exported to {0}.", fileName),
|
||||
"Success"
|
||||
);
|
||||
"Success");
|
||||
}
|
||||
|
||||
private void SubGrid_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for the sorting of the moviedetails in PlayMovie.cs
|
||||
/// Used for the sorting of the movie details in PlayMovie.cs
|
||||
/// </summary>
|
||||
public class MovieDetails
|
||||
{
|
||||
|
|
|
@ -87,20 +87,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
return null;
|
||||
}
|
||||
|
||||
//System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start();
|
||||
var movie = PreLoadMovieFile(file, force);
|
||||
if (movie == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//watch.Stop(); Console.WriteLine("[{0}] {1}",watch.ElapsedMilliseconds,Path.GetFileName(filename));
|
||||
|
||||
int? index;
|
||||
lock (_movieList)
|
||||
{
|
||||
//need to check IsDuplicateOf within the lock
|
||||
// need to check IsDuplicateOf within the lock
|
||||
index = IsDuplicateOf(filename);
|
||||
if (index.HasValue) return index;
|
||||
if (index.HasValue)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
_movieList.Add(movie);
|
||||
index = _movieList.Count - 1;
|
||||
|
@ -111,7 +112,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int? IsDuplicateOf(string filename)
|
||||
|
@ -226,7 +226,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
HighlightMovie(mostRecent);
|
||||
return;
|
||||
}
|
||||
|
||||
private void HighlightMovie(int index)
|
||||
|
@ -257,27 +256,33 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
string dp = dpTodo.Dequeue();
|
||||
|
||||
//enqueue subdirectories if appropriate
|
||||
// enqueue subdirectories if appropriate
|
||||
if (Global.Config.PlayMovie_IncludeSubdir)
|
||||
foreach(var subdir in Directory.GetDirectories(dp))
|
||||
{
|
||||
foreach (var subdir in Directory.GetDirectories(dp))
|
||||
{
|
||||
dpTodo.Enqueue(subdir);
|
||||
}
|
||||
}
|
||||
|
||||
//add movies
|
||||
// add movies
|
||||
fpTodo.AddRange(Directory.GetFiles(dp, "*." + MovieService.DefaultExtension));
|
||||
fpTodo.AddRange(Directory.GetFiles(dp, "*." + TasMovie.Extension));
|
||||
}
|
||||
|
||||
//in parallel, scan each movie
|
||||
Parallel.For(0, fpTodo.Count, (i) =>
|
||||
//for(int i=0;i<fpTodo.Count;i++)
|
||||
// in parallel, scan each movie
|
||||
Parallel.For(0, fpTodo.Count, i =>
|
||||
{
|
||||
var file = fpTodo[i];
|
||||
lock(ordinals) ordinals[file] = i;
|
||||
AddMovieToList(file, force: false);
|
||||
}
|
||||
);
|
||||
lock (ordinals)
|
||||
{
|
||||
ordinals[file] = i;
|
||||
}
|
||||
|
||||
//sort by the ordinal key to maintain relatively stable results when rescanning
|
||||
AddMovieToList(file, force: false);
|
||||
});
|
||||
|
||||
// sort by the ordinal key to maintain relatively stable results when rescanning
|
||||
_movieList.Sort((a, b) => ordinals[a.Filename].CompareTo(ordinals[b.Filename]));
|
||||
|
||||
RefreshMovieList();
|
||||
|
|
|
@ -111,6 +111,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
movieToRecord.TextSavestate = sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: do we want to support optionally not saving this?
|
||||
if (true)
|
||||
{
|
||||
|
@ -169,8 +170,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (movieDirException is IOException ||
|
||||
movieDirException is UnauthorizedAccessException ||
|
||||
movieDirException is PathTooLongException
|
||||
)
|
||||
movieDirException is PathTooLongException)
|
||||
{
|
||||
//TO DO : Pass error to user?
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
this.OK.TabIndex = 0;
|
||||
this.OK.Text = "&Save";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
private void Ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
Sub.Frame = (int)FrameNumeric.Value;
|
||||
Sub.Message = Message.Text;
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return PromptLabel.Text;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
PromptLabel.Text = value ?? string.Empty;
|
||||
|
|
|
@ -38,5 +38,6 @@
|
|||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SG/@EntryIndexedValue">SG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String></wpf:ResourceDictionary>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String></wpf:ResourceDictionary>
|
||||
|
Loading…
Reference in New Issue