Click here to Skip to main content
15,881,559 members
Articles / Mobile Apps

AGENT Smartwatch All in One Apps using C#

Rate me:
Please Sign up or sign in to vote.
4.37/5 (11 votes)
24 Sep 2015CPOL10 min read 28.2K   270   8   8
Creating a simple App for AGENT Smartwatch
This article shows how to create and run your first AGENT Smartwatch Application, create a Simple AGENT Smartwatch to add our custom fonts, Add Images, Draw Text and Image and create the All in One App for AGENT Smartwatch.

Introduction

* Kindly view my Youtube video to learn AGENT Smartwatch All in One Apps using C#.

In this article, we will see how to create a simple app for AGENT Smartwatch. Why I have selected AGENT Smart to support both Windows, Android and IOS mobiles and also SDK for AGENT Smartwatch was been based on .NET Micro Framework. .NET Micro Framework can be used to develop embedded device applications. For more details regarding the AGENT Smartwatch, check their official website here.

Prerequisites: Download all the below prerequisites and install it in your computer.

http://www.agentwatches.com/downloads/agentsdk.exe

  1. Visual Studio 2015 - You can download it from this link.
  2. .NET Micro Framework SDK 4.3 for VS2015 project
  3. AGENT SDK
  4. Tiny Font Tool GUI

In this article, we will see how to:

  1. create and run our first AGENT Smartwatch Application
  2. create a Simple AGENT Smartwatch to add our custom fonts, Add Images, Draw Text and Image
  3. create my All in One App for AGENT Smart watch

What is Shanu All in One App for AGENT Smart Watch?

Smartwatch makes our life more easy and comfortable. If you ask me a question that we already have Smartphones, so why do we need Smartwatches, then I will answer as it’s important to use smartwatches as well as smartphones in today’s busy world. For example, let’s consider now we are in a meeting and at the same time, we are getting some continuous calls. We were not able to check for who’s calling at the moment. If suppose, it’s a very important and urgent call, then we will be missing it without seeing who’s calling. If consider, we are using the Smartwatch, then without disturbing the meeting, we can check for who’s calling and if it’s a very important call, then we can answer it.

To make things easier and more convenient, I have made the All in One App using AGENT Smart watch. In my All in One App for Smartwatch, I have five different functionalities. They are:

  1. Simple Text Animation

    Image 1

  2. Display Date and Time

    Image 2

  3. Display Today's Appointment

    Image 3

  4. Display Animation for simple Game

    Image 4

  5. Stopwatch

    Image 5

Using the Code

1) Create and Run Our First AGENT Smartwatch Application

Kindly download and install all the prerequisites need to create our first AGENT Smartwatch application using C#. After you have installed all the above prerequisites:

Click Start -> Programs-> Select Visual Studio 2015 - Click Visual Studio 2015

Click New -> Project - > Select Micro Framework from template -> Click Windows Application. Select your project folder and give proper name for your project ->Click OK.

Image 6

Once we have created our AGENT Smartwatch Application, we can see in the Solution Explorer that it will contain program.cs and Resources.resx. The program.cs class file is the main file where we write all our coding to create our Apps. The program.cs will have the Main method from where the program will start executing. The Resources.resx is used to add resources like Image, Tiny Font, String, etc.

Image 7

Default Target Framework: The default target language will be .NET Micro Framework 4.3. When we right click our project and click on properties, we can see the target framework will be selected as .NET Micro Framework 4.3.

Image 8

Default Deployment: Default deployment device will be selected as AGENT Emulator. When we run the program, we can see the output in the AGENT Emulator.

Image 9

Program.cs

I will recommend this website which is a very good place for any beginner to write code with AGENT Smartwatch using C# from this link which was written by Matt from RougrCode.

By default, when we create the program, the Program.cs will contain some set of code to display the output as “Hello World”. The Program.cs will add default Header files to run the program. Here, we can see the set of default header files added.

.NET Micro Framework will have very limited functionality compared to our .NET Framework. So we cannot use all references which we are using in our normal .NET Framework.

C#
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;

Main Method

By default, when we create main method, it will create a window to display the default “hello world” text.

C#
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);
        }

In Createwindow method, the default code will be added to add the Text to the window and loading the text content from the resource File. Note to see our resource string, we can double click on “Resources.resx” file from the Solution Explorer. If we want, we can add more string or we can change the Hello World text as we like to display different text.

Image 10

C#
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);

                      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;
               }

Here in this method, after creating the main window, the eventhandler will be added for the AGENT Smart watch button click events.

OnButtonUp Event: This event will be raised whenever the user clicks on buttons of the AGENT Smart watch. The AGENT Smart watch will contain five buttons, three buttons on the right and two buttons on the left.

C#
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());
        }

Run and Test Our First Program

Without writing any code, we can run our first AGENT Smartwatch application to display the “Hello World” text display.

Image 11

So we succeeded in creating our first AGENT Smart watch Application and testing it.

2) Create a Simple AGENT Smartwatch to Add our Custom Fonts, Add Images, Draw Text and Image

Follow all the above steps to create your AGENT Smartwatch application.

We have already seen that when we create our AGENT Smartwatch application, it will add default code to create a Windows and display the “Hello world” text.

Now let’s see how to Draw Text, Add Image and add Tiny font to display different font text in our AGENT Smartwatch.

By default, we will have this header file:

C#
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;

I will be adding few more references to the project to draw text and Image and to add colors and for using Thread.

C#
using Microsoft.SPOT.Presentation.Media;
using System.Threading;

Next, we will delete all the code part except the main method. Here, instead of creating the new Window, I will be drawing text and Image from main method.

So now my program.cs file will look like this:

C#
using System.Diagnostics;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation.Controls;

namespace test
{
    public class Program : Microsoft.SPOT.Application
       {
               public static void Main()
               {                     

               }
       }
}

Here, first will create object for bitmap to drawtext.

C#
static Bitmap _myFace;

Inside the main method, we will draw text to display our content. Here, we can see first, I will create the bitmap Image with maxwidth and maxheight.

We will be adding font from the resource file. Default small font will added in our resource file.

Image 12

Here now, I have used the default font to display the text. Using the DrawText, I will draw the text in desired location which I have given. The Thread.Sleep() was used to display the text continuously.

C#
public class Program : Microsoft.SPOT.Application
       {
               static Bitmap _myFace;
               public static void Main()
               {
                      _myFace = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
                      _myFace.Clear();
                      Font fontS = Resources.GetFont(Resources.FontResources.small);
                      _myFace.DrawText("SHANU", fontS, Color.White, 12, 10);
                      _myFace.Flush();
                      Thread.Sleep(Timeout.Infinite);
               }
       }

When we run the program, we can see the output as:

Image 13

Adding Custom Fonts

By default, we will be having only one font in our application. We can also add our Custom fonts to our application from resource. Note we need to add only tiny font .To convert our normal font to Tiny font, there is a free tool available from this link, you can download and change any available fonts to Tiny font. Save the font to your folder and add the Tiny font to your resource file.

Image 14

I have converted the Tahoma Font as tiny font and saved in my folder. Now let’s see how to add the tiny font in our application.

To add the Custom converted font, double click on our resource file and click Add Existing File. Select your new Converted Tahoma Tiny Font. Click Save for save changes.

Image 15

In your main method code, create new object for font to add your new font and draw the text.

C#
public static void Main()
               {
                      _myFace = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
                      _myFace.Clear();
                      Font fontS = Resources.GetFont(Resources.FontResources.small);
                      _myFace.DrawText("SHANU", fontS, Color.White, 12, 10);
                      Font font = Resources.GetFont(Resources.FontResources.ThahomaFont);
                      _myFace.DrawText("SHANU", font, Color.White, 12, 26);
                      _myFace.Flush();
                      Thread.Sleep(Timeout.Infinite);
               }

When we run the program, we can see the output as:

Image 16

Adding Image and Draw Image

To add image, double click on our resource file and click Add Existing File. Select your Image file and save it. I will be adding only GIF and JPEG images.

Image 17

In your main method code, create new object for font to add your new font and draw the text. First, I will create the bitmap image from the Resource file and using the Draw Image, I will draw the image to the desired location. Note the last four points are used to crop the image and display.

C#
public class Program : Microsoft.SPOT.Application
       {
               static Bitmap _myFace;
               public static void Main()
               {
                      _myFace = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
                      _myFace.Clear();
                      Font fontS = Resources.GetFont(Resources.FontResources.small);
                      _myFace.DrawText("SHANU", fontS, Color.White, 12, 10);
                      Font font = Resources.GetFont(Resources.FontResources.ThahomaFont);
                      _myFace.DrawText("SHANU", font, Color.White, 12, 26);

                      Bitmap myImage = new Bitmap
                      (Resources.GetBytes(Resources.BinaryResources.shanu), 
                                          Bitmap.BitmapImageType.Jpeg);

                      _myFace.DrawImage(40, 40, myImage, 0, 0, 128, 128);
                      _myFace.Flush();
                      Thread.Sleep(Timeout.Infinite);
               }
       }

When we run the program, we can see the output as:

Image 18

Hope now you have a clearer idea of how to develop a simple Apps for AGENT Smartwatch. Next, we will see in detail how I have created my All in one App.

3) How to Create My All in One App for AGENT Smartwatch

As I have already explained in my All in One App, I have created five different functionalities in one app. They are:

  1. Simple Text Animation
  2. Display Date and Time
  3. Display Todays Appointment
  4. Display Animation for simple Game
  5. Stopwatch

We will see one by one in detail how to create using AGENT Smartwatch application development.

Create new project as mentioned above and I will be using the default create main window to display my name by default and in button click events, I will perform all the five different functionalities.

Add all header files:

C#
using System;
using System.Diagnostics;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation.Controls;

Declare all the local variables. I will be using this variable to perform five different functionalities.

C#
//Main bitmap to draw all text

               static Bitmap _myFace;
               const int HEIGHT = 128;
               const int WIDTH = 128;
               static int _ButtonClickNumber = 0;
               static Timer _TiimeDispTimer;

               //To display text Animation

               static int name1Xval = 2;
               static int name1Yval = 20;

               static int name2Xval = Bitmap.MaxWidth;
               static int name2Yval = 70;

               static int name3Xval = 10;
               static int name3Yval = Bitmap.MaxHeight - 10;

               //Ball Draw

               static int ballXval = 50;
               static int ballYval = 90;

               //Man Draw

               static int manfaceXval = 10;
               static int manfaceYval = 40;

               static int leg1Xval = manfaceXval + 1;
               static int leg1Yval = manfaceYval + 30;
               static int leg1X1val = manfaceXval - 4;
               static int leg1Y1val = manfaceYval + 54;
               static int leg2Xval = manfaceXval + 1;
               static int leg2Yval = manfaceYval + 30;
               static int leg2X1val = manfaceXval + 4;
               static int leg2Y1val = manfaceYval + 54;

               static int goalXVal = 60;
               static int goalYVal = 8;

               Boolean cicked = false;
               Boolean goals = false;

               //For StopWatch

               static int secounds = 0;
               static int Miniutes = 0;
               string secounds_str = "00";
               string Miniutes_str = "00";

In main method, we call the create Window method to create the main window and display default text as output.

C#
public static void Main()
        {
               Program myApplication = new Program();
               _myFace = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
               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;

In Createwindow method, I will create new window and add the default text to display.

Create new Timer with timer event to run every one second. Next, create a handler to perform the AGENT Smartwatch button Up events.

C#
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);
       text.TextContent =
            Resources.GetString(Resources.StringResources.Name1);
       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;

       TimeSpan startTime =
           new TimeSpan(0, 0, 0, 0,
           DateTime.Now.Millisecond);   // start after a Second
       TimeSpan SecondsAdd =
           new TimeSpan(0, 0, 0, 1, 0); // Add Secounds for Update
       _TiimeDispTimer =
           new Timer(UpdateTime, null,
           startTime, SecondsAdd);      // start  Timer to Display Time

       // Attach the button focus to the window.
       Buttons.Focus(mainWindow);
       return mainWindow;
}

ButtonUp Event: As I have explained, AGENT Smartwatch will contain five buttons, three buttons on the right and two buttons on the left and each button will contain a unique Number.

  • Right Top Watch Button – 38
  • Right Middle Watch Button – 41
  • Right Bottom Watch Button – 40
  • Left Top Watch Button – 37
  • Left Top Watch Button – 39

In this event, I will check for each button up unique number and call the desired function.

C#
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());

                      if (e.Button.ToString() == "38") //Right Top Watch Button -> 
                                                       //To Display Names
                      {
                              _ButtonClickNumber = 38;
                      }
              else if (e.Button.ToString() == "41")    // right Middle Watch Button -> 
                                                       // To Display Time
                      {
                              name1Xval = 6;
                              name2Xval = Bitmap.MaxWidth - 6;
                              name3Yval = Bitmap.MaxHeight - 10;
                              _ButtonClickNumber = 41;
                              showTime();
                      }
        else if (e.Button.ToString() == "40") // Right Bottom Watch Button -> 
                                              // To Display  Appointment
                      {
                              _ButtonClickNumber = 40;
                              showAppointment();
                      }
        else if (e.Button.ToString() == "37") // Left Top Watch Button -> 
                                              // To Display  Animation
                      {
                              _ButtonClickNumber = 37;

                              // To Start New Animation
                              cicked = false;
                              goals = false;
                              ballXval = 50;
                              ballYval = 90;

                              //Man Draw
                              manfaceXval = 10;
                              manfaceYval = 40;

                              leg1Xval = manfaceXval + 1;
                              leg1Yval = manfaceYval + 30;
                              leg1X1val = manfaceXval - 4;
                              leg1Y1val = manfaceYval + 54;

                              leg2Xval = manfaceXval + 1;
                              leg2Yval = manfaceYval + 30;
                              leg2X1val = manfaceXval + 4;
                              leg2Y1val = manfaceYval + 54;

                              showAnimation();
                      }
                      else if (e.Button.ToString() == "39") // Left Bottom Watch Button -> 
                                                            // To Display 
                      {
                             _ButtonClickNumber = 39;
                             secounds = 0;
                             Miniutes = 0;
                             secounds_str = "00";
                             Miniutes_str = "00";
                             spotWatch(); 
                      }
               }

In my program, I will be displaying Time, Text Animation and Simple football game animation using Timer. In timer event, I will check for each button up number and call the function.

C#
public void UpdateTime(object state)
              {
                     if (_ButtonClickNumber == 41)
                      {
                              showTime();
                      }
                      else if (_ButtonClickNumber == 38)
                      {
                              showName();
                      }
                      else if(_ButtonClickNumber == 37)
                      {
                              showAnimation();
                      }
                      else if(_ButtonClickNumber == 39)
                      {
                              spotWatch();
                      }
              }

showName(): In this method, I will be displaying simple text animation.

Image 19

In this method, I will be displaying simple text animation. I will display the text using DrawText method and using timer, I will move the text from left to right, right to left and from bottom to top.

C#
public void showName()
               {
                      _myFace.Clear();
                      Font font = Resources.GetFont(Resources.FontResources.shanuName);
                      _myFace.DrawRectangle(Color.White, 1, 0, 0, Bitmap.MaxWidth, 
                      Bitmap.MaxHeight, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

                      _myFace.DrawText(Resources.GetString(Resources.StringResources.Name1), 
                      font, Color.White, name1Xval, name1Yval);

                      if(name1Xval<= Bitmap.MaxWidth)
                      {
                              name1Xval = name1Xval + 4;
                      }
                      else
                      {
                              name1Xval = 6;
                      }

                      _myFace.DrawText(Resources.GetString(Resources.StringResources.Name2), 
                      font, Color.White, name2Xval, name2Yval);

                      if (name2Xval >= 0)
                      {
                              name2Xval = name2Xval - 4;
                      }
                      else
                      {
                              name2Xval = Bitmap.MaxWidth - 6;
                      }

                      _myFace.DrawText(Resources.GetString(Resources.StringResources.Name3), 
                      font, Color.White, name3Xval, name3Yval);

                      if (name3Yval >= 0)
                      {
                              name3Yval = name3Yval - 4;
                      }
                      else
                      {
                              name3Yval = Bitmap.MaxHeight-10;
                      }
                      _myFace.Flush();
               }

showTime(): In this method, I will be displaying Date and Time.

Image 20

In this method, I will be displaying today's Date and Time. Here, we can see that I have added two different custom fonts to display the date and time.

C#
public void showTime()
               {                  
                      _myFace.Clear();
                      Font font = Resources.GetFont(Resources.FontResources.shanuNumber);
                      Font fontS = Resources.GetFont(Resources.FontResources.shanuName);

                      _myFace.DrawRectangle(Color.White, 1, 0, 0, Bitmap.MaxWidth, 
                      Bitmap.MaxHeight, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

                      _myFace.DrawText(DateTime.Now.ToString("yyyy-MM-dd"), 
                                       fontS, Color.White, 4, 20);
                      _myFace.DrawText(DateTime.Now.ToString("yyyy-MM-dd"), 
                                       fontS, Color.Black, 4, 21);
                      _myFace.DrawText(DateTime.Now.ToString("yyyy-MM-dd"), 
                                       fontS, Color.White, 4, 22);

                      _myFace.DrawText(DateTime.Now.ToString("HH:mm:ss"), 
                                       font, Color.White, 2, 70);
                      _myFace.DrawText(DateTime.Now.ToString("HH:mm:ss"), 
                                       font, Color.Black, 2, 71);
                      _myFace.DrawText(DateTime.Now.ToString("HH:mm:ss"), 
                                       font, Color.White, 2, 72);
                      _myFace.Flush();
               }

showAppointment(): This method will have today's Plan Schedule for the user.

Image 21

In this method, I will be displaying today's Appointment for the user. First, I will be adding all of today's plan list in the Resource string like below:

Image 22

In the method from this resource file will display Today's plan one by one using DrawText method. I will also check for the current time with Appointment time. If current time is equal to Appointment time, then I will draw rectangle bar and line under text as alert to the user to indicate the user as its time to perform the current plan.

C#
public void showAppointment()
        {
               _myFace.Clear();
               Font fontB = Resources.GetFont(Resources.FontResources.NinaB);
               Font fonts = Resources.GetFont(Resources.FontResources.small);
               _myFace.DrawRectangle(Color.White, 1, 0, 0, Bitmap.MaxWidth,
               Bitmap.MaxHeight, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

               _myFace.DrawText(" Today's Plan", fontB, Color.White, 6, 6);
               //_myFace.DrawText("Todays Plan ", fontB, Color.White, 40, 6);
               _myFace.DrawLine(Color.White, 1, 6, 27, 120, 27);

               // to get the Current Hour
               string hours = "12";
               hours = (DateTime.Now.Hour % 12).ToString();

               //To display First Appointment
               string apt1 = Resources.GetString
                             (Resources.StringResources.Appointment1);
               string[] apt1Chk = apt1.Split(' ');
               if(apt1Chk[0]== hours)
         {
               _myFace.DrawRectangle(Color.White,2, 4, 36, 4, 4, 0, 0,
               Color.White, 0, 0, Color.White, 0, 0, 0);
                       _myFace.DrawLine(Color.White, 1, 20, 48, 70, 48);
               }
               _myFace.DrawText(apt1, fonts, Color.White, 14, 34);

               //To display Second Appointment
               string apt2 = Resources.GetString
                             (Resources.StringResources.Appointment2);
               string[] apt2Chk = apt2.Split(' ');

               if (apt2Chk[0] == hours)
               {
                       _myFace.DrawRectangle(Color.White, 2, 4, 56, 4, 4, 0, 0,
                       Color.White, 0, 0, Color.White, 0, 0, 0);
                       _myFace.DrawLine(Color.White, 1, 20, 64, 70, 64);
               }
               _myFace.DrawText(apt2, fonts, Color.White, 14, 52);

               //To display Third Appointment
               string apt3 = Resources.GetString
                             (Resources.StringResources.Appointment3);
               string[] apt3Chk = apt3.Split(' ');

               if (apt3Chk[0] == hours)
               {

                       _myFace.DrawRectangle(Color.White, 2, 4, 74, 4, 4, 0, 0,
                       Color.White, 0, 0, Color.White, 0, 0, 0);
                       _myFace.DrawLine(Color.White, 1, 20, 82, 70, 82);
               }
               _myFace.DrawText(apt3, fonts, Color.White, 14, 70);

               //To display Fourth Appointment
               string apt4 = Resources.GetString
                             (Resources.StringResources.Appointment4);
               string[] apt4Chk = apt4.Split(' ');

               if (apt4Chk[0] == hours)
               {
                   _myFace.DrawRectangle(Color.White, 2, 4, 92, 4, 4, 0, 0,
                   Color.White, 0, 0, Color.White, 0, 0, 0);
                       _myFace.DrawLine(Color.White, 1, 20, 102, 70, 102);
               }
               _myFace.DrawText(apt4, fonts, Color.White, 14, 88);

               //To display Fifth Appointment
               string apt5 = Resources.GetString
                             (Resources.StringResources.Appointment5);
               string[] apt5Chk = apt5.Split(' ');

               if (apt5Chk[0] == hours)
               {
                   _myFace.DrawRectangle(Color.White, 2, 4, 112, 4, 4, 0, 0,
                   Color.White, 0, 0, Color.White, 0, 0, 0);
                       _myFace.DrawLine(Color.White, 1, 20, 122, 70, 122);
               }
               _myFace.DrawText(apt5, fonts, Color.White, 14, 108);
               _myFace.Flush();
        }

showAnimation(): In this method, I will be showing a simple football game animation to the user.

Image 23

In this method, I will be drawing simple graphics to display simple animation to draw a player moving from left to right till he reaches the football and when he reaches the ball, he kicks the ball and stands in the same place. The ball will be moving slowly and reach the Goal Post. Once the ball reaches the goal post, I will display the text as Goal. This will be happening as a routine.

C#
public void showAnimation()
               {
                      _myFace.Clear();
                      Font font = Resources.GetFont(Resources.FontResources.shanuNumber);
                      _myFace.DrawRectangle(Color.White, 1, 0, 0, Bitmap.MaxWidth, 
                      Bitmap.MaxHeight, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

                      // Goal Point
                      _myFace.DrawRectangle(Color.White, 1, goalXVal, 0, goalXVal, 
                      goalYVal, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

                      // ball Draw
                      _myFace.DrawEllipse(Color.White, 6, ballXval, ballYval, 
                      2, 2, Color.White, 0, 0, Color.White, 0, 0, 0);            
                      _myFace.DrawEllipse(Color.White, manfaceXval, manfaceYval, 6, 6); //Face
                      _myFace.DrawLine(Color.White, 1, manfaceXval , manfaceYval +6,  
                      manfaceXval , manfaceYval+30); // Body

                      _myFace.DrawLine(Color.White, 1, manfaceXval + 1, manfaceYval + 16, 
                      manfaceXval - 4, manfaceYval + 22); //Hand 1
                      _myFace.DrawLine(Color.White, 1, manfaceXval + 1, manfaceYval + 20, 
                      manfaceXval + 4, manfaceYval + 22); //Hand 2
                      _myFace.DrawLine
                      (Color.White, 1, leg1Xval, leg1Yval, leg1X1val, leg1Y1val); //leg 1

                      _myFace.DrawLine
                      (Color.White, 1, leg2Xval, leg2Yval, leg2X1val, leg2Y1val); //leg 2
                      if (manfaceXval <= ballXval - 14)
                      {
                              if(cicked==false)
                              {
                              manfaceXval = manfaceXval + 8;
                              leg1Xval = leg1Xval + 8;
                              leg1X1val = leg1X1val + 8;
                              leg2Xval = leg2Xval + 8;
                              leg2X1val = leg2X1val + 8;
                              }
                      }      

                      if (manfaceXval >= ballXval - 14)
                      {
                              cicked = true;
                      }
                      if(cicked==true)
                      {
                              if(ballYval>= goalYVal)
                              {
                              ballXval = ballXval + 8;
                              ballYval = ballYval - 12;
                              }
                              else
                              {
                                     goals = true;                                   
                              }
                      }
                      if(goals==true)
                      {
                              _myFace.DrawText("Goal", font, Color.White, 40, 80);

                              ival = ival + 1;

                              if(ival>2)
                              {
                                     cicked = false;
                                     goals = false;
                                     ballXval = 50;
                                     ballYval = 90;

                                     //Man Draw
                                     manfaceXval = 10;
                                     manfaceYval = 40;

                                     leg1Xval = manfaceXval + 1;
                                     leg1Yval = manfaceYval + 30;
                                     leg1X1val = manfaceXval - 4;
                                     leg1Y1val = manfaceYval + 54;

                                     leg2Xval = manfaceXval + 1;
                                     leg2Yval = manfaceYval + 30;
                                     leg2X1val = manfaceXval + 4;
                                     leg2Y1val = manfaceYval + 54;
                              }
                      }
                      _myFace.Flush();
               }

spotWatch(): In this method, I will be showing a simple stopwatch.

Image 24

In this method, I will be displaying a simple Stopwatch with simple text animation. In this stopwatch, I will be displaying the counter value as Seconds and Minute.

C#
public void spotWatch()
               {
                      _myFace.Clear();
                      Font font = Resources.GetFont(Resources.FontResources.shanuNumber);
                      Font fontS = Resources.GetFont(Resources.FontResources.shanuName);
                      _myFace.DrawRectangle(Color.White, 1, 0, 0, Bitmap.MaxWidth, 
                      Bitmap.MaxHeight, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);

                      Font fonts = Resources.GetFont(Resources.FontResources.small);
                      _myFace.DrawText("StopWatch", fontS, Color.White, 14, 6);
                      _myFace.DrawLine(Color.White, 1,6, 24, 120, 24);

                      _myFace.DrawText(Miniutes_str + " : " + secounds_str, 
                                       font, Color.White, 12, 38);
                      _myFace.DrawText(Miniutes_str + " : " + secounds_str, 
                                       font, Color.White, 12, 39);
                      _myFace.DrawText(Miniutes_str + " : " + secounds_str, 
                                       font, Color.White, 12, 40);

                      _myFace.DrawLine(Color.White, 1, 6, 80, 120, 80);

                      _myFace.DrawText(Resources.GetString(Resources.StringResources.Name1), 
                                       fontS, Color.White, name1Xval-30, 92);

                      if (name1Xval <= Bitmap.MaxWidth)
                      {
                              name1Xval = name1Xval + 16;
                      }
                      else
                      {
                              name1Xval = 6;
                      }

                      _myFace.Flush();
                      if(secounds <= 59)
                      {
                              secounds = secounds + 1;
                              if (secounds<=9)
                              {
                                     secounds_str = "0" + secounds;
                      }
                              else
                              {
                                     secounds_str = secounds.ToString();
                              }                             
                      }
                      else
                      {
                              secounds = 0;
                              Miniutes = Miniutes + 1;                          
                      }
                      if (Miniutes <= 9)
                      {
                              Miniutes_str = "0" + Miniutes;
                      }
                      else
                      {
                              Miniutes_str = Miniutes.ToString();
                      }
               }

Points of Interest

Hope you like this and now have a clearer idea to start working with AGENT Smartwatch App development. Have fun! You can find both my All in one App for AGENT Smartwatch source file and another source folder for adding Image in AGENT Smartwatch.

History

  • 25th September, 2015: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
India India
Microsoft MVP | Code Project MVP | CSharp Corner MVP | Author | Blogger and always happy to Share what he knows to others. MyBlog

My Interview on Microsoft TechNet Wiki Ninja Link

Comments and Discussions

 
GeneralMy vote of 1 Pin
soulhuntre8-Oct-15 10:40
soulhuntre8-Oct-15 10:40 
QuestionGood Article Pin
Santhakumar M25-Sep-15 1:21
professionalSanthakumar M25-Sep-15 1:21 
AnswerRe: Good Article Pin
aarif moh shaikh27-Sep-15 19:38
professionalaarif moh shaikh27-Sep-15 19:38 
GeneralGood article - my vote up Pin
Gaurav Aroraa25-Sep-15 0:27
professionalGaurav Aroraa25-Sep-15 0:27 
QuestionGood and interesting article but whats the point? Pin
Petoj8724-Sep-15 22:53
Petoj8724-Sep-15 22:53 
AnswerRe: Good and interesting article but whats the point? Pin
Afzaal Ahmad Zeeshan25-Sep-15 7:46
professionalAfzaal Ahmad Zeeshan25-Sep-15 7:46 
AnswerRe: Good and interesting article but whats the point? Pin
themr2325-Sep-15 9:24
themr2325-Sep-15 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.