public static List <MenuResult> GetCategoryMenu(this IGenericRepository <Category> categoryRepository) { var parentCategories = GetAllCategory(categoryRepository); var menuResultList = new List <MenuResult>(); foreach (Category parentCategory in parentCategories) { MenuResult menuResult = new MenuResult(); menuResult.ParentCategoryId = parentCategory.CategoryId; menuResult.ParentCategoryName = parentCategory.Name; var subCategories = categoryRepository.Find(x => x.ParentCategoryId == parentCategory.CategoryId && x.IsDeleted != true && x.Published == true).OrderBy(z => z.GroupDisplayOrder) .ThenBy(y => y.CategoryGroupTag).ThenBy(g => g.DisplayOrder); menuResult.SubMenu = new List <SubMenuResult>(); foreach (Category category in subCategories) { SubMenuResult subMenuResult = new SubMenuResult(); subMenuResult.SubCategoryId = category.CategoryId; subMenuResult.SubCategoryName = category.Name; subMenuResult.CategoryGroupTag = category.CategoryGroupTag; menuResult.SubMenu.Add(subMenuResult); } menuResultList.Add(menuResult); } return(menuResultList); }
public SelectButton(T returnValue, Color buttonColor, string displayText, MenuResult <T> result = null) { this.returnValue = returnValue; this.buttonColor = buttonColor; this.displayText = displayText; this.result = result; }
public MenuResult Update(System.Drawing.Point mousePos, bool clicked) { foreach (ControlElement elm in this.elements) { if (elm.CheckElement(mousePos)) { if (clicked) { elm.ElementClick(); if (elm is MenuButton) { this.result = (elm as MenuButton).Result; //return this.result; } } else { elm.ElementHover(); } } else { elm.ElementLeave(); } elm.Draw(); } return(this.result); }
private static string GetMenuResultCommand(MenuResult menuResult) { switch (menuResult) { case MenuResult.DefaultSequence: return("{{default}}"); case MenuResult.Delay: return("Delay({{end}})"); case MenuResult.DefaultCameraAngle: return("Camera(default)"); case MenuResult.UpdateTracker: return("UpdateTracker()"); case MenuResult.Continue: return("Continue()"); case MenuResult.ContinueTrue: return("SetContinueMode(true)"); case MenuResult.ContinueFalse: return("SetContinueMode(false)"); default: return(string.Empty); } }
public void TestGetResult_4() { var list = new List <MenuResponse> { GetNode1(), GetNode2(), GetNode3(), GetNode4() }; var result = new MenuResult(list).GetResult(); //根节点 Assert.Equal(2, result.Count); var root = result.First(); Assert.Equal(Id, root.Id); //根节点2 var root2 = result[1]; Assert.Equal(Id3, root2.Id); //子节点 Assert.Equal(2, root.Children.Count); var child = root.Children[0]; Assert.Equal(Id2, child.Id); //子节点2 Assert.Equal(2, root.Children.Count); var child2 = root.Children[1]; Assert.Equal(Id4, child2.Id); }
public void TestGetResult_3() { var list = new List <MenuResponse> { GetNode1(), GetNode2(), GetNode3() }; var result = new MenuResult(list).GetResult(); //根节点1 Assert.Equal(2, result.Count); var root = result.First(); Assert.Equal(Id, root.Id); Assert.Equal(Title, root.Text); //根节点2 var root2 = result[1]; Assert.Equal(Id3, root2.Id); Assert.Equal(Title3, root2.Text); Assert.Equal("a", root2.Icon); Assert.Equal("http://localhost/a/b", root2.ExternalLink); //子节点 Assert.Single(root.Children); var child = root.Children[0]; Assert.Equal(Id2, child.Id); Assert.Equal(Title2, child.Text); }
// Display menu and get user input private static MenuResult DisplayMenu() { var result = new MenuResult(); Console.WriteLine("1. Find By Id"); Console.WriteLine("2. Find By Name"); Console.WriteLine("3. Find By Visibility"); Console.Write("Please Enter Option (1/2/3): "); result.Option = Convert.ToInt16(Console.ReadLine()); switch (result.Option) { case 1: Console.Write("Enter the Id: "); result.Id = Convert.ToInt16(Console.ReadLine()); break; case 2: Console.Write("Enter full or part of the name: "); result.Name = Console.ReadLine(); break; case 3: Console.Write("Enter visibility (true/false): "); result.Visibility = Convert.ToBoolean(Console.ReadLine()); break; } return(result); }
public MenuOption(MenuResult result, String optionText, String helpText) { this.result = result; this.optionText = optionText; this.optionString = helpText; this.type = MenuType.Normal; }
public MenusParent(Device device) { MenuBackGround back = new MenuBackGround(device); elements = new List <ControlElement>(); elements.Add(back); result = MenuResult.None; }
public MenuResult CreateMenu(AuthIdentity identity, Menu menu, params Guid[] recipeIds) { using (var session = GetSession()) { menu.Title = menu.Title.Trim(); var ret = new MenuResult(); using (var transaction = session.BeginTransaction()) { Models.Menus dbMenu; var dupes = session.QueryOver <Models.Menus>() .Where(p => p.UserId == identity.UserId) .Where(p => p.Title == menu.Title) .ToRowCountQuery() .RowCount(); if (dupes > 0) { throw new MenuAlreadyExistsException(); } session.Save(dbMenu = new Models.Menus { UserId = identity.UserId, Title = menu.Title, CreatedDate = DateTime.Now, }); foreach (var rid in recipeIds.NeverNull()) { var fav = new Favorites { UserId = identity.UserId, Recipe = new Models.Recipes() { RecipeId = rid }, Menu = dbMenu }; session.Save(fav); } transaction.Commit(); ret.MenuCreated = true; ret.NewMenuId = dbMenu.MenuId; } return(ret); } }
//This mutates the buttons it's provided, technically, though they're doing nothing afterwards. //Probably use a better pattern public async Task <T> getResultFromSelection <T>(List <SelectButton <T> > buttons, string selectionTitle) { text.text = selectionTitle; MenuResult <T> result = new MenuResult <T>(); buttons.ForEach(button => { button.result = result; }); addButtons(buttons); T resultVal = await result.getResult(); clearButtons(); return(resultVal); }
public void TestGetResult_1() { var list = new List <MenuResponse> { GetNode1() }; var result = new MenuResult(list).GetResult(); Assert.Single(result); var node = result.First(); Assert.Equal(Id, node.Id); Assert.Equal(Title, node.Text); Assert.Equal("/a/b", node.Link); }
private static string ApplyMenuResult(MenuResult menuResult, string sequence) { GUI.changed = true; var newCommand = GetMenuResultCommand(menuResult); if (string.IsNullOrEmpty(newCommand)) { return(sequence); } else { return(AddCommandToSequence(sequence, newCommand)); } }
private static async Task ProcessMenuResult(MenuResult getMenu) { //pizza's var submenus = getMenu.MenuPages[0].SubMenus; foreach (var sub in submenus) { foreach (var product in sub.Products) { var pizza = await GetPizzaDetails(product.LinkedItem.ItemCode); Pizzases.Add(pizza); } } }
protected override void HandleMenuResult(MenuResult _result) { if (_result == MenuResult.Continue) { MatchInitializationData matchInitData = new MatchInitializationData(); matchInitData.P1_Character = DetermineSelectedCharacter(P1); matchInitData.P2_Character = DetermineSelectedCharacter(P2); m_currentSetData.SetMatchInitData(matchInitData); ApplicationStateManager.GetInstance().SetGameplayState(m_currentSetData); } else if (_result == MenuResult.Back) { ApplicationStateManager.GetInstance().SetMainMenu();//go to main menu } }
public MenuButton(Device device, MenuResult result, string text, System.Drawing.Point position) : base(device) { this.result = result; this.text = text; this.textureNormal = TextureLoader.FromFile(device, @"Resources/Button.dds"); this.textureHover = TextureLoader.FromFile(device, @"Resources/Buttonhover.dds"); //this.textureClick = this.textureHover; System.Drawing.Image img = System.Drawing.Image.FromFile(@"Resources/Button.png"); this.size = img.Size; this.textPosition = new System.Drawing.Point(30, 10); img.Dispose(); this.position = position; }
public MenuResult UpdateState(string screen) { MenuResult result; switch (screen) { case "Pub": result = MenuResult.Pub; break; case "Title": result = MenuResult.Title; break; case "ToBeContinued": result = MenuResult.ToBeContinued; this.currentMenu = this.tobecontinue; this.previusMenu = this.main; break; case "Gameover": result = MenuResult.Gameover; this.currentMenu = this.gameover; this.previusMenu = this.main; break; case "MainMenu": result = MenuResult.MainMenu; this.currentMenu = this.main; this.previusMenu = this.main; break; case "Restart": result = MenuResult.Restart; this.currentMenu = this.pub; this.previusMenu = this.main; break; default: result = MenuResult.None; break; } this.menuState = result; return(result); }
private void button1_Click(object sender, EventArgs e) { //urun ekle panelurunekle.Visible = true; var client = new RestClient("http://loc.deepram.com/api/Menu/MenuListele/?sube_id=" + frmgiris.subeid + "&token=" + frmgiris.oldtoken); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); IRestResponse response = client.Execute(request); menuler = JsonConvert.DeserializeObject <MenuResult>(response.Content); foreach (Menu _kategori in menuler.menu) { comboBox1.Items.Add(_kategori.kategori_adi); } }
public Response <bool> SaveMenu(MenuResult node) { var result = new Response <bool>(); Menu menu = new Menu() { Id = node.Id, Name = node.Name, Handler = node.Handler, Icon = node.Icon ?? "", Remark = node.Remark ?? "" }; menuDao.BatchUpdate(new List <Menu> { menu }, "id=?4", n => n.Name, n => n.Handler, n => n.Icon, n => n.Remark, n => n.Id); result.Result = true; return(result); }
protected override void HandleMenuResult(MenuResult _result) { if (_result == MenuResult.Continue) { SetData set = new SetData(); if (P1.SelectionState == PlayerInMenu.SelectionStates.Confirmed) { if (P1.SelectedItem.ItemName == STR_CHARACTERSELECT) { ApplicationStateManager.GetInstance().SetCharacterSelectScreen(set); //go to character select screen } } if (P2.SelectionState == PlayerInMenu.SelectionStates.Confirmed) { if (P2.SelectedItem.ItemName == STR_CHARACTERSELECT) { ApplicationStateManager.GetInstance().SetCharacterSelectScreen(set); //go to character select screen } } } }
public void TestGetResult_2() { var list = new List <MenuResponse> { GetNode1(), GetNode2() }; var result = new MenuResult(list).GetResult(); //根节点 Assert.Single(result); var root = result.First(); Assert.Equal(Id, root.Id); Assert.Equal(Title, root.Text); //子节点 Assert.Single(root.Children); var child = root.Children[0]; Assert.Equal(Id2, child.Id); Assert.Equal(Title2, child.Text); }
public static void Main(string[] args) { MenuResult menuResult = DisplayMenu(); var graph = ConstructGraph(); IEnumerable <Item> result = new List <Item>(); // Find by Id if (menuResult.Option == 1) { result = graph.Traverse(i => i.Id == menuResult.Id); } // Find by name if (menuResult.Option == 2) { result = graph.Traverse(i => i.Name.Contains(menuResult.Name)); } // Find by visibility if (menuResult.Option == 3) { result = graph.Traverse(i => i.IsVisible == menuResult.Visibility); } Console.WriteLine(); Console.WriteLine("Matching Items:"); // Display the results if any foreach (var item in result) { Console.WriteLine(item); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private void HandleMenuData(MenuResult item, List <SysMenu> list) { if (item == null) { return; } var mapConfig = new MapperConfiguration(cfg => { cfg.CreateMap <string, int?>().ConvertUsing(new NullableIntUtcTimeTypeConverter()); cfg.CreateMap <string, DateTime?>().ConvertUsing(new NullableUtcTimeTypeConverter()); cfg.CreateMap <MenuResult, SysMenu>(); }); //mapConfig.AssertConfigurationIsValid(); var result = item.MapTo <MenuResult, SysMenu>(mapConfig); list.Add(result); if (item.ChildrenList.IsAny()) { item.ChildrenList.Each(a => { HandleMenuData(a, list); }); } }
/// <summary> /// /// </summary> /// <param name="parentId"></param> /// <param name="menu"></param> /// <param name="emenuList"></param> private void SetMenu(string parentId, MenuResult menu, List <Emenu> emenuList) { for (int i = 0; i < emenuList.Count; i++) { if (emenuList[i].ParentId == parentId) { var re = new MenuResult(); re.TabId = Convert.ToString(emenuList[i].TabId); re.Id = Convert.ToString(emenuList[i].Id); re.icon = emenuList[i].Micon; re.name = emenuList[i].Mname; re.url = emenuList[i].Mlink; SetMenu(Convert.ToString(emenuList[i].Id), re, emenuList); if (parentId.Equals("0")) { EmenuList.Add(re); } else { menu.Child.Add(re); } } } }
/// <summary> /// Get the Menu details based on the logged in UserId. /// </summary> /// <param name="UId">string</param> /// <returns>list(object)</returns> public List <Menu> GetMenu(string UId) { MenuResult result = new MenuResult(); List <Menu> lstMenu = new List <Menu>(); try { var Parameter = new { UId = UId }; var SPName = "MRG_Menu"; Menu oMenu = new Menu(); using (var conn = Connection()) { var reader = conn.QueryMultiple(SPName, Parameter, commandType: CommandType.StoredProcedure); result.MainMenu = reader.Read <MasterMenuDetails>().ToList(); result.SubMenu = reader.Read <SubMenuDetails>().ToList(); } foreach (MasterMenuDetails details in result.MainMenu) { oMenu = new Menu(); oMenu.MdlId = details.MdlId; oMenu.Module = details.Module; oMenu.Action = details.Action; oMenu.Controller = details.Controller; oMenu.MenuLink = details.MenuLink; oMenu.SubMenu = result.SubMenu.Where(x => x.RefId == details.MdlId).ToList(); lstMenu.Add(oMenu); } } catch (Exception ex) { logger.Error(ex.Message); } return(lstMenu); }
public bool TryConvert(MenuResultModel o, out IMenuResult result) { result = null; if (o == null) { return(false); } MenuResultType type; if (TryParse(o.Type, out type)) { result = new MenuResult { Type = type, Value = o.Value }; return(true); } return(false); }
public MenuResult CreateMenu(AuthIdentity identity, Menu menu, params Guid[] recipeIds) { using (var session = this.GetSession()) { menu.Title = menu.Title.Trim(); var ret = new MenuResult(); using (var transaction = session.BeginTransaction()) { Menus menus; var dupes = session .QueryOver<Menus>() .Where(p => p.UserId == identity.UserId) .Where(p => p.Title == menu.Title) .ToRowCountQuery() .RowCount(); if (dupes > 0) { throw new MenuAlreadyExistsException(); } session.Save(menus = new Menus { UserId = identity.UserId, Title = menu.Title, CreatedDate = DateTime.Now, }); foreach (var rid in recipeIds.NeverNull()) { var fav = new Favorites { UserId = identity.UserId, Recipe = new Models.Recipes() { RecipeId = rid }, Menu = menus }; session.Save(fav); } transaction.Commit(); ret.MenuCreated = true; ret.NewMenuId = menus.MenuId; } return ret; } }
public MenuResult Update(GameTime gameTime) { cooldown -= gameTime.ElapsedGameTime.Milliseconds; if (cooldown < 0) cooldown = 0; if (state == SummaryMenuState.WAIT && animateTime > 1000) { SoundEffects.PlayClick(); result = MenuResult.GoToResults; String nextText = null; if (TutorialStage.controlLessonIndex == TutorialStage.introIndex) { optionList = new List<MenuOption>(); } else { optionList = new List<MenuOption>(); optionList.Add(new MenuOption(MenuResult.GoToResults, "Continue")); } state = SummaryMenuState.READY; nextText = TutorialStage.IntroText(); text = nextText; cooldown = 250; } if (state == SummaryMenuState.NURSEIN || state == SummaryMenuState.NURSEOUT || state == SummaryMenuState.WAIT) { animateTime += gameTime.ElapsedGameTime.Milliseconds; } if (state == SummaryMenuState.NURSEIN && animateTime > 250) { state = SummaryMenuState.READY; } if (state == SummaryMenuState.NURSEOUT && animateTime > 250) { animateTime = 0; state = SummaryMenuState.NURSEIN; return result; } if (state == SummaryMenuState.READY && cooldown == 0) { GamePadState gamePadState = GamePad.GetState(Game.playerIndex); Vector2 leftStick = gamePadState.ThumbSticks.Left; Vector2 rightStick = gamePadState.ThumbSticks.Right; if (!(TutorialStage.phase != TutorialPhase.None && TutorialStage.introIndex - 1 == TutorialStage.controlLessonIndex)) { if (Keyboard.GetState().IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.Start)) { SoundEffects.PlayClick(); result = optionList[selectedOption].result; String nextText = null; if (TutorialStage.phase == TutorialPhase.Intro) { if (TutorialStage.controlLessonIndex == TutorialStage.introIndex) { optionList = new List<MenuOption>(); } else { optionList = new List<MenuOption>(); optionList.Add(new MenuOption(MenuResult.GoToResults, "Continue")); } nextText = TutorialStage.IntroText(); } else if (TutorialStage.phase == TutorialPhase.Pass) { nextText = TutorialStage.SuccessText(); if (TutorialStage.IsEndOfSection()) { optionList = new List<MenuOption>(); optionList.Add(new MenuOption(MenuResult.GoToResults, "Continue")); optionList.Add(new MenuOption(MenuResult.Replay, "Practice")); } } else if (TutorialStage.phase == TutorialPhase.Fail) { nextText = TutorialStage.FailureText(); if (TutorialStage.IsEndOfSection()) { optionList = new List<MenuOption>(); optionList.Add(new MenuOption(MenuResult.Replay, "Try Again")); optionList.Add(new MenuOption(MenuResult.GoToMainMenu, "Main Menu")); } } if (nextText != null) { text = nextText; cooldown = 250; } else { if ((TutorialStage.phase == TutorialPhase.Pass && result != MenuResult.Replay) || TutorialStage.phase == TutorialPhase.Fail) { return result; } animateTime = 0; state = SummaryMenuState.NURSEOUT; } } if (gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Right) || leftStick.X > Game.gameSettings.controlStickTrigger || rightStick.X > Game.gameSettings.controlStickTrigger) { SoundEffects.PlayClick(); selectedOption++; if (selectedOption >= optionList.Count()) selectedOption = optionList.Count() - 1; cooldown = 250; } if (gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || leftStick.X < -Game.gameSettings.controlStickTrigger || rightStick.X < -Game.gameSettings.controlStickTrigger) { SoundEffects.PlayClick(); selectedOption--; if (selectedOption < 0) selectedOption = 0; cooldown = 250; } } else { if (TutorialStage.restrictions==ControlRestrictions.StickOnly && (gamePadState.IsButtonDown(Buttons.DPadUp) || Keyboard.GetState().IsKeyDown(Keys.Up) || gamePadState.ThumbSticks.Left.Y > Game.gameSettings.controlStickTrigger || gamePadState.IsButtonDown(Buttons.DPadDown) || Keyboard.GetState().IsKeyDown(Keys.Down) || gamePadState.ThumbSticks.Left.Y < -Game.gameSettings.controlStickTrigger || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || gamePadState.ThumbSticks.Left.X > Game.gameSettings.controlStickTrigger || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Left) || gamePadState.ThumbSticks.Left.X < -Game.gameSettings.controlStickTrigger)) { state = SummaryMenuState.WAIT; animateTime = 0; } if (TutorialStage.restrictions == ControlRestrictions.ShouldersOnly && (gamePadState.IsButtonDown(Buttons.LeftShoulder) || gamePadState.IsButtonDown(Buttons.RightShoulder) || Keyboard.GetState().IsKeyDown(Keys.A) || Keyboard.GetState().IsKeyDown(Keys.S))) { state = SummaryMenuState.WAIT; animateTime = 0; } if (TutorialStage.restrictions == ControlRestrictions.TriggersOnly && (gamePadState.IsButtonDown(Buttons.LeftTrigger) || gamePadState.IsButtonDown(Buttons.RightTrigger) || Keyboard.GetState().IsKeyDown(Keys.Q) || Keyboard.GetState().IsKeyDown(Keys.W))) { state = SummaryMenuState.WAIT; animateTime = 0; } } } return MenuResult.None; }
private void QuitButtonClick(object sender, System.Windows.RoutedEventArgs e) { HideHandlerDialog(); UnlockParent(); result = MenuResult.Quit; }
private void BackToLobbypageButtonClick(object sender, System.Windows.RoutedEventArgs e) { HideHandlerDialog(); UnlockParent(); result = MenuResult.LobbyPage; }
public QuitMenu() : base() { this.InitializeComponent(); this.playing = true; result = MenuResult.None; }
public MenuResult Update(GameTime gameTime) { cooldown -= gameTime.ElapsedGameTime.Milliseconds; if (cooldown < 0) cooldown = 0; if (state == PauseMenuState.NURSEIN || state == PauseMenuState.NURSEOUT) { animateTime+=gameTime.ElapsedGameTime.Milliseconds; } if (state == PauseMenuState.NURSEIN && animateTime > 250) { state = PauseMenuState.READY; } if (state == PauseMenuState.NURSEOUT && animateTime > 250) { animateTime = 0; state = PauseMenuState.NURSEIN; return result; } if (state == PauseMenuState.READY && cooldown == 0) { GamePadState gamePadState = GamePad.GetState(Game.playerIndex); Vector2 leftStick = gamePadState.ThumbSticks.Left; Vector2 rightStick = gamePadState.ThumbSticks.Right; if (Keyboard.GetState().IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.Start)) { result = optionList[selectedOption].result; animateTime = 0; state = PauseMenuState.NURSEOUT; SoundEffects.PlayMove(); } if (gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Right) || leftStick.X > Game.gameSettings.controlStickTrigger || rightStick.X > Game.gameSettings.controlStickTrigger) { selectedOption++; SoundEffects.PlayClick(); if (selectedOption >= optionList.Count()) selectedOption = optionList.Count() - 1; cooldown = 250; } if (gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || leftStick.X < -Game.gameSettings.controlStickTrigger || rightStick.X < -Game.gameSettings.controlStickTrigger) { selectedOption--; SoundEffects.PlayClick(); if (selectedOption < 0) selectedOption = 0; cooldown = 250; } if (gamePadState.IsButtonDown(Buttons.B)) { result = MenuResult.ResumeGame; animateTime = 0; state = PauseMenuState.NURSEOUT; SoundEffects.PlayMove(); } } return MenuResult.None; }
public async Task <TData <object> > GetPageListAndUserInfo() { var operatorInfo = await _operatorCache.Current(); var objMenu = await _menuBLL.GetList(null); var menuList = objMenu.Data; menuList = menuList.Where(p => p.MenuStatus == StatusEnum.Yes.ParseToInt()).ToList(); if (operatorInfo.IsSystem != 1) { var objMenuAuthorize = await _menuAuthorizeBLL.GetAuthorizeList(operatorInfo); var authorizeMenuIdList = objMenuAuthorize.Data.Select(p => p.MenuId).ToList(); menuList = menuList.Where(p => authorizeMenuIdList.Contains(p.Id)).ToList(); } #region 导航栏数据处理 var menuResult = new List <MenuResult>(); foreach (var menu in menuList.Where(p => p.ParentId == 0).OrderBy(p => p.MenuSort)) { var menu_a = new MenuResult(); menu_a.url = HttpHelper.IsUrl(menu.MenuUrl) ? menu.MenuUrl : "javascript:;"; menu_a.icon = menu.MenuIcon; menu_a.name = menu.MenuName; menu_a.subMenus = new List <MenuResult>(); foreach (var secondMenu in menuList.Where(p => p.ParentId == menu.Id).OrderBy(p => p.MenuSort)) { var menu_b = new MenuResult(); menu_b.url = HttpHelper.IsUrl(secondMenu.MenuUrl) ? secondMenu.MenuUrl : "javascript:;"; menu_b.name = secondMenu.MenuName; menu_b.url = secondMenu.MenuUrl; if (menuList.Where(p => p.ParentId == secondMenu.Id && p.MenuType != (int)MenuTypeEnum.Button) .Count() != 0) { menu_b.subMenus = new List <MenuResult>(); foreach (var thirdMenu in menuList.Where(p => p.ParentId == secondMenu.Id) .OrderBy(p => p.MenuSort)) { var menu_c = new MenuResult(); menu_c.url = HttpHelper.IsUrl(thirdMenu.MenuUrl) ? thirdMenu.MenuUrl : "javascript:;"; menu_c.name = thirdMenu.MenuName; menu_c.url = thirdMenu.MenuUrl; menu_b.subMenus.Add(menu_c); } } menu_a.subMenus.Add(menu_b); } menuResult.Add(menu_a); } #endregion var data = new TData <object>(); data.Tag = 1; data.Data = new { operatorInfo, menuResult }; return(data); }
public static string DrawLayout(GUIContent guiContent, string sequence, ref Rect rect, ref SequenceSyntaxState syntaxState) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(guiContent); EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(sequence)); if (GUILayout.Button(new GUIContent("Check", "Check sequence for errors."), EditorStyles.miniButton, GUILayout.Width(52))) { syntaxState = CheckSyntax(sequence); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginChangeCheck(); if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(26))) { DrawContextMenu(sequence); } EditorGUILayout.EndHorizontal(); if (menuResult != MenuResult.Unselected) { sequence = ApplyMenuResult(menuResult, sequence); menuResult = MenuResult.Unselected; } //EditorWindowTools.StartIndentedSection(); // Removed indent; looks better without. SetSyntaxStateGUIColor(syntaxState); var newSequence = EditorGUILayout.TextArea(sequence); ClearSyntaxStateGUIColor(); if (!string.Equals(newSequence, sequence)) { sequence = newSequence; GUI.changed = true; } switch (Event.current.type) { case EventType.Repaint: rect = GUILayoutUtility.GetLastRect(); break; case EventType.DragUpdated: case EventType.DragPerform: if (rect.Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (var obj in DragAndDrop.objectReferences) { if (obj is AudioClip) { // Drop audio clip according to selected audio command: var clip = obj as AudioClip; var path = AssetDatabase.GetAssetPath(clip); if (path.Contains("Resources")) { sequence = AddCommandToSequence(sequence, GetCurrentAudioCommand() + "(" + GetResourceName(path) + ")"); GUI.changed = true; } else if (GetCurrentAudioCommand() == "LipSync") { sequence = AddCommandToSequence(sequence, GetCurrentAudioCommand() + "(" + System.IO.Path.GetFileNameWithoutExtension(path) + ")"); GUI.changed = true; } else { EditorUtility.DisplayDialog("Not in Resources Folder", "To use drag-n-drop, audio clips must be located in the hierarchy of a Resources folder.", "OK"); } } else if (obj is GameObject) { // Drop GameObject. var go = obj as GameObject; if (sequence.EndsWith("(")) { // If sequence ends in open paren, add GameObject and close: sequence += go.name + ")"; } else { // Drop GameObject according to selected GameObject command: var command = Event.current.alt ? alternateGameObjectDragDropCommand : gameObjectDragDropCommand; sequence = AddCommandToSequence(sequence, GetCurrentGameObjectCommand(command, go.name)); } GUI.changed = true; } else if (obj is Component) { // Drop component. var component = obj as Component; var go = component.gameObject; if (sequence.EndsWith("(")) { // If sequence ends in open paren, add component and close: sequence += component.GetType().Name + ")"; } else { // Drop component according to selected component command: var command = Event.current.alt ? alternateComponentDragDropCommand : componentDragDropCommand; sequence = AddCommandToSequence(sequence, GetCurrentComponentCommand(command, component.GetType().Name, go.name)); } GUI.changed = true; } } } } break; } // If content changed, reset syntax check state: if (EditorGUI.EndChangeCheck()) { syntaxState = SequenceSyntaxState.Unchecked; } //EditorWindowTools.EndIndentedSection(); return(sequence); }
public MenuResult UpdateMenu( AuthIdentity identity, Guid? menuId, Guid[] recipesAdd, Guid[] recipesRemove, MenuMove[] recipesMove, bool clear, string newName = null) { var menuResult = new MenuResult(); menuResult.MenuUpdated = true; // TODO: Verify actual changes were made before setting MenuUpdated to true using (var session = this.GetSession()) { using (var transaction = session.BeginTransaction()) { Menus dbMenu = null; IList<Favorites> dbRecipes; if (menuId.HasValue) { dbMenu = session .QueryOver<Menus>() .Fetch(prop => prop.Recipes).Eager .Where(p => p.MenuId == menuId) .SingleOrDefault(); if (dbMenu == null) { throw new MenuNotFoundException(); } if (dbMenu.UserId != identity.UserId) { throw new UserDoesNotOwnMenuException(); } if (!string.IsNullOrWhiteSpace(newName)) { dbMenu.Title = newName.Trim(); } dbRecipes = dbMenu.Recipes; } else { dbRecipes = session .QueryOver<Favorites>() .Where(p => p.UserId == identity.UserId) .Where(p => p.Menu == null) .List(); } if (recipesAdd.Any()) { var existing = from r in dbRecipes select r.Recipe.RecipeId; recipesAdd = recipesAdd.Except(existing).ToArray(); foreach (var rid in recipesAdd) { var fav = new Favorites { UserId = identity.UserId, Recipe = new Recipes { RecipeId = rid }, Menu = dbMenu }; session.Save(fav); } } if (recipesRemove.Any()) { var toDelete = from r in dbRecipes where recipesRemove.Contains(r.Recipe.RecipeId) select r; toDelete.ForEach(session.Delete); } if (clear) { dbRecipes.ForEach(session.Delete); } if (recipesMove.Any()) { foreach (var moveAction in recipesMove) { Menus dbTarget = null; if (moveAction.TargetMenu.HasValue) { dbTarget = session .QueryOver<Menus>() .Where(p => p.MenuId == moveAction.TargetMenu.Value) .Where(p => p.UserId == identity.UserId) .SingleOrDefault(); if (dbTarget == null) { throw new MenuNotFoundException(moveAction.TargetMenu.Value); } } var rToMove = moveAction.MoveAll ? dbRecipes : dbRecipes.Where(r => moveAction.RecipesToMove.Contains(r.Recipe.RecipeId)); rToMove.ForEach(a => a.Menu = dbTarget); } } transaction.Commit(); } } return menuResult; }
private static void SetMenuResult(object data) { menuResult = (MenuResult)data; }
public MenuResult Update(GameTime gameTime) { cooldown -= gameTime.ElapsedGameTime.Milliseconds; if (cooldown < 0) cooldown = 0; if (state == GameOverMenuState.SCORECHECK) { currentCharacter = 0; rank = -1; HighScoreData highScoreData = HighScoreTracker.LoadHighScores(); if (Game.currentSettings.mode == GameMode.TimeAttack) { levelData = highScoreData.timeAttackLevels[level]; highScoreData.timeAttackLevels[level].played = true; if (highScoreData.timeAttackLevels[level].rank < 3 && score >= Game.currentSettings.three_star) { congratulationsMessage = "Outstanding job! This patient has made a full \nrecovery, giving you the top ranking! Way to go!"; highScoreData.timeAttackLevels[level].rank = 3; } else if (highScoreData.timeAttackLevels[level].rank < 2 && score >= Game.currentSettings.two_star) { congratulationsMessage = "Great job! You've earned two stars! Try to score\n" + Game.currentSettings.three_star + " points to make it to the next rank!"; highScoreData.timeAttackLevels[level].rank = 2; } else if (highScoreData.timeAttackLevels[level].rank == 0) { highScoreData.timeAttackLevels[level].rank = 1; congratulationsMessage = "Good job! You've earned one star! Try to score " + Game.currentSettings.two_star + " \npoints to make it to the next rank!"; } else if (highScoreData.timeAttackLevels[level].rank == 3) { congratulationsMessage = "This patient has already made a full recovery! \nYou should see if you can beat your high score!"; } else if (highScoreData.timeAttackLevels[level].rank == 2) { congratulationsMessage = "Try to score " + Game.currentSettings.three_star + " points to earn three \nstars!"; } else if (highScoreData.timeAttackLevels[level].rank == 1) { congratulationsMessage = "Try to score " + Game.currentSettings.two_star + " points to earn two \nstars!"; } else { congratulationsMessage = "BUG!"; } for (int i = 4; i >= 0; i--) { if (score >= levelData.highScores[i]) { if (i < 4) { levelData.highScores[i + 1] = levelData.highScores[i]; levelData.playerNames[i + 1] = levelData.playerNames[i]; } initials = levelData.playerNames[i]; rank = i; levelData.highScores[i] = score; } } if (score >= Game.currentSettings.two_star && level < highScoreData.timeAttackLevels.Count()-1) { if(highScoreData.timeAttackLevels[level+1]!=null) highScoreData.timeAttackLevels[level + 1].unlocked = true; } } if (Game.currentSettings.mode == GameMode.MoveChallenge) { levelData = highScoreData.moveChallengeLevels[level]; highScoreData.moveChallengeLevels[level].played = true; if (highScoreData.moveChallengeLevels[level].rank < 3 && score >= Game.currentSettings.three_star) { congratulationsMessage = "Outstanding job! This patient has made a full \nrecovery, giving you the top ranking! Way to go!"; highScoreData.moveChallengeLevels[level].rank = 3; } else if (highScoreData.moveChallengeLevels[level].rank < 2 && score >= Game.currentSettings.two_star) { congratulationsMessage = "Great job! You've earned two stars! Try to score \n" + Game.currentSettings.three_star + " points to make it to the next rank!"; highScoreData.moveChallengeLevels[level].rank = 2; } else if (highScoreData.moveChallengeLevels[level].rank == 0) { highScoreData.moveChallengeLevels[level].rank = 1; congratulationsMessage = "Good job! You've earned one star! Try to score " + Game.currentSettings.two_star + " \npoints to make it to the next rank!"; } else if (highScoreData.moveChallengeLevels[level].rank == 3) { congratulationsMessage = "This patient has already made a full recovery! \nYou should see if you can beat your high score!"; } else if (highScoreData.moveChallengeLevels[level].rank == 2) { congratulationsMessage = "Try to score " + Game.currentSettings.three_star + " points to earn three \nstars!"; } else if (highScoreData.moveChallengeLevels[level].rank == 1) { congratulationsMessage = "Try to score " + Game.currentSettings.two_star + " points to earn two \nstars!"; } else { congratulationsMessage = "BUG!"; } for (int i = 4; i >= 0; i--) { if (score >= levelData.highScores[i]) { if (i < 4) { levelData.highScores[i + 1] = levelData.highScores[i]; levelData.playerNames[i + 1] = levelData.playerNames[i]; } initials = levelData.playerNames[i]; rank = i; levelData.highScores[i] = score; } } if (score >= Game.currentSettings.two_star && level < highScoreData.moveChallengeLevels.Count() - 1) { if (highScoreData.moveChallengeLevels[level + 1] != null) highScoreData.moveChallengeLevels[level + 1].unlocked = true; } } else if (Game.currentSettings.mode == GameMode.Puzzle) { levelData = highScoreData.puzzleLevels[level]; highScoreData.puzzleLevels[level].played = true; TimeSpan twoStarTime = new TimeSpan(0, 0, 0, 0, Game.currentSettings.two_star); TimeSpan threeStarTime = new TimeSpan(0, 0, 0, 0, Game.currentSettings.three_star); if (highScoreData.puzzleLevels[level].rank < 3 && score <= Game.currentSettings.three_star) { congratulationsMessage = "Outstanding job! This patient has made a full \nrecovery, giving you the top ranking! Way to go!"; highScoreData.puzzleLevels[level].rank = 3; } else if (highScoreData.puzzleLevels[level].rank < 2 && score <= Game.currentSettings.two_star) { congratulationsMessage = string.Format("Great job! You've earned two stars! Try to finish \nin under {0}:{1:D2} to make it to the next rank!",threeStarTime.Minutes,threeStarTime.Seconds); highScoreData.puzzleLevels[level].rank = 2; } else if (highScoreData.puzzleLevels[level].rank == 0) { highScoreData.puzzleLevels[level].rank = 1; congratulationsMessage = string.Format("Good job! You've earned one star! Try to finish \nin under {0}:{1:D2} to make it to the next rank!",twoStarTime.Minutes,twoStarTime.Seconds); } else if (highScoreData.puzzleLevels[level].rank == 3) { congratulationsMessage = "This patient has already made a full recovery! \nSee if you can beat your high score!"; } else if (highScoreData.puzzleLevels[level].rank == 2) { congratulationsMessage = string.Format("Try to finish in under {0}:{1:D2} to earn three \nstars!", threeStarTime.Minutes, threeStarTime.Seconds); } else if (highScoreData.puzzleLevels[level].rank == 1) { congratulationsMessage = string.Format("Try to finish in under {0}:{1:D2} to earn two \nstars!",twoStarTime.Minutes,twoStarTime.Seconds); } else { congratulationsMessage = "BUG!"; } for (int i = 4; i >= 0; i--) { if (score <= levelData.highScores[i]) { if (i < 4) { levelData.highScores[i + 1] = levelData.highScores[i]; levelData.playerNames[i + 1] = levelData.playerNames[i]; } initials = levelData.playerNames[i]; rank = i; levelData.highScores[i] = score; } } if (score <= Game.currentSettings.two_star && level < highScoreData.puzzleLevels.Count() - 1) { List<Settings> puzzleSettings = SettingsLoader.LoadPuzzleLevels(); if (Game.currentSettings.difficulty == Difficulty.EASY) { for (int i = 0; i < puzzleSettings.Count(); i++) { if (highScoreData.puzzleLevels[i] != null && (puzzleSettings[i].difficulty == Difficulty.MEDIUM || puzzleSettings[i].difficulty == Difficulty.EASY)) highScoreData.puzzleLevels[i].unlocked = true; } } if (Game.currentSettings.difficulty == Difficulty.MEDIUM) { for (int i = 0; i < puzzleSettings.Count(); i++) { if (highScoreData.puzzleLevels[i] != null && puzzleSettings[i].difficulty == Difficulty.HARD) highScoreData.puzzleLevels[i].unlocked = true; } } } } HighScoreTracker.SaveHighScores(highScoreData); state = GameOverMenuState.DOCTORIN; } if (state == GameOverMenuState.DOCTORIN || state == GameOverMenuState.DOCTOROUT || state == GameOverMenuState.ANIMATEDOWN || state == GameOverMenuState.ANIMATEUP) { animateTime+=gameTime.ElapsedGameTime.Milliseconds; } if (state == GameOverMenuState.DOCTORIN && animateTime > 250) { MusicControl.PlayMenuMusic(); state = GameOverMenuState.READY; if(rank!=-1) state = GameOverMenuState.INITIALS; } if (state == GameOverMenuState.DOCTOROUT && animateTime > 250) { animateTime = 0; state = GameOverMenuState.DOCTORIN; return result; } if (state == GameOverMenuState.ANIMATEDOWN && animateTime > 250) { animateTime = 0; state = GameOverMenuState.READY; } if (state == GameOverMenuState.ANIMATEUP && animateTime > 250) { animateTime = 0; state = GameOverMenuState.READY; } if (state == GameOverMenuState.INITIALS && cooldown == 0) { GamePadState gamePadState = GamePad.GetState(Game.playerIndex); Vector2 leftStick = gamePadState.ThumbSticks.Left; Vector2 rightStick = gamePadState.ThumbSticks.Right; if (gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.IsButtonDown(Buttons.DPadDown) || Keyboard.GetState().IsKeyDown(Keys.Down) || leftStick.Y < -Game.gameSettings.controlStickTrigger || rightStick.Y < -Game.gameSettings.controlStickTrigger) { SoundEffects.PlayClick(); Char[] cArray = initials.ToCharArray(); Char c = cArray[currentCharacter]; c--; if (c < 'A') c = 'Z'; cArray[currentCharacter] = c; initials = new String(cArray); cooldown = 100; } if (gamePadState.IsButtonDown(Buttons.DPadUp) || gamePadState.IsButtonDown(Buttons.DPadUp) || Keyboard.GetState().IsKeyDown(Keys.Up) || leftStick.Y > Game.gameSettings.controlStickTrigger || rightStick.Y > Game.gameSettings.controlStickTrigger) { SoundEffects.PlayClick(); Char[] cArray = initials.ToCharArray(); Char c = cArray[currentCharacter]; c++; if (c > 'Z') c = 'A'; cArray[currentCharacter] = c; initials = new String(cArray); cooldown = 100; } if (gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Right) || gamePadState.IsButtonDown(Buttons.A)) { currentCharacter++; cooldown = 250; if (currentCharacter > 2) { SoundEffects.PlayScore(); cooldown = 500; levelData.playerNames[rank] = initials; HighScoreData data = HighScoreTracker.LoadHighScores(); levelData.played = true; if (Game.currentSettings.mode == GameMode.TimeAttack) { data.timeAttackLevels[level] = levelData; } else if (Game.currentSettings.mode == GameMode.Puzzle) { data.puzzleLevels[level] = levelData; } else { data.moveChallengeLevels[level] = levelData; } HighScoreTracker.SaveHighScores(data); state = GameOverMenuState.READY; } else { SoundEffects.PlayClick(); } } if (gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || gamePadState.IsButtonDown(Buttons.B)) { SoundEffects.PlayClick(); if (currentCharacter > 0) { currentCharacter--; cooldown = 250; } } } if (state == GameOverMenuState.READY && cooldown == 0) { GamePadState gamePadState = GamePad.GetState(Game.playerIndex); Vector2 leftStick = gamePadState.ThumbSticks.Left; Vector2 rightStick = gamePadState.ThumbSticks.Right; if (Keyboard.GetState().IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.Start)) { result = optionList[selectedIndex].result; animateTime = 0; state = GameOverMenuState.DOCTOROUT; SoundEffects.PlayScore(); } if (gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.IsButtonDown(Buttons.DPadDown) || Keyboard.GetState().IsKeyDown(Keys.Down) || leftStick.Y < -Game.gameSettings.controlStickTrigger || rightStick.Y < -Game.gameSettings.controlStickTrigger) { if (selectedIndex < optionList.Count() - 1) { state = GameOverMenuState.ANIMATEDOWN; animateTime = 0; selectedIndex++; cooldown = 250; SoundEffects.PlayMove(); } } if (gamePadState.IsButtonDown(Buttons.DPadUp) || gamePadState.IsButtonDown(Buttons.DPadUp) || Keyboard.GetState().IsKeyDown(Keys.Up) || leftStick.Y > Game.gameSettings.controlStickTrigger || rightStick.Y > Game.gameSettings.controlStickTrigger) { if (selectedIndex > 0) { state = GameOverMenuState.ANIMATEUP; animateTime = 0; selectedIndex--; cooldown = 250; SoundEffects.PlayMove(); } } } return MenuResult.None; }
public static string DrawLayout(GUIContent guiContent, string sequence, ref Rect rect) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(guiContent); if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(26))) { DrawContextMenu(sequence); } EditorGUILayout.EndHorizontal(); if (menuResult != MenuResult.Unselected) { sequence = ApplyMenuResult(menuResult, sequence); menuResult = MenuResult.Unselected; } EditorWindowTools.StartIndentedSection(); var newSequence = EditorGUILayout.TextArea(sequence); if (!string.Equals(newSequence, sequence)) { sequence = newSequence; GUI.changed = true; } switch (Event.current.type) { case EventType.Repaint: rect = GUILayoutUtility.GetLastRect(); break; case EventType.DragUpdated: case EventType.DragPerform: if (rect.Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (var obj in DragAndDrop.objectReferences) { if (obj is AudioClip) { // Drop audio clip according to selected audio command: var clip = obj as AudioClip; var path = AssetDatabase.GetAssetPath(clip); if (path.Contains("Resources")) { sequence = AddCommandToSequence(sequence, GetCurrentAudioCommand() + "(" + GetResourceName(path) + ")"); GUI.changed = true; } else { EditorUtility.DisplayDialog("Not in Resources Folder", "Audio clips must be located in the hierarchy of a Resources folder or an AssetBundle.", "OK"); } } else if (obj is GameObject) { // Drop GameObject. var go = obj as GameObject; if (sequence.EndsWith("(")) { // If sequence ends in open paren, add GameObject and close: sequence += go.name + ")"; } else { // Drop GameObject according to selected GameObject command: var command = Event.current.alt ? alternateGameObjectDragDropCommand : gameObjectDragDropCommand; sequence = AddCommandToSequence(sequence, GetCurrentGameObjectCommand(command, go.name)); } GUI.changed = true; } } } } break; } EditorWindowTools.EndIndentedSection(); return(sequence); }
public void AddMenuItem(MenuResult result, String text) { optionList.Add(new MenuOption(result, text, "BUG")); }