In this activity the GetTime application as implemented in the native code and XAML chapters, is implemented as a Managed Code C# .NET CF application.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace ManagedTime { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void TimeButton_Click(object sender, EventArgs e) { } private void ExitButton_Click(object sender, EventArgs e) { } } }
Listing 17.1 The C# code behind with the button event handlers.
textBox1.Text = DateTime.Now.ToString();
Application.Exit();
Now to run the application on the target device using CoreCon. Refer the 16.4 CoreCon Application Development Connectivity.
DateTime localTime = DateTime.Now; string dateTimeStr = string.Format( "Time {0}:{1}:{2} Date {3}/{4}/{5}", localTime.Hour, localTime.Minute, localTime.Second, localTime.Day, localTime.Month, localTime.Year); textBox1.Text = dateTimeStr;
DateTime localTime = DateTime.Now;
string dateTimeStr = string.Format(
"Time {0}:{1}:{2} Date {3}/{4}/{5}",
localTime.Hour, localTime.Minute, localTime.Second,
localTime.Day, localTime.Month, localTime.Year);
textBox1.Text = dateTimeStr;
More: 17.3 Managed Code VB GetTime Application
Click here to provide feedback and input