Build 57 - some fixes and improvements in Tables

Doc update for improvements
pull/104/head v2.23beta
bm98 8 years ago
parent ac0ca1c208
commit a7a21aae43

@ -1613,7 +1613,9 @@ namespace SCJMapper_V2
{
// only if needed
if ( ( FTAB != null ) && FTAB.Visible ) {
FTAB.SuspendDGV( );
m_AT.ActionMaps.toDataSet( FTAB.DS_AMaps);
FTAB.ResumeDGV( );
FTAB.Populate( );
}
}
@ -1625,17 +1627,19 @@ namespace SCJMapper_V2
if ( ( FTAB != null ) && FTAB.Visible ) {
string actionID = m_AT.SelectedActionID;
m_AT.ActionMaps.updateDataSet( FTAB.DS_AMaps, actionID );
FTAB.UpdateRow( actionID );
// FTAB.UpdateRow( actionID ); seems not needed...
}
}
// Show the Table Window
private void btTable_Click( object sender, EventArgs e )
{
bool created = false;
if (FTAB == null ) {
FTAB = new FormTable( );
FTAB.EditActionEvent += FTAB_EditActionEvent;
FTAB.UpdateEditEvent += FTAB_UpdateEditEvent;
created = true;
}
if ( FTAB.Visible ) {
@ -1646,9 +1650,13 @@ namespace SCJMapper_V2
} else {
FTAB.Show( );
FTAB.Size = m_AppSettings.FormTableSize;
FTAB.Location = m_AppSettings.FormTableLocation;
FTAB.LastColSize = m_AppSettings.FormTableColumnWidth;
if (created) {
FTAB.Size = m_AppSettings.FormTableSize;
FTAB.Location = m_AppSettings.FormTableLocation;
FTAB.LastColSize = m_AppSettings.FormTableColumnWidth;
}
// reload the data to display
UpdateTable( );
}

@ -76,9 +76,11 @@
this.DGV.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.DGV.Size = new System.Drawing.Size(438, 230);
this.DGV.TabIndex = 0;
this.DGV.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DGV_CellMouseClick);
this.DGV.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DGV_CellMouseDoubleClick);
this.DGV.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.DGV_CellValueChanged);
this.DGV.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.DGV_ColumnWidthChanged);
this.DGV.CurrentCellDirtyStateChanged += new System.EventHandler(this.DGV_CurrentCellDirtyStateChanged);
this.DGV.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DGV_RowHeaderMouseClick);
//
// dS_ActionMaps
@ -330,7 +332,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(760, 320);
this.Name = "FormTable";
this.Text = "FormTable";
this.Text = "Actiontree as Table";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormTable_FormClosing);
this.LocationChanged += new System.EventHandler(this.FormTable_LocationChanged);
this.SizeChanged += new System.EventHandler(this.FormTable_SizeChanged);

@ -16,19 +16,17 @@ namespace SCJMapper_V2.Table
{
InitializeComponent( );
DS_AMaps = new DS_ActionMaps( ); // init once
DS_AMaps = new DS_ActionMaps( ); // init once for the lifetime of the App
m_bSrc.DataSource = DS_AMaps;
m_bSrc.DataMember = "T_Action";
m_bSrc.Filter = "ActionName LIKE '*view*'";
DGV.AutoGenerateColumns = true;
DGV.DataSource = m_bSrc;
DGV.MultiSelect = false;
DGV.Columns["ID_Action"].Visible = false;
DGV.AutoResizeColumns( DataGridViewAutoSizeColumnsMode.AllCells );
DGV.AutoResizeColumns( DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader );
// handle Edits (Blended Col is only allowed to be edited by the user)
btUpdateFromEdit.Enabled = chkEditBlend.Checked;
DGV.Columns["Usr_Binding"].ReadOnly = true;
DGV.Columns["Usr_Modifier"].ReadOnly = true;
@ -66,23 +64,35 @@ namespace SCJMapper_V2.Table
public DS_ActionMaps DS_AMaps { get; private set; }
public void SuspendDGV( )
{
// add things to improve speed while re-loading the DataSet outside - nothing found so far
}
public void ResumeDGV()
{
// finish things to improve speed while re-loading the DataSet outside - nothing found so far
}
/// <summary>
/// Populate the view from the dataset
/// </summary>
public void Populate( )
{
DGV.SuspendLayout( );
// m_bSrc.ResetBindings( false );
// DGV.SuspendLayout( );
if ( !string.IsNullOrEmpty( LastColSize ) ) {
string[] e = LastColSize.Split( new char [] {';'}, StringSplitOptions.RemoveEmptyEntries );
for ( int i = 0; i < e.Length; i++ ) {
DGV.Columns[i].Width = int.Parse( e[i] );
if ( i < DGV.Columns.Count )
DGV.Columns[i].Width = int.Parse( e[i] );
}
}
DGV.AllowUserToResizeColumns = true;
ComposeFilter( );
DGV.ResumeLayout( );
// DGV.ResumeLayout( );
}
/// <summary>
@ -93,7 +103,6 @@ namespace SCJMapper_V2.Table
public void UpdateRow( string actionID )
{
if ( string.IsNullOrEmpty( actionID ) ) return; // nothing to do
// Populate( ); // cheap
}
@ -119,13 +128,23 @@ namespace SCJMapper_V2.Table
private void ComposeFilter( )
{
string actFilter = string.Format( "(ActionName LIKE '*{0}*')", txFilterAction.Text );
string defBindFilter = string.Format( "(Def_Binding LIKE '*{0}*')", txFilterDefBinding.Text );
string usrBindFilter = string.Format( "(Usr_Binding LIKE '*{0}*')", txFilterUsrBinding.Text );
// make sure we only add parts that are really used - else it is using too much time to resolve '*'
string filter = "";
if ( ! string.IsNullOrEmpty( txFilterAction.Text)) {
filter += string.Format( "(ActionName LIKE '*{0}*')", txFilterAction.Text );
}
if ( !string.IsNullOrEmpty( txFilterDefBinding.Text ) ) {
if ( !string.IsNullOrEmpty( filter ) ) filter += " AND ";
filter += string.Format( "(Def_Binding LIKE '*{0}*')", txFilterDefBinding.Text );
}
if ( !string.IsNullOrEmpty( txFilterUsrBinding.Text ) ) {
if ( !string.IsNullOrEmpty( filter ) ) filter += " AND ";
filter += string.Format( "(Usr_Binding LIKE '*{0}*')", txFilterUsrBinding.Text );
}
string deviceFilter = "";
if ( ( chkJoystick.Checked == false ) && ( chkGamepad.Checked == false ) && ( chkMouse.Checked == false ) && ( chkKbd.Checked == false ) ) {
// none checked means all
deviceFilter = "( Device LIKE '*' )";
} else {
deviceFilter = "( Device='X'"
+ ( ( chkJoystick.Checked ) ? string.Format( " OR Device = 'joystick'" ) : "" )
@ -135,10 +154,16 @@ namespace SCJMapper_V2.Table
+ " )";
}
m_bSrc.Filter =
actFilter + " AND " + defBindFilter + " AND " + usrBindFilter + " AND " + deviceFilter;
if ( !string.IsNullOrEmpty( deviceFilter ) ) {
if ( !string.IsNullOrEmpty( filter ) ) filter += " AND ";
filter += deviceFilter;
}
m_bSrc.Filter = filter;
}
private void txFilterAction_TextChanged( object sender, EventArgs e )
{
ComposeFilter( );
@ -194,6 +219,7 @@ namespace SCJMapper_V2.Table
private void FormTable_FormClosing( object sender, FormClosingEventArgs e )
{
if ( e.CloseReason == CloseReason.UserClosing ) {
this.Hide( );
e.Cancel = true;
}
@ -226,8 +252,17 @@ namespace SCJMapper_V2.Table
EditRow( e.RowIndex );
}
private void DGV_CellMouseClick( object sender, DataGridViewCellMouseEventArgs e )
{
if ( e.ColumnIndex < 0 && e.RowIndex < 0 ) m_bSrc.Sort = ""; // revert any sorting
}
private void DGV_CellMouseDoubleClick( object sender, DataGridViewCellMouseEventArgs e )
{
if ( e.RowIndex < 0 ) return; // would be the header row
EditRow( e.RowIndex );
}
@ -239,31 +274,47 @@ namespace SCJMapper_V2.Table
private void chkEditBlend_CheckedChanged( object sender, EventArgs e )
{
// toggle the Edit mode of the Blend Column
btUpdateFromEdit.Enabled = chkEditBlend.Checked;
DGV.ReadOnly = !chkEditBlend.Checked;
}
private void btCancelEdit_Click( object sender, EventArgs e )
{
bool test = DS_AMaps.HasChanges( );
// Undo Edits so far
DS_AMaps.RejectChanges( );
//m_bSrc.ResetBindings( false );
}
private void DGV_CellValueChanged( object sender, DataGridViewCellEventArgs e )
private void DGV_CurrentCellDirtyStateChanged( object sender, EventArgs e )
{
if ( e.ColumnIndex == DGV.Columns["Blended"].Index ) {
if ( ( bool )DGV.Rows[e.RowIndex].Cells[DGV.Columns["Blended"].Index].Value == true )
DGV.Rows[e.RowIndex].Cells[DGV.Columns["Usr_Binding"].Index].Value = DeviceCls.BlendedInput;
else
DGV.Rows[e.RowIndex].Cells[DGV.Columns["Usr_Binding"].Index].Value = ""; // don't know anything else...
// Immediately handle changes of the Blended Checkbox - workaround the regular DGV behavior
if ( !DGV.IsCurrentCellDirty ) return;
if ( DGV.CurrentCell.ColumnIndex != DGV.Columns["Blended"].Index ) return;
// only if dirty and the Blended column ..
// it still has it's previous value i.e. inverse the logic here - commit the value imediately
if ( ( bool )DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Blended"].Index].Value == false ) {
DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Blended"].Index].Value = true; // toggle value - triggers the ValueChanged Event below
} else {
DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Blended"].Index].Value = false;
}
DGV.NotifyCurrentCellDirty( false ); // have set the value - so set not dirty anymore
}
private void DGV_CellValueChanged( object sender, DataGridViewCellEventArgs e )
{
// set the Usr_Binding only if Blended column items Changes
if ( e.ColumnIndex != DGV.Columns["Blended"].Index ) return;
if ( ( bool )DGV.Rows[e.RowIndex].Cells[DGV.Columns["Blended"].Index].Value == true )
DGV.Rows[e.RowIndex].Cells[DGV.Columns["Usr_Binding"].Index].Value = DeviceCls.BlendedInput;
else
DGV.Rows[e.RowIndex].Cells[DGV.Columns["Usr_Binding"].Index].Value = ""; // don't know anything else...
}
}
}//class
}

Binary file not shown.
Loading…
Cancel
Save