Hi fellas, i was hoping somebody could help me out.
I am using the Intel Mobile SDK 1.2 in order to access powerevents when the power is connected and disconnected.
Currently i have the events registering and a message box poping up when this happens, but i want to be able to log the events to a text box on my windows form, also i want to be able to re-size a picture when the power is disconnected, and then make it larger when power is connected again (power saving)but i cannot do either of these, it just seems to be the message box that pops up. I am using C#
Any ideas as to why this is not working for me, i have access to everything when the form.
here is my code:
thanks fellas,
PS my form is [MTATHREAD]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Intel.Mobile.Base;
using Intel.Mobile.Battery;
using Intel.Mobile.Context;
namespace PowerExample
{
public partial class Form2 : Form
{
ContextClass myClass = new ContextClass();
public PowerInstance myInstance;
internal static bool LoopFlag = true;
internal static readonly System.Object Mutex = new System.Object();
private DelegateObserver.ObserverNotifyDelegate DisconnectNotifyDelegate = null;
NT>public Form2()
{
InitializeComponent();
myInstance = (PowerInstance)
myClass.GetInstance("Power");
DelegateObserver.ObserverNotifyDelegate del = new DelegateObserver.ObserverNotifyDelegate(ConnectedEventHandler);
Observer connectedChangeObsvr = new DelegateObserver(del);
myInstance.ExternallyPowered.AddObserver(connectedChangeObsvr);
myInstance.InternallyPowered.AddObserver(connectedChangeObsvr);
}
private void ConnectedEventHandler(Event eEvent)
{
try
{
if (eEvent.GetType() == EventBase.EventType.eExternallyPowered)
{
//textBox1.AppendText("Connected 1 " + DateTime.Now);
MessageBox.Show("Ac Adapter Connectd");
//textBox1.AppendText("Conneted 2 " + DateTime.Now);
}
if(eEvent.GetType() == EventBase.EventType.eInternallyPowered)
{
//textBox1.AppendText("Disconnect 1 " + DateTime.Now);
MessageBox.Show("Ac Adapter Disconnected");
//textBox1.AppendText("Disconnect 2 " + DateTime.Now);
}
}
catch (IntelMobileException ex)
{
textBox1.Text = (ex.ToString());
}
catch (Exception e)
{
textBox1.Text = ("------------ Exception Occurred ------------");
textBox1.Text = ("Message: " + e.Message);
textBox1.Text = ("Source: " + e.Source);
textBox1.Text = ("Target Site: " ize=2> + e.TargetSite);
}
}
}
internal class DelegateObserver : Observer
{
public delegate void ObserverNotifyDelegate(Event eEvent);
public DelegateObserver(ObserverNotifyDelegate Notifydelegate)
{
this.MyNotifydelegate = Notifydelegate;
}
public override void Notify(Event ev)
{
this.MyNotifydelegate(ev);
}
private ObserverNotifyDelegate MyNotifydelegate;
}
}

