/// <summary> /// 计算LoadingImage的参数,以便自绘 /// </summary> private void GetParameter(Image img) { try { // 计算FrameNumber,如果宽度大于高度,X轴切割, 高度大于宽度Y轴切割 // 如果高宽相等,只有一帧,不需要动画 if ((img.Size.Width > img.Size.Height)) { mCutStyle = CutStyle.XAxis; mCutStepWidth = img.Size.Width / mFrameNumber; mCutStepHeight = img.Size.Height; mCutMax = img.Size.Width; } else if ((img.Size.Width == img.Size.Height)) { mCutStyle = CutStyle.None; mCutMax = 0; mCutStepWidth = img.Size.Width; mCutStepHeight = img.Size.Height; } else if ((img.Size.Height > img.Size.Width)) { mCutStyle = CutStyle.YAxis; mCutStepWidth = img.Size.Height / mFrameNumber; mCutStepHeight = img.Size.Width; mCutMax = img.Size.Height; } } catch (Exception ex) { } }
public void SingleConditionCut(CutStyle style, int CutCount) { switch (style) { case CutStyle.ColumnCut: SplitContainer Colsplitter = new SplitContainer(); this.Controls.Add(Colsplitter); Colsplitter.Dock = DockStyle.Fill; Colsplitter.Orientation = Orientation.Vertical; Colsplitter.SplitterDistance = PanelWidth; LsSplitChildPanel.Add(Colsplitter.Panel1); PanelCols--; PanelColsCut(Colsplitter.Panel2); break; case CutStyle.RowCut: SplitContainer Rowsplitter = new SplitContainer(); this.Controls.Add(Rowsplitter); Rowsplitter.Dock = DockStyle.Fill; Rowsplitter.Orientation = Orientation.Horizontal; Rowsplitter.SplitterDistance = PanelHeight; LsSplitChildPanel.Add(Rowsplitter.Panel1); CutCount--; PanelRowsCut(Rowsplitter.Panel2, CutCount); break; default: break; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ImageUrl,Price,Remarks")] CutStyle cutStyle) { if (id != cutStyle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cutStyle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CutStyleExists(cutStyle.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cutStyle)); }
public async Task <IActionResult> Create([Bind("Id,Name,ImageUrl,Price,Remarks")] CutStyle cutStyle) { if (ModelState.IsValid) { _context.Add(cutStyle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cutStyle)); }
public AutoSplitContainer(int PanelCount, CutStyle SplitStyle) { InitializeComponent(); if (SplitStyle == CutStyle.RowCut) { PanelHeight = this.Height / PanelCount; PanelRows = PanelCount; } else { PanelWidth = this.Width / PanelCount; PanelCols = PanelCount; } SingleConditionCut(SplitStyle, PanelCount); }
protected override void Seed(PizzeriaContext context) { var brisbane = new Location() { Name = "Brisbane" }; var sydney = new Location() { Name = "Sydney" }; var locations = new List <Location>() { brisbane, sydney, }; context.Locations.AddRange(locations); context.SaveChanges(); var ingredients = new string[] { "mushrooms", "cheese", "ham", "mozarella", "olives", "pastrami", "onion", "garlic", "oregano", "chili peppers", "chicken" } .ToDictionary(ingred => ingred, ingred => new Ingredient() { Name = ingred }); context.Ingredients.AddRange(ingredients.Values); context.SaveChanges(); foreach (var loc in locations) { foreach (var ingred in ingredients.Values) { context.LocationIngredients.Add(new LocationIngredient() { Location = loc, Ingredient = ingred, Price = 2 }); } } /*var locationIngredients = locations.ToDictionary(loc => loc.Name, loc => ingredients.Values.ToDictionary(ingred => ingred.Name, ingred => new LocationIngredient() { LocationID = loc.ID, IngredientID = ingred.ID, Price = 2 })); * context.LocationIngredients.AddRange(locationIngredients.Values.SelectMany(x => x.Values));*/ var standardBake = new BakingMethod() { Duration = 30, Temperature = 200 }; var margheritaBake = new BakingMethod() { Duration = 15, Temperature = 200 }; context.BakingMethods.AddRange(new BakingMethod[] { standardBake, margheritaBake }); context.SaveChanges(); var standardCutStyle = new CutStyle() { NumberOfSlices = 8 }; var florenzaCutStyle = new CutStyle() { NumberOfSlices = 6, ExtraInstructions = "with a special knife" }; var capriciosa = new Pizza() { Name = "Capriciosa", BakingMethod = standardBake, CutStyle = standardCutStyle }; var florenza = new Pizza() { Name = "Florenza", BakingMethod = standardBake, CutStyle = florenzaCutStyle }; var margherita = new Pizza() { Name = "Margherita", BakingMethod = margheritaBake, CutStyle = standardCutStyle }; var inferno = new Pizza() { Name = "Inferno", BakingMethod = standardBake, CutStyle = standardCutStyle }; AddIngredientsToPizza(capriciosa, new string[] { "mushrooms", "cheese", "ham", "mozarella" }, ingredients); AddIngredientsToPizza(florenza, new string[] { "olives", "pastrami", "mozarella", "onion" }, ingredients); AddIngredientsToPizza(margherita, new string[] { "mozarella", "onion", "garlic", "oregano" }, ingredients); AddIngredientsToPizza(inferno, new string[] { "chili peppers", "mozarella", "chicken", "cheese" }, ingredients); context.Pizzas.AddRange(new Pizza[] { capriciosa, florenza, margherita, inferno }); context.SaveChanges(); context.PizzaMenuItems.Add(new PizzaMenuItem() { PizzaID = capriciosa.ID, LocationID = brisbane.ID, BasePrice = 20 }); context.PizzaMenuItems.Add(new PizzaMenuItem() { PizzaID = florenza.ID, LocationID = brisbane.ID, BasePrice = 21 }); context.PizzaMenuItems.Add(new PizzaMenuItem() { PizzaID = margherita.ID, LocationID = brisbane.ID, BasePrice = 22 }); context.PizzaMenuItems.Add(new PizzaMenuItem() { PizzaID = capriciosa.ID, LocationID = sydney.ID, BasePrice = 30 }); context.PizzaMenuItems.Add(new PizzaMenuItem() { PizzaID = inferno.ID, LocationID = sydney.ID, BasePrice = 31 }); context.SaveChanges(); base.Seed(context); }