diff --git a/FormMain.Designer.cs b/FormMain.Designer.cs index 2be37f0..13a247b 100644 --- a/FormMain.Designer.cs +++ b/FormMain.Designer.cs @@ -133,6 +133,8 @@ this.tcXML = new System.Windows.Forms.TabControl(); this.tPageDump = new System.Windows.Forms.TabPage(); this.tPageOther = new System.Windows.Forms.TabPage(); + this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); + this.cbxAutoTabXML = new System.Windows.Forms.CheckBox(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.tsBtReset = new System.Windows.Forms.ToolStripDropDownButton(); this.resetDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -147,9 +149,7 @@ this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); - this.lbxOther = new System.Windows.Forms.ListBox(); - this.cbxAutoTabXML = new System.Windows.Forms.CheckBox(); + this.lbxOther = new System.Windows.Forms.RichTextBox(); this.cmCopyPaste.SuspendLayout(); this.panel2.SuspendLayout(); this.cmMouseEntry.SuspendLayout(); @@ -166,8 +166,8 @@ this.tcXML.SuspendLayout(); this.tPageDump.SuspendLayout(); this.tPageOther.SuspendLayout(); - this.statusStrip1.SuspendLayout(); this.tableLayoutPanel6.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // btDumpList @@ -1220,6 +1220,32 @@ this.tPageOther.Text = "All Mappings"; this.tPageOther.UseVisualStyleBackColor = true; // + // tableLayoutPanel6 + // + this.tableLayoutPanel6.ColumnCount = 1; + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel6.Controls.Add(this.cbxAutoTabXML, 0, 0); + this.tableLayoutPanel6.Controls.Add(this.lbxOther, 0, 1); + this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3); + this.tableLayoutPanel6.Name = "tableLayoutPanel6"; + this.tableLayoutPanel6.RowCount = 2; + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel6.Size = new System.Drawing.Size(348, 654); + this.tableLayoutPanel6.TabIndex = 0; + // + // cbxAutoTabXML + // + this.cbxAutoTabXML.AutoSize = true; + this.cbxAutoTabXML.Location = new System.Drawing.Point(3, 3); + this.cbxAutoTabXML.Name = "cbxAutoTabXML"; + this.cbxAutoTabXML.Size = new System.Drawing.Size(233, 17); + this.cbxAutoTabXML.TabIndex = 2; + this.cbxAutoTabXML.Text = "Switch XML/Mapping tab automatically"; + this.cbxAutoTabXML.UseVisualStyleBackColor = true; + this.cbxAutoTabXML.CheckedChanged += new System.EventHandler(this.cbxAutoTabXML_CheckedChanged); + // // toolStripStatusLabel2 // this.toolStripStatusLabel2.BackColor = System.Drawing.Color.DarkKhaki; @@ -1361,43 +1387,17 @@ this.statusStrip1.TabIndex = 26; this.statusStrip1.Text = "statusStrip1"; // - // tableLayoutPanel6 - // - this.tableLayoutPanel6.ColumnCount = 1; - this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel6.Controls.Add(this.lbxOther, 0, 1); - this.tableLayoutPanel6.Controls.Add(this.cbxAutoTabXML, 0, 0); - this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3); - this.tableLayoutPanel6.Name = "tableLayoutPanel6"; - this.tableLayoutPanel6.RowCount = 2; - this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel6.Size = new System.Drawing.Size(348, 654); - this.tableLayoutPanel6.TabIndex = 0; - // // lbxOther // this.lbxOther.BackColor = System.Drawing.Color.WhiteSmoke; + this.lbxOther.BorderStyle = System.Windows.Forms.BorderStyle.None; this.lbxOther.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbxOther.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbxOther.FormattingEnabled = true; - this.lbxOther.ItemHeight = 14; this.lbxOther.Location = new System.Drawing.Point(3, 33); this.lbxOther.Name = "lbxOther"; this.lbxOther.Size = new System.Drawing.Size(342, 618); - this.lbxOther.TabIndex = 1; - // - // cbxAutoTabXML - // - this.cbxAutoTabXML.AutoSize = true; - this.cbxAutoTabXML.Location = new System.Drawing.Point(3, 3); - this.cbxAutoTabXML.Name = "cbxAutoTabXML"; - this.cbxAutoTabXML.Size = new System.Drawing.Size(233, 17); - this.cbxAutoTabXML.TabIndex = 2; - this.cbxAutoTabXML.Text = "Switch XML/Mapping tab automatically"; - this.cbxAutoTabXML.UseVisualStyleBackColor = true; - this.cbxAutoTabXML.CheckedChanged += new System.EventHandler(this.cbxAutoTabXML_CheckedChanged); + this.lbxOther.TabIndex = 3; + this.lbxOther.Text = ""; + this.lbxOther.WordWrap = false; // // MainForm // @@ -1436,10 +1436,10 @@ this.tcXML.ResumeLayout(false); this.tPageDump.ResumeLayout(false); this.tPageOther.ResumeLayout(false); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); this.tableLayoutPanel6.ResumeLayout(false); this.tableLayoutPanel6.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1560,8 +1560,8 @@ private System.Windows.Forms.TabPage tPageOther; private System.Windows.Forms.TabPage tPageDump; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; - private System.Windows.Forms.ListBox lbxOther; private System.Windows.Forms.CheckBox cbxAutoTabXML; + private System.Windows.Forms.RichTextBox lbxOther; } } diff --git a/FormMain.cs b/FormMain.cs index f5185b1..b6e84f5 100644 --- a/FormMain.cs +++ b/FormMain.cs @@ -1535,15 +1535,14 @@ namespace SCJMapper_V2 AutoTabXML_Assignment( EATabXML.Tab_Assignment ); string devInput = ActionCls.DevInput( lblLastJ.Text, InputMode ); - List r = m_AT.FindAllActions( devInput ); - lbxOther.Items.Clear( ); - foreach ( string s in r ) lbxOther.Items.Add( s ); + RTF.RTFformatter RTF = new RTF.RTFformatter( ); + m_AT.FindAllActionsRTF( devInput, RTF ); // have to check if throttle is used and if - add those to the list string altDevInput = JoystickCls.MakeThrottle( devInput, true ); if ( altDevInput != devInput ) { - r = m_AT.FindAllActions( altDevInput ); - foreach ( string s in r ) lbxOther.Items.Add( s ); + m_AT.FindAllActionsRTF( altDevInput, RTF ); } + lbxOther.Rtf = RTF.RTFtext; } diff --git a/FormMain.resx b/FormMain.resx index bfb0979..16ed368 100644 --- a/FormMain.resx +++ b/FormMain.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8 - EAAAAk1TRnQBSQFMAgEBCQEAAaABEQGgAREBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + EAAAAk1TRnQBSQFMAgEBCQEAAagBEQGoAREBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/RTF/RTFformatter.cs b/RTF/RTFformatter.cs new file mode 100644 index 0000000..db336e2 --- /dev/null +++ b/RTF/RTFformatter.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SCJMapper_V2.RTF +{ + /// + /// A simple class to support RTF formatting for the RTF control + /// + class RTFformatter + { + private const string c_Header = @"\rtf1\ansi\ansicpg437\deff0\deflang9"; // plain ANSI with old IBM codepage, def font use 0, lang is Gen English + private const string c_Leader = @"\viewkind4\uc1\b0\f0\cf0 "; // 4 Normal view, Unicode 1 byte (ANSI) + + #region Font + + private const int c_FontSize = 11; + private string FontSize_low( int ptSize ) + { + int ps = ( ptSize == 0 ) ? c_FontSize : ptSize; + return @"\fs" + ( ps * 2 ).ToString( ).Trim( ); + } + public void FontSize( int ptSize ) + { + m_rTFtextLine += FontSize_low( ptSize ); + } + + private string m_fmtFont = @"\f0"; + private const string c_Fonts = @"{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Courier New;}}"; // some fonts (Sans, Mono) + public enum ERFont + { + ERF_Sans = 0, + ERF_Mono, + } + + private ERFont m_rFont = ERFont.ERF_Sans; + public ERFont RFont + { + get { return m_rFont; } + set { + m_rFont = value; + m_fmtFont = string.Format( @"\f{0} ", ( (int)m_rFont ).ToString( ).Trim( ) ); + m_rTFtextLine += m_fmtFont; + } + } + + private string m_fmtBold = @"\f0 "; + private bool m_rBold = false; + public bool RBold + { + get { return m_rBold; } + set { + m_rBold = value; + m_fmtBold = ( m_rBold ) ? @"\b " : @"\b0 "; + m_rTFtextLine += m_fmtBold; + } + } + + private string m_fmtULine = @"\ulnone "; + private bool m_rULine = false; + public bool RULine + { + get { return m_rULine; } + set { + m_rULine = value; + m_fmtULine = ( m_rULine ) ? @"\ul " : @"\ulnone "; + m_rTFtextLine += m_fmtULine; + } + } + #endregion + + + #region Text Color + + private const string c_Colors = @"{\colortbl ;\red255\green0\blue0;\red0\green176\blue80;\red0\green77\blue187;\red173\green255\blue47;}"; // some colors (Black, Red, Green, Blue) + public enum ERColor + { + ERC_Black = 0, + ERC_Red, + ERC_MidGreen, + ERC_Blue, + ERC_Green, + } + + private string m_fmtColor = @"\cf0"; + private ERColor m_rColor = ERColor.ERC_Black; + public ERColor RColor + { + get { return m_rColor; } + set { + m_rColor = value; + m_fmtColor = string.Format( @"\cf{0} ", ( (int)m_rColor ).ToString( ).Trim( ) ); + m_rTFtextLine += m_fmtColor; + } + } + + private string m_fmtHLight = @"\highlight0 "; + private ERColor m_rHighlightColor = ERColor.ERC_Black; + public ERColor RHighlightColor + { + get { return m_rHighlightColor; } + set { + m_rHighlightColor = value; + m_fmtHLight = string.Format( @"\highlight{0} ", ( (int)m_rHighlightColor ).ToString( ).Trim( ) ); + m_rTFtextLine += m_fmtHLight; + } + } + + #endregion + + + #region RTF text + + private const string c_NL = @"\par"; + private string LineFormatter( string input ) + { + string ret = @"\pard\sl0\slmult1" + TabHeader + " "; // reset, line size determined by char, spacing 1 + + return ret + input + c_NL; + } + + private string m_rTFtextLine = ""; + private List m_rTFtext = new List( ); + public string RTFtext + { + get { + // Build the stuff... + string ret = "{" + string.Format( "{0}\n{1}\n{2}\n{3}\n", c_Header, c_Fonts, c_Colors, c_Leader ); + foreach ( string s in m_rTFtext ) + ret += string.Format( "{0}\n", s ); + ret += "}"; + return ret; + } + } + #endregion + + + #region Tabs + + private List m_tabs = new List( ); + private string TabHeader + { + get { + string ret = ""; + foreach ( int i in m_tabs ) { + ret += @"\tx" + i.ToString( ); + } + return ret; + } + } + + public void ClearTabs() + { + m_tabs = new List( ); + } + + /// + /// Set a tab in twips (1/20pt) this is RTF style.. + /// + /// Tab position in twips + public void SetTab( int tabPos ) + { + m_tabs.Add( tabPos ); + } + #endregion + + + #region Input + + public void Clear() + { + m_rTFtext.Clear( ); + m_rTFtextLine = ""; + } + + public void WriteTab( string input ) + { + m_rTFtextLine += @"\tab " + input; + } + + public void Write( string text ) + { + m_rTFtextLine += text; + } + + public void WriteLn( string text ) + { + m_rTFtextLine += text; + WriteLn( ); + } + + public void WriteLn() + { + m_rTFtext.Add( LineFormatter( m_rTFtextLine ) ); + m_rTFtextLine = ""; + } + + #endregion + + + } +} diff --git a/SCJMapper-V2.csproj b/SCJMapper-V2.csproj index b7d8605..556d5e6 100644 --- a/SCJMapper-V2.csproj +++ b/SCJMapper-V2.csproj @@ -140,6 +140,7 @@ FormOptions.cs + diff --git a/actions/ActionTree.cs b/actions/ActionTree.cs index bca5de4..ba9489a 100644 --- a/actions/ActionTree.cs +++ b/actions/ActionTree.cs @@ -250,7 +250,7 @@ namespace SCJMapper_V2 ActionCommandCls acc = ac.AddCommand( "", matin.Index ); // show stuff FilterTree( ); - FindAndSelectCtrlByName( matn.Name, (matn.Parent as ActionTreeNode ).Action ); + FindAndSelectCtrlByName( matn.Name, ( matn.Parent as ActionTreeNode ).Action ); // jump to the latest if a new one was added if ( Ctrl.SelectedNode.LastNode != null ) { Ctrl.SelectedNode = Ctrl.SelectedNode.LastNode; @@ -1021,6 +1021,52 @@ namespace SCJMapper_V2 return ret; } + /// + /// Find all actions that are mapped to this input + /// formatted as RTF text + /// + /// The input string to find + public void FindAllActionsRTF( string input, RTF.RTFformatter rtf ) + { + if ( string.IsNullOrEmpty( input ) ) return; // nothing to find here... + if ( ActionCls.IsBlendedInput( input ) ) return; // nothing to find here... + rtf.FontSize( 12 ); + rtf.Write( "Actions listed for input: " ); + rtf.RBold = true; rtf.WriteLn( input ); rtf.RBold = false; + + rtf.FontSize( 9 ); // 9pt + rtf.ClearTabs( ); rtf.SetTab( 852 ); rtf.SetTab( 4260 ); rtf.SetTab( 6532 ); + + rtf.WriteLn( ); + rtf.RULine = true; + rtf.Write( "Location" ); rtf.WriteTab( "Action" ); rtf.WriteTab( "Actionmap" ); rtf.WriteTab( "Activation Mode".PadRight( 40 ) ); rtf.WriteLn( ); + rtf.RULine = false; + rtf.WriteLn( ); + string aMode = ""; + foreach ( ActionMapCls acm in ActionMaps ) { + // have to search Actions in Maps + foreach ( ActionCls ac in acm ) { + if ( ac.defBinding == input ) { + aMode = string.Format( "{0};{1}", ac.defActivationMode.Name, ac.defActivationMode.MultiTap ); + rtf.Write( "profile" ); rtf.WriteTab( ac.name ); rtf.WriteTab( acm.name ); rtf.WriteTab( aMode ); rtf.WriteLn( ); + rtf.WriteLn( ); + } + foreach ( ActionCommandCls acc in ac.inputList ) { + if ( acc.DevInput == input ) { + aMode = string.Format( "modified;{0};{1}", acc.ActivationMode.Name, acc.ActivationMode.MultiTap ); + if ( acc.ActivationMode == ActivationMode.Default ) + aMode = string.Format( "default" ); + rtf.RHighlightColor = RTF.RTFformatter.ERColor.ERC_Green; + rtf.Write( "mapped" ); rtf.WriteTab( ac.name ); rtf.WriteTab( acm.name ); rtf.WriteTab( aMode.PadRight( 80 ) ); rtf.WriteLn( ); + rtf.RHighlightColor = RTF.RTFformatter.ERColor.ERC_Black; + rtf.WriteLn( ); + } + } + } + } + } + + /// /// Find a control the the actionmap that contains the Text /// diff --git a/doc/ReadMe.txt b/doc/ReadMe.txt index b35c12b..fb23881 100644 --- a/doc/ReadMe.txt +++ b/doc/ReadMe.txt @@ -1,5 +1,5 @@ SC Joystick Mapper V 2.30 - Build 64 BETA -(c) Cassini, StandardToaster - 14-May-2017 +(c) Cassini, StandardToaster - 19-May-2017 Contains 9 files: diff --git a/doc/SCJMapper_QGuide V2.30beta.pdf b/doc/SCJMapper_QGuide V2.30beta.pdf index 5663375..a1ad0b4 100644 Binary files a/doc/SCJMapper_QGuide V2.30beta.pdf and b/doc/SCJMapper_QGuide V2.30beta.pdf differ diff --git a/doc/SCJMapper_QGuide V2.x.pub b/doc/SCJMapper_QGuide V2.x.pub index 24b8350..b70fc44 100644 Binary files a/doc/SCJMapper_QGuide V2.x.pub and b/doc/SCJMapper_QGuide V2.x.pub differ