Esempio n. 1
0
        public MenuGfxMgr(TableManager tmgr)
        {
            _objectList = new List<MenuObject>();

            //Fill object List
            List<Type> typelist = GetSimObjectTypes();
            foreach(Type tp in typelist)
            {
                try
                {
                    object o = Activator.CreateInstance(tp);
                    SimulationObject so = o as SimulationObject;
                    MenuObject mo = new MenuObject();
                    mo.name = so.Name;
                    mo.category = so.Category;
                    mo.shortsign = so.ShortSign;
                    mo.type = tp;
                    _objectList.Add(mo);
                }
                catch (Exception)
                {

                }
            }

            //AssignTableManager
            _tableManager = tmgr;
            _tableManager.OnNewObjectList += new TableManager.TableManagerObjectHandler(_tableManager_OnNewObjectList);
            //Create graphical menu
            _tableManager.DisplayManager.WorkThreadSafe((Action) (() =>
                                                                      {
                                                                          _gfxMenu = new GUI.Table.Menu.Menu();
                                                                          _tableManager.DisplayManager.AddElement(
                                                                              _gfxMenu,
                                                                              ObjectTable.Code.Display.DisplayManager.
                                                                                  DisplayLayer.bottom);
                                                                          Canvas.SetLeft(_gfxMenu, 0);
                                                                          Canvas.SetTop(_gfxMenu, 50);
                                                                          //Get Regions
                                                                          GetRegions(out _b4, out _b3, out _b2, out _b1);
                                                                      }), null,false);
            UpdateMenuGUI();

            //init Scrolltimer
            _menuScrollTimer = new Timer();
            _menuScrollTimer.Interval = 500;
            _menuScrollTimer.Elapsed += new ElapsedEventHandler(_menuScrollTimer_Elapsed);
            //timer is initialized when the first tableObjects are recognized
        }
Esempio n. 2
0
        private void UpdateMenuGUI()
        {
            //Fill the menu according to the index
            MenuObject i1 = null, i2= null, i3=null, i4=null;

            //Special case: less than 5 items
            if (_objectList.Count < 4)
            {
                if (_objectList.Count == 0)
                {
                    i1 = new MenuObject();
                    i2 = new MenuObject();
                    i3 = new MenuObject();
                    i4 = new MenuObject();
                }
                else if (_objectList.Count < 2)
                {
                    i1 = _objectList[_index];
                    i2 = new MenuObject();
                    i3 = new MenuObject();
                    i4 = new MenuObject();
                }
                else if (_objectList.Count < 3)
                {
                    i1 = _objectList[_index];
                    i2 = _objectList[_index + 1];
                    i3 = new MenuObject();
                    i4 = new MenuObject();
                }
                else if (_objectList.Count < 4)
                {
                    i1 = _objectList[_index];
                    i2 = _objectList[_index + 1];
                    i3 = _objectList[_index + 2];
                    i4 = new MenuObject();
                }
            }
            else
            {
                //More than 4 items
                i1 = _objectList[_index];
                i2 = _objectList[_index + 1];
                i3 = _objectList[_index + 2];
                i4 = _objectList[_index + 3];
            }

            //Now fill the items
            _tableManager.DisplayManager.WorkThreadSafe((Action) (() => _gfxMenu.SetElements(new MenuObject[]
                                                                                                 {i1, i2, i3, i4})), null);
        }
Esempio n. 3
0
 public void SetElements(MenuObject[] obj)
 {
     mi1.SetInfo(obj[0].name, obj[0].category, obj[0].shortsign);
     mi2.SetInfo(obj[1].name, obj[1].category, obj[1].shortsign);
     mi3.SetInfo(obj[2].name, obj[2].category, obj[2].shortsign);
     mi4.SetInfo(obj[3].name, obj[3].category, obj[3].shortsign);
 }