Tastudio - branches - convert listview to inputroll

This commit is contained in:
adelikat 2015-07-22 17:26:25 -04:00
parent a32cb8f3bf
commit 72d73cd754
2 changed files with 45 additions and 47 deletions

View File

@ -35,10 +35,7 @@
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem();
this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BranchView = new BizHawk.Client.EmuHawk.VirtualListView();
this.BranchNumberColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.FrameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.TimeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.BranchView = new InputRoll();
this.BookmarksBranchesGroupBox.SuspendLayout();
this.BranchesContextMenu.SuspendLayout();
this.SuspendLayout();
@ -101,42 +98,17 @@
this.BranchView.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.BranchView.BlazingFast = false;
this.BranchView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.BranchNumberColumn,
this.FrameColumn,
this.TimeColumn});
this.BranchView.ContextMenuStrip = this.BranchesContextMenu;
this.BranchView.FullRowSelect = true;
this.BranchView.GridLines = true;
this.BranchView.ItemCount = 0;
this.BranchView.Location = new System.Drawing.Point(6, 19);
this.BranchView.MultiSelect = false;
this.BranchView.Name = "BranchView";
this.BranchView.SelectAllInProgress = false;
this.BranchView.selectedItem = -1;
this.BranchView.Size = new System.Drawing.Size(186, 224);
this.BranchView.TabIndex = 0;
this.BranchView.UseCompatibleStateImageBehavior = false;
this.BranchView.UseCustomBackground = true;
this.BranchView.View = System.Windows.Forms.View.Details;
this.BranchView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDoubleClick);
//
// BranchNumberColumn
//
this.BranchNumberColumn.Text = "#";
this.BranchNumberColumn.Width = 30;
//
// FrameColumn
//
this.FrameColumn.Text = "Frame";
this.FrameColumn.Width = 68;
//
// TimeColumn
//
this.TimeColumn.Text = "Length";
this.TimeColumn.Width = 83;
//
// BookmarksBranchesBox
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -152,10 +124,7 @@
#endregion
private System.Windows.Forms.GroupBox BookmarksBranchesGroupBox;
private VirtualListView BranchView;
private System.Windows.Forms.ColumnHeader BranchNumberColumn;
private System.Windows.Forms.ColumnHeader FrameColumn;
private System.Windows.Forms.ColumnHeader TimeColumn;
private InputRoll BranchView;
private System.Windows.Forms.ContextMenuStrip BranchesContextMenu;
private System.Windows.Forms.ToolStripMenuItem AddContextMenu;
private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;

View File

@ -15,6 +15,10 @@ namespace BizHawk.Client.EmuHawk
{
public partial class BookmarksBranchesBox : UserControl
{
private const string BranchNumberColumnName = "BranchNumberColumn";
private const string FrameColumnName = "FrameColumn";
private const string TimeColumnName = "TimeColumn";
private readonly PlatformFrameRates FrameRates = new PlatformFrameRates();
public TAStudio Tastudio { get; set; }
@ -26,6 +30,29 @@ namespace BizHawk.Client.EmuHawk
public BookmarksBranchesBox()
{
InitializeComponent();
BranchView.AllColumns.AddRange(new InputRoll.RollColumn[]
{
new InputRoll.RollColumn
{
Name = BranchNumberColumnName,
Text = "#",
Width = 30
},
new InputRoll.RollColumn
{
Name = FrameColumnName,
Text = "Frame",
Width = 68
},
new InputRoll.RollColumn
{
Name = TimeColumnName,
Text = "Length",
Width = 83
},
});
BranchView.QueryItemText += QueryItemText;
BranchView.QueryItemBkColor += QueryItemBkColor;
}
@ -34,9 +61,9 @@ namespace BizHawk.Client.EmuHawk
{
get
{
if (BranchView.SelectedIndices.Count > 0)
if (BranchView.SelectedRows.Any())
{
return Branches[BranchView.SelectedIndices[0]];
return Branches[BranchView.SelectedRows.First()];
}
return null;
@ -45,32 +72,30 @@ namespace BizHawk.Client.EmuHawk
private int CurrentBranch = -1;
private void QueryItemText(int index, int column, out string text)
private void QueryItemText(int index, InputRoll.RollColumn column, out string text)
{
text = string.Empty;
var columnName = BranchView.Columns[column].Name;
if (index >= Tastudio.CurrentTasMovie.TasBranches.Count)
{
return;
}
switch (column)
switch (column.Name)
{
case 0: // BranchNumberColumn
case BranchNumberColumnName:
text = index.ToString();
break;
case 1: // FrameColumn
case FrameColumnName:
text = Branches[index].Frame.ToString();
break;
case 2: // TimeColumn
case TimeColumnName:
text = MovieTime(Branches[index].Frame).ToString(@"hh\:mm\:ss\.fff");
break;
}
}
private void QueryItemBkColor(int index, int column, ref Color color)
private void QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
{
if (index == CurrentBranch)
color = SystemColors.HotTrack;
@ -91,22 +116,25 @@ namespace BizHawk.Client.EmuHawk
};
Branches.Add(branch);
BranchView.ItemCount = Branches.Count;
BranchView.RowCount = Branches.Count;
BranchView.Refresh();
}
private void BranchView_MouseDoubleClick(object sender, MouseEventArgs e)
{
LoadSelectedBranch();
}
private void LoadBranchContextMenuItem_Click(object sender, EventArgs e)
{
LoadSelectedBranch();
}
private void LoadSelectedBranch()
{
if (SelectedBranch != null)
{
CurrentBranch = BranchView.selectedItem;
CurrentBranch = BranchView.SelectedRows.First();
BranchView.Refresh();
LoadBranch(SelectedBranch);
}
@ -124,7 +152,8 @@ namespace BizHawk.Client.EmuHawk
if (SelectedBranch != null)
{
Branches.Remove(SelectedBranch);
BranchView.ItemCount = Branches.Count;
BranchView.RowCount = Branches.Count;
BranchView.Refresh();
}
}
@ -181,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
BranchView.ItemCount = Branches.Count;
BranchView.RowCount = Branches.Count;
}
public void Branch()