Hi
Newbie in c# programming. I was wondering what was wrong in this code. What I wanted is that I have to show counting on display, however, it only shows the last count. I checked the output and I see my debug.prints… which indeed says that it has entered the loop.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
namespace FEZ_Cobra_Window_Application4
{
public class Program : Microsoft.SPOT.Application
{
public static void Main()
{
Program myApplication = new Program();
Window mainWindow = myApplication.CreateWindow();
// Create the object that configures the GPIO pins to buttons.
GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);
// Start the application
myApplication.Run(mainWindow);
}
private Window mainWindow;
public Window CreateWindow()
{
// Create a window object and set its size to the
// size of the display.
mainWindow = new Window();
mainWindow.Height = SystemMetrics.ScreenHeight;
mainWindow.Width = SystemMetrics.ScreenWidth;
// Create a single text control.
Text text = new Text();
text.Font = Resources.GetFont(Resources.FontResources.small);
for (int x = 0; x < 10; x++)
{
text.TextContent = "Hi User!";
Thread.Sleep(200);
text.TextContent = x.ToString();
Thread.Sleep(200);
}
// text.TextContent = Resources.GetString(Resources.StringResources.String1);
text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;
// Add the text control to the window.
mainWindow.Child = text;
// Connect the button handler to all of the buttons.
mainWindow.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false);
// Set the window visibility to visible.
mainWindow.Visibility = Visibility.Visible;
// Attach the button focus to the window.
Buttons.Focus(mainWindow);
return mainWindow;
}
private void OnButtonUp(object sender, RoutedEventArgs evt)
{
ButtonEventArgs e = (ButtonEventArgs)evt;
// Print the button code to the Visual Studio output window.
Debug.Print(e.Button.ToString());
}
}
}
Hope you could help me with this.
Thanks!