EditCommentsForm - some code and whitespace cleanup
This commit is contained in:
parent
149a759a26
commit
b10ef0b1a4
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -8,42 +10,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class EditCommentsForm : Form
|
||||
{
|
||||
private IMovie _selectedMovie;
|
||||
private String _lastHeaderClicked;
|
||||
private Boolean _sortReverse;
|
||||
|
||||
public EditCommentsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_lastHeaderClicked = "";
|
||||
_sortReverse = false;
|
||||
}
|
||||
private string _lastHeaderClicked;
|
||||
private bool _sortReverse;
|
||||
|
||||
private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
SortColumn(CommentGrid.Columns[e.ColumnIndex]);
|
||||
}
|
||||
|
||||
private void SortColumn(DataGridViewColumn e)
|
||||
{
|
||||
ListSortDirection _direction;
|
||||
DataGridViewColumn _column = e;
|
||||
if (_lastHeaderClicked != _column.Name)
|
||||
{
|
||||
_sortReverse = false;
|
||||
}
|
||||
if (!_sortReverse)
|
||||
{
|
||||
_direction = ListSortDirection.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
_direction = ListSortDirection.Descending;
|
||||
}
|
||||
CommentGrid.Sort(_column, _direction);
|
||||
_lastHeaderClicked = _column.Name;
|
||||
_sortReverse = !_sortReverse;
|
||||
CommentGrid.Refresh();
|
||||
}
|
||||
public EditCommentsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_lastHeaderClicked = string.Empty;
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
private void EditCommentsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -60,6 +35,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public void GetMovie(IMovie m)
|
||||
{
|
||||
_selectedMovie = m;
|
||||
if (!m.Comments.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m.Comments.Count; i++)
|
||||
{
|
||||
CommentGrid.Rows.Add();
|
||||
var c = CommentGrid.Rows[i].Cells[0];
|
||||
c.Value = m.Comments[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
|
@ -80,22 +71,33 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
|
||||
public void GetMovie(IMovie m)
|
||||
private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
_selectedMovie = m;
|
||||
if (m.Comments.Count == 0) return;
|
||||
SortColumn(CommentGrid.Columns[e.ColumnIndex]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < m.Comments.Count; i++)
|
||||
private void SortColumn(DataGridViewColumn e)
|
||||
{
|
||||
ListSortDirection _direction;
|
||||
DataGridViewColumn _column = e;
|
||||
if (_lastHeaderClicked != _column.Name)
|
||||
{
|
||||
var str = m.Comments[i];
|
||||
if (str.Length >= 7 && str.Substring(0, 7) == "comment")
|
||||
{
|
||||
str = str.Remove(0, 7);
|
||||
}
|
||||
CommentGrid.Rows.Add();
|
||||
var c = CommentGrid.Rows[i].Cells[0];
|
||||
c.Value = str;
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
if (!_sortReverse)
|
||||
{
|
||||
_direction = ListSortDirection.Ascending;
|
||||
}
|
||||
else
|
||||
{
|
||||
_direction = ListSortDirection.Descending;
|
||||
}
|
||||
|
||||
CommentGrid.Sort(_column, _direction);
|
||||
_lastHeaderClicked = _column.Name;
|
||||
_sortReverse = !_sortReverse;
|
||||
CommentGrid.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue