using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace SCJMapper_V2 { public class JoystickList : List { private FormReassign FR = null; public Dictionary JsReassingList { get; set; } // oldJs, newJs public List NewJsList { get; set; } // index is this[idx] public void Deactivate( ) { foreach ( JoystickCls j in this ) j.Activated = false; } public void Activate( ) { foreach ( JoystickCls j in this ) j.Activated =true; } /// /// Show the jsN Reassign Dialog /// public DialogResult ShowReassign( ) { if ( FR == null ) { FR = new FormReassign( this ); JsReassingList = new Dictionary( ); NewJsList = new List( ); } FR.ShowDialog( ); if ( FR.Canceled == false ) { int jIdx = 0; // update the new js indication in the tabs foreach ( JoystickCls j in this ) j.JSAssignment = NewJsList[jIdx++]; JoystickCls.ReassignJsColor( NewJsList ); } return ( FR.Canceled ) ? DialogResult.Cancel : DialogResult.OK; } public void ResetJsNAssignment( ) { foreach ( JoystickCls j in this ) j.JSAssignment = 0; if ( this.Count > 0 ) this[0].JSAssignment = 1; if ( this.Count > 1 ) this[1].JSAssignment = 2; } /// /// Returns the Joystick instance for the given jsN /// /// The JsN /// The instance or null if not found public JoystickCls Find_jsN( int n ) { foreach ( JoystickCls j in this ) { if ( j.JSAssignment == n ) return j; } return null; } /// /// Returns the Joystick instance for the given device name /// /// The device name /// The instance or null if not found public JoystickCls Find_jsDev( String devName ) { foreach ( JoystickCls j in this ) { if ( j.DevName == devName ) return j; } return null; } /// /// Returns the Joystick instance for the given device instance GUID /// /// The instance GUID /// The instance or null if not found public JoystickCls Find_jsInstance( String instGUID ) { foreach ( JoystickCls j in this ) { if ( j.DevInstanceGUID == instGUID ) return j; } return null; } } }