2014-06-22 12:31:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Drawing;
|
2014-06-28 20:31:31 +00:00
|
|
|
|
using SCJMapper_V2.Properties;
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
|
|
|
|
namespace SCJMapper_V2
|
|
|
|
|
{
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maintains the action tree and its GUI representation, the TreeView
|
|
|
|
|
/// - the TreeView is managed primary in memory (Master Tree) and copied to the GUI tree via the Filter functions
|
|
|
|
|
/// </summary>
|
2014-06-22 12:31:57 +00:00
|
|
|
|
class ActionTree
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
2014-06-28 23:03:44 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
public ActionMapsCls ActionMaps { get; set; } // the Action Maps and Actions
|
|
|
|
|
|
|
|
|
|
private TreeView m_MasterTree = new TreeView( ); // the master TreeView (mem only)
|
|
|
|
|
private TreeView m_ctrl = null; // the TreeView in the GUI - injected from GUI via Ctrl property
|
|
|
|
|
public TreeView Ctrl
|
|
|
|
|
{
|
2014-07-06 16:13:32 +00:00
|
|
|
|
get { return m_ctrl; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_ctrl = value;
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// copy props needed
|
|
|
|
|
m_MasterTree.Font = m_ctrl.Font;
|
2014-07-06 16:13:32 +00:00
|
|
|
|
m_MasterTree.ImageList = m_ctrl.ImageList;
|
2014-06-29 21:24:58 +00:00
|
|
|
|
}
|
2014-07-06 16:13:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// maintains the change status (gets reset by reloading the complete tree)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Boolean Dirty { get; set; }
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
2014-07-06 16:13:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Blend (insert jsx_reserved") into undmapped items
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Boolean BlendUnmapped { get; set; }
|
|
|
|
|
|
2014-08-02 20:28:13 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// a comma separated list of actionmaps to ignore
|
|
|
|
|
/// </summary>
|
|
|
|
|
public String IgnoreMaps { get; set; }
|
|
|
|
|
|
2014-07-06 16:13:32 +00:00
|
|
|
|
private String m_Filter = ""; // the tree content filter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ctor
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ActionTree( Boolean blendUnmapped )
|
|
|
|
|
{
|
|
|
|
|
BlendUnmapped = blendUnmapped;
|
2014-08-02 20:28:13 +00:00
|
|
|
|
IgnoreMaps = ""; // nothing to ignore
|
2014-07-06 16:13:32 +00:00
|
|
|
|
}
|
2014-06-28 23:03:44 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
2014-08-31 13:05:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Copy return the complete ActionTree while reassigning JsN
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="newJsList">The JsN reassign list</param>
|
|
|
|
|
/// <returns>The ActionTree Copy with reassigned input</returns>
|
|
|
|
|
public ActionTree ReassignJsN( Dictionary<int, int> newJsList )
|
|
|
|
|
{
|
|
|
|
|
ActionTree nTree = new ActionTree( BlendUnmapped );
|
|
|
|
|
// full copy from 'this'
|
|
|
|
|
nTree.m_MasterTree = this.m_MasterTree;
|
|
|
|
|
nTree.m_ctrl = this.m_ctrl;
|
|
|
|
|
nTree.IgnoreMaps = this.IgnoreMaps;
|
|
|
|
|
nTree.m_Filter = this.m_Filter;
|
|
|
|
|
|
|
|
|
|
nTree.ActionMaps = this.ActionMaps.ReassignJsN( newJsList );
|
|
|
|
|
|
|
|
|
|
nTree.Dirty = true;
|
|
|
|
|
return nTree;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Instantiates a copy of the node - copies only the needed properties
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="srcNode">A source node</param>
|
|
|
|
|
/// <returns>A new TreeNode</returns>
|
|
|
|
|
private TreeNode TNCopy( TreeNode srcNode )
|
|
|
|
|
{
|
|
|
|
|
if ( srcNode == null ) return null;
|
|
|
|
|
|
|
|
|
|
TreeNode nn = new TreeNode( );
|
|
|
|
|
nn.Name = srcNode.Name;
|
|
|
|
|
nn.Text = srcNode.Text;
|
|
|
|
|
nn.BackColor = srcNode.BackColor;
|
|
|
|
|
nn.ForeColor = srcNode.ForeColor;
|
|
|
|
|
nn.NodeFont = srcNode.NodeFont;
|
|
|
|
|
nn.ImageKey = srcNode.ImageKey;
|
|
|
|
|
return nn;
|
|
|
|
|
}
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Apply the filter to the GUI TreeView
|
|
|
|
|
/// </summary>
|
2014-06-28 23:03:44 +00:00
|
|
|
|
private void ApplyFilter( )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "ApplyFilter - Entry" );
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
TreeNode topNode = null; // allow to backup the view - will carry the first node items
|
|
|
|
|
|
2014-06-28 23:03:44 +00:00
|
|
|
|
Ctrl.BeginUpdate( );
|
2014-06-29 21:24:58 +00:00
|
|
|
|
Ctrl.Nodes.Clear( ); // start over
|
|
|
|
|
|
|
|
|
|
// traverse the master tree and build the GUI tree from it
|
|
|
|
|
foreach ( TreeNode tn in m_MasterTree.Nodes ) {
|
|
|
|
|
TreeNode tnMap = TNCopy( tn ); Ctrl.Nodes.Add( tnMap ); // copy level 0 nodes
|
|
|
|
|
if ( topNode == null ) topNode = tnMap;
|
|
|
|
|
|
2014-06-28 23:03:44 +00:00
|
|
|
|
// have to search nodes of nodes
|
|
|
|
|
Boolean allHidden = true;
|
|
|
|
|
foreach ( TreeNode stn in tn.Nodes ) {
|
2014-07-06 16:13:32 +00:00
|
|
|
|
if ( ( stn.Tag != null ) && ( ( Boolean )stn.Tag == true ) ) {
|
2014-06-29 21:24:58 +00:00
|
|
|
|
; // don't create it i.e hide it - though you cannot hide TreeViewNodes at all...
|
2014-06-28 23:03:44 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2014-06-29 21:24:58 +00:00
|
|
|
|
TreeNode tnAction = TNCopy( stn ); tnMap.Nodes.Add( tnAction ); // copy level 1 nodes
|
2014-06-28 23:03:44 +00:00
|
|
|
|
allHidden = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// make it tidier..
|
2014-06-29 21:24:58 +00:00
|
|
|
|
if ( allHidden ) tnMap.Collapse( );
|
|
|
|
|
else tnMap.Expand( );
|
2014-06-28 23:03:44 +00:00
|
|
|
|
}
|
2014-06-29 21:24:58 +00:00
|
|
|
|
if ( topNode != null ) Ctrl.TopNode = topNode; // set view to topnode
|
2014-06-28 23:03:44 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
Ctrl.EndUpdate( ); // enable GUI update
|
2014-06-28 23:03:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// <summary>
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// Filters the master tree - only Actions (level 1) and not actionmaps (level 0)
|
|
|
|
|
/// - Tag gets Bool hidden=true if not to be shown
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
private void FilterTree( )
|
|
|
|
|
{
|
2014-06-29 21:24:58 +00:00
|
|
|
|
Boolean hidden = !String.IsNullOrEmpty( m_Filter ); // hide only if there is a find string
|
|
|
|
|
foreach ( TreeNode tn in m_MasterTree.Nodes ) {
|
2014-06-28 23:03:44 +00:00
|
|
|
|
// have to search nodes of nodes
|
|
|
|
|
foreach ( TreeNode stn in tn.Nodes ) {
|
|
|
|
|
if ( !stn.Text.Contains( m_Filter ) ) stn.Tag = hidden;
|
|
|
|
|
else stn.Tag = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-29 21:24:58 +00:00
|
|
|
|
ApplyFilter( ); // to the GUI tree
|
2014-06-28 23:03:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// Filters entries with given criteria
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="filter">The text snip to filter</param>
|
|
|
|
|
public void FilterTree( String filter )
|
|
|
|
|
{
|
|
|
|
|
m_Filter = filter;
|
|
|
|
|
FilterTree( );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2014-08-02 22:10:55 +00:00
|
|
|
|
/// Load Mappings into the ActionList and create the Master TreeView
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="defaultProfileName">The name of the profile to load (w/o extension)</param>
|
|
|
|
|
/// <param name="applyDefaults">True if default mappings should be carried on</param>
|
2014-06-28 20:31:31 +00:00
|
|
|
|
public void LoadTree( String defaultProfileName, Boolean applyDefaults )
|
2014-06-22 12:31:57 +00:00
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "LoadTree - Entry" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
TreeNode tn = null;
|
|
|
|
|
TreeNode[] cnl = { };
|
|
|
|
|
TreeNode cn = null;
|
|
|
|
|
TreeNode topNode = null;
|
|
|
|
|
|
|
|
|
|
ActionCls ac = null;
|
|
|
|
|
ActionMapCls acm = null;
|
|
|
|
|
|
|
|
|
|
ActionMaps = new ActionMapsCls( );
|
2014-06-29 21:24:58 +00:00
|
|
|
|
m_MasterTree.Nodes.Clear( );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read the action items into the TreeView
|
|
|
|
|
DProfileReader dpReader = new DProfileReader( ); // we may read a profile
|
|
|
|
|
TextReader txReader = null;
|
|
|
|
|
|
2014-06-28 20:31:31 +00:00
|
|
|
|
dpReader.fromXML( SCDefaultProfile.DefaultProfile( defaultProfileName + ".xml" ) );
|
2014-06-28 13:08:26 +00:00
|
|
|
|
if ( dpReader.ValidContent ) {
|
|
|
|
|
txReader = new StringReader( dpReader.CSVMap );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using ( TextReader sr = txReader ) {
|
|
|
|
|
String buf = sr.ReadLine( );
|
|
|
|
|
while ( !String.IsNullOrEmpty( buf ) ) {
|
|
|
|
|
String[] elem = buf.Split( new char[] { ';', ',', ' ' } );
|
|
|
|
|
if ( elem.Length > 1 ) {
|
2014-08-02 20:28:13 +00:00
|
|
|
|
if ( !IgnoreMaps.Contains( "," + elem[0] + "," ) ) {
|
|
|
|
|
// must have 2 elements min
|
|
|
|
|
Array.Resize( ref cnl, 0 );
|
|
|
|
|
acm = new ActionMapCls( ); acm.name = elem[0]; // get actionmap name
|
|
|
|
|
// process items
|
|
|
|
|
for ( int ei=1; ei < elem.Length; ei += 2 ) { // step 2 - action;defaultBinding come in pairs
|
|
|
|
|
if ( !String.IsNullOrEmpty( elem[ei] ) ) {
|
|
|
|
|
String action = elem[ei].Substring( 1 );
|
|
|
|
|
String defBinding = elem[ei + 1].Substring( 0 );
|
|
|
|
|
cn = new TreeNode( action ); cn.Name = elem[ei]; cn.BackColor = Color.White; // name with the key it to find it..
|
|
|
|
|
String devID = elem[ei].Substring( 0, 1 );
|
|
|
|
|
String device = ActionCls.DeviceFromID( devID );
|
|
|
|
|
cn.ImageKey = devID;
|
|
|
|
|
cn.BackColor = Color.White; // some stuff does not work properly...
|
|
|
|
|
|
|
|
|
|
Array.Resize( ref cnl, cnl.Length + 1 ); cnl[cnl.Length - 1] = cn;
|
|
|
|
|
ac = new ActionCls( ); ac.key = cn.Name; ac.name = action; ac.device = device; ac.defBinding = defBinding;
|
|
|
|
|
acm.Add( ac ); // add to our map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( applyDefaults ) {
|
|
|
|
|
// right now this application only works with joysticks
|
|
|
|
|
if ( JoystickCls.IsJoystick( ac.device ) ) {
|
|
|
|
|
int jNum = JoystickCls.JSNum( ac.defBinding );
|
|
|
|
|
if ( JoystickCls.IsJSValid( jNum ) ) {
|
|
|
|
|
ac.input = ac.defBinding;
|
|
|
|
|
cn.Text += " - " + ac.defBinding;
|
2014-08-31 13:05:56 +00:00
|
|
|
|
cn.BackColor = JoystickCls.JColor[jNum - 1]; // color list is 0 based
|
2014-08-02 20:28:13 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ( BlendUnmapped ) {
|
|
|
|
|
ac.input = JoystickCls.BlendedJsInput;
|
|
|
|
|
cn.Text += " - " + JoystickCls.BlendedJsInput;
|
|
|
|
|
}
|
2014-07-06 16:13:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-02 20:28:13 +00:00
|
|
|
|
else {
|
|
|
|
|
// init empty
|
|
|
|
|
if ( JoystickCls.IsJoystick( ac.device ) && BlendUnmapped ) {
|
|
|
|
|
ac.input = JoystickCls.BlendedJsInput;
|
|
|
|
|
cn.Text += " - " + JoystickCls.BlendedJsInput;
|
|
|
|
|
}
|
2014-06-28 13:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-02 20:28:13 +00:00
|
|
|
|
}//for
|
|
|
|
|
|
|
|
|
|
tn = new TreeNode( acm.name, cnl ); tn.Name = acm.name; // name it to find it..
|
|
|
|
|
tn.ImageIndex = 0; tn.NodeFont = new Font( m_MasterTree.Font, FontStyle.Bold );
|
|
|
|
|
m_MasterTree.BackColor = Color.White; // fix for defect TreeView (cut off bold text)
|
|
|
|
|
m_MasterTree.Nodes.Add( tn ); // add to control
|
|
|
|
|
if ( topNode == null ) topNode = tn; // once to keep the start of list
|
|
|
|
|
ActionMaps.Add( acm ); // add to our map
|
|
|
|
|
}//not ignored
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}// if valid line
|
|
|
|
|
buf = sr.ReadLine( );
|
|
|
|
|
}//while
|
|
|
|
|
}
|
|
|
|
|
// fix for defect TreeView (cut off bold text at last element -despite the BackColor fix) add another and delete it
|
|
|
|
|
tn = new TreeNode( "DUMMY" ); tn.Name = "DUMMY";
|
2014-06-29 21:24:58 +00:00
|
|
|
|
tn.ImageIndex = 0; tn.NodeFont = new Font( m_MasterTree.Font, FontStyle.Bold );
|
|
|
|
|
m_MasterTree.BackColor = m_MasterTree.BackColor; // fix for defect TreeView (cut off bold text)
|
|
|
|
|
m_MasterTree.Nodes.Add( tn ); // add to control
|
|
|
|
|
m_MasterTree.Nodes.RemoveByKey( "DUMMY" );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// fix for defect TreeView (cut off bold text)
|
|
|
|
|
|
|
|
|
|
txReader = null;
|
|
|
|
|
Dirty = false;
|
2014-06-28 13:59:35 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// finally apply the filter and make it visible
|
2014-06-28 23:03:44 +00:00
|
|
|
|
FilterTree( );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// input is like js1_button3
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Apply an update the the treenode
|
|
|
|
|
/// First apply to the GUI tree where the selection happend then copy it over to master tree
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input">The new Text property</param>
|
2014-06-22 12:31:57 +00:00
|
|
|
|
public void UpdateSelectedItem( String input )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "UpdateSelectedItem - Entry" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
if ( Ctrl.SelectedNode == null ) return;
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
2014-07-06 16:13:32 +00:00
|
|
|
|
// Apply the input to the ActionTree
|
|
|
|
|
ActionCls ac = null;
|
|
|
|
|
ActionMapCls ACM = ActionMaps.Find( delegate( ActionMapCls acm ) { return acm.name == Ctrl.SelectedNode.Parent.Name; } );
|
|
|
|
|
if ( ACM != null ) {
|
|
|
|
|
ac = ACM.Find( delegate( ActionCls _AC ) { return _AC.key == Ctrl.SelectedNode.Name; } );
|
|
|
|
|
if ( ac != null ) {
|
|
|
|
|
if ( String.IsNullOrEmpty( input ) ) {
|
|
|
|
|
// unmapped
|
|
|
|
|
if ( JoystickCls.IsJoystick( ac.device ) && BlendUnmapped ) ac.input = JoystickCls.BlendedJsInput;
|
|
|
|
|
else ac.input = "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// mapped
|
|
|
|
|
ac.input = input;
|
|
|
|
|
}
|
|
|
|
|
Dirty = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
log.Error( "UpdateSelectedItem - Action Not found in tree" );
|
|
|
|
|
return; // ERROR - Action Not found in tree
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// applies only to ActionNodes
|
2014-06-22 12:31:57 +00:00
|
|
|
|
if ( Ctrl.SelectedNode.Level == 1 ) {
|
|
|
|
|
String[] elements = Ctrl.SelectedNode.Text.Split( );
|
|
|
|
|
if ( String.IsNullOrEmpty( input ) ) {
|
2014-07-06 16:13:32 +00:00
|
|
|
|
// unmapped
|
|
|
|
|
if ( JoystickCls.IsJoystick( ac.device ) && BlendUnmapped ) Ctrl.SelectedNode.Text = elements[0] + " - " + JoystickCls.BlendedJsInput;
|
|
|
|
|
else Ctrl.SelectedNode.Text = elements[0];
|
|
|
|
|
Ctrl.SelectedNode.BackColor = Color.White;
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2014-07-06 16:13:32 +00:00
|
|
|
|
// mapped
|
2014-06-22 12:31:57 +00:00
|
|
|
|
Ctrl.SelectedNode.Text = elements[0] + " - " + input;
|
|
|
|
|
int jNum = JoystickCls.JSNum( input );
|
2014-08-31 13:05:56 +00:00
|
|
|
|
Ctrl.SelectedNode.BackColor = JoystickCls.JColor[jNum - 1]; // color list is 0 based
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
2014-07-06 16:13:32 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// copy to master node
|
|
|
|
|
TreeNode[] masterNode = m_MasterTree.Nodes.Find( Ctrl.SelectedNode.Name, true ); // find the same node in master
|
|
|
|
|
if ( masterNode.Length == 0 ) throw new IndexOutOfRangeException( "ActionTree ERROR - cannot find synched node in master" ); // OUT OF SYNC
|
|
|
|
|
masterNode[0].Text = Ctrl.SelectedNode.Text;
|
|
|
|
|
masterNode[0].BackColor = Ctrl.SelectedNode.BackColor;
|
|
|
|
|
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the mappings back into the treeview control
|
|
|
|
|
/// Note: this takes a while as the list grows...
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void ReloadCtrl( )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "ReloadCtrl - Entry" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
foreach ( ActionMapCls acm in ActionMaps ) {
|
2014-08-02 22:10:55 +00:00
|
|
|
|
if ( IgnoreMaps.Contains( "," + acm.name + "," ) ) break; // next
|
2014-06-22 12:31:57 +00:00
|
|
|
|
try {
|
2014-06-29 21:24:58 +00:00
|
|
|
|
TreeNode amTn = m_MasterTree.Nodes[acm.name]; // get the map node
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// find the item to reload into the treeview
|
|
|
|
|
foreach ( ActionCls ac in acm ) {
|
|
|
|
|
try {
|
|
|
|
|
TreeNode tnl = amTn.Nodes[ac.key];
|
|
|
|
|
String[] elements = tnl.Text.Split( );
|
2014-07-06 16:13:32 +00:00
|
|
|
|
if ( String.IsNullOrEmpty( ac.input ) || ( ac.input == JoystickCls.BlendedJsInput ) ) {
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// grabed input is not mapped
|
2014-08-31 13:05:56 +00:00
|
|
|
|
if ( JoystickCls.IsJoystick( ac.device ) && BlendUnmapped ) {
|
|
|
|
|
ac.input = JoystickCls.BlendedJsInput;
|
|
|
|
|
tnl.Text = elements[0] + " - " + JoystickCls.BlendedJsInput;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ac.input = "";
|
|
|
|
|
tnl.Text = elements[0];
|
|
|
|
|
}
|
2014-07-06 16:13:32 +00:00
|
|
|
|
tnl.BackColor = Color.White;
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2014-07-06 16:13:32 +00:00
|
|
|
|
// mapped
|
2014-06-22 12:31:57 +00:00
|
|
|
|
int jNum = JoystickCls.JSNum( ac.input );
|
|
|
|
|
tnl.Text = elements[0] + " - " + ac.input;
|
2014-08-31 13:05:56 +00:00
|
|
|
|
tnl.BackColor = JoystickCls.JColor[jNum - 1]; // color list is 0 based
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
; // key not found
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
; // map key not found ??
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-28 23:03:44 +00:00
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// finally apply the filter and make it visible
|
2014-06-28 23:03:44 +00:00
|
|
|
|
FilterTree( );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 21:24:58 +00:00
|
|
|
|
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// <summary>
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// Find a control that contains the string and mark it
|
|
|
|
|
/// this method is applied to the GUI TreeView only
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// </summary>
|
2014-06-29 21:24:58 +00:00
|
|
|
|
/// <param name="m_MasterTree">The string to find</param>
|
2014-06-22 12:31:57 +00:00
|
|
|
|
public void FindCtrl( String ctrl )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "FindCtrl - Entry" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
Boolean found = false;
|
|
|
|
|
foreach ( TreeNode tn in Ctrl.Nodes ) {
|
|
|
|
|
// have to search nodes of nodes
|
|
|
|
|
foreach ( TreeNode stn in tn.Nodes ) {
|
|
|
|
|
if ( stn.Text.Contains( ctrl ) ) {
|
|
|
|
|
Ctrl.SelectedNode = stn;
|
|
|
|
|
Ctrl.SelectedNode.EnsureVisible( );
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( found ) break; // exit all loops
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-28 23:03:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports a summary list of the mapped items
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2014-06-22 12:31:57 +00:00
|
|
|
|
public String ReportActions( )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "FindCtrl - ReportActions" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
String repList = "";
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// JS assignments
|
2014-06-22 12:31:57 +00:00
|
|
|
|
if ( !String.IsNullOrEmpty( ActionMaps.js1 ) ) repList += String.Format( "** js1 = {0}\n", ActionMaps.js1 );
|
|
|
|
|
if ( !String.IsNullOrEmpty( ActionMaps.js2 ) ) repList += String.Format( "** js2 = {0}\n", ActionMaps.js2 );
|
|
|
|
|
if ( !String.IsNullOrEmpty( ActionMaps.js3 ) ) repList += String.Format( "** js3 = {0}\n", ActionMaps.js3 );
|
|
|
|
|
if ( !String.IsNullOrEmpty( ActionMaps.js4 ) ) repList += String.Format( "** js4 = {0}\n", ActionMaps.js4 );
|
2014-06-29 21:24:58 +00:00
|
|
|
|
// now the mapped actions
|
2014-06-27 23:42:48 +00:00
|
|
|
|
repList += String.Format( "\n" );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
foreach ( ActionMapCls acm in ActionMaps ) {
|
|
|
|
|
String rep = String.Format( "*** {0}\n", acm.name );
|
|
|
|
|
repList += rep;
|
|
|
|
|
foreach ( ActionCls ac in acm ) {
|
2014-07-06 16:13:32 +00:00
|
|
|
|
if ( !String.IsNullOrEmpty( ac.input ) && !( ac.input == JoystickCls.BlendedJsInput ) ) {
|
2014-06-29 21:24:58 +00:00
|
|
|
|
rep = String.Format( " {0} - {1} - ({2})\n", ac.name.PadRight( 35 ), ac.input.PadRight( 20 ), ac.device );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
repList += rep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
repList += String.Format( "\n" );
|
|
|
|
|
}
|
|
|
|
|
return repList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|