示例#1
0
        public IActionResult SubmitAdd(string obj)
        {
            MMenu  obj_   = new MMenu();
            string errMsg = Validate(obj, ref obj_);

            if (errMsg == "")
            {
                obj_.ID = obj_.ID.ToUpper();
                bool isDuplicate = mmgr.CheckIsExist(obj_.ID, ref errMsg);
                if (errMsg == "")
                {
                    errMsg = isDuplicate ? "Data Already Exist" : "";
                }
                else
                {
                    _logger.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }

            if (errMsg == "")
            {
                errMsg = mmgr.Add(obj_);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    _logger.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }

            return(Z_Result.SetResult(errMsg));
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Root = GameRoot.Instance;
            this.Canvas1.Scene = Root;

            Application.Current.Exit += Current_Exit;
            //MenuManager.CurrentChanged += MenuManager_CurrentChanged;

            MenuManager.Register(MenuType.Profiles, ScreenProfiles);
            MenuManager.Register(MenuType.Main, ScreenMain);
            MenuManager.Register(MenuType.Controls, ScreenControls);
            MenuManager.Register(MenuType.Highscores, ScreenHighscores);
            MenuManager.Register(MenuType.Options, ScreenOptions);
            MenuManager.Register(MenuType.Help, ScreenHelp);
            MenuManager.Register(MenuType.HUD, ScreenHUD);
            MenuManager.Register(MenuType.Pause, ScreenPause);
            MenuManager.Register(MenuType.GameOver, ScreenGameOver);

            MenuManager.Add(MenuType.Profiles);

            Profiles.CurrentChanged += Instance_CurrentChanged;

            Sounds.Music.Play();
        }
示例#3
0
        public void Stop()
        {
            isRunning = false;

            Sounds.Jet.Stop();
            MenuManager.Clear();
            MenuManager.Add(MenuType.Pause);
        }
示例#4
0
        public void Resume()
        {
            isRunning = true;
            Last      = DateTime.Now;

            MenuManager.Clear();
            MenuManager.Add(MenuType.HUD);
        }
示例#5
0
        public void Start()
        {
            Last      = DateTime.Now;
            isRunning = true;
            Profiles.Current.State = new GameState();

            MenuManager.Clear();
            MenuManager.Add(MenuType.HUD);
        }
示例#6
0
        public void LoadMenus()
        {
            Menu startMenu = new Menu();

            startMenu.type            = MenuType.StartMenu;
            startMenu.defaultTexture  = Content.Load <Texture2D>("StartGame");
            startMenu.hoverTexture    = Content.Load <Texture2D>("StartGameGlow");
            startMenu.sprite.texture  = startMenu.defaultTexture;
            startMenu.sprite.position = new Vector2(GraphicsDevice.Viewport.Width / 2 - startMenu.sprite.texture.Width / 2, GraphicsDevice.Viewport.Height / 2 - startMenu.sprite.texture.Height / 2);
            startMenu.sprite.origin   = new Vector2(startMenu.sprite.texture.Width / 2, startMenu.sprite.texture.Height / 2);
            menuManager.Add(startMenu);

            Menu creditMenu = new Menu();

            creditMenu.type            = MenuType.CreditsMenu;
            creditMenu.defaultTexture  = Content.Load <Texture2D>("Credits");
            creditMenu.hoverTexture    = Content.Load <Texture2D>("Credits_Glow");
            creditMenu.sprite.texture  = creditMenu.defaultTexture;
            creditMenu.sprite.position = new Vector2(GraphicsDevice.Viewport.Width / 2 - creditMenu.sprite.texture.Width / 2, GraphicsDevice.Viewport.Height / 2 - creditMenu.sprite.texture.Height / 2 + 2 * startMenu.sprite.texture.Height);
            creditMenu.sprite.origin   = new Vector2(creditMenu.sprite.texture.Width / 2, creditMenu.sprite.texture.Height / 2);
            menuManager.Add(creditMenu);

            Menu exitMenu = new Menu();

            exitMenu.type            = MenuType.ExitMenu;
            exitMenu.defaultTexture  = Content.Load <Texture2D>("Exit");
            exitMenu.hoverTexture    = Content.Load <Texture2D>("Exit_Glow");
            exitMenu.sprite.texture  = exitMenu.defaultTexture;
            exitMenu.sprite.position = new Vector2(GraphicsDevice.Viewport.Width / 2 - exitMenu.sprite.texture.Width / 2, GraphicsDevice.Viewport.Height / 2 - exitMenu.sprite.texture.Height / 2 + 4 * startMenu.sprite.texture.Height);
            exitMenu.sprite.origin   = new Vector2(exitMenu.sprite.texture.Width / 2, exitMenu.sprite.texture.Height / 2);
            menuManager.Add(exitMenu);

            Menu orbTitle = new Menu();

            orbTitle.type            = MenuType.Title;
            orbTitle.defaultTexture  = Content.Load <Texture2D>("ORBTitle");
            orbTitle.hoverTexture    = Content.Load <Texture2D>("ORBTitle");
            orbTitle.sprite.texture  = exitMenu.defaultTexture;
            orbTitle.sprite.position = new Vector2(GraphicsDevice.Viewport.Width / 2 - exitMenu.sprite.texture.Width / 2 - 115, GraphicsDevice.Viewport.Height / 2 - exitMenu.sprite.texture.Height / 2 - 3 * startMenu.sprite.texture.Height);
            orbTitle.sprite.origin   = new Vector2(exitMenu.sprite.texture.Width / 2, exitMenu.sprite.texture.Height / 2);
            menuManager.Add(orbTitle);
        }
示例#7
0
        public void GameOver()
        {
            isRunning = false;

            Sounds.Jet.Stop();
            Highscores.Add();
            MenuManager.Clear();
            MenuManager.Add(MenuType.GameOver);

            Profiles.Current.State = null;
        }
示例#8
0
        public void Menu_commands_added_after_toolbar_is_set_are_added_immediately()
        {
            var          menuManager = new MenuManager();
            const string menuId      = "MenuId";
            var          items       = new List <ToolStripMenuItem>();

            menuManager.SetToolstrip(items);

            menuManager.Add(menuId, () => new MenuCommand());

            Assert.That(items.Count, Is.EqualTo(1));
            var toolStripMenuItem = items.First();

            Assert.That(toolStripMenuItem.Text, Is.EqualTo(menuId));
            Assert.That(toolStripMenuItem.DropDownItems.Count, Is.EqualTo(1));
        }
示例#9
0
 public void AddMenu(MenuManager menuMgr)
 {
     menuMgr.Add(
         Menu("Alignment settings").Add(
             Menu(() => LabelOnOff(Active, "State:", "ENABLED", "OFF"))
             .Enter("toggleAlign", () => Active = !Active),
             Menu(() => LabelOnOff(!Inverted, "Inverted:", "NO", "YES"))
             .Enter("toggleAlignInvert", () => Inverted = !Inverted),
             Menu(() => LabelOnOff(!IgnoreGravity, "Against:", "Gravity or velocity", "Only velocity"))
             .Enter("toggleAlignVelocity", () => IgnoreGravity = !IgnoreGravity),
             Menu(() => LabelOnOff(!RocketMode, "Mode:", "Ship", "Rocket"))
             .Enter("toggleAlignRocket", () => RocketMode = !RocketMode),
             Menu(() => $"Gyro coeff: {GyroCoeff}")
             .Left(() => GyroCoeff  -= 0.1)
             .Right(() => GyroCoeff += 0.1)
             .Back(() => GyroCoeff   = 0.5),
             Menu(() => $"Num Gyros: {gyros.Count}")
             )
         );
 }
示例#10
0
        public ApiResult <bool> AddMenu([FromBody] Menu valuse)
        {
            ApiResult <bool> apiResult = new ApiResult <bool>();

            valuse.creater     = this.GetCurrentUser().Uid;
            valuse.createrTime = System.DateTime.Now;
            valuse.menuid      = valuse.id;
            if (string.IsNullOrEmpty(valuse.parentid))
            {
                valuse.path = "/home/" + valuse.name;
            }
            else
            {
                Menu parentmenu = menuManager.Get(valuse.parentid);
                valuse.path = parentmenu.path + "/" + valuse.name;
            }
            apiResult.Code    = ApiResultStatu.OK;
            apiResult.Data    = menuManager.Add(valuse);
            apiResult.Success = true;
            return(apiResult);
        }
 public void AddMenu(MenuManager menuMgr)
 {
     menuMgr.Add(
         Menu("Ascend/Descend controller").Add(
             Menu(() => LabelOnOff(OperationMode == Mode.Descend, $"Mode {(IsRunning ? "[ACTIVE]" : "[Idle]")}: ", "Descend-Fall", "Ascend-Lift"))
             .Enter(() => ToggleRunState())
             .Left(() => OperationMode  = Mode.Descend)
             .Right(() => OperationMode = Mode.Ascend),
             Menu(() => $"{OperationMode} max speed: {MaxSpeed} m/s")
             .Left(() => MaxSpeed  -= 10)
             .Right(() => MaxSpeed += 10)
             .Back(() => MaxSpeed   = (Mode.Ascend == OperationMode ? 100 : 110)),
             Menu(() => OperationMode == Mode.Ascend ? "(Not for ascend mode) BrakeDistFact." : $"BrakeDistFact.: {BrakeDistanceFactor:0.00}")
             .Left(() => BrakeDistanceFactor  -= 0.01)
             .Right(() => BrakeDistanceFactor += 0.01)
             .Back(() => BrakeDistanceFactor   = 1.1),
             Menu(() => OperationMode == Mode.Ascend ? "(Not for ascend mode) Use parachutes" : LabelOnOff(UseParachute, "Use parachutes:", $"YES at height {ParachuteHeight}", "NO"))
             .Enter(() => UseParachute = !UseParachute)
             .Back(() => { UseParachute = false; ParachuteHeight = 1000; })
             .Left(() => ParachuteHeight  -= 100)
             .Right(() => ParachuteHeight += 100)
             )
         );
 }
示例#12
0
 public static void Add(string title, FunctionCallS func, float param, float left, float right) => MenuManager.Add(title, func, param, left, right);
示例#13
0
 public static void Add(string title, FunctionCallP func, object param, bool state) => MenuManager.Add(title, state, func, param);
示例#14
0
 public static void Add(string title, Action <Vector3> func, KeyCode key = KeyCode.None) => MenuManager.Add(title, func, key);
示例#15
0
 public static void Add(string title, FunctionCall func, bool state) => MenuManager.Add(title, state, func);
示例#16
0
 public static void Add(string title) => MenuManager.Add(title);
示例#17
0
 public static void Add(Menu menu) => MenuManager.Add(menu);
示例#18
0
            public void AddMenu(MenuManager menuMgr)
            {
                var tls        = Menu("Tools");
                var foundTools = false;

                foreach (var tool in new[] { GR, WL, OD, DR })
                {
                    if (HasTool(tool))
                    {
                        foundTools = true;
                        tls.Add(
                            Menu(() => GetText(tool))
                            .Collect(this)
                            .Enter("toggle" + tool, () => ToolToggle(tool))
                            .Back(() => ToolEnable(tool, false))
                            .Left(() => ToolDistance(tool, -1))
                            .Right(() => ToolDistance(tool, 1))
                            );
                    }
                }

                if (HasTool(DR))
                {
                    Action <int> yawRotate = (dir) => {
                        ActionOnBlocksOfType <IMyGyro>(Pgm, Me, g => {
                            if (NameContains(g, DR))
                            {
                                var yawRpm = g.Yaw;
                                if (0 == dir)
                                {
                                    if (g.Enabled)
                                    {
                                        g.Enabled = false;
                                    }
                                    else
                                    {
                                        yawRpm    = -yawRpm;
                                        g.Enabled = true;
                                    }
                                }
                                else
                                {
                                    yawRpm    = Math.Sign(dir) * Math.Abs(yawRpm);
                                    g.Enabled = true;
                                }
                                g.Yaw = yawRpm;
                            }
                        });
                    };

                    tls.Add(
                        Menu("Yaw rotation  left< toggle >right")
                        .Enter("toggleYaw", () => yawRotate(0))
                        .Left(() => yawRotate(-1))
                        .Right(() => yawRotate(1))
                        );

                    Pgm.cargoMgr?.AddMenu(tls);
                }

                if (HasSensors())
                {
                    foundTools = true;

                    const int e = 11, d = 16, f = 10;
                    int[]     pad = { 0,
                                      e + 2, e + 1, e + 3, e + 2, e + 2, e + 0,     0, 0, 0, 0,
                                      d + 0, d + 0, d + 2, d + 1, d + 2, d + 1, d + 0, 0, 0, 0,
                                      f + 1, f + 1, f + 2, f + 0, };

                    int      i    = 0;
                    MenuItem bbox = Menu("Extend/Boundaries");
                    foreach (var txt in Pgm.DIRECTIONS)
                    {
                        int j = ++i;
                        bbox.Add(
                            Menu(() => SensorText(txt, j, pad[j]))
                            .Left(() => SensorProp(j, -1))
                            .Right(() => SensorProp(j, 1))
                            .Back(() => SensorProp(j, 0))
                            );
                    }

                    i = 10;
                    MenuItem typs = Menu("Object detection");
                    foreach (var txt in new[] { "Large ships", "Small ships", "Stations", "Subgrids", "Players", "Asteroids", "Floating obj." })
                    {
                        int j = ++i;
                        typs.Add(
                            Menu(() => SensorText(txt, j, pad[j]))
                            .Enter(() => SensorProp(j, 0))
                            );
                    }

                    i = 20;
                    MenuItem fctn = Menu("Faction recognition");
                    foreach (var txt in new[] { "Owner", "Friendly", "Neutral", "Enemy" })
                    {
                        int j = ++i;
                        fctn.Add(
                            Menu(() => SensorText(txt, j, pad[j]))
                            .Enter(() => SensorProp(j, 0))
                            );
                    }

                    tls.Add(
                        Menu("Sensors").Add(
                            Menu(() => SensorText("Selected", 0, 0))
                            .Left(() => SensorProp(0, -1))
                            .Right(() => SensorProp(0, 1))
                            .Enter(() => ToggleSensor()),
                            bbox,
                            typs,
                            fctn
                            )
                        );
                }

                if (0 < GetBlocksOfType(Pgm, LG, Me).Count)
                {
                    foundTools = true;
                    Action <int> lgMode = (wanted) => {
                        var lst = GetBlocksOfType(Pgm, LG, Me);
                        if (-1 == wanted)
                        {
                            int[] cnts = { 0, 0, 0 };
                            foreach (var b in lst)
                            {
                                cnts[(int)(b as IMyLandingGear).LockMode]++;
                            }
                            wanted = 0 < cnts[1] ? 2 : 0;                             // `ReadyToLock` takes priority over `Unlocked`.
                        }
                        foreach (var b in lst)
                        {
                            var l = b as IMyLandingGear;
                            switch ((int)l.LockMode)
                            {
                            // BUG: Why is `LandingGearMode` not whitelisted?
                            case 0: break;

                            case 1: if (2 == wanted)
                                {
                                    l.Lock();
                                }
                                break;

                            case 2: if (0 == wanted)
                                {
                                    l.Unlock();
                                }
                                break;
                            }
                        }
                    };
                    tls.Add(
                        Menu(() => GetText(LG, 2))
                        .Collect(this)
                        .Enter("toggle" + LG, () => lgMode(-1))
                        .Left(() => lgMode(2))
                        .Right(() => lgMode(0))
                        );
                }

                if (HasProjectors())
                {
                    foundTools = true;
                    MenuItem tp = Menu("Projectors").Add(
                        Menu(() => ProjectorText("Selected", 0))
                        .Left(() => ProjectorProp(0, -1))
                        .Right(() => ProjectorProp(0, 1))
                        .Enter(() => ToggleProjector())
                        );

                    int i = 0;
                    foreach (var txt in new[] { "Offset X", "Offset Y", "Offset Z", "Rotate X", "Rotate Y", "Rotate Z" })
                    {
                        int j = ++i;
                        tp.Add(
                            Menu(() => ProjectorText(txt, j))
                            .Left(() => ProjectorProp(j, -1))
                            .Right(() => ProjectorProp(j, 1))
                            .Back(() => ProjectorProp(j, 0))
                            );
                    }

                    tls.Add(tp);
                }

                if (HasGravityGenerators())
                {
                    foundTools = true;
                    MenuItem tp = Menu("Gravity generators").Add(
                        Menu(() => GravityGeneratorText("Selected", 0))
                        .Left(() => GravityGeneratorProp(0, -1))
                        .Right(() => GravityGeneratorProp(0, 1))
                        .Enter(() => ToggleGravityGen())
                        );

                    int i = 0;
                    foreach (var txt in new[] { "Width", "Height", "Depth", "Strength" })
                    {
                        int j = ++i;
                        tp.Add(
                            Menu(() => GravityGeneratorText(txt, j))
                            .Left(() => GravityGeneratorProp(j, -1))
                            .Right(() => GravityGeneratorProp(j, 1))
                            .Back(() => GravityGeneratorProp(j, 0))
                            );
                    }

                    tls.Add(tp);
                }

                if (foundTools)
                {
                    menuMgr.Add(tls);
                }
            }
示例#19
0
        public static void init()
        {
            //初始化表
            manager.InitTable();

            Menu menu = new Menu();

            menu.id          = "od9a2123-2151-43cf-b8f0-384dbf763740";
            menu.createrTime = System.DateTime.Now;
            menu.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu.menuid      = "od9a2123-2151-43cf-b8f0-384dbf763740"; //id
            menu.displayName = "快乐";                                   //菜单名称
            menu.ico         = "el-icon-s-tools";                      //菜单图标
            menu.type        = MenuType.Link;                          //菜单类型
            menu.path        = "/home/hello";                          //菜单路径
            menu.name        = "hello";                                //菜单名称
            menu.component   = "views/home/hello.vue";                 //对应的页面

            Menu menu1 = new Menu();

            menu1.id          = "od9a2123-2151-43cf-b8f0-384dbf763741";
            menu.createrTime  = System.DateTime.Now;
            menu.creater      = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu1.menuid      = "od9a2123-2151-43cf-b8f0-384dbf763741"; //id
            menu1.displayName = "角色管理";                                 //菜单名称
            menu1.ico         = "el-icon-user-solid";                   //菜单图标
            menu1.type        = MenuType.Link;                          //菜单类型
            menu1.path        = "/home/role";                           //菜单路径
            menu1.name        = "role";                                 //菜单名称
            menu1.component   = "views/home/RoleManager/Role.vue";      //对应的页面
            menu1.parentid    = menu.id;


            Menu menu2 = new Menu();

            menu2.id          = "od9a2123-2151-43cf-b8f0-384dbf763742";
            menu2.createrTime = System.DateTime.Now;
            menu2.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu2.menuid      = "od9a2123-2151-43cf-b8f0-384dbf763742";          //id
            menu2.displayName = "组织管理";                                          //菜单名称
            menu2.ico         = "el-icon-user-solid";                            //菜单图标
            menu2.type        = MenuType.Link;                                   //菜单类型
            menu2.path        = "/home/organizaiton";                            //菜单路径
            menu2.name        = "organizaiton";                                  //菜单名称
            menu2.component   = "views/home/OrgnizationManager/Orgnization.vue"; //对应的页面
            menu2.parentid    = menu.id;

            Menu menu3 = new Menu();

            menu3.id          = "od9a2123-2151-43cf-b8f0-384dbf763743";
            menu3.createrTime = System.DateTime.Now;
            menu3.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu3.menuid      = menu3.id;             //id
            menu3.displayName = "菜单管理";               //菜单名称
            menu3.ico         = "el-icon-user-solid"; //菜单图标
            menu3.type        = MenuType.Link;        //菜单类型
            menu3.path        = "/home/menuManager";  //菜单路径
            menu3.name        = "menuManager";        //菜单名称
            menu3.component   = "";                   //对应的页面
            menu3.parentid    = menu.id;


            Menu menu3_2 = new Menu();

            menu3_2.id          = "od9a2123-2151-43cf-b8f0-384dbf763732";
            menu3_2.createrTime = System.DateTime.Now;
            menu3_2.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu3_2.menuid      = menu3_2.id;                           //id
            menu3_2.displayName = "菜单管理1";                              //菜单名称
            menu3_2.ico         = "el-icon-user-solid";                 //菜单图标
            menu3_2.type        = MenuType.Link;                        //菜单类型
            menu3_2.path        = "/home/menuManager/menuchildMamager"; //菜单路径
            menu3_2.name        = "menuchildMamager_menuchildMamager";  //菜单名称
            menu3_2.component   = "";                                   //对应的页面
            menu3_2.parentid    = menu3.id;

            Menu menu3_1 = new Menu();

            menu3_1.id          = "od9a2123-2151-43cf-b8f0-384dbf763731";
            menu3_1.createrTime = System.DateTime.Now;
            menu3_1.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu3_1.menuid      = menu3_1.id;                            //id
            menu3_1.displayName = "菜单列表";                                //菜单名称
            menu3_1.ico         = "el-icon-user-solid";                  //菜单图标
            menu3_1.type        = MenuType.Link;                         //菜单类型
            menu3_1.path        = "/home/menuManager/menu";              //菜单路径
            menu3_1.name        = "menuManager";                         //菜单名称
            menu3_1.component   = "views/home/MenuManager/MenuList.vue"; //对应的页面
            menu3_1.parentid    = menu3.id;

            Menu menu3_2_1 = new Menu();

            menu3_2_1.id          = "od9a2123-2151-43cf-b8f0-384dbf763321";
            menu3_2_1.createrTime = System.DateTime.Now;
            menu3_2_1.creater     = "ad9a2123-2151-43cf-b8f0-384dbf763741";
            menu3_2_1.menuid      = menu3_2_1.id;                              //id
            menu3_2_1.displayName = "菜单列表1";                                   //菜单名称
            menu3_2_1.ico         = "el-icon-user-solid";                      //菜单图标
            menu3_2_1.type        = MenuType.Link;                             //菜单类型
            menu3_2_1.path        = "/home/menuManager/menuchildMamager/menu"; //菜单路径
            menu3_2_1.name        = "menuchildMamager_menu";                   //菜单名称
            menu3_2_1.component   = "views/home/MenuManager/MenuList.vue";     //对应的页面
            menu3_2_1.parentid    = menu3_2.id;


//初始化表
            manager.InitTable();
            Menu vorg      = manager.Get(menu.id);
            Menu vorg1     = manager.Get(menu1.id);     //验证当前user是否已经存在
            Menu vorg2     = manager.Get(menu2.id);     //验证当前user是否已经存在
            Menu vorg3     = manager.Get(menu3.id);     //验证当前user是否已经存在
            Menu vorg3_1   = manager.Get(menu3_1.id);   //验证当前user是否已经存在
            Menu vorg3_2   = manager.Get(menu3_2.id);   //验证当前user是否已经存在
            Menu vorg3_2_1 = manager.Get(menu3_2_1.id); //验证当前user是否已经存在

            //不存在就初始化当前数据
            if (vorg == null || string.IsNullOrEmpty(vorg.id))
            {
                manager.Add(menu);
                Console.WriteLine("初始化菜单成功");
            }

            if (vorg1 == null || string.IsNullOrEmpty(vorg1.id))
            {
                manager.Add(menu1);
                Console.WriteLine("初始化菜单成功");
            }

            if (vorg2 == null || string.IsNullOrEmpty(vorg2.id))
            {
                manager.Add(menu2);
                Console.WriteLine("初始化菜单成功");
            }
            if (vorg3 == null || string.IsNullOrEmpty(vorg3.id))
            {
                manager.Add(menu3);
                Console.WriteLine("初始化菜单成功");
            }

            if (vorg3_1 == null || string.IsNullOrEmpty(vorg3_1.id))
            {
                manager.Add(menu3_1);
                Console.WriteLine("初始化菜单成功");
            }
            if (vorg3_2 == null || string.IsNullOrEmpty(vorg3_2.id))
            {
                manager.Add(menu3_2);
                Console.WriteLine("初始化菜单成功");
            }
            if (vorg3_2_1 == null || string.IsNullOrEmpty(vorg3_2_1.id))
            {
                manager.Add(menu3_2_1);
                Console.WriteLine("初始化菜单成功");
            }
        }
            public void AddMenu(MenuManager menuMgr)
            {
                if (1 > GetThrustBlocks(ThrustFlags.All, Pgm, Me).Count)
                {
                    return;                     // No thrusters found
                }
                const int p = 16;               // padding
                MenuItem  tt;

                menuMgr.Add(
                    tt = Menu("Engine/Thrust settings").Add(
                        Menu(() => GetText(1, "All Thrusters", p))
                        .Collect(this)
                        .Enter("toggleEngines", () => tsToggle(ThrustFlags.All))
                        .Left(() => tsEnable(ThrustFlags.All, true))
                        .Right(() => tsEnable(ThrustFlags.All, false)),
                        Menu("Engine types").Add(
                            Menu(() => GetText(1, "Atmospheric", p + 0))
                            .Collect(this)
                            .Enter("toggleAtmos", () => tsToggle(ThrustFlags.Atmospheric))
                            .Left(() => tsEnable(ThrustFlags.Atmospheric, true))
                            .Right(() => tsEnable(ThrustFlags.Atmospheric, false)),
                            Menu(() => GetText(1, "Ion", p + 8))
                            .Collect(this)
                            .Enter("toggleIon", () => tsToggle(ThrustFlags.Ion))
                            .Left(() => tsEnable(ThrustFlags.Ion, true))
                            .Right(() => tsEnable(ThrustFlags.Ion, false)),
                            Menu(() => GetText(1, "Hydrogen", p + 2))
                            .Collect(this)
                            .Enter("toggleHydro", () => tsToggle(ThrustFlags.Hydrogen))
                            .Left(() => tsEnable(ThrustFlags.Hydrogen, true))
                            .Right(() => tsEnable(ThrustFlags.Hydrogen, false))
                            )
                        )
                    );

                if (null == Pgm.GetShipController())
                {
                    menuMgr.WarningText += "\n ShipController missing. Some features unavailable!";
                }
                else
                {
                    MenuItem md  = Menu("Directions");
                    MenuItem mo  = Menu("Override thrust");
                    int[]    pad = new[] { p + 2, p + 1, p + 3, p + 1, p + 2, p + 0 };

                    int i = 0;
                    foreach (string txt in Pgm.DIRECTIONS)
                    {
                        ThrustFlags tf = (ThrustFlags)(1 << i);
                        int         j  = i++;
                        md.Add(
                            Menu(() => GetText(1, txt, pad[j]))
                            .Collect(this)
                            .Enter("toggle" + txt, () => tsToggle(tf))
                            .Left(() => tsEnable(tf, true))
                            .Right(() => tsEnable(tf, false))
                            );
                        mo.Add(
                            Menu(() => GetText(2, txt, pad[j]))
                            .Collect(this)
                            .Enter("thrust" + txt, () => tsPower(tf, 100f))
                            .Left(() => tsPower(tf, -1))
                            .Right(() => tsPower(tf, 1))
                            .Back(() => tsPower(tf, 0))
                            );
                    }

                    tt.Add(md, mo);
                }
            }