Exemplo n.º 1
0
 public IdleManager(SkeneClient client)
 {
     this.Client = client;
     idleTimer = new Stopwatch();
     idleThread = new Thread(new ThreadStart(IdleThread));
     idleThread.Start();
     idleState = false;
 }
Exemplo n.º 2
0
 public TargetInfo(string targetName, string linkedGazeTarget, SkeneClient skene)
 {
     Linked = true;
     LinkedTargetName = linkedGazeTarget;
     TargetName = targetName;
     this.skene = skene;
     if (Linked && skene != null && skene.Targets.ContainsKey(LinkedTargetName))
     {
         Coordinates = skene.Targets[LinkedTargetName].Coordinates;
         GazeTarget = skene.Targets[LinkedTargetName].GazeTarget;
     }
 }
Exemplo n.º 3
0
 public static void Save(string filename, SkeneClient bpc)
 {
     TargetsFile t = new TargetsFile();
     lock (bpc.Targets.Values)
     {
         t.Targets = new List<TargetInfo>(bpc.Targets.Values);
     }
     using (StreamWriter file = File.CreateText(filename))
     {
         JsonSerializer serializer = new JsonSerializer();
         serializer.Serialize(file, t);
     }
 }
Exemplo n.º 4
0
 public static void Load(string filename, SkeneClient skene)
 {
     using (StreamReader file = File.OpenText(filename))
     {
         JsonSerializer serializer = new JsonSerializer();
         TargetsFile f = (TargetsFile)serializer.Deserialize(file, typeof(TargetsFile));
         currentFileName = filename;
         foreach (TargetInfo t in f.Targets)
         {
             skene.Targets[t.TargetName.ToLower()] = t;
         }
     }
 }
Exemplo n.º 5
0
        public GazeManager(SkeneClient client)
        {
            this.SkeneClient = client;
            this.DefaultGazeSpeed = Properties.Settings.Default.DefaultGazeSpeed;
            client.ClickPointChanged+=Click;
            client.PersonVisibleChanged += PersonVisibleChanged;
            client.PersonGazeDirectionChanged+=PersonGazeDirectionChanged;
            client.PersonAngleChanged += HeadTracking;
            GazeState = GazeTarget.Random;

            gazeStateTimer = new System.Timers.Timer();
            gazeStateTimer.AutoReset = false;
            gazeStateTimer.Elapsed += gazeStateTimer_Elapsed;
        }
 public MainWindowController(MainWindow window, string characterName = "")
 {
     _window = window;
     refreshStopwatch = new Stopwatch();
     refreshStopwatch.Start();
     //if (_client != null && _client.IsConnected) _client.Dispose();
     _client = SkeneClient.GetInstance(characterName);
     _client.ClientConnected += delegate() { _window.StatusMessage("connected", System.Drawing.Color.Green); };
     _client.ClientDisconnected += delegate { _window.StatusMessage("NOT connected", System.Drawing.Color.Red); };
     _window.FormClosed += delegate (object sender, System.Windows.Forms.FormClosedEventArgs e){
         _client.Dispose();
     };
     _client.ClickPointChanged += (SkeneClient.ClickPointChangedHandler)((point) => _window.Invoke((MethodInvoker)(()=>_window.SetTrackingClickPoint(point))));
     _client.PersonAngleChanged += (SkeneClient.PersonAngleChangedHandler)((userId, angle) =>
     {
         if (refreshStopwatch.ElapsedMilliseconds > 1000)
         {
             _window.Invoke((MethodInvoker)(() => _window.SetTrackingPersonAngle(userId, angle)));
             refreshStopwatch.Restart();
         }
     });
     _client.ScreenPointChanged += (SkeneClient.ScreenPointChangedHandler)((point) => _window.Invoke((MethodInvoker)(() => _window.SetTrackingScreenAngle(point))));
 }
Exemplo n.º 7
0
 public SkenePublisher(dynamic publisher, SkeneClient skene)
 {
     this.publisher = publisher;
     this.skene = skene;
 }
Exemplo n.º 8
0
 public static SkeneClient GetInstance(string characterName = "")
 {
     return _instance ?? (_instance = new SkeneClient(characterName));
 }
Exemplo n.º 9
0
 public static void Save(SkeneClient bpc)
 {
     if (currentFileName != "") Save(currentFileName, bpc);
 }
Exemplo n.º 10
0
 public void Generate(SkeneClient bpc, TargetType target = TargetType.Gaze, bool dontPerform = false)
 {
     string realTargetName = TargetName;
     if (Linked && skene != null && skene.Targets.ContainsKey(LinkedTargetName))
     {
         realTargetName = skene.Targets[LinkedTargetName].TargetName;
         Coordinates = skene.Targets[LinkedTargetName].Coordinates;
         GazeTarget = skene.Targets[LinkedTargetName].GazeTarget;
     }
     switch (target)
     {
         case TargetType.Waving:
             if (GazeTarget == EmoteCommonMessages.GazeTarget.ScreenPoint)
             {
                 bpc.Debug("Generated WavingScreen {0} {1}", Coordinates.X, Coordinates.Y);
                 bpc.WaveAtScreen("", Coordinates.X, Coordinates.Y, 5, 4, 2);
             }
             else
             {
                 bpc.Debug("Generated WavingAngle {0} {1}", Coordinates.X, Coordinates.Y);
                 bpc.SkPublisher.Waving("", Coordinates.X, Coordinates.Y, 2, 10, 2);
             }
             break;
         case TargetType.Pointing:
             if (GazeTarget == EmoteCommonMessages.GazeTarget.ScreenPoint)
             {
                 bpc.Debug("Generated PointScreen {0} {1}", Coordinates.X, Coordinates.Y);
                 bpc.PointAtScreen("", Coordinates.X, Coordinates.Y);
             }
             else
             {
                 bpc.Debug("Generated PointAngle {0} {1}", Coordinates.X, Coordinates.Y);
                 bpc.SkPublisher.PointingAngle("", Coordinates.X, Coordinates.Y, 0.5, Coordinates.X < 0 ? Thalamus.Actions.PointingMode.LeftHand : Thalamus.Actions.PointingMode.RightHand);
             }
             break;
         case TargetType.Highlight:
             if (realTargetName != "")
             {
                 switch (realTargetName)
                 {
                     case "rightAnswer":
                         bpc.SkPublisher.HighlightRightAnswer();
                         break;
                 }
             }
             else
             {
                 bpc.Debug("Generated Highlight {0} {1}", Coordinates.X, Coordinates.Y);
                 bpc.SkPublisher.Highlight(Coordinates.X, Coordinates.Y);
             }
             break;
         case TargetType.Glance:
             if (GazeTarget == GazeTarget.ScreenPoint)
             {
                 bpc.Debug("Generated Glance Screen: " + Coordinates);
                 bpc.GazeManager.Glance(this);
             }
             else if (GazeTarget == GazeTarget.Angle)
             {
                 bpc.Debug("Generated Glance Angle: " + Coordinates);
                 bpc.GazeManager.Glance(this);
             }
             else
             {
                 bpc.Debug("Generated Glance: " + GazeTarget);
                 bpc.GazeManager.Glance(this);
             }
             break;
         case TargetType.Gaze:
         default:
             if (GazeTarget == GazeTarget.ScreenPoint)
             {
                 bpc.Debug("Generated Gaze Screen: " + Coordinates);
                 bpc.GazeManager.Gaze(new TargetInfo(Coordinates), dontPerform);
             }
             else if (GazeTarget == GazeTarget.Angle)
             {
                 bpc.Debug("Generated Gaze Angle: " + Coordinates);
                 bpc.GazeManager.Gaze(new TargetInfo(Coordinates, "", EmoteCommonMessages.GazeTarget.Angle), dontPerform);
             }
             else
             {
                 bpc.Debug("Generated Gaze: " + GazeTarget);
                 bpc.GazeManager.Gaze(GazeTarget, dontPerform);
             }
             break;
     }
 }