private void Initialize() { if (Element is not SvgAnchor svgAnchor) { return;; } IsAntialias = SvgExtensions.IsAntialias(svgAnchor); GeometryBounds = SKRect.Empty; CreateGeometryBounds(); Transform = SvgExtensions.ToMatrix(svgAnchor.Transforms); Fill = null; Stroke = null; ClipPath = null; MaskDrawable = null; Opacity = IgnoreAttributes.HasFlag(DrawAttributes.Opacity) ? null : SvgExtensions.GetOpacityPaint(svgAnchor); Filter = null; }
public override void PostProcess() { var element = Element; if (element == null) { return; } var enableMask = !IgnoreAttributes.HasFlag(Attributes.Mask); ClipPath = null; if (enableMask == true) { MaskDrawable = SvgClippingExtensions.GetSvgElementMask(element, TransformedBounds, new HashSet <Uri>(), _disposable); if (MaskDrawable != null) { CreateMaskPaints(); } } else { MaskDrawable = null; } Opacity = null; Filter = null; }
public override void PostProcess() { var element = Element; if (element == null) { return; } var enableOpacity = !IgnoreAttributes.HasFlag(Attributes.Opacity); ClipPath = null; MaskDrawable = null; if (enableOpacity == true) { Opacity = SvgPaintingExtensions.GetOpacitySKPaint(element, _disposable); } else { Opacity = null; } Filter = null; foreach (var child in ChildrenDrawables) { child.PostProcess(); } }
public override void PostProcess() { var element = Element; if (element is null) { return; } var enableMask = !IgnoreAttributes.HasFlag(Attributes.Mask); ClipPath = null; if (enableMask) { MaskDrawable = SvgModelExtensions.GetSvgElementMask(element, TransformedBounds, new HashSet <Uri>(), AssetLoader); if (MaskDrawable is { })
public override void PostProcess(SKRect?viewport, SKMatrix totalMatrix) { var element = Element; if (element is null) { return; } var enableMask = !IgnoreAttributes.HasFlag(DrawAttributes.Mask); ClipPath = null; if (enableMask) { MaskDrawable = SvgExtensions.GetSvgElementMask(element, GeometryBounds, new HashSet <Uri>(), AssetLoader, References); if (MaskDrawable is { })
protected bool IsIgnored(ICustomAttributeProvider provider) { return(provider.GetCustomAttributes(true) .Any(a => { var t = a.GetType(); if (IgnoreAttributes != null && IgnoreAttributes.Any(s => s == t.Name || s == t.FullName)) { return true; } if (IgnoreAttributeTypes != null && IgnoreAttributeTypes.Any(it => t == it)) { return true; } return false; })); }
public override void PostProcess() { var element = Element; if (element is null) { return; } var enableOpacity = !IgnoreAttributes.HasFlag(Attributes.Opacity); ClipPath = null; MaskDrawable = null; Opacity = enableOpacity ? SvgModelExtensions.GetOpacityPaint(element) : null; Filter = null; foreach (var child in ChildrenDrawables) { child.PostProcess(); } }
public override void PostProcess(SKRect?viewport, SKMatrix totalMatrix) { var element = Element; if (element is null) { return; } var enableOpacity = !IgnoreAttributes.HasFlag(DrawAttributes.Opacity); ClipPath = null; MaskDrawable = null; Opacity = enableOpacity ? SvgExtensions.GetOpacityPaint(element) : null; Filter = null; TotalTransform = totalMatrix.PreConcat(Transform); TransformedBounds = TotalTransform.MapRect(GeometryBounds); foreach (var child in ChildrenDrawables) { child.PostProcess(viewport, totalMatrix); } }
private void WriteMetricsToFile(TaxonomyInfo taxonomy, int taxonomyMaxDepth) { // bool noRowIfNoSchema = true; var attributes = (from sci in _currentDb.SchemaInfos join scd in _currentDb.SchemaDatas on sci.ID equals scd.SchemaID join a in _currentDb.Attributes on sci.AttributeID equals a.ID where scd.Active && sci.TaxonomyID == taxonomy.ID && scd.InSchema select a).ToList().Where(p => !IgnoreAttributes.Contains(p.AttributeName)).OrderBy( p => p.AttributeName).ToList(); var taxonomyString = taxonomy.ToString(); if (IgnoreT1Taxonomy) { taxonomyString = taxonomyString.Substring(taxonomy.ToString().IndexOf('>') + 1); } if (string.IsNullOrEmpty(taxonomy.ToString())) { return; } var taxParts = taxonomyString.Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None); var taxonomyParts = new string[taxonomyMaxDepth]; StatusMessage = string.Format("{1}{0}Reading node", Environment.NewLine, taxonomy); IEnumerable <Sku> allSkus = (from sku in _currentDb.Skus join si in _currentDb.SkuInfos on sku.ID equals si.SkuID where si.TaxonomyID == taxonomy.ID && si.Active select sku).ToList(); StatusMessage = string.Format("{1}{0}Filtering SKUs", Environment.NewLine, taxonomy); IEnumerable <Sku> filteredSkus = GetFilteredSkuList(allSkus, true, _parsedSkuInclusions, _parsedSkuExclusions).ToList(); var filteredSkuCount = filteredSkus.Count(); if (!NoSchemaIfNoSku || filteredSkuCount != 0) { for (var i = 0; i < taxonomyMaxDepth; i++) { taxonomyParts[i] = i < taxParts.Length ? taxParts[i].Trim() : string.Empty; _attributeFile.Write(taxonomyParts[i] + "\t"); // valueFile.Write(taxonomyParts[i] + "\t"); // skuFile.Write(taxonomyParts[i] + "\t"); } } if (filteredSkuCount <= 0) { if (!NoSchemaIfNoSku) { _attributeFile.WriteLine(); } //print new line // valueFile.Write("{0}", Environment.NewLine); // skuFile.Write("{0}", Environment.NewLine); return; } // Even though we only export fill rates for filtered SKUs, we export all attributes in this node StatusMessage = string.Format("{1}{0}Fetching Attributes", Environment.NewLine, taxonomy); StatusMessage = string.Format("{1}{0}Reading values", Environment.NewLine, taxonomy); IEnumerable <EntityData> filteredEntityDatas = GetEntityDatas(filteredSkus).ToList(); if (!attributes.Any()) { //print new line //this line should be uncommented _attributeFile.WriteLine(); // valueFile.Write("{0}", Environment.NewLine); // skuFile.Write("{0}", Environment.NewLine); } else // taxonomy has attributes { for (var i = 0; i < attributes.Count(); i++) { if (i != 0) { //print taxonomy for (var j = 0; j < taxonomyMaxDepth; j++) { taxonomyParts[j] = j < taxParts.Length ? taxParts[j].Trim() : string.Empty; _attributeFile.Write(taxonomyParts[j] + "\t"); // valueFile.Write(taxonomyParts[j] + "\t"); // skuFile.Write(taxonomyParts[j] + "\t"); } } var currentAttribute = attributes[i]; StatusMessage = string.Format("{1}{0}Attribute {2}", Environment.NewLine, taxonomy, currentAttribute); var schemaData = taxonomy.SchemaInfos.Where(si => si.Attribute.Equals(currentAttribute)).Select( si => si.SchemaData).FirstOrDefault(); if (schemaData == null || !schemaData.InSchema) // Only export In Schema attributes { continue; } IEnumerable <EntityData> values = filteredEntityDatas.Where(ed => ed.Attribute.Equals(currentAttribute)).ToList(); var attrCount = values.Select(ed => ed.EntityInfo.SkuID).Distinct().Count(); _attributeFile.WriteLine("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}", _delimiter, currentAttribute, filteredSkuCount, attrCount, filteredSkuCount == 0 ? 0 : attrCount * 100.00 / filteredSkuCount, schemaData.NavigationOrder, schemaData.DisplayOrder, currentAttribute.AttributeType); IEnumerable <string> distinctValues = values.Select(ed => ed.Value + _delimiter + (ed.Uom ?? string.Empty)).Distinct().OrderBy( val => val); var totalSkus = 0; if (distinctValues.Count() != 0) { for (var v = 0; v < distinctValues.Count(); v++) { var currentValue = distinctValues.ToList()[v]; var valueCount = values.Where( ed => (ed.Value + _delimiter + (ed.Uom ?? string.Empty)).Equals(currentValue)). Select(ed => ed.EntityInfo.SkuID).Distinct().Count(); totalSkus += valueCount; for (var j = 0; j < taxonomyMaxDepth; j++) { taxonomyParts[j] = j < taxParts.Length ? taxParts[j].Trim() : string.Empty; _valueFile.Write(taxonomyParts[j] + "\t"); } _valueFile.WriteLine( "{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}", _delimiter, currentAttribute, currentValue, filteredSkuCount, valueCount, filteredSkuCount == 0 ? 0 : valueCount * 100.00 / filteredSkuCount, filteredSkuCount == 0 ? 0 : attrCount * 100.00 / filteredSkuCount, schemaData.NavigationOrder, schemaData.DisplayOrder, currentAttribute.AttributeType); } //end of for } //end of if if (totalSkus < filteredSkuCount) { var currentValue = string.Empty + _delimiter + string.Empty; var valueCount = filteredSkuCount - totalSkus; for (var j = 0; j < taxonomyMaxDepth; j++) { taxonomyParts[j] = j < taxParts.Length ? taxParts[j].Trim() : string.Empty; _valueFile.Write(taxonomyParts[j] + "\t"); } _valueFile.WriteLine( "{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}", _delimiter, currentAttribute, currentValue, filteredSkuCount, valueCount, filteredSkuCount == 0 ? 0 : valueCount * 100.00 / filteredSkuCount, filteredSkuCount == 0 ? 0 : attrCount * 100.00 / filteredSkuCount, schemaData.NavigationOrder, schemaData.DisplayOrder, currentAttribute.AttributeType); } } //end of for } //end of else StatusMessage = string.Format("{1}{0}Fetching Navigation and Display attributes", Environment.NewLine, taxonomy); var navigationAttributes = taxonomy.SchemaInfos.Where(si => { var sd = si.SchemaData; return(sd != null && sd.NavigationOrder > 0); }).Select(si => si.Attribute).ToDictionary( att => att, att => att.AttributeName); var displayAttributes = taxonomy.SchemaInfos.Where(si => { var sd = si.SchemaData; return(sd != null && sd.DisplayOrder > 0); }).Select(si => si.Attribute).ToDictionary( att => att, att => att.AttributeName); var ctr = 0; for (var i = 0; i < filteredSkus.Count(); i++) { StatusMessage = string.Format("{1}{0}{2} Skus", Environment.NewLine, taxonomy, ++ctr); var currentSku = filteredSkus.ToList()[i]; IEnumerable <EntityData> skuEntityDatas = currentSku.EntityInfos.SelectMany(ei => ei.EntityDatas.Where(ed => ed.Active)).ToList(); var skuAttCount = skuEntityDatas.Where(ed => attributes.Contains(ed.Attribute)).Select(ed => ed.AttributeID). Distinct().Count(); var skuNavAttCount = skuEntityDatas.Where(ed => navigationAttributes.ContainsKey(ed.Attribute)).Select( ed => ed.AttributeID).Distinct().Count(); var skuDispAttCount = skuEntityDatas.Where(ed => displayAttributes.ContainsKey(ed.Attribute)).Select( ed => ed.AttributeID).Distinct().Count(); //print taxonomy for (var j = 0; j < taxonomyMaxDepth; j++) { taxonomyParts[j] = j < taxParts.Length ? taxParts[j].Trim() : string.Empty; _skuFile.Write(taxonomyParts[j] + "\t"); } _skuFile.WriteLine("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}{0}{10}", _delimiter, currentSku.ItemID, attributes.Count, navigationAttributes.Count, displayAttributes.Count, skuAttCount, skuNavAttCount, skuDispAttCount, attributes.Count == 0 ? 0 : skuAttCount * 100.0 / attributes.Count, navigationAttributes.Count == 0 ? 0 : skuNavAttCount * 100.0 / navigationAttributes.Count, displayAttributes.Count == 0 ? 0 : skuDispAttCount * 100.0 / displayAttributes.Count); } }