示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Create Beamerscreen
            _bscrw = new BeamerScreenWindow();
            _bscrw.Show();

            _bscrw.Closed += new EventHandler(_bscrw_Closed);
            _tablemanager = new TableManager(_bscrw.GetBeamerUC());

            //Add debug object
            ScreenCircle sc1 =
                new ScreenCircle(new ObjectTable.Code.Recognition.DataStructures.TPoint(500, 500,
                                                                                        ObjectTable.Code.Recognition.
                                                                                            DataStructures.TPoint.
                                                                                            PointCreationType.screen));
            sc1.SetColor(ScreenCircle.EColor.green);
            sc1.RotationSpeed = 10.0;

            ScreenCrosshair sch1 = new ScreenCrosshair(new ObjectTable.Code.Recognition.DataStructures.TPoint(200, 300,
                                                                                                              ObjectTable
                                                                                                                  .Code.
                                                                                                                  Recognition
                                                                                                                  .
                                                                                                                  DataStructures
                                                                                                                  .
                                                                                                                  TPoint
                                                                                                                  .
                                                                                                                  PointCreationType
                                                                                                                  .
                                                                                                                  screen));

            _tablemanager.DisplayManager.AddElement(sc1, ObjectTable.Code.Display.DisplayManager.DisplayLayer.top);
            _tablemanager.DisplayManager.AddElement(sch1, ObjectTable.Code.Display.DisplayManager.DisplayLayer.top);
            //Canvas.SetLeft(sch1, 450);
            //Canvas.SetTop(sch1, 150);
        }
        void _tableManager_OnNewObjectList()
        {
            //clear the surface
            _tableManager.DisplayManager.ClearScreen();
            //Create a crosshair for each new longTerm object on the surface
            foreach (TableObject obj in _tableManager.TableObjects.Where(obj => obj.TrackingStatus == TableObject.ETrackingStatus.LongTermTracked))
            {
                if (_drawCircles)
                {
                    ScreenCircle sc = null;
                    _tableManager.DisplayManager.WorkThreadSafe((Action)(() =>
                                                                              {
                                                                                  sc = new ScreenCircle(obj.Center);
                                                                                  sc.SetColor(ScreenCircle.EColor.blue);
                                                                                  sc.SetText(1, obj.ObjectID.ToString());
                                                                                  sc.SetText(2, obj.ObjectID.ToString());
                                                                                  sc.SetText(3, obj.ObjectID.ToString());
                                                                                  sc.SetText(4, obj.ObjectID.ToString());
                                                                              }), null);

                    _tableManager.DisplayManager.AddElement(sc, ObjectTable.Code.Display.DisplayManager.DisplayLayer.top);
                }
                else
                {
                    ScreenCrosshair sch = null;
                    _tableManager.DisplayManager.WorkThreadSafe((Action)(() => sch = new ScreenCrosshair(obj.Center)),null);
                    _tableManager.DisplayManager.AddElement(sch, ObjectTable.Code.Display.DisplayManager.DisplayLayer.top);
                }
            }
        }
        void _tableManager_OnNewLongTermObject(List<int> ObjectIDList)
        {
            if (!_drawCircles)
                return;
            foreach (int i in ObjectIDList)
            {
                //Create a new UI Element
                TableObject obj = _tableManager.TableObjects.Where(o => o.ObjectID == i).ToList()[0];

                ScreenCircle sc = null;
                _tableManager.DisplayManager.WorkThreadSafe((Action) (() =>
                                                                          {
                                                                              sc = new ScreenCircle(obj.Center);
                                                                              sc.SetColor(ScreenCircle.EColor.blue);
                                                                              sc.SetText(1, obj.ObjectID.ToString());
                                                                              sc.SetText(2, obj.ObjectID.ToString());
                                                                              sc.SetText(3, obj.ObjectID.ToString());
                                                                              sc.SetText(4, obj.ObjectID.ToString());
                                                                              sc.RotationSpeed = 40;
                                                                          }), null,false);

                _uiArray[obj.ObjectID] = sc;
                _tableManager.DisplayManager.AddElement(sc, ObjectTable.Code.Display.DisplayManager.DisplayLayer.top);
            }

            //For enhanced fun, check whether there are exactly 2 lto. if so, create a line between them
            /*if (_tableManager.TableObjects.Where(o2 => o2.TrackingStatus == TableObject.ETrackingStatus.LongTermTracked).Count() == 2)
            {
                CreateScreenline();
            }*/
        }