Пример #1
0
        public void videoCaptureThread()
        {
            capturing = true;
            if (startCapture(filename) != 0)
            {
                Console.WriteLine("Failed to start video capture");
            }
            imageData = new byte[921654];
            Thread.Sleep(100);
            MemoryStream ms;
            BitmapImage  bitmapImage;

            while (capturing)
            {
                _uiThreadDispatcher.BlockingInvoke(() =>
                {
                    getImage(imageData);
                    ms          = new MemoryStream(imageData);
                    bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms;
                    bitmapImage.EndInit();
                    story.captureImage.Source = bitmapImage;
                });
                Thread.Sleep(35);
            }
        }
Пример #2
0
        private void SetUpGame(IUIThreadDispatcher uiThreadDispatcher)
        {
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game.SetItUp();
                game.AgentCardsController.AutoPlay = false;
                game.GameState.MoveHappened       += m =>
                {
                    if (m.Player == Player.One &&
                        (!(m is DrawMove)))
                    {
                        _remote.Send("rummy.human_move"
                                     , getMoveAsJson(m));
                        game.GameState.CheckForWinnerInTheMiddleOfTurns();
                    }
                };

                game.GameState.StateChanged += (oldState, newState) =>
                {
                    _remote.Send("rummy.game_state", getGameStateAsJson());
                };

                game.AgentCardsController.CanPlay += (s, e) =>
                {
                    //here, sending all the possible moves to Java
                    _remote.Send("rummy.available_moves", getPossibleMovesAsJson());
                };
                game.GameState.GameOver += p =>
                {
                    _remote.Send("rummy.gameover", getPlayerAsJson(p));
                };
            });
        }
Пример #3
0
        public RummyPlugin(bool agentStarts, IMessageDispatcher remote
                           , IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote = remote;
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game                  = new GameShape();
                pluginContainer       = new Viewbox();
                pluginContainer.Child = game;
            });

            _remote.RegisterReceiveHandler("rummy.agent_move",
                                           new MessageHandlerDelegateWrapper(x => PlayAgentMove(x)));

            _remote.RegisterReceiveHandler("rummy.playability",
                                           new MessageHandlerDelegateWrapper(x => SetPlayability(x)));

            _remote.RegisterReceiveHandler("rummy.setupgame",
                                           new MessageHandlerDelegateWrapper(x => SetUpGame(uiThreadDispatcher)));

            _remote.RegisterReceiveHandler("rummy.starting_player",
                                           new MessageHandlerDelegateWrapper(x => SetStartingPlayer(x)));

            _remote.RegisterReceiveHandler("rummy.reset",
                                           new MessageHandlerDelegateWrapper(x => Reset(uiThreadDispatcher)));
        }
Пример #4
0
 public void ResetGame(IUIThreadDispatcher uiThreadDispatcher)
 {
     uiThreadDispatcher.BlockingInvoke(() =>
     {
         this.grdBoard.Children.Clear();
         this.Reset();
     });
 }
Пример #5
0
 private void display(JObject m)
 {
     lock (displayLock)
     {
         _uiThreadDispatcher.BlockingInvoke(() =>
         {
             string name = "", age = "", gender = "", relationship = "",
             zipcode     = "", spouse = "", skype = "", bd = "";
             if (m["name"] != null)
             {
                 name = m["name"].ToString().Trim();
             }
             if (m["age"] != null)
             {
                 if (m["age"].ToString() != "0")
                 {
                     age = m["age"].ToString().Trim();
                 }
             }
             if (m["gender"] != null)
             {
                 gender = m["gender"].ToString().Trim();
             }
             if (m["relationship"] != null)
             {
                 relationship = m["relationship"].ToString().Trim();
             }
             if (m["zipcode"] != null)
             {
                 if (m["zipcode"].ToString() != "0")
                 {
                     zipcode = m["zipcode"].ToString().Trim();
                 }
             }
             if (m["spouse"] != null)
             {
                 spouse = m["spouse"].ToString().Trim();
             }
             if (m["skypeAccount"] != null)
             {
                 skype = m["skypeAccount"].ToString().Trim();
             }
             if (m["birthday"] != null)
             {
                 bd = m["birthday"].ToString().Trim();
             }
             enrollEntryPanel.label10.Content = name;
             enrollEntryPanel.label11.Content = age;
             enrollEntryPanel.label12.Content = gender;
             enrollEntryPanel.label13.Content = relationship;
             enrollEntryPanel.label15.Content = zipcode;
             enrollEntryPanel.label16.Content = spouse;
             enrollEntryPanel.label18.Content = skype;
             enrollEntryPanel.label14.Content = bd;
         });
     }
 }
Пример #6
0
        private void Reset(IUIThreadDispatcher uiThreadDispatcher)
        {
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game = new GameShape();
                pluginContainer.Child = game;
            });

            currentMoveSuggestions.Clear();
        }
Пример #7
0
 public SoftKeyboardPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher, string contextString, bool isNumeric)
 {
     this._remote             = remote;
     this._uiThreadDispatcher = uiThreadDispatcher;
     uiThreadDispatcher.BlockingInvoke(() =>
     {
         keyboard              = new KeyboardPanel(contextString, remote, isNumeric);
         pluginContainer       = new Viewbox();
         pluginContainer.Child = keyboard;
     });
 }
Пример #8
0
 public StoryPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
 {
     this._remote             = remote;
     this._uiThreadDispatcher = uiThreadDispatcher;
     uiThreadDispatcher.BlockingInvoke(() =>
     {
         story                 = new StoryPage();
         pluginContainer       = new Viewbox();
         pluginContainer.Child = story;
     });
     _remote.RegisterReceiveHandler("story.stopRecording",
                                    new MessageHandlerDelegateWrapper(m => endVideoCapture()));
     _remote.RegisterReceiveHandler("story.startRecording",
                                    new MessageHandlerDelegateWrapper(m => startVideoCapture(m)));
 }
Пример #9
0
        public EnrollPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote             = remote;
            this._uiThreadDispatcher = uiThreadDispatcher;
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                enrollEntryPanel = new EnrollEntryPanel();
                //Example pluginContainer code
                pluginContainer       = new Viewbox();
                pluginContainer.Child = enrollEntryPanel;
                //End of example
            });

            _remote.RegisterReceiveHandler("enroll.display",
                                           new MessageHandlerDelegateWrapper(m => display(m)));
        }
Пример #10
0
        public CalendarPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote             = remote;
            this._uiThreadDispatcher = uiThreadDispatcher;
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                calendar = new CalendarPanel();
                calendar.EventSelected += entrySelected;
                calendar.DaySelected   += daySelected;

                calendar.getMonthPanel().NumRows = 4;
                pluginContainer       = new Viewbox();
                pluginContainer.Child = calendar;
            });

            _remote.RegisterReceiveHandler("calendar.display",
                                           new MessageHandlerDelegateWrapper(m => display(m)));
        }
Пример #11
0
        public StoryPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote             = remote;
            this._uiThreadDispatcher = uiThreadDispatcher;
            uiThreadDispatcher.BlockingInvoke(() =>
            {
                story                 = new StoryPage();
                pluginContainer       = new Viewbox();
                pluginContainer.Child = story;
            });
            _remote.RegisterReceiveHandler("story.stopRecording",
                                           new MessageHandlerDelegateWrapper(m => endVideoCapture()));
            _remote.RegisterReceiveHandler("story.startRecording",
                                           new MessageHandlerDelegateWrapper(m => startVideoCapture(m)));
            _remote.RegisterReceiveHandler("story.saveRecording",
                                           new MessageHandlerDelegateWrapper(m => saveRecording(m)));

            foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video))
            {
                //Debug.WriteLine("found a video deviced named: " + edv.Name);
                videoDevice = edv;
            }
            foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Audio))
            {
                //Debug.WriteLine("found a audio deviced named: " + edv.Name);
                if (edv.Name.ToLower().Contains("microphone"))
                {
                    audioDevice = edv;
                }
            }

            story.SizeChanged += new System.Windows.SizeChangedEventHandler(story_SizeChanged);
            job = new LiveJob();


            if (!System.IO.Directory.Exists("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\"))
            {
                System.IO.Directory.CreateDirectory("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\");
            }

            fileOut = new FileArchivePublishFormat();
            fileOut.OutputFileName = "C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\tempVideo.wmv";
            System.Console.WriteLine(fileOut.OutputFileName);
        }
Пример #12
0
        public CheckersPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote             = remote;
            this._uiThreadDispatcher = uiThreadDispatcher;

            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game             = new GameShape();
                game.UserPlayed += (s, e) =>
                {
                    JObject body      = new JObject();
                    body["humanMove"] = ((CheckerEventArg)e).moveDesc;
                    _remote.Send("checkers.human_played_move", body);
                };
                game.UserTouchedAgentChecker += (s, e) =>
                {
                    JObject body    = new JObject();
                    body["howMany"] =
                        ((UserTouchedAgentStuffEventArg)e).howManyTimes;
                    _remote.Send("checkers.touched_agent_piece", body);
                };
                pluginContainer       = new Viewbox();
                pluginContainer.Child = game;
                game.MakeTheBoardUnplayable();
            });

            _remote.RegisterReceiveHandler("checkers.agent_move",
                                           new MessageHandlerDelegateWrapper(x => PlayAgentMove(x)));

            _remote.RegisterReceiveHandler("checkers.reset",
                                           new MessageHandlerDelegateWrapper(x => game.ResetGame(_uiThreadDispatcher)));

            _remote.RegisterReceiveHandler("checkers.confirm_human_move",
                                           new MessageHandlerDelegateWrapper(x => game.ReceivedConfirmation()));

            _remote.RegisterReceiveHandler("checkers.playability",
                                           new MessageHandlerDelegateWrapper(x => SetPlayability(x)));
        }
Пример #13
0
        public TTTPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher)
        {
            this._remote             = remote;
            this._uiThreadDispatcher = uiThreadDispatcher;

            uiThreadDispatcher.BlockingInvoke(() =>
            {
                game         = new GameShape();
                game.Played += (s, e) =>
                {
                    JObject body    = new JObject();
                    body["cellNum"] = ((cellEventArg)e).cellNum;
                    _remote.Send("tictactoe.human_played_cell", body);
                };
                pluginContainer       = new Viewbox();
                pluginContainer.Child = game;
            });

            _remote.RegisterReceiveHandler("tictactoe.agent_cell",
                                           new MessageHandlerDelegateWrapper(x => PlayAgentMove(x)));

            _remote.RegisterReceiveHandler("tictactoe.playability",
                                           new MessageHandlerDelegateWrapper(x => SetPlayability(x)));
        }
Пример #14
0
        private void display(JObject m)
        {
            lock (displayLock)
            {
                _uiThreadDispatcher.BlockingInvoke(() =>
                {
                    calendar.getDayPanel().Visibility   = System.Windows.Visibility.Collapsed;
                    calendar.getWeekPanel().Visibility  = System.Windows.Visibility.Collapsed;
                    calendar.getMonthPanel().Visibility = System.Windows.Visibility.Collapsed;

                    if (m["type"].ToString().Equals("day"))
                    {
                        calendar.getDayPanel().Date = m["label"].ToString();

                        JObject data = (JObject)m["dayData"];
                        calendar.getDayPanel().IsToday     = (bool)data["isToday"];
                        calendar.getDayPanel().IsTouchable = (bool)data["isTouchable"];
                        JArray eventData = (JArray)data["entries"];
                        Entry[] events   = new Entry[eventData.Count];
                        for (int j = 0; j < eventData.Count; ++j)
                        {
                            events[j] = asEvent((JObject)eventData.ElementAt(j));
                        }
                        calendar.getDayPanel().setEvents(events);
                        calendar.getDayPanel().Visibility = System.Windows.Visibility.Visible;
                    }
                    else if (m["type"].ToString().Equals("week"))
                    {
                        calendar.getWeekPanel().clearBorders();
                        calendar.getWeekPanel().WeekLabel = m["weekLabel"].ToString();
                        JArray dayData = (JArray)m["dayData"];
                        for (int i = 0; i < dayData.Count; ++i)
                        {
                            JObject data     = (JObject)dayData[i];
                            string date      = data["date"].ToString();
                            JArray eventData = (JArray)data["entries"];
                            Entry[] events   = new Entry[eventData.Count];
                            for (int j = 0; j < eventData.Count; ++j)
                            {
                                events[j] = asEvent((JObject)eventData.ElementAt(j));
                            }
                            calendar.getWeekPanel().setDay(i, date, (bool)data["isToday"], (bool)data["isTouchable"], events);
                        }
                        calendar.getWeekPanel().Visibility = System.Windows.Visibility.Visible;
                    }
                    else if (m["type"].ToString().Equals("month"))
                    {
                        calendar.getMonthPanel().MonthLabel = m["monthLabel"].ToString();
                        calendar.getMonthPanel().NumRows    = (int)m["numRows"];

                        JArray dayLabelsData = (JArray)m["dayLabels"];
                        string[] dayLabels   = new string[dayLabelsData.Count];
                        for (int i = 0; i < dayLabels.Count(); ++i)
                        {
                            dayLabels[i] = (string)dayLabelsData.ElementAt(i);
                        }
                        calendar.getMonthPanel().setDayLabels(dayLabels);

                        JArray dayData = (JArray)m["dayData"];
                        Day[] days     = new Day[dayData.Count];
                        for (int i = 0; i < dayData.Count; ++i)
                        {
                            days[i] = asDay((JObject)dayData.ElementAt(i));
                        }
                        calendar.getMonthPanel().setDays(days);
                        calendar.getMonthPanel().Visibility = System.Windows.Visibility.Visible;
                    }
                });
            }
        }