Please help me out.
Unable to remove this error from my application x-(
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.MultiPoint.CommonTypes;
using Microsoft.MultiPoint.MousePlugIn;
using Microsoft.MultiPoint.Controls;
using System.Drawing;
using System.Media;
using Microsoft.MultiPoint.SDK;
namespace InfernoMT
{
/// <summary>
/// Interaction logic for Window3.xaml
/// </summary>
public partial class girl_intro_H : Window
{
public girl_intro_H()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void girl_intro_ended(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
Intro_living_H window = new Intro_living_H();
window.Show();
this.Close();
}
private void girl_intro_H_loaded(object sender, RoutedEventArgs e)
{
MultiPointSDK.Instance.Initialize(this);
this.KeyDown += new KeyEventHandler(end_keydown);
MultiPointSDK.Instance.DeviceArrivalEvent += new EventHandler<DeviceNotifyEventArgs>(MultiPointObject_DeviceArrivalEvent);
for (int i = 0; i < MultiPointSDK.Instance.MouseDeviceList.Count; i++)
{
// Act on each individual MouseDevice here
DeviceInfo mouseObject = (DeviceInfo)MultiPointSDK.Instance.MouseDeviceList[i];
MultiPointMouseDevice mpMouseDevice = (MultiPointMouseDevice)mouseObject.DeviceVisual;
mpMouseDevice.CursorImage =
**********************************************************************
EXCEPTION HERE
ConvertBitmapToBitmapImage(GetCursorImage(i)); GOT AN ERROR HERE
}
**********************************************************************
MultiPointSDK.Instance.DeviceRemoveCompleteEvent += new EventHandler<DeviceNotifyEventArgs>(this.MultiPointObject_DeviceRemoveCompleteEvent);
EnforceMouseLimit(4);
}
private void MultiPointObject_DeviceArrivalEvent(object sender, DeviceNotifyEventArgs e)
{
// add code to handle the arrival of the device here
if (e.DeviceInfo.DeviceType == DeviceType.Mouse)
{
DeviceInfo mouseObject = e.DeviceInfo;
MultiPointMouseDevice mpMouseDevice = (MultiPointMouseDevice)mouseObject.DeviceVisual;
Bitmap cursorBitmap = GetCursorImage(MultiPointSDK.Instance.MouseDeviceList.Count);
mpMouseDevice.CursorImage = ConvertBitmapToBitmapImage(cursorBitmap);
}
}
private Bitmap GetCursorImage(int id)
{
switch (id)
{
case 0:
return Properties.Resources.boy_01;
case 1:
return Properties.Resources.boy_06;
case 2:
return Properties.Resources.boy_08;
case 3:
return Properties.Resources.girl_02;
default:
return Properties.Resources.girl_02;
}
}
private void EnforceMouseLimit(int max)
{
// Too many mice - disable extras
if (MultiPointSDK.Instance.MouseDeviceList.Count > max)
{
// Disable extra mice.
for (int i = max;
i < MultiPointSDK.Instance.MouseDeviceList.Count;
i++)
{
DeviceInfo mouseObject =
(DeviceInfo)MultiPointSDK.Instance.MouseDeviceList[i];
MultiPointMouseDevice mpMouseDevice =
(MultiPointMouseDevice)mouseObject.DeviceVisual;
mpMouseDevice.Visible = false;
}
}
}
private void MultiPointObject_DeviceRemoveCompleteEvent(object sender, DeviceNotifyEventArgs e)
{
// Ensure that the device that was unplugged was a mouse device
if (e.DeviceInfo.DeviceType == DeviceType.Mouse)
{
if (MultiPointSDK.Instance.MouseDeviceList.Count < 3)
{
MessageBox.Show("Please connect 4 mice and restart the application");
App.Current.Shutdown();
}
}
}
public static BitmapImage ConvertBitmapToBitmapImage(System.Drawing.Bitmap b)
{
BitmapImage bmpimg = new BitmapImage();
System.IO.MemoryStream memStream =
new System.IO.MemoryStream();
bmpimg.BeginInit();
b.MakeTransparent(System.Drawing.Color.White);
b.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
bmpimg.StreamSource = memStream;
bmpimg.EndInit();
return bmpimg;
}
private void end_keydown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
App.Current.Shutdown();
}
}
}
}