I am using GHI Libs - 1.0.0
UCM Dev Board Rev E with a UC5550/WiFi
UD700 Rev A display
using GHIElectronics.TinyCLR.UI;
using GHIElectronics.TinyCLR.Pins;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Devices.Display;
using GHIElectronics.TinyCLR.UI.Controls;
using TinyCLR_UI.Properties; // Needed for Resources
using GTUM = GHIElectronics.TinyCLR.UI.Media;
using GTUC = GHIElectronics.TinyCLR.UI.Controls;
namespace TinyCLR_UI
{
class Program : Application
{
public static GpioPin led_GPIOC;
public static GpioPin backlight_GPIOA;
public Program(DisplayController d) : base(d)
{
}
static void Main()
{
//Enable the UD700 Rev A Backlight - High = ON
backlight_GPIOA = GpioController.GetDefault().OpenPin(UC5550.GpioPin.PD7);
backlight_GPIOA.SetDriveMode(GpioPinDriveMode.Output);
backlight_GPIOA.Write(GpioPinValue.High);
// LED by the IRQ A button - For some reason it is ON at power-Up
// The signal can be found on Header B Pin GPIO C
led_GPIOC = GpioController.GetDefault().OpenPin(UC5550.GpioPin.PG3);
led_GPIOC.SetDriveMode(GpioPinDriveMode.Output);
led_GPIOC.Write(GpioPinValue.Low); // OFF
var displayController = DisplayController.GetDefault();
displayController.SetConfiguration(new ParallelDisplayControllerSettings
{
//Your display configuration
Width = 800,
Height = 480,
DataFormat = GHIElectronics.TinyCLR.Devices.Display.DisplayDataFormat.Rgb565,
HorizontalBackPorch = 46,
HorizontalFrontPorch = 16,
HorizontalSyncPolarity = false,
HorizontalSyncPulseWidth = 1,
DataEnableIsFixed = false,
DataEnablePolarity = false,
PixelClockRate = 20000000,
PixelPolarity = false,
VerticalBackPorch = 23,
VerticalFrontPorch = 7,
VerticalSyncPolarity = false,
VerticalSyncPulseWidth = 1
});
displayController.Enable();
var app = new Program(displayController);
app.Run(Program.CreateWindow(displayController));
}
//Main
private static Window CreateWindow(DisplayController disp)
{
var screen = System.Drawing.Graphics.FromHdc(disp.Hdc);
var Largefont = Resources.GetFont(Resources.FontResources.ninab);
// Background window to fill LCD screen. Uses ListBox 1
var window1 = new Window
{
Top = 0,
Left = 0,
Height = 480,
Width = 800
};
//Set window rectangle. Uses ListBox 2
var window2 = new Window
{
Top = 50,
Left = 50,
Height = 120,
Width = 200
};
// Text inside Window 2 white rectangle
var txt2 = new GTUC.TextBox
{
Font = Largefont,
Text = " Window 2 ListBox 2"
};
window1.Background = new GTUM.SolidColorBrush(GTUM.Color.FromArgb(255, 50, 50, 50)); //gray
window2.Background = new GTUM.SolidColorBrush(GTUM.Color.FromArgb(255, 255, 215, 0)); //gold
var listBox1 = new GTUC.ListBox();
listBox1.Child.Width = 300;
listBox1.Child.Height = 130;
listBox1.Child.HorizontalAlignment = HorizontalAlignment.Center;
listBox1.Child.VerticalAlignment = VerticalAlignment.Top;
var listBox2 = new GTUC.ListBox();
listBox2.Child.Width = 200;
listBox2.Child.Height = 120;
listBox2.Child.HorizontalAlignment = HorizontalAlignment.Center;
listBox2.Child.VerticalAlignment = VerticalAlignment.Top;
listBox2.SetMargin(0);
listBox2.Items.Add(txt2);
var text1 = new Text(Largefont, "Background Window 1 using ListBox 1");
text1.SetMargin(8);
text1.ForeColor = GTUM.Color.FromRgb(255, 255, 255); //White
listBox1.Items.Add(text1);
listBox2.Child.HorizontalAlignment = HorizontalAlignment.Center;
listBox2.Child.VerticalAlignment = VerticalAlignment.Top;
listBox2.SetMargin(0);
window1.Child = listBox1;
window2.Child = listBox2;
for (var i = 1; i <= 1; i++) //Only one item for now
{
// Text inside Window 2 ListBox 2 (Yellow rectangle)
var text = new Text(Largefont, $" Window2 ListBox2 > {i}");
text.ForeColor = GTUM.Color.FromRgb(0, 0, 255); //Blue
text.SetMargin(2); // Y spacing
listBox2.Items.Add(text);
}
//
// Items[0] is the text within the white rectangle
// Items[1] is the text within the yellow rectangle with a count number > 1
var item = listBox2.Items[1];
var selectable = item.IsSelectable; //returns true
listBox2.SelectedIndex = 1;
listBox2.SelectedItem = item;
object[] objCollection = new object[listBox2.Items.Count];
listBox2.Items.CopyTo(objCollection, 0);
window1.Visibility = Visibility.Visible;
window2.Visibility = Visibility.Visible;
//return a window; Does not seem to matter which window is used
return window1;
} //CreateWindow
} //Program
} //Namespace
How do I ‘GET’ the objCollection item(s) string(s) as shown in the Gif file?
object[] objCollection = new object[listBox2.Items.Count];
listBox2.Items.CopyTo(objCollection, 0);
I have no idea how to. (Not the brightest guy in the world)