Пример #1
0
 public void RoundComplete(Round r)
 {
     if (RoundCompleted != null)
     {
         RoundCompleted(this, r);
     }
 }
Пример #2
0
        public MainWindow()
        {
            rounds = new Dictionary<Round.RoundId, Round>()
            {
                { Round.RoundId.PAPER_DIVERGE, new Round(Round.RoundId.PAPER_DIVERGE, 1, Properties.Settings.Default.Round_1_Time, Properties.Settings.Default.Round_1_Instructions) },
                { Round.RoundId.PAPER_CONVERGE, new Round(Round.RoundId.PAPER_CONVERGE, 2, Properties.Settings.Default.Round_2_Time, Properties.Settings.Default.Round_2_Instructions) },
                { Round.RoundId.PAPER_TRANSCEND, new Round(Round.RoundId.PAPER_TRANSCEND, 3, Properties.Settings.Default.Round_3_Time, Properties.Settings.Default.Round_3_Instructions) },
                { Round.RoundId.VIDEO_BROWSE, new Round(Round.RoundId.VIDEO_BROWSE, 4, Properties.Settings.Default.Round_4_Time, Properties.Settings.Default.Round_4_Instructions) },
                { Round.RoundId.RESEARCH_QUESTION, new Round(Round.RoundId.RESEARCH_QUESTION, 0, TimeSpan.Zero, "") },
                { Round.RoundId.VIDEO_DIVERGE, new Round(Round.RoundId.VIDEO_DIVERGE, 5, Properties.Settings.Default.Round_5_Time, Properties.Settings.Default.Round_5_Instructions) },
                { Round.RoundId.VIDEO_CONVERGE, new Round(Round.RoundId.VIDEO_CONVERGE, 6, Properties.Settings.Default.Round_6_Time, Properties.Settings.Default.Round_6_Instructions) },
                { Round.RoundId.COMPLETE, new Round(Round.RoundId.COMPLETE, 0, new TimeSpan(), Properties.Settings.Default.Complete_Instructions) }
            };

            currentRound = rounds[Round.RoundId.PAPER_DIVERGE];
            tablets = new Dictionary<int, ICallbackContract>();
            roundInProgress = false;
            gameStarted = false;
            camera = new CameraCapture();
            presses = new List<Press>();
            lastPercentageUpdate = DateTime.UtcNow;
            fileDownloadService = new FileDownloadService();
            researchQuestionSet = false;

            panopticonProcessor = new PanopticonProcessor();
            panopticonProcessor.PercentageChanged += new PanopticonProcessor.PercentageChangedEventHandler(panopticonProcessor_PercentageChanged);
            panopticonProcessor.ProcessingCompleted += new PanopticonProcessor.ProcessingCompletedEventHandler(panopticonProcessor_ProcessingCompleted);
            panopticonProcessor.ProcessingFailed += new PanopticonProcessor.ProcessingFailedEventHandler(panopticonProcessor_ProcessingFailed);

            NetTcpBinding serviceBinding = new NetTcpBinding(SecurityMode.None);
            serviceBinding.ReceiveTimeout = TimeSpan.MaxValue;
            serviceBinding.SendTimeout = TimeSpan.MaxValue;
            serviceHost = new ServiceHost(this);
            serviceHost.AddServiceEndpoint(typeof(ITableService), serviceBinding, "net.tcp://localhost:8010");
            serviceHost.Open();

            Loaded += new RoutedEventHandler(MainWindow_Loaded);

            InitializeComponent();
        }
Пример #3
0
        public void RoundComplete(Round r)
        {
            try
            {
                if (r.Id == Round.RoundId.PAPER_TRANSCEND)
                {
                    StartPanopticonProcessing();
                }

                int i = (int)(r.Id + 1);
                Round.RoundId newId = (Round.RoundId)(i % Round.NUM_ROUNDS);

                if (newId != currentRound.Id)
                {
                    currentRound = rounds[newId];
                    roundInProgress = false;

                    bool restart = false;
                    switch (currentRound.Id)
                    {
                        case Round.RoundId.VIDEO_BROWSE:
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                Tabletop.VideoFile = camera.VideoFileName;
                                Tabletop.Presses = presses;
                                Tabletop.Visibility = Visibility.Visible;
                                Screensaver.Visibility = Visibility.Hidden;
                            }));
                            break;
                        case Round.RoundId.COMPLETE:
                            restart = true;
                            break;
                    }

                    tablets.AsParallel().ForAll((kvp) =>
                    {
                        try
                        {
                            kvp.Value.SetRound(currentRound);
                        }
                        catch (CommunicationObjectAbortedException)
                        {
                        }
                    });

                    if (restart)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Disconnect();
                            App.Restart();
                        }));
                    }
                }
            }
            catch (Exception e)
            {
                throw new FaultException(new FaultReason(e.Message + "\r\n" + e.StackTrace));
            }
        }
Пример #4
0
        public void SetRound(Round r)
        {
            this.currentRound = r;
            HideAll();

            switch (r.Id)
            {
                case Round.RoundId.PAPER_DIVERGE:
                case Round.RoundId.PAPER_CONVERGE:
                case Round.RoundId.PAPER_TRANSCEND:
                    Stage1Control.Visibility = Visibility.Visible;
                    Stage1Control.Round = r;
                    break;
                case Round.RoundId.VIDEO_BROWSE:
                case Round.RoundId.RESEARCH_QUESTION:
                case Round.RoundId.VIDEO_DIVERGE:
                case Round.RoundId.VIDEO_CONVERGE:
                    Stage2Control.Visibility = Visibility.Visible;
                    Stage2Control.PanopticonVideoState = panopticonState;
                    Stage2Control.PanopticonPercentage = panopticonPercentage;
                    Stage2Control.Round = r;

                    if (panopticonState == Stage2UI.PanopticonState.PROCESSING)
                    {
                        Thread t = new Thread(() =>
                        {
                            if (proxy.IsPanopticonProcessingComplete())
                            {
                                DownloadData();
                            }
                        });
                        t.Start();
                    }
                    break;
                case Round.RoundId.COMPLETE:
                    App.Restart();
                    break;
            }
        }