public BuildComponentRectangle CreateBuildComponentRectangle(FabricStyle fabricStyle, Area area) { m_rectangleId += 1; var id = "R." + m_rectangleId; return(new BuildComponentRectangle(id, fabricStyle, area)); }
public BuildComponentYardage CreateBuildComponentYardage(FabricStyle fabricStyle, AreaSizes areaSize) { m_yardageId += 1; var id = "Y." + m_yardageId; return(new BuildComponentYardage(id, fabricStyle, areaSize)); }
public BuildComponentRectangle(string id, FabricStyle fabricStyle, Area area) : base(id) { if (fabricStyle == null) { throw new ArgumentNullException(nameof(fabricStyle)); } if (area == null) { throw new ArgumentNullException(nameof(area)); } if (area.Width < area.Height) { area = new Area(area.Height, area.Width); } m_area = area; m_styleKey = CreateStyleKey(fabricStyle, area); var rectangleShapeNode = new RectangleShapeNode(fabricStyle); var scale = DimensionScale.CreateIdentity(area.Width.Unit); rectangleShapeNode.UpdatePath(PathGeometries.Rectangle.CreatePath(m_area.Width, m_area.Height), PathOrientation.CreateDefault(), scale); m_rectangleShapeNode = rectangleShapeNode; }
public BuildComponentFlyingGoose CreateBuildComponentFlyingGooose(FabricStyle fabricStyleBody, FabricStyle fabricStyleCorner, Area area, bool trim) { m_flyingGooseId += 1; var id = "FG." + m_flyingGooseId; return(new BuildComponentFlyingGoose(id, fabricStyleBody, fabricStyleCorner, area, trim)); }
protected ShapeNode(FabricStyle fabricStyle, IPathGeometry pathGeometry) : base(pathGeometry) { if (pathGeometry == null) { throw new ArgumentNullException(nameof(pathGeometry)); } m_fabricStyle = fabricStyle ?? throw new ArgumentNullException(nameof(fabricStyle)); }
public static MDesign_FabricStyle MDesign_FabricStyle(FabricStyle fabricStyle) { var result = new MDesign_FabricStyle() { Sku = fabricStyle.Sku, Color = MDesign_Color(fabricStyle.Color) }; return(result); }
public BuildFabricStyle(FabricStyle fabricStyle) { if (fabricStyle == null) { throw new ArgumentNullException(nameof(fabricStyle)); } m_sku = fabricStyle.Sku; m_color = fabricStyle.Color; }
private static XDesign_FabricStyle XDesign_FabricStyle(FabricStyle fabricStyle) { var result = new XDesign_FabricStyle() { sku = fabricStyle.Sku, color = XDesign_Color(fabricStyle.Color) }; return(result); }
public KitSpecification() { m_width = DefaultWidth; m_height = DefaultHeight; m_borderWidth = DefaultBorderWidth; m_bindingWidth = DefaultBindingWidth; m_hasBacking = DefaultHasBacking; m_trimTriangles = DefaultTrimTriangles; m_borderFabricStyle = DefaultBorderFabricStyle; m_bindingFabricStyle = DefaultBindingFabricStyle; m_backingFabricStyle = DefaultBackingFabricStyle; }
protected ShapeNode(JToken json) : base(json) { var jsonFabricStyle = json[JsonNames.FabricStyle]; if (jsonFabricStyle != null) { m_fabricStyle = new FabricStyle(jsonFabricStyle); } else { m_fabricStyle = FabricStyle.Default; } }
public static string CreateStyleKey(FabricStyle fabricStyle, Area area) { var sb = new StringBuilder() .Append(typeof(BuildComponentRectangle).Name) .Append(StyleKeyDelimiter) .Append(fabricStyle.Sku) .Append(StyleKeyDelimiter) .Append(area.LargestDimension.ToString()) .Append(StyleKeyDelimiter) .Append(area.SmallestDimension.ToString()); return(sb.ToString()); }
public BuildComponentFlyingGoose(string id, FabricStyle fabricStyleBody, FabricStyle fabricStyleCorner, Area area, bool trim) : base(id) { if (fabricStyleBody == null) { throw new ArgumentNullException(nameof(fabricStyleBody)); } if (fabricStyleCorner == null) { throw new ArgumentNullException(nameof(fabricStyleCorner)); } if (area == null) { throw new ArgumentNullException(nameof(area)); } if (area.Width < area.Height) { area = new Area(area.Height, area.Width); } m_area = area; m_fabricStyles = new FabricStyle[] { fabricStyleBody, fabricStyleCorner }; m_trim = trim; m_styleKey = CreateStyleKey(fabricStyleBody, fabricStyleCorner, area); var halfSquareTriangleNode1 = new HalfSquareTriangleLayoutNode(); halfSquareTriangleNode1.LayoutSites[0].Node = new TriangleShapeNode(fabricStyleCorner); halfSquareTriangleNode1.LayoutSites[1].Node = new TriangleShapeNode(fabricStyleBody); var halfSquareTriangleNode2 = new HalfSquareTriangleLayoutNode(); halfSquareTriangleNode2.LayoutSites[0].Node = new TriangleShapeNode(fabricStyleCorner); halfSquareTriangleNode2.LayoutSites[1].Node = new TriangleShapeNode(fabricStyleBody); var gridLayoutNode = new GridLayoutNode(1, 2); gridLayoutNode.GetLayoutSite(0, 0).Node = halfSquareTriangleNode1; gridLayoutNode.GetLayoutSite(0, 1).Node = halfSquareTriangleNode2; gridLayoutNode.GetLayoutSite(0, 1).PathOrientation.PointOffset = 3; var scale = DimensionScale.CreateIdentity(area.Width.Unit); gridLayoutNode.UpdatePath(PathGeometries.Rectangle.CreatePath(area.Width, area.Height), PathOrientation.CreateDefault(), scale); m_gridLayoutNode = gridLayoutNode; }
public BorderLayoutNode(FabricStyle fabricStyle, Dimension width) : base(PathGeometries.Rectangle) { if (width < new Dimension(0, width.Unit)) { throw new ArgumentOutOfRangeException(nameof(width)); } m_fabricStyle = fabricStyle ?? throw new ArgumentNullException(nameof(fabricStyle)); m_width = width; m_layoutSites = new LayoutSiteList(this) { new LayoutSite(this, PathGeometries.Rectangle) }; }
private void AddRectangleInput(BuildComponentFactory factory, Area area, FabricStyle fabricStyle) { var matchingComponent = FindRectangle(BuildComponentRectangle.CreateStyleKey(fabricStyle, area)); if (matchingComponent != null) { matchingComponent.Quantity += 1; } else { var component = factory.CreateBuildComponentRectangle(fabricStyle, area); AddInput(component); } }
private void AddFlyingGooseInputs(BuildComponentFactory factory, FabricStyle fabricStyleBody, FabricStyle fabricStyleCorner, Area area, bool trimTriangles) { var matchingComponent = FindFlyingGoose(BuildComponentFlyingGoose.CreateStyleKey(fabricStyleBody, fabricStyleCorner, area)); if (matchingComponent != null) { matchingComponent.Quantity += 1; } else { var component = factory.CreateBuildComponentFlyingGooose(fabricStyleBody, fabricStyleCorner, area, trimTriangles); AddInput(component); } }
public static string CreateStyleKey(FabricStyle fabricStyle1, FabricStyle fabricStyle2, Area area) { var sb = new StringBuilder(); sb.Append(typeof(BuildComponentHalfSquareTriangle).Name); sb.Append(StyleKeyDelimiter); sb.Append(fabricStyle1.Sku.CompareTo(fabricStyle2.Sku) <= 0 ? fabricStyle1.Sku : fabricStyle2.Sku); sb.Append(StyleKeyDelimiter); sb.Append(fabricStyle1.Sku.CompareTo(fabricStyle2.Sku) <= 0 ? fabricStyle2.Sku : fabricStyle1.Sku); sb.Append(StyleKeyDelimiter); sb.Append(area.LargestDimension.ToString()); sb.Append(StyleKeyDelimiter); sb.Append(area.SmallestDimension.ToString()); return(sb.ToString()); }
public BorderLayoutNode(JToken json) : base(json) { if (json == null) { throw new ArgumentNullException(nameof(json)); } var jsonFabricStyle = json[JsonNames.FabricStyle]; m_fabricStyle = jsonFabricStyle != null ? new FabricStyle(jsonFabricStyle) : FabricStyle.Default; m_width = Dimension.Parse((string)json[JsonNames.Width]); m_layoutSites = new LayoutSiteList(this, json[JsonNames.LayoutSites]); }
public static string CreateStyleKey(FabricStyle fabricStyleBody, FabricStyle fabricStyleCorner, Area area) { var result = new StringBuilder() .Append(typeof(BuildComponentFlyingGoose).Name) .Append(StyleKeyDelimiter) .Append(fabricStyleBody.Sku) .Append(StyleKeyDelimiter) .Append(fabricStyleCorner.Sku) .Append(StyleKeyDelimiter) .Append(area.LargestDimension.ToString()) .Append(StyleKeyDelimiter) .Append(area.SmallestDimension.ToString()) .ToString(); return(result); }
public BuildComponentYardage(string id, FabricStyle fabricStyle, AreaSizes areaSize) : base(id) { if (fabricStyle == null) { throw new ArgumentNullException(nameof(fabricStyle)); } m_fabricStyles = new FabricStyle[] { fabricStyle }; m_areaSize = areaSize; m_area = Area.Create(areaSize); m_styleKey = CreateStyleKey(fabricStyle, areaSize); m_regions = new List <BuildComponentYardageRegion>(); }
private void AddOrUpdateInput(BuildComponentFactory factory, FabricStyle style, Area area) { foreach (var input in Consumes) { if (input is BuildComponentRectangle inputRectangle && inputRectangle.FabricStyle.Sku == style.Sku && inputRectangle.Area.Matches(area)) { inputRectangle.Quantity += 1; return; } } var component = factory.CreateBuildComponentRectangle(style, area); AddInput(component); }
protected KitSpecification(KitSpecification prototype) { if (prototype == null) { throw new ArgumentNullException(nameof(prototype)); } m_width = prototype.m_width; m_height = prototype.m_height; m_borderWidth = prototype.m_borderWidth; m_bindingWidth = prototype.m_bindingWidth; m_hasBacking = prototype.m_hasBacking; m_trimTriangles = prototype.m_trimTriangles; m_borderFabricStyle = prototype.m_borderFabricStyle.Clone(); m_bindingFabricStyle = prototype.m_bindingFabricStyle.Clone(); m_backingFabricStyle = prototype.m_backingFabricStyle.Clone(); }
protected BorderLayoutNode(BorderLayoutNode prototype) : base(prototype) { if (prototype == null) { throw new ArgumentNullException(nameof(prototype)); } m_fabricStyle = prototype.m_fabricStyle.Clone(); m_width = prototype.m_width; m_layoutSites = prototype.m_layoutSites.Clone(this); m_borderShapes.Clear(); foreach (var borderShape in prototype.m_borderShapes) { m_borderShapes.Add((ShapeNode)borderShape.Clone()); } }
public KitSpecification(JToken json) { if (json == null) { throw new ArgumentNullException(nameof(json)); } m_width = GetDimension(json[JsonNames.Width], DefaultWidth); m_height = GetDimension(json[JsonNames.Height], DefaultHeight); m_borderWidth = GetDimension(json[JsonNames.BorderWidth], DefaultBorderWidth); m_bindingWidth = GetDimension(json[JsonNames.BindingWidth], DefaultBindingWidth); m_hasBacking = GetBoolean(json[JsonNames.HasBacking], DefaultHasBacking); m_trimTriangles = GetBoolean(json[JsonNames.TrimTriangles], DefaultTrimTriangles); m_borderFabricStyle = GetFabricStyle(json[JsonNames.BorderFabricStyle], DefaultBorderFabricStyle); m_bindingFabricStyle = GetFabricStyle(json[JsonNames.BindingFabricStyle], DefaultBindingFabricStyle); m_backingFabricStyle = GetFabricStyle(json[JsonNames.BackingFabricStyle], DefaultBackingFabricStyle); }
private static XDesign_LayoutSite[] XDesign_LayoutSites(IEnumerable <LayoutSite> layoutSites, IPalette palette) { var result = new List <XDesign_LayoutSite>(); foreach (var layoutSite in layoutSites) { FabricStyle fabricStyle = null; if (layoutSite.Style != null) { fabricStyle = palette.GetFabricStyle(int.Parse(layoutSite.Style)); } result.Add(XDesign_LayoutSite(layoutSite, fabricStyle)); } return(result.ToArray()); }
private FabricStyle GetFabricStyle(JToken token, FabricStyle defaultValue) { return(token != null ? new FabricStyle(token) : defaultValue); }
protected ShapeNode(ShapeNode prototype) : base(prototype) { m_fabricStyle = prototype.m_fabricStyle.Clone(); }
public async Task <MDesign_FabricStyleCatalog> GetFabricStyles() { using var log = BeginFunction(nameof(DesignMicroService), nameof(GetFabricStyles)); try { using var ctx = QuiltContextFactory.Create(); var inventoryItems = await(from ii in ctx.InventoryItems where ii.InventoryItemTypeCode == InventoryItemTypeCodes.Fabric && (ii.Quantity - ii.ReservedQuantity) > 0 orderby ii.Hue, ii.Saturation, ii.Value select ii).ToListAsync().ConfigureAwait(false); var tags = await(from iit in ctx.InventoryItemTags join t in ctx.Tags on iit.TagId equals t.TagId select new { iit.InventoryItemId, t.TagTypeCode, t.Value }).ToListAsync().ConfigureAwait(false); var manufacturerNames = new Dictionary <long, string>(); var collectionNameSets = new Dictionary <long, List <string> >(); foreach (var tag in tags) { var inventoryItem = inventoryItems.Where(ii => ii.InventoryItemId == tag.InventoryItemId).SingleOrDefault(); if (inventoryItem != null) { // Note: assumes an inventory item is associated with only one manufacturer. // if (tag.TagTypeCode == TagTypeCodes.Manufacturer) { manufacturerNames[tag.InventoryItemId] = tag.Value; } if (tag.TagTypeCode == TagTypeCodes.Collection) { if (!collectionNameSets.TryGetValue(tag.InventoryItemId, out var collectionNameSet)) { collectionNameSet = new List <string>(); collectionNameSets[tag.InventoryItemId] = collectionNameSet; } collectionNameSet.Add(tag.Value); } } } var manufacturers = new Dictionary <string, MDesign_FabricStyleManufacturer>(); var collectionSets = new Dictionary <MDesign_FabricStyleManufacturer, List <MDesign_FabricStyleCollection> >(); var fabricSets = new Dictionary <MDesign_FabricStyleCollection, List <MDesign_FabricStyle> >(); foreach (var inventoryItem in inventoryItems) { var manufacturerName = manufacturerNames[inventoryItem.InventoryItemId]; var collectionNameSet = collectionNameSets[inventoryItem.InventoryItemId]; if (!manufacturers.TryGetValue(manufacturerName, out var manufacturer)) { manufacturer = new MDesign_FabricStyleManufacturer() { ManufacturerName = manufacturerName }; manufacturers[manufacturerName] = manufacturer; collectionSets[manufacturer] = new List <MDesign_FabricStyleCollection>(); } var collectionSet = collectionSets[manufacturer]; foreach (var collectionName in collectionNameSet) { var collection = collectionSet.Where(r => r.CollectionName == collectionName).SingleOrDefault(); if (collection == null) { collection = new MDesign_FabricStyleCollection() { CollectionName = collectionName }; collectionSet.Add(collection); fabricSets[collection] = new List <MDesign_FabricStyle>(); } var fabricSet = fabricSets[collection]; var color = Color.FromAhsb(255, inventoryItem.Hue, inventoryItem.Saturation / 100.0, inventoryItem.Value / 100.0); var fabricStyle = new FabricStyle(inventoryItem.Sku, color); fabricSet.Add(Create.MDesign_FabricStyle(fabricStyle)); } } foreach (var collection in fabricSets.Keys) { collection.FabricStyles = fabricSets[collection].ToArray(); } foreach (var manufacturer in collectionSets.Keys) { manufacturer.Collections = collectionSets[manufacturer].ToArray(); } var result = new MDesign_FabricStyleCatalog() { Manufacturers = manufacturers.Values.ToArray() }; log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public RectangleShapeNode(FabricStyle fabricStyle) : base(fabricStyle, PathGeometries.Rectangle) { }
private static FabricStyle CreateFabricStyle(XDesign_FabricStyle xFabricStyle) { var result = new FabricStyle(xFabricStyle.sku, CreateColor(xFabricStyle.color)); return(result); }
public TriangleShapeNode(FabricStyle fabricStyle) : base(fabricStyle, PathGeometries.Triangle) { }