2013-12-01 04:00:02 +00:00
using System ;
using System.Collections.Generic ;
using System.Drawing ;
using System.IO ;
2013-12-05 19:18:20 +00:00
using System.Linq ;
2013-12-01 04:00:02 +00:00
using System.Windows.Forms ;
2013-12-01 20:55:52 +00:00
2013-12-01 04:00:02 +00:00
using BizHawk.Client.Common ;
2014-07-06 21:20:43 +00:00
using BizHawk.Client.Common.MovieConversionExtensions ;
2013-12-01 04:00:02 +00:00
namespace BizHawk.Client.EmuHawk
{
2014-07-08 16:08:52 +00:00
public partial class TAStudio : Form , IToolForm , IControlMainform
2013-12-01 04:00:02 +00:00
{
2013-12-14 14:40:33 +00:00
// TODO: UI flow that conveniently allows to start from savestate
2013-12-07 17:29:47 +00:00
private const string MarkerColumnName = "MarkerColumn" ;
private const string FrameColumnName = "FrameColumn" ;
2013-12-06 15:47:23 +00:00
2014-02-01 15:44:51 +00:00
private readonly MarkerList _markers = new MarkerList ( ) ;
private readonly List < TasClipboardEntry > _tasClipboard = new List < TasClipboardEntry > ( ) ;
2013-12-01 04:00:02 +00:00
private int _defaultWidth ;
private int _defaultHeight ;
2013-12-05 19:18:20 +00:00
private TasMovie _tas ;
2013-12-01 04:00:02 +00:00
2013-12-10 01:45:45 +00:00
// Input Painting
2014-02-01 15:44:51 +00:00
private string _startDrawColumn = string . Empty ;
2014-06-19 21:37:28 +00:00
//private bool _startOn;
2014-02-01 15:44:51 +00:00
private bool _startMarkerDrag ;
private bool _startFrameDrag ;
2013-12-10 01:45:45 +00:00
2014-07-06 22:13:12 +00:00
private Dictionary < string , string > _map = null ;
private Dictionary < string , string > ColumnNames
{
get
{
if ( _map = = null )
{
var lg = new Bk2LogEntryGenerator ( string . Empty ) ;
lg . SetSource ( Global . MovieSession . MovieControllerAdapter ) ;
_map = lg . Map ( ) ;
}
return _map ;
}
}
2013-12-01 04:00:02 +00:00
public TAStudio ( )
{
InitializeComponent ( ) ;
2014-02-01 15:44:51 +00:00
TasView . QueryItemText + = TasView_QueryItemText ;
TasView . QueryItemBkColor + = TasView_QueryItemBkColor ;
2013-12-20 03:28:25 +00:00
TasView . VirtualMode = true ;
2013-12-01 04:00:02 +00:00
Closing + = ( o , e ) = >
{
if ( AskSave ( ) )
{
SaveConfigSettings ( ) ;
2014-07-08 15:15:35 +00:00
GlobalWin . MainForm . StopMovie ( saveChanges : true ) ;
DisengageTastudio ( ) ;
2013-12-01 04:00:02 +00:00
}
else
{
e . Cancel = true ;
}
} ;
2014-02-01 15:44:51 +00:00
TopMost = Global . Config . TAStudioSettings . TopMost ;
2013-12-20 03:28:25 +00:00
TasView . InputPaintingMode = Global . Config . TAStudioDrawInput ;
2014-02-01 15:44:51 +00:00
TasView . PointedCellChanged + = TasView_PointedCellChanged ;
2013-12-01 04:00:02 +00:00
}
2014-02-01 15:44:51 +00:00
private void TasView_QueryItemBkColor ( int index , int column , ref Color color )
2013-12-01 04:00:02 +00:00
{
2013-12-06 15:47:23 +00:00
var record = _tas [ index ] ;
2013-12-15 02:50:50 +00:00
if ( _markers . CurrentFrame = = index + 1 )
{
color = Color . LightBlue ;
}
else if ( ! record . HasState )
2013-12-06 15:47:23 +00:00
{
color = BackColor ;
}
else
{
2013-12-07 21:37:52 +00:00
color = record . Lagged ? Color . Pink : Color . LightGreen ;
2013-12-06 15:47:23 +00:00
}
2013-12-01 04:00:02 +00:00
}
2014-02-01 15:44:51 +00:00
private void TasView_QueryItemText ( int index , int column , out string text )
2013-12-01 04:00:02 +00:00
{
2013-12-07 01:50:52 +00:00
try
2013-12-06 15:47:23 +00:00
{
2013-12-20 03:28:25 +00:00
var columnName = TasView . Columns [ column ] . Name ;
2014-06-29 02:33:50 +00:00
//var columnText = TasView.Columns[column].Text;
2013-12-07 01:50:52 +00:00
2013-12-07 17:29:47 +00:00
if ( columnName = = MarkerColumnName )
2013-12-07 01:50:52 +00:00
{
2014-02-02 17:49:40 +00:00
text = _markers . CurrentFrame = = index + 1 ? ">" : string . Empty ;
2013-12-07 01:50:52 +00:00
}
2013-12-07 17:29:47 +00:00
else if ( columnName = = FrameColumnName )
2013-12-07 01:50:52 +00:00
{
2013-12-15 02:50:50 +00:00
text = ( index + 1 ) . ToString ( ) . PadLeft ( 5 , '0' ) ;
2013-12-07 01:50:52 +00:00
}
else
{
2014-02-08 22:41:47 +00:00
//Serialize TODO
//text = _tas[index].IsPressed(columnName) ? columnText : string.Empty;
text = string . Empty ;
2013-12-07 01:50:52 +00:00
}
2013-12-06 15:47:23 +00:00
}
2013-12-07 01:50:52 +00:00
catch ( Exception ex )
2013-12-06 18:27:06 +00:00
{
2014-02-02 17:49:40 +00:00
text = string . Empty ;
2013-12-07 21:37:52 +00:00
MessageBox . Show ( "oops\n" + ex ) ;
2013-12-06 18:27:06 +00:00
}
2013-12-01 04:00:02 +00:00
}
2014-02-02 17:49:40 +00:00
private void Tastudio_Load ( object sender , EventArgs e )
2013-12-01 04:00:02 +00:00
{
2014-07-08 13:33:01 +00:00
// Start Scenario 1: A regular movie is active
2014-07-06 21:20:43 +00:00
if ( Global . MovieSession . Movie . IsActive & & ! ( Global . MovieSession . Movie is TasMovie ) )
2013-12-01 22:29:38 +00:00
{
2014-07-06 21:20:43 +00:00
var result = MessageBox . Show ( "In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?" , "Convert movie" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ;
if ( result = = DialogResult . OK )
{
2014-07-08 15:15:35 +00:00
ConvertCurrentMovieToTasproj ( ) ;
2014-07-06 21:20:43 +00:00
}
else
2013-12-01 22:29:38 +00:00
{
Close ( ) ;
return ;
}
}
2014-07-08 13:33:01 +00:00
// Start Scenario 2: A tasproj is already active
2014-07-06 21:20:43 +00:00
else if ( Global . MovieSession . Movie . IsActive & & Global . MovieSession . Movie is TasMovie )
{
2014-07-08 15:15:35 +00:00
// Nothing to do
2014-07-06 21:20:43 +00:00
}
2014-07-08 13:33:01 +00:00
// Start Scenario 3: No movie, but user wants to autload their last project
2014-07-06 21:20:43 +00:00
else if ( Global . Config . AutoloadTAStudioProject )
2013-12-14 19:51:07 +00:00
{
2014-07-08 15:15:35 +00:00
LoadProject ( Global . Config . RecentTas . MostRecent ) ;
2013-12-14 19:51:07 +00:00
}
2014-07-08 13:33:01 +00:00
// Start Scenario 4: No movie, default behavior of engaging tastudio with a new default project
2013-12-14 19:51:07 +00:00
else
{
2014-07-08 15:15:35 +00:00
NewTasMovie ( ) ;
StartSessionFromTasMovie ( ) ;
2013-12-14 19:51:07 +00:00
}
2014-07-08 15:15:35 +00:00
EngageTastudio ( ) ;
2014-07-06 22:13:12 +00:00
SetUpColumns ( ) ;
2014-07-07 19:48:58 +00:00
LoadConfigSettings ( ) ;
2013-12-05 19:18:20 +00:00
}
2014-07-08 15:15:35 +00:00
private void ConvertCurrentMovieToTasproj ( )
{
Global . MovieSession . Movie . Save ( ) ;
Global . MovieSession . Movie = Global . MovieSession . Movie . ToTasMovie ( ) ;
Global . MovieSession . Movie . Save ( ) ;
}
private void EngageTastudio ( )
2013-12-10 16:37:41 +00:00
{
GlobalWin . OSD . AddMessage ( "TAStudio engaged" ) ;
2014-07-08 15:15:35 +00:00
_tas = Global . MovieSession . Movie as TasMovie ;
2014-07-08 16:08:52 +00:00
GlobalWin . MainForm . RelinquishControl ( this ) ;
2014-07-08 15:15:35 +00:00
}
2014-07-08 13:46:59 +00:00
2014-07-08 15:15:35 +00:00
private void DisengageTastudio ( )
{
GlobalWin . OSD . AddMessage ( "TAStudio disengaged" ) ;
Global . MovieSession . Movie = MovieService . DefaultInstance ;
2014-07-08 16:08:52 +00:00
GlobalWin . MainForm . TakeControl ( ) ;
2014-07-08 15:15:35 +00:00
}
2014-07-08 13:46:59 +00:00
2014-07-08 15:15:35 +00:00
private void NewTasMovie ( )
{
Global . MovieSession . Movie = new TasMovie ( ) ;
2013-12-10 16:37:41 +00:00
_tas = Global . MovieSession . Movie as TasMovie ;
2014-07-08 15:15:35 +00:00
_tas . Filename = DefaultTasProjName ( ) ; // TODO don't do this, take over any mainform actions that can crash without a filename
_tas . PopulateWithDefaultHeaderValues ( ) ;
}
private static string DefaultTasProjName ( )
{
return Path . Combine (
PathManager . MakeAbsolutePath ( Global . Config . PathEntries . MoviesPathFragment , null ) ,
PathManager . FilesystemSafeName ( Global . Game ) + "." + TasMovie . Extension ) ;
2013-12-10 16:37:41 +00:00
}
2014-07-08 15:15:35 +00:00
private void StartSessionFromTasMovie ( )
2013-12-10 16:37:41 +00:00
{
if ( AskSave ( ) )
{
2014-07-07 19:48:58 +00:00
GlobalWin . MainForm . StartNewMovie ( _tas , record : true ) ;
2013-12-20 03:28:25 +00:00
TasView . ItemCount = _tas . InputLogLength ;
2013-12-10 16:37:41 +00:00
}
}
2014-07-08 15:15:35 +00:00
public void LoadProject ( string path )
{
if ( AskSave ( ) )
{
NewTasMovie ( ) ;
_tas . Filename = path ;
var loadResult = Global . MovieSession . MovieLoad ( ) ;
if ( ! loadResult )
{
ToolHelpers . HandleLoadError ( Global . Config . RecentTas , path ) ;
}
else
{
Global . Config . RecentTas . Add ( path ) ;
RefreshDialog ( ) ;
}
}
}
private void RefreshDialog ( )
{
TasView . ItemCount = _tas . InputLogLength ;
}
2013-12-05 19:18:20 +00:00
private void SetUpColumns ( )
{
2013-12-20 03:28:25 +00:00
TasView . Columns . Clear ( ) ;
2014-07-06 22:13:12 +00:00
AddColumn ( MarkerColumnName , string . Empty , 18 ) ;
2013-12-07 17:29:47 +00:00
AddColumn ( FrameColumnName , "Frame#" , 68 ) ;
2013-12-05 19:18:20 +00:00
2014-07-06 22:13:12 +00:00
foreach ( var kvp in ColumnNames )
2013-12-05 19:18:20 +00:00
{
2014-07-07 16:03:22 +00:00
AddColumn ( kvp . Key , kvp . Value , 20 * kvp . Value . Length ) ;
2013-12-07 17:29:47 +00:00
}
}
public void AddColumn ( string columnName , string columnText , int columnWidth )
{
2013-12-20 03:28:25 +00:00
if ( TasView . Columns [ columnName ] = = null )
2013-12-07 17:29:47 +00:00
{
var column = new ColumnHeader
{
Name = columnName ,
Text = columnText ,
Width = columnWidth ,
} ;
2013-12-20 03:28:25 +00:00
TasView . Columns . Add ( column ) ;
2013-12-05 19:18:20 +00:00
}
2013-12-01 04:00:02 +00:00
}
private void LoadConfigSettings ( )
{
_defaultWidth = Size . Width ;
_defaultHeight = Size . Height ;
2014-02-01 15:44:51 +00:00
if ( Global . Config . TAStudioSettings . UseWindowPosition )
2013-12-01 04:00:02 +00:00
{
2014-02-01 15:44:51 +00:00
Location = Global . Config . TAStudioSettings . WindowPosition ;
2013-12-01 04:00:02 +00:00
}
2014-02-01 15:44:51 +00:00
if ( Global . Config . TAStudioSettings . UseWindowSize )
2013-12-01 04:00:02 +00:00
{
2014-02-01 15:44:51 +00:00
Size = Global . Config . TAStudioSettings . WindowSize ;
2013-12-01 04:00:02 +00:00
}
}
private void SaveConfigSettings ( )
{
2014-02-01 15:44:51 +00:00
Global . Config . TAStudioSettings . Wndx = Location . X ;
Global . Config . TAStudioSettings . Wndy = Location . Y ;
Global . Config . TAStudioSettings . Width = Right - Left ;
Global . Config . TAStudioSettings . Height = Bottom - Top ;
2013-12-01 04:00:02 +00:00
}
2013-12-15 04:45:46 +00:00
private void GoToFrame ( int frame )
{
2014-02-01 15:44:51 +00:00
// If past greenzone, emulate and capture states
// If past greenzone AND movie, record input and capture states
// If in greenzone, loadstate
// If near a greenzone item, load and emulate
// Do capturing and recording as needed
2013-12-15 04:45:46 +00:00
if ( _tas [ frame - 1 ] . HasState ) // Go back 1 frame and emulate
{
_tas . SwitchToPlay ( ) ;
Global . Emulator . LoadStateBinary ( new BinaryReader ( new MemoryStream ( _tas [ frame ] . State . ToArray ( ) ) ) ) ;
2014-02-02 17:49:40 +00:00
Global . Emulator . FrameAdvance ( true ) ;
2013-12-15 04:45:46 +00:00
GlobalWin . DisplayManager . NeedsToPaint = true ;
2013-12-20 03:28:25 +00:00
TasView . ensureVisible ( frame ) ;
TasView . Refresh ( ) ;
2013-12-15 04:45:46 +00:00
}
else
{
2014-02-01 15:44:51 +00:00
// Find the earliest frame before this state
2013-12-15 04:45:46 +00:00
}
}
2013-12-19 03:45:11 +00:00
private void SetSplicer ( )
{
// TODO: columns selected
// TODO: clipboard
2014-02-01 15:44:51 +00:00
var list = TasView . SelectedIndices ;
2014-02-02 17:49:40 +00:00
string message ;
2013-12-19 03:45:11 +00:00
if ( list . Count > 0 )
{
2014-02-01 15:44:51 +00:00
message = list . Count + " rows, 0 col, clipboard: " ;
2013-12-19 03:45:11 +00:00
}
else
{
2014-02-01 15:44:51 +00:00
message = list . Count + " selected: none, clipboard: " ;
2013-12-19 03:45:11 +00:00
}
2014-02-01 15:44:51 +00:00
message + = _tasClipboard . Any ( ) ? _tasClipboard . Count . ToString ( ) : "empty" ;
2013-12-19 03:45:11 +00:00
SplicerStatusLabel . Text = message ;
}
2014-02-01 15:44:51 +00:00
private void RefreshFloatingWindowControl ( )
{
Owner = Global . Config . TAStudioSettings . FloatingWindow ? null : GlobalWin . MainForm ;
}
2013-12-01 04:00:02 +00:00
#region Events
#region File Menu
2013-12-10 01:45:45 +00:00
private void FileSubMenu_DropDownOpened ( object sender , EventArgs e )
{
2014-07-07 16:14:33 +00:00
ToBk2MenuItem . Enabled =
SaveTASMenuItem . Enabled =
! string . IsNullOrWhiteSpace ( _tas . Filename ) ;
2013-12-10 01:45:45 +00:00
}
2013-12-10 02:13:50 +00:00
private void RecentSubMenu_DropDownOpened ( object sender , EventArgs e )
{
RecentSubMenu . DropDownItems . Clear ( ) ;
RecentSubMenu . DropDownItems . AddRange (
2014-07-08 15:15:35 +00:00
ToolHelpers . GenerateRecentMenu ( Global . Config . RecentTas , LoadProject )
2013-12-10 02:13:50 +00:00
) ;
}
2014-02-02 17:49:40 +00:00
private void NewTasMenuItem_Click ( object sender , EventArgs e )
2013-12-10 16:37:41 +00:00
{
2014-07-08 13:33:01 +00:00
GlobalWin . OSD . AddMessage ( "new TAStudio session started" ) ;
2014-07-08 15:15:35 +00:00
StartSessionFromTasMovie ( ) ;
2013-12-10 16:37:41 +00:00
}
2014-02-02 17:49:40 +00:00
private void OpenTasMenuItem_Click ( object sender , EventArgs e )
2013-12-10 02:13:50 +00:00
{
2013-12-14 19:51:07 +00:00
if ( AskSave ( ) )
2013-12-10 02:13:50 +00:00
{
2013-12-14 19:51:07 +00:00
var file = ToolHelpers . GetTasProjFileFromUser ( _tas . Filename ) ;
if ( file ! = null )
{
_tas . Filename = file . FullName ;
_tas . Load ( ) ;
Global . Config . RecentTas . Add ( _tas . Filename ) ;
2013-12-20 03:28:25 +00:00
TasView . ItemCount = _tas . InputLogLength ;
2014-02-02 17:49:40 +00:00
MessageStatusLabel . Text = Path . GetFileName ( _tas . Filename ) + " loaded." ;
2013-12-14 19:51:07 +00:00
}
2013-12-10 02:13:50 +00:00
}
}
2014-02-01 15:44:51 +00:00
private void SaveTasMenuItem_Click ( object sender , EventArgs e )
2013-12-10 01:45:45 +00:00
{
2014-02-01 15:44:51 +00:00
if ( string . IsNullOrEmpty ( _tas . Filename ) )
2013-12-14 14:40:33 +00:00
{
2014-02-01 15:44:51 +00:00
SaveAsTasMenuItem_Click ( sender , e ) ;
2013-12-14 14:40:33 +00:00
}
else
{
_tas . Save ( ) ;
2014-02-02 17:49:40 +00:00
MessageStatusLabel . Text = Path . GetFileName ( _tas . Filename ) + " saved." ;
2013-12-14 14:40:33 +00:00
}
2013-12-10 01:45:45 +00:00
}
2014-02-01 15:44:51 +00:00
private void SaveAsTasMenuItem_Click ( object sender , EventArgs e )
2013-12-10 01:45:45 +00:00
{
var file = ToolHelpers . GetTasProjSaveFileFromUser ( _tas . Filename ) ;
2013-12-10 16:37:41 +00:00
if ( file ! = null )
2013-12-10 01:45:45 +00:00
{
_tas . Filename = file . FullName ;
_tas . Save ( ) ;
2013-12-10 02:13:50 +00:00
Global . Config . RecentTas . Add ( _tas . Filename ) ;
2014-02-02 17:49:40 +00:00
MessageStatusLabel . Text = Path . GetFileName ( _tas . Filename ) + " saved." ;
2013-12-10 01:45:45 +00:00
}
}
2014-07-07 16:14:33 +00:00
private void ToBk2MenuItem_Click ( object sender , EventArgs e )
{
var bk2 = _tas . ToBk2 ( ) ;
bk2 . Save ( ) ;
MessageStatusLabel . Text = Path . GetFileName ( bk2 . Filename ) + " created." ;
}
2013-12-01 04:00:02 +00:00
private void ExitMenuItem_Click ( object sender , EventArgs e )
{
Close ( ) ;
}
#endregion
2013-12-08 19:30:57 +00:00
#region Config
private void ConfigSubMenu_DropDownOpened ( object sender , EventArgs e )
{
DrawInputByDraggingMenuItem . Checked = Global . Config . TAStudioDrawInput ;
}
private void DrawInputByDraggingMenuItem_Click ( object sender , EventArgs e )
{
2013-12-20 03:28:25 +00:00
TasView . InputPaintingMode = Global . Config . TAStudioDrawInput ^ = true ;
2013-12-08 19:30:57 +00:00
}
2013-12-19 03:45:11 +00:00
private void CopyMenuItem_Click ( object sender , EventArgs e )
{
2014-02-01 15:44:51 +00:00
_tasClipboard . Clear ( ) ;
var list = TasView . SelectedIndices ;
for ( var i = 0 ; i < list . Count ; i + + )
2013-12-19 03:45:11 +00:00
{
2014-02-08 22:41:47 +00:00
//Serialize TODO
//_tasClipboard.Add(new TasClipboardEntry(list[i], _tas[i].Buttons));
2013-12-19 03:45:11 +00:00
}
SetSplicer ( ) ;
}
2013-12-08 19:30:57 +00:00
#endregion
2013-12-01 04:00:02 +00:00
#region Settings Menu
2013-12-08 19:30:57 +00:00
2013-12-01 04:00:02 +00:00
private void SettingsSubMenu_DropDownOpened ( object sender , EventArgs e )
{
2014-02-01 15:44:51 +00:00
SaveWindowPositionMenuItem . Checked = Global . Config . TAStudioSettings . SaveWindowPosition ;
2013-12-01 04:00:02 +00:00
AutoloadMenuItem . Checked = Global . Config . AutoloadTAStudio ;
2013-12-14 19:51:07 +00:00
AutoloadProjectMenuItem . Checked = Global . Config . AutoloadTAStudioProject ;
2014-02-01 15:44:51 +00:00
AlwaysOnTopMenuItem . Checked = Global . Config . TAStudioSettings . TopMost ;
FloatingWindowMenuItem . Checked = Global . Config . TAStudioSettings . FloatingWindow ;
2013-12-01 04:00:02 +00:00
}
private void AutoloadMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . AutoloadTAStudio ^ = true ;
}
2013-12-07 21:37:52 +00:00
2013-12-14 19:51:07 +00:00
private void AutoloadProjectMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . AutoloadTAStudioProject ^ = true ;
}
2013-12-01 04:00:02 +00:00
private void SaveWindowPositionMenuItem_Click ( object sender , EventArgs e )
{
2014-02-01 15:44:51 +00:00
Global . Config . TAStudioSettings . SaveWindowPosition ^ = true ;
2013-12-01 04:00:02 +00:00
}
private void AlwaysOnTopMenuItem_Click ( object sender , EventArgs e )
{
2014-02-01 15:44:51 +00:00
Global . Config . TAStudioSettings . TopMost ^ = true ;
}
private void FloatingWindowMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . TAStudioSettings . FloatingWindow ^ = true ;
RefreshFloatingWindowControl ( ) ;
2013-12-01 04:00:02 +00:00
}
2013-12-14 14:48:05 +00:00
private void RestoreDefaultSettingsMenuItem_Click ( object sender , EventArgs e )
{
Size = new Size ( _defaultWidth , _defaultHeight ) ;
2014-02-01 15:44:51 +00:00
Global . Config . TAStudioSettings . SaveWindowPosition = true ;
Global . Config . TAStudioSettings . TopMost = false ;
Global . Config . TAStudioSettings . FloatingWindow = false ;
RefreshFloatingWindowControl ( ) ;
2013-12-14 14:48:05 +00:00
}
2013-12-01 04:00:02 +00:00
#endregion
2013-12-08 18:44:41 +00:00
#region TASView Events
2014-02-01 15:44:51 +00:00
private void TasView_MouseDown ( object sender , MouseEventArgs e )
2013-12-08 18:44:41 +00:00
{
2014-02-01 15:44:51 +00:00
if ( TasView . PointedCell . Row . HasValue & & ! string . IsNullOrEmpty ( TasView . PointedCell . Column ) )
2013-12-08 19:30:57 +00:00
{
2013-12-20 03:28:25 +00:00
if ( TasView . PointedCell . Column = = MarkerColumnName )
2013-12-15 02:50:50 +00:00
{
2014-02-01 15:44:51 +00:00
_startMarkerDrag = true ;
2013-12-15 02:50:50 +00:00
}
2013-12-20 03:28:25 +00:00
else if ( TasView . PointedCell . Column = = FrameColumnName )
2013-12-15 02:50:50 +00:00
{
2014-02-01 15:44:51 +00:00
_startFrameDrag = true ;
2013-12-15 02:50:50 +00:00
}
else
{
2014-06-14 21:37:51 +00:00
//_tas.ToggleButton(TasView.PointedCell.Row.Value, TasView.PointedCell.Column);
2013-12-20 03:28:25 +00:00
TasView . Refresh ( ) ;
2013-12-08 19:42:07 +00:00
2014-02-01 15:44:51 +00:00
_startDrawColumn = TasView . PointedCell . Column ;
2014-06-14 21:37:51 +00:00
//_startOn = _tas.IsPressed(TasView.PointedCell.Row.Value, TasView.PointedCell.Column);
2013-12-15 02:50:50 +00:00
}
2013-12-08 19:30:57 +00:00
}
}
2014-02-01 15:44:51 +00:00
private void TasView_MouseUp ( object sender , MouseEventArgs e )
2013-12-15 02:50:50 +00:00
{
2014-02-01 15:44:51 +00:00
_startMarkerDrag = false ;
_startFrameDrag = false ;
_startDrawColumn = string . Empty ;
2013-12-15 02:50:50 +00:00
}
2014-02-01 15:44:51 +00:00
private void TasView_PointedCellChanged ( object sender , TasListView . CellEventArgs e )
2013-12-08 19:30:57 +00:00
{
2014-02-01 15:44:51 +00:00
if ( _startMarkerDrag )
2013-12-15 02:50:50 +00:00
{
2013-12-15 04:45:46 +00:00
if ( e . NewCell . Row . HasValue )
{
2013-12-15 17:19:22 +00:00
GoToFrame ( e . NewCell . Row . Value ) ;
2013-12-15 04:45:46 +00:00
}
2013-12-15 02:50:50 +00:00
}
2014-02-01 15:44:51 +00:00
else if ( _startFrameDrag )
2013-12-15 02:50:50 +00:00
{
2013-12-20 03:28:25 +00:00
if ( e . OldCell . Row . HasValue & & e . NewCell . Row . HasValue )
2013-12-15 17:19:22 +00:00
{
2013-12-20 03:28:25 +00:00
int startVal , endVal ;
if ( e . OldCell . Row . Value < e . NewCell . Row . Value )
{
startVal = e . OldCell . Row . Value ;
endVal = e . NewCell . Row . Value ;
}
else
{
startVal = e . NewCell . Row . Value ;
endVal = e . OldCell . Row . Value ;
}
2014-02-02 17:49:40 +00:00
for ( var i = startVal + 1 ; i < = endVal ; i + + )
2013-12-20 03:28:25 +00:00
{
TasView . SelectItem ( i , true ) ;
}
2013-12-15 17:19:22 +00:00
}
2013-12-15 02:50:50 +00:00
}
2014-02-01 15:44:51 +00:00
else if ( TasView . IsPaintDown & & e . NewCell . Row . HasValue & & ! string . IsNullOrEmpty ( _startDrawColumn ) )
2013-12-08 18:44:41 +00:00
{
2014-07-07 18:03:02 +00:00
//_tas.SetBoolButton(e.NewCell.Row.Value, _startDrawColumn, /*_startOn*/ false); // Notice it uses new row, old column, you can only paint across a single column
2013-12-20 03:28:25 +00:00
TasView . Refresh ( ) ;
2013-12-08 18:44:41 +00:00
}
}
2014-02-01 15:44:51 +00:00
private void TasView_SelectedIndexChanged ( object sender , EventArgs e )
2013-12-19 03:45:11 +00:00
{
SetSplicer ( ) ;
}
2013-12-08 18:44:41 +00:00
#endregion
2013-12-10 01:45:45 +00:00
2014-02-01 15:44:51 +00:00
#region Dialog Events
protected override void OnShown ( EventArgs e )
{
RefreshFloatingWindowControl ( ) ;
base . OnShown ( e ) ;
}
#endregion
2013-12-19 03:45:11 +00:00
#endregion
#region Classes
public class TasClipboardEntry
2013-12-19 02:52:27 +00:00
{
2013-12-19 03:45:11 +00:00
private readonly Dictionary < string , bool > _buttons ;
2014-02-01 15:44:51 +00:00
private readonly int _frame ;
2013-12-19 02:52:27 +00:00
2013-12-19 03:45:11 +00:00
public TasClipboardEntry ( int frame , Dictionary < string , bool > buttons )
{
_frame = frame ;
_buttons = buttons ;
}
public int Frame
{
get { return _frame ; }
}
public Dictionary < string , bool > Buttons
{
get { return _buttons ; }
}
2013-12-19 02:52:27 +00:00
}
2013-12-10 01:45:45 +00:00
#endregion
2013-12-01 04:00:02 +00:00
}
}