public override void DragEffectEndIn() { OperateSound.Play(); dragRect.position = ShadowRect.position; dragRect.sizeDelta = ShadowRect.sizeDelta; dragRect.transform.SetParent(SelfRect.transform); dragRect.SetAsFirstSibling(); CookingStep deleteStep = dragRect.GetComponent <CookingStep>(); deleteStep.StartTime = startTime; /* for (int i = 0; i < menuHolder.childCount; i++) //被依赖的步骤可以拖了 * { * var stepChild = menuHolder.GetChild(i); * var step = stepChild.GetComponent<CookingStep>(); * if (step.DependNotSatisfied.Contains(deleteStep)) * step.DependNotSatisfied.Remove(deleteStep); * if (step.DependNotSatisfied.Count == 0) * step.canDrag = true; * } */ AddOrder(); dragStep.Belong = this; dragStep = null; dragRect = null; HideShadow(); ShadowRect.SetAsFirstSibling(); }
public ViewResult CookingStepList(int rId) { int existingCookingSteps = cookingStepRepository.CookingSteps .Where(c => c.RecipeId == rId) .OrderBy(c => c.CookingStepNumber) .ToList() .Count(); if (existingCookingSteps == 0) // recipe exists but has no cooking steps. { CookingStep cs = new CookingStep() { CookingStepNumber = 1, RecipeId = rId, RecipeName = recipeRepository.Recipes .FirstOrDefault(r => r.RecipeId == rId) .Name }; return(View("../Admin/EditCookingStep", cs)); } else // Recipe exists and has one or more cooking steps. { return(View(cookingStepRepository.CookingSteps .Where(c => c.RecipeId == rId) .OrderBy(c => c.CookingStepNumber) .ToList())); // Sends an ordered list. } }
public ViewResult AddCookingStep(CookingStep cs) { repository.addCookingStep(cs); Recipe recipe = repository.getRecipeByID(cs.recipeId);//repository.Recipes.FirstOrDefault(r => r.Id == cs.recipeId); return(View("Edit", recipe)); }
public ViewResult DeleteCookingStep(int csId) { int rId = cookingStepRepository.CookingSteps.FirstOrDefault(c => c.CookingStepId == csId).RecipeId; CookingStep deletedCookingStep = cookingStepRepository.DeleteCookingStep(csId); if (deletedCookingStep != null) { TempData["message"] = $"Step number {deletedCookingStep.CookingStepNumber} has been deleted!"; } int existingCookingSteps = cookingStepRepository.CookingSteps .Where(c => c.RecipeId == rId) .OrderBy(c => c.CookingStepNumber) .ToList() .Count(); if (existingCookingSteps == 0) // No remaining steps. { return(View("EditRecipe", recipeRepository.Recipes.FirstOrDefault(r => r.RecipeId == rId))); } else // Existing steps. { return(View("../Home/CookingStepList", cookingStepRepository.CookingSteps .Where(c => c.RecipeId == deletedCookingStep.RecipeId) .OrderBy(c => c.CookingStepNumber) .ToList())); } }
public ViewResult AddCookingStep(int id) { CookingStep cs = new CookingStep(); cs.recipeId = id; return(View(cs)); }
/// <summary> /// Method adds new step to the list of steps in CommonMethodOfMenu /// </summary> private void AddStepToList() { Console.WriteLine("\nEnter a discription of cooking step:"); CookingStep cookingStep = new CookingStep(); cookingStep.Description = Console.ReadLine(); steps.Add(cookingStep); }
private async Task EditAsync(int cookingStepId) { CookingStep cookingStep = await _cookingStepsController.GetCookingStepByIdAsync(cookingStepId); Console.WriteLine($"\n Describe the cooking step {cookingStep.Step}: "); string stepName = await ValidationNavigation.CheckNullOrEmptyTextAsync(Console.ReadLine()); cookingStep.Name = stepName; await _cookingStepsController.EditAsync(cookingStep); }
public async Task DeleteAsync(int cookingStepId) { CookingStep stepRecipe = await GetCookingStepByIdAsync(cookingStepId); List <CookingStep> cookingStepsRecipe = await UnitOfWork.Repository.GetListWhereAsync <CookingStep>(x => x.RecipeId == stepRecipe.RecipeId && x.Step > stepRecipe.Step); foreach (CookingStep cookingStep in cookingStepsRecipe) { cookingStep.Step--; } await UnitOfWork.SaveChanges(); await UnitOfWork.Repository.DeleteAsync(stepRecipe); }
private void InitializedMenu(string filename) { //StreamReader streamreader = new StreamReader(Application.dataPath + filename); //JsonReader jr = new JsonReader(streamreader); //JsonData jd = JsonMapper.ToObject(jr); JsonData jd = JsonMapper.ToObject(Resources.Load <TextAsset>(filename).text); gameController.dishinfo = (string)jd["简介"]; gameController.dishinst = (string)jd["详介"]; foreach (JsonData i in jd["步骤"]) { CookingStep cs = Instantiate(stepPrefab, transform); cs.Init((string)i["名字"], (int)i["持续时间"], (bool)i["能否同时"], (string)i["图片"], (int)i["台子"]); var drag = cs.GetComponent <Dragable>(); gameController.stepCollection.CookingSteps.Add(cs); } for (int i = 0; i < jd["步骤"].Count; i++) { CookingStep cs = gameController.stepCollection.CookingSteps[i]; string path = "Images/步骤/" + cs.spritePath; Sprite sprite = Resources.Load <Sprite>(path); Image t = cs.GetComponentsInChildren <Image>()[2]; t.sprite = sprite; t.preserveAspect = true; Text timeText = cs.GetComponentsInChildren <Text>().Where(x => x.name == "Time").First(); timeText.text = cs.Time.ToString() + " min"; Text nameText = cs.GetComponentsInChildren <Text>().Where(x => x.name == "Name").First(); nameText.text = cs.Name; JsonData depend = jd["步骤"][i]["前置条件"]; foreach (JsonData j in depend) { cs.DirectDepend.Add(gameController.stepCollection.FindByName((string)j)); } } gameController.stepCollection.CalcDepend(); gameController.stepCollection.CookingSteps.ForEach((x) => x.Depend.ForEach((y) => x.DependNotSatisfied.Add(y) ) ); /* foreach(var step in gameController.stepCollection.CookingSteps) * { * if (step.DependNotSatisfied.Count > 0) * { * step.canDrag = false; * } * } */ }
public IActionResult EditCookingStep(CookingStep cookingStep) { if (ModelState.IsValid) { cookingStepRepository.SaveCookingStep(cookingStep); TempData["message"] = $"Step number {cookingStep.CookingStepNumber} has been saved!"; return(View("../Home/CookingStepList", cookingStepRepository.CookingSteps .Where(c => c.RecipeId == cookingStep.RecipeId) .OrderBy(c => c.CookingStepNumber) .ToList())); } else { return(View(cookingStep)); } }
public ViewResult AddCookingStep(int rId) { int stepCount = cookingStepRepository.CookingSteps .Where(x => x.RecipeId == rId) .OrderByDescending(x => x.CookingStepNumber) .First() .CookingStepNumber; CookingStep cs = new CookingStep() { CookingStepNumber = stepCount + 1, RecipeId = rId, RecipeName = cookingStepRepository.CookingSteps .FirstOrDefault(c => c.RecipeId == rId) .RecipeName }; return(View("EditCookingStep", cs)); }
private void AddStep_Click(object sender, RoutedEventArgs e) { bool IsFullInfo = (StepDerc.Text.Length != 0 && ImagePaths.Count() != 0) ? true : false; if (IsFullInfo) { var newTutorial = new CookingStep() { StepDerc = StepDerc.Text }; ImagePaths.ForEach(item => { newTutorial.StepImages.Add($"{ImagePathDirectory}{item}"); }); MyRecipe.Tutorials.Add(newTutorial); } StepDerc.Text = ""; ImagePaths.Clear(); CountStepImageButton.Visibility = Visibility.Collapsed; }
public override void DragEffectEndIn() { CookingStep addStep = drag.GetComponent <CookingStep>(); // 被拖的步骤 /* foreach(var step in addStep.Control) // 依赖addStep且在时间条上的自动弹回菜单栏 * { * if(!step.DependNotSatisfied.Exists(t => t.name == addStep.name)) * { * step.DependNotSatisfied.Add(addStep); * step.transform.SetParent(transform); * step.GetComponent<Dragable>().SetDragSize(unitSize); * step.canDrag = false; * step.Belong = null; * step.GetComponent<Dragable>().ImageChange(); * } * } */ drag.transform.SetParent(transform); drag.GetComponent <CookingStep>().Belong = null; drag.SetDragSize(unitSize); drag = null; }
void Start() { dragRect = GetComponent <RectTransform>(); transform.SetSiblingIndex(1); // 把这个物体放在最上,防止按不到 MenuHolder = GameObject.FindWithTag("MenuHolder").GetComponent <MenuHolder>(); timeHolder1 = GameObject.FindWithTag("TimeHolder1").GetComponent <TimeHolder>(); timeHolder2 = GameObject.FindWithTag("TimeHolder2").GetComponent <TimeHolder>(); menuRect = MenuHolder.transform.parent.GetComponent <RectTransform>(); timeRect1 = timeHolder1.GetComponent <RectTransform>(); timeRect2 = timeHolder2.GetComponent <RectTransform>(); cookingStep = GetComponent <CookingStep>(); children = GetComponentsInChildren <Transform>(); clock = children.Where(x => x.name == "ClockImage").First(); rt = children.Where(x => x.name == "Image").First().GetComponent <RectTransform>(); frameImage = children.Where(x => x.name == "FrameImage").First().GetComponent <RectTransform>(); animationController = FindObjectOfType <AnimationController>(); cookingSteps = FindObjectOfType <GameController>().stepCollection; }
private void Dfs(CookingStep x, List <CookingStep> y) { y.Add(x); x.DirectDepend.ForEach((z) => Dfs(z, y)); }
public override void DragEffectBegin(Dragable d) { dragRect = d.GetComponent<RectTransform>(); dragStep = d.GetComponent<CookingStep>(); ShadowRect.sizeDelta = new Vector2(minScale * dragStep.Time - minScale * 7 / 60, SelfRect.sizeDelta.y); }
public override void DragEffectEndOut() { dragStep = null; dragRect = null; oldStartTime = -1; isFirst = true; }
public async Task EditAsync(CookingStep cookingStep) { await UnitOfWork.Repository.UpdateAsync(cookingStep); }
public void DeleteCookingStep(CookingStep item) { _unitOfWork.Repository.DeleteAsync(item); }
public void UpdateCookingStep(CookingStep item) { _unitOfWork.Repository.UpdateAsync(item); }