To anyone that cares…
I restructured my code and I still could not get String.Concat() to work. I even tried Concat in a new thread.
However, a simple for loop did the thick! (I was going to use a loop in the first place)
Updated code that worked. At the end of the code you can see the string I wanted.
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
Bitmap TBitmap;
Text text;
Text textS;
char[] NinaBfont;
string[] parts;
void ProgramStarted()
{
Debug.Print("Program Started");
TBitmap = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
Font myFont = Resources.GetFont(Resources.FontResources.NinaB);
text = new Text();
textS = new Text();
// Set Font
text.Font = Resources.GetFont(Resources.FontResources.NinaB);
textS.Font = Resources.GetFont(Resources.FontResources.small);
NinaBfont = new char[130];
parts = new string[130];
beginhere();
}
void beginhere()
{
//Do not allow code to run until button is pressed
//This is because of ***ASSERT*** when using string result = String.Concat(parts);
while(!button.IsPressed)
{
Debug.Print("CANNOT RUN - SAFETY CHECK");
if (button.IsPressed)
{
break;
}
}
Debug.Print("RUNNING - SAFETY CHECK");
uint x = 2;
uint y = 0;
uint W = 0;
uint H = 0;
string part;
y += (uint)text.Font.Height + 3;
x = 2;
for (ushort i = 0; i <= 128; ++i)
{
char T = Convert.ToChar(i);
W = (uint) text.Font.CharWidth(T);
H = (uint)text.Font.Height;
NinaBfont[i] = T;
part = String.Empty;
part = T.ToString();
parts[i] = part;
x += (W + 2);
if(x > 300)
{
x = 2;
y+= (H + 2);
}
}
//Added thread for a test
Thread thread = new Thread(new ThreadStart(generateString));
thread.Start();
thread.Abort();
/*
x = 2;
y += 24;
char[] smallFont = new char[129];
for (ushort i = 0; i <= 128; ++i)
{
char T = Convert.ToChar(i);
W = (uint)textS.Font.CharWidth(T);
H = (uint)textS.Font.Height;
smallFont[i] = T;
display_T35.SimpleGraphics.DisplayText(T.ToString(), textS.Font, GT.Color.White, x, y);
x += (W + 2);
if (x > 300)
{
x = 2;
y += (H + 2);
}
}
*/
}
//
private void generateString()
{
string result = String.Empty;
for (uint i = 0; i <= 128; ++i)
{
result += parts[i];
}
// result = String.Concat(parts); Fails with *****ABORT*****
// The for loop returns the string I wanted
// "\a\b\t\n\v\f\re !\"#$%&'()*+,-./0123456789:;<=>?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
}
} //end class
} //end namespace
Bye!