示例#1
0
        //[TestMethod]
        public void TestMethod1()
        {
            MSEMultiSurface mse = new MSEMultiSurface(30,20, false);
            mse.Start();

            Console.WriteLine("Sleeping for 10s after starting MSE");
            Thread.Sleep(10000);

            IAIntAirAct intAirAct = IAIntAirAct.New();
            intAirAct.Port = 3456;
            intAirAct.Route(Routes.GetAllDeviceInfoRoute, delegate(IARequest request, IAResponse response)
            {
                response.SetBodyWithString("[{\"identifier\": \"SENG10(2)\", \"orientation\": 30,\"location\": \"30.0, 40.0\",\"isComplete\": true}]");

            });

            intAirAct.Start();

            //Wait for them to find each other
            Console.WriteLine("Sleeping for 10s after starting IntAirAct server");
            Thread.Sleep(10000);

            mse.Locator.GetDevicesInSystem(delegate(List<MSEDevice> devices)
            {
                Console.WriteLine(devices);

            }, delegate(Exception error)
            {

            });

            Console.WriteLine("Sleeping for 5m");
            Thread.Sleep(300000);

            Console.WriteLine("Done");
        }
示例#2
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            mseMultiSurface = new MSEMultiSurface(30.0, 30.0, false);

            mseMultiSurface.Ready += new MSEMultiSurface.MSEOnReadyHandler(mseMultiSurface_Ready);

            mseMultiSurface.AddReceivedDictionaryHandler(delegate(Dictionary<string, string> dictionary, String dictionaryType, MSEDevice originDevice, MSEGesture originGesture)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DataTextBlock.Text += "Key\t\tValue\n\n";

                    foreach (KeyValuePair<string, string> pair in dictionary)
                    {
                        DataTextBlock.Text += pair.Key + "\t" + pair.Value + "\n";
                    }

                    DataTextBlock.Text += "\n";

                }));

            });

            mseMultiSurface.ReceivedDataHandlers.Add(delegate(byte[] data, MSEDevice originDevice, MSEGesture originGesture)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DataTextBlock.Text += System.Text.Encoding.ASCII.GetString(data) + "\n\n";
                }));

            });

            mseMultiSurface.ReceivedImageHandlers.Add(delegate(System.Drawing.Image image, String imageName, MSEDevice originDevice, MSEGesture originGesture)
            {

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    OutputImage.Source = Util.ConvertFromImageToBitmap(image);

                }));

            });

            mseMultiSurface.IntAirAct.DeviceFound += delegate(IntAirAct.IADevice device, bool ownDevice) {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "Found " + device.Name.ToString() + "\n";
                }));
            };

            mseMultiSurface.IntAirAct.DeviceLost += delegate(IntAirAct.IADevice device)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "Lost " + device.Name.ToString() + "\n";
                }));
            };

            mseMultiSurface.Ready += delegate(MSEDevice ownDevice) {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "MSE API Ready. Identifier - " + ownDevice.Identifier + "\n";
                }));
            };

            mseMultiSurface.Start();
        }