mirror of
https://github.com/SCToolsfactory/SCJMapper-V2.git
synced 2024-11-14 18:12:45 +00:00
29ebc857fe
fixed #36 Ctrl key works now fix - keyboard command formatting ActivationMode handling finished user ActivationMode change indication in mapping tree partial internal cleanup doc update
126 lines
3.0 KiB
C#
126 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SCJMapper_V2
|
|
{
|
|
/// <summary>
|
|
/// Our INPUT TreeNode - inherits a regular one and adds some functionality
|
|
///
|
|
/// contains the input command i.e. - js2_button3 OR ! js1_x (MODs applies at the very beginning of the string)
|
|
/// </summary>
|
|
class ActionTreeInputNode : ActionTreeNode
|
|
{
|
|
|
|
#region Static items
|
|
|
|
|
|
// Handle all text label composition and extraction here
|
|
|
|
public static String ComposeNodeText( String cmd, Boolean modified = false )
|
|
{
|
|
if ( String.IsNullOrEmpty( cmd ) ) {
|
|
return "";
|
|
}
|
|
else {
|
|
if ( modified )
|
|
return string.Format( "{0} {1}", cmd, ActionTreeNode.ModDiv ); // js1_button1 #
|
|
else
|
|
return string.Format( "{0}", cmd ); // js1_button1
|
|
}
|
|
}
|
|
|
|
|
|
public static void DecompNodeText( String nodeText, out String cmd )
|
|
{
|
|
String[] e = nodeText.Split( new char[] { RegDiv, ModDiv }, StringSplitOptions.RemoveEmptyEntries );
|
|
if ( e.Length > 0 )
|
|
cmd = e[0].TrimEnd( );
|
|
else
|
|
cmd = nodeText;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns the command part from a node text
|
|
/// i.e. v_pitch - js1_x returns js1_x
|
|
/// </summary>
|
|
/// <param name="nodeText">The node text in 'action - command' notation</param>
|
|
/// <returns>the command part or an empty string</returns>
|
|
public new static String CommandFromNodeText( String nodeText )
|
|
{
|
|
String cmd;
|
|
ActionTreeInputNode.DecompNodeText( nodeText, out cmd );
|
|
return cmd;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
// Object defs
|
|
|
|
// ctor
|
|
public ActionTreeInputNode( )
|
|
: base( )
|
|
{
|
|
}
|
|
|
|
// ctor
|
|
public ActionTreeInputNode( ActionTreeInputNode srcNode )
|
|
: base( srcNode )
|
|
{
|
|
if ( srcNode == null ) return;
|
|
/*
|
|
this.Name = srcNode.Name;
|
|
this.Text = srcNode.Text;
|
|
this.BackColor = srcNode.BackColor;
|
|
this.ForeColor = srcNode.ForeColor;
|
|
this.NodeFont = srcNode.NodeFont;
|
|
this.ImageKey = srcNode.ImageKey;
|
|
this.Tag = srcNode.Tag;
|
|
this.m_command = srcNode.m_command;
|
|
*/
|
|
}
|
|
|
|
// ctor
|
|
public ActionTreeInputNode( string text )
|
|
: base ( text )
|
|
{
|
|
//this.Text = text;
|
|
}
|
|
|
|
// ctor
|
|
public ActionTreeInputNode( string text, ActionTreeInputNode[] children )
|
|
: base( text, children )
|
|
{
|
|
}
|
|
|
|
|
|
//private String m_command ="";
|
|
|
|
public new String Text
|
|
{
|
|
get { return base.Text; }
|
|
set
|
|
{
|
|
ActionTreeInputNode.DecompNodeText( value, out m_command );
|
|
base.Text = ActionTreeInputNode.ComposeNodeText( "$" + m_command, m_modified ); // tag for the node processing
|
|
}
|
|
}
|
|
|
|
|
|
public new String Command
|
|
{
|
|
get { return m_command; }
|
|
set
|
|
{
|
|
m_command = value;
|
|
Text = ActionTreeInputNode.ComposeNodeText( m_command, m_modified ); // compose - later it will be decomposed again
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|