2014-12-22 00:34:09 +00:00
|
|
|
|
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>
|
2015-01-04 00:56:04 +00:00
|
|
|
|
class ActionTreeInputNode : ActionTreeNode
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region Static items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle all text label composition and extraction here
|
|
|
|
|
|
2016-12-30 01:04:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a the cmd with standard modifier if modified == true
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cmd">Any string</param>
|
|
|
|
|
/// <param name="modified">Bool true if a modifier shall be added</param>
|
|
|
|
|
/// <returns>The string with added Modifier if requested</returns>
|
|
|
|
|
public static string ComposeNodeText( string cmd, bool modified = false )
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
2016-12-30 01:04:21 +00:00
|
|
|
|
if ( string.IsNullOrEmpty( cmd ) ) {
|
2014-12-22 00:34:09 +00:00
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2016-01-02 23:15:26 +00:00
|
|
|
|
if ( modified )
|
|
|
|
|
return string.Format( "{0} {1}", cmd, ActionTreeNode.ModDiv ); // js1_button1 #
|
|
|
|
|
else
|
|
|
|
|
return string.Format( "{0}", cmd ); // js1_button1
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-30 01:04:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the cmd part of a string like "cmd - anything #"
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nodeText">A nodetext string like "cmd - anything #"</param>
|
|
|
|
|
/// <param name="cmd">contains the cmd part if delimiters are present - else returns the input</param>
|
|
|
|
|
public static void DecompNodeText( string nodeText, out string cmd )
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
2016-12-30 01:04:21 +00:00
|
|
|
|
string[] e = nodeText.Split( new char[] { RegDiv, ModDiv }, StringSplitOptions.RemoveEmptyEntries );
|
2016-01-02 23:15:26 +00:00
|
|
|
|
if ( e.Length > 0 )
|
|
|
|
|
cmd = e[0].TrimEnd( );
|
|
|
|
|
else
|
|
|
|
|
cmd = nodeText;
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the command part from a node text
|
2016-12-30 01:04:21 +00:00
|
|
|
|
/// i.e. "v_pitch - js1_x" returns v_pitch
|
2014-12-22 00:34:09 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nodeText">The node text in 'action - command' notation</param>
|
|
|
|
|
/// <returns>the command part or an empty string</returns>
|
2016-12-30 01:04:21 +00:00
|
|
|
|
public new static string CommandFromNodeText( string nodeText )
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
2016-12-30 01:04:21 +00:00
|
|
|
|
string cmd;
|
2015-01-04 00:56:04 +00:00
|
|
|
|
ActionTreeInputNode.DecompNodeText( nodeText, out cmd );
|
2014-12-22 00:34:09 +00:00
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Object defs
|
|
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
|
public ActionTreeInputNode( )
|
|
|
|
|
: base( )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
|
public ActionTreeInputNode( ActionTreeInputNode srcNode )
|
2015-01-04 00:56:04 +00:00
|
|
|
|
: base( srcNode )
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
|
|
|
|
if ( srcNode == null ) return;
|
2015-01-04 00:56:04 +00:00
|
|
|
|
/*
|
2014-12-22 00:34:09 +00:00
|
|
|
|
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;
|
2015-01-04 00:56:04 +00:00
|
|
|
|
*/
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
|
public ActionTreeInputNode( string text )
|
2015-01-04 00:56:04 +00:00
|
|
|
|
: base ( text )
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
2015-01-04 00:56:04 +00:00
|
|
|
|
//this.Text = text;
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
|
public ActionTreeInputNode( string text, ActionTreeInputNode[] children )
|
|
|
|
|
: base( text, children )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-12-30 01:04:21 +00:00
|
|
|
|
//private string m_command ="";
|
2014-12-22 00:34:09 +00:00
|
|
|
|
|
2016-12-30 01:04:21 +00:00
|
|
|
|
public new string Text
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
|
|
|
|
get { return base.Text; }
|
|
|
|
|
set
|
|
|
|
|
{
|
2015-01-04 00:56:04 +00:00
|
|
|
|
ActionTreeInputNode.DecompNodeText( value, out m_command );
|
2016-01-02 23:15:26 +00:00
|
|
|
|
base.Text = ActionTreeInputNode.ComposeNodeText( "$" + m_command, m_modified ); // tag for the node processing
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-12-30 01:04:21 +00:00
|
|
|
|
public new string Command
|
2014-12-22 00:34:09 +00:00
|
|
|
|
{
|
|
|
|
|
get { return m_command; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_command = value;
|
2016-01-02 23:15:26 +00:00
|
|
|
|
Text = ActionTreeInputNode.ComposeNodeText( m_command, m_modified ); // compose - later it will be decomposed again
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-02 23:15:26 +00:00
|
|
|
|
|
2014-12-22 00:34:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|