- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We've had a few people ask for sample code demonstrating the use of the Intel Mobile Platfrom SDK (See: http://www.intel.com/software/products/mobileplatform) within a Windows Forms application. Note that the SDK comes with extensive sample code but it is limited to console application. For those who would like a forms app that runs on .Net v1.1 see the attached zip file. The source code shows a simple forms application that receive the connected and disconnected events and updates the GUI each time this happens.
Thanks,
Lester Memmott
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like the forum is having trouble with attachments so here it is as text:
// _____________________________________________________________________________
// Copyright (C) Intel Corporation (2006)
// DISCLAIMER OF WARRANTY
// NEITHER INTEL NOR ITS SUPPLIERS MAKE ANY REPRESENTATION OR WARRANTY OR
// CONDITION OF ANY KIND WHETHER EXPRESS OR IMPLIED (EITHER IN FACT OR BY
// OPERATION OF LAW) WITH RESPECT TO THE SOURCE CODE. INTEL AND ITS SUPPLIERS
// EXPRESSLY DISCLAIM ALL WARRANTIES OR CONDITIONS OF MERCHANTABILITY OR
// FITNESS FOR A PARTICULAR PURPOSE. INTEL AND ITS SUPPLIERS DO NOT WARRANT
// THAT THE SOURCE CODE IS ERROR-FREE OR THAT OPERATION OF THE SOURCE CODE WILL
// BE SECURE OR UNINTERRUPTED AND HEREBY DISCLAIM ANY AND ALL LIABILITY ON
// ACCOUNT THEREOF. THERE IS ALSO NO IMPLIED WARRANTY OF NON-INFRINGEMENT.
// SOURCE CODE IS LICENSED TO LICENSEE ON AN "AS IS" BASIS AND NEITHER INTEL
// NOR ITS SUPPLIERS WILL PROVIDE ANY SUPPORT, ASSISTANCE, INSTALLATION,
// TRAINING OR OTHER SERVICES. INTEL AND ITS SUPPLIERS WILL NOT PROVIDE ANY
// UPDATES, ENHANCEMENTS OR EXTENSIONS.
// ____________________________________________________________________________
using
System;using
System.Drawing;using
System.Collections;using
System.ComponentModel;using
System.Windows.Forms;using
System.Data;using
Intel.Mobile.Base;using
Intel.Mobile.Context;namespace
EventFormSample{
///{
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label Label_Status; public System.Windows.Forms.TextBox textBox_info; private ContextClass myClass; private System.Windows.Forms.Label label2; public static EventObserver m_clObserver; ///{
// // Required for Windows Form Designer support //InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call //}
///{
if( disposing ){
if (components != null){
components.Dispose();
}
}
base.Dispose( disposing );}
#region
Windows Form Designer generated code ///{
this.label1 = new System.Windows.Forms.Label(); this.Label_Status = new System.Windows.Forms.Label();}
#endregion
///[MTAThread]
static void Main(){
Application.Run(
new Form1());}
private void Form1_Load(object sender, System.EventArgs e){
try{
myClass =
new ContextClass();ConnectivityInstance myInstance = (ConnectivityInstance) myClass.GetInstance("Co nnectivity");
m_clObserver =
new EventObserver();myInstance.Connected.AddObserver( m_clObserver );
myInstance.Disconnected.AddObserver( m_clObserver );
Label_Status.Text = myInstance.IsConnected.GetValue()?"Connected":"Disconnected";
m_clObserver.MyEvent +=
new EventObserver.MyEventHandler(EventHandler);}
catch (IntelMobileException ex){
MessageBox.Show(Form.ActiveForm, "Message: " + ex.Message, "Exception" );
}
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e){
ConnectivityInstance myInstance = (ConnectivityInstance) myClass.GetInstance("Connectivity");
myInstance.Connected.RemoveObserver( m_clObserver );
myInstance.Disconnected.AddObserver( m_clObserver );
m_clObserver.Close();
}
private void EventHandler(bool bStatus, String sInfo){
textBox_info.AppendText( sInfo );
textBox_info.AppendText( " " );
Label_Status.Text = bStatus?"Connected":"Disconnected";
}
}
public class EventObserver : Observer{
public delegate void MyEventHandler(bool bStatus, String sInfo); public event MyEventHandler MyEvent; public override void Notify(Event ev){
try{
if ( ev.GetType() == EventBase.EventType.eConnected ){
MyEvent(
true, ev.GetTSstring() + " Connected event occurred for " + ev.GetOriginator().GetType() );}
if ( ev.GetType() == EventBase.EventType.eDisconnected ){
MyEvent (
false, ev.GetTSstring() + " Disconnected event occurred for " + ev.GetOriginator().GetType() );}
}
catch (IntelMobileException ex){
MessageBox.Show(Form.ActiveForm, "Message: " + ex.Message, "Exception" );
}
}
}
}

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page