locked
SystemState... RRS feed

  • Question

  • Hi!

    I've been told that i need to use the SystemState so that i can make my application notify me about any received phonecall or sms... I have an application that i've build using c#. So if you can provide me with a guide or your professional experties, that would be great.
    Thursday, December 24, 2009 10:11 AM

Answers

  • Hi,

    You can try the following code :-

    	private void pictureBox1_Click(object sender, EventArgs e)
            {
                InitializeComponent();
    	   SystemState _PhoneMissedCalls = new SystemState(SystemProperty.PhoneMissedCalls);
    	   _PhoneMissedCalls.Changed += new ChangeEventHandler(_PhoneMissedCalls_Changed);
            }
    
            void _PhoneMissedCalls_Changed(object sender, ChangeEventArgs args)
            {
                throw new Exception("The method or operation is not implemented.");
            }
    
            void _PhoneRoaming_Changed(object sender, ChangeEventArgs args)
            {
    	   if (SystemProperty.PhoneMissedCalls == 0)
    	   {
    	      // Show phone missed calls
    	   }
            }
    Remember to add the following using statement to your class :-

    using Microsoft.WindowsMobile.Status;
    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    • Proposed as answer by Paul Diston Thursday, December 24, 2009 12:46 PM
    • Marked as answer by Chabbe11 Thursday, December 24, 2009 1:46 PM
    Thursday, December 24, 2009 12:22 PM

All replies

  • Hey Paul!

    I followed the links and i'm trying to write this code into my form1:

            private void pictureBox1_Click(object sender, EventArgs e)
            {
                InitializeComponent();
    SystemState _PhoneMissedCalls = new SystemState(
                                SystemProperty.PhoneMissedCalls);


    _PhoneMissedCalls.Change += new ChangeEventHandler(
                            _PhoneMissedCalls_Changed);}


    void _PhoneMissedCalls_Changed(object sender, ChangeEventArgs args)
    {
       throw new Exception("The method or operation is not implemented.");
    }

    void _PhoneRoaming_Changed(object sender, ChangeEventArgs args)
    {
       if (SystemProperty.PhoneMissedCalls == false)
       {
          // Show phone missed calls
           }
        }
        }
    }


    But I end up with "The type or namespace name "ChangeEventArgs" could not be found (Are you missing a using directive or an assemblt reference?)

    Please Help
    Thursday, December 24, 2009 11:26 AM
  • Hi,

    You need to add references for both the Microsoft.WindowsMobile and Microsoft.WindowsMobile.Status assemblies and add the relevant using statements as well.

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Thursday, December 24, 2009 11:32 AM
  • I've now added the references, but how do i add the relevant using statements?? I'm so thankful for your patience :)
    Thursday, December 24, 2009 11:38 AM
  • Hi,

    Right click on the ChangeEventArgs and there should be an option to Resolve, with one of the optios being to add a using statement to your class.

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Thursday, December 24, 2009 11:41 AM
  • Hey, i've now added the relevant statement

    but i'm now facing other problems...

    Error 1 'Microsoft.WindowsMobile.Status.SystemState' does not contain a definition for 'Change' and no extension method 'Change' accepting a first argument of type 'Microsoft.WindowsMobile.Status.SystemState' could be found (are you missing a using directive or an assembly reference?) C:\Users\Chabbe\Documents\Visual Studio 2008\Projects\WinMobUI - Visual C#\WinMobUI\WinMobUItoday.cs 182 31 WinMobUI

    Error 2 Operator '==' cannot be applied to operands of type 'Microsoft.WindowsMobile.Status.SystemProperty' and 'bool' C:\Users\Chabbe\Documents\Visual Studio 2008\Projects\WinMobUI - Visual C#\WinMobUI\WinMobUItoday.cs 194 17 WinMobUI

    Btw. i'm writing this code in a picturebox, should i change to a textbox or a label?? Because i have the "baloon" image and i want the number of missed calls to show on top of the image, as this picture show:

    http://winmobui.webs.com/not.png
    Thursday, December 24, 2009 11:47 AM
  • Thursday, December 24, 2009 11:51 AM
  • Haha, okey now i'm not following :) As i said before, i'm a newbie so be patient :D


    Thursday, December 24, 2009 11:55 AM
  • Hi,

    No problem, we were all new once.

    Have you managed to solve the problem?

    Thanks

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Thursday, December 24, 2009 12:00 PM
  • Unfortunately, no...

    I can't understand what i'll do with the two new links you gave me.

    Should i delete the code that i've written and start over with the code in the new links?
    Thursday, December 24, 2009 12:02 PM
  • Hi,

    No, the links I provided show the name of the event, so rather than use Change, use Changed.

    The second link shows the return type of the property, therefore instead of using if (SystemProperty.PhoneMissedCalls == false) use if (SystemProperty.PhoneMissedCalls == 0).

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Thursday, December 24, 2009 12:04 PM
  • My code sample now looks like this:

    private void pictureBox1_Click(object sender, EventArgs e)
            {
                InitializeComponent();
                SystemState _PhoneMissedCalls = new SystemState(
                                            (SystemProperty.PhoneMissedCalls == 0)


                _PhoneMissedCalls.Changed += new ChangedEventHandler(
                                        _SystemProperty.PhoneMissedCalls == 0);
            }


            void _PhoneMissedCalls_Changed(object sender, ChangeEventArgs args)
            {
                throw new Exception("The method or operation is not implemented.");
            }

            void _PhoneRoaming_Changed(object sender, ChangedEventArgs args)
            {
                if (SystemProperty.PhoneMissedCalls == 0)
                {
                    // Show phone missed calls
                }

    And i get the following errors:

    Error 1 ) expected C:\Users\Chabbe\Documents\Visual Studio 2008\Projects\WinMobUI - Visual C#\WinMobUI\WinMobUItoday.cs 179 79 WinMobUI
    Error 2 ; expected C:\Users\Chabbe\Documents\Visual Studio 2008\Projects\WinMobUI - Visual C#\WinMobUI\WinMobUItoday.cs 179 79 WinMobUI
    Error 3 The type or namespace name 'ChangedEventArgs' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Chabbe\Documents\Visual Studio 2008\Projects\WinMobUI - Visual C#\WinMobUI\WinMobUItoday.cs 192 51 WinMobUI


    Please remember that i'm writing this code in a picturebox...

    Thursday, December 24, 2009 12:11 PM
  • Hi,

    You can try the following code :-

    	private void pictureBox1_Click(object sender, EventArgs e)
            {
                InitializeComponent();
    	   SystemState _PhoneMissedCalls = new SystemState(SystemProperty.PhoneMissedCalls);
    	   _PhoneMissedCalls.Changed += new ChangeEventHandler(_PhoneMissedCalls_Changed);
            }
    
            void _PhoneMissedCalls_Changed(object sender, ChangeEventArgs args)
            {
                throw new Exception("The method or operation is not implemented.");
            }
    
            void _PhoneRoaming_Changed(object sender, ChangeEventArgs args)
            {
    	   if (SystemProperty.PhoneMissedCalls == 0)
    	   {
    	      // Show phone missed calls
    	   }
            }
    Remember to add the following using statement to your class :-

    using Microsoft.WindowsMobile.Status;
    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    • Proposed as answer by Paul Diston Thursday, December 24, 2009 12:46 PM
    • Marked as answer by Chabbe11 Thursday, December 24, 2009 1:46 PM
    Thursday, December 24, 2009 12:22 PM
  • I thank you from the bottom of my heart :D It works perfect, thank you for all your help.

    Best regards
    Thursday, December 24, 2009 12:43 PM