public override void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies) { InProcCacheEntry cacheEntry = new InProcCacheEntry { GeneratedImage = generatedImage, Dependencies = dependencies }; Cache.Insert(cacheKey, cacheEntry); }
public async Task <GeneratedImageGetModel> Get(int pGGANId, int id) { GeneratedImage generatedImage = await _generationImageService.Get(id); GeneratedImageGetModel generatedImageGetModel = _mapper.Map <GeneratedImageGetModel>(generatedImage); generatedImageGetModel.PolygonalModel = new PolygonalModelGetModel { RockFaces = Convert.ToBase64String(generatedImage.PolygonalModel.RockFaces) }; return(generatedImageGetModel); }
public void SaveResized(Composition composition, string fileName, string folderName) { GeneratedImage generatedImage = composition.GenerateImage(); string finalPath = savePath + folderName + @"/"; if (!Directory.Exists(finalPath)) { Directory.CreateDirectory(finalPath); } generatedImage.Save(finalPath + fileName); }
public override void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies) { EnsureDocument(); // Save image to disk. SaveImageToDiskCache(cacheKey, generatedImage); lock (_doc) { // Double-check that item hasn't been added to cache since we checked. if (ExistsInCache(cacheKey)) { return; } var itemElement = new XElement("item", new XAttribute("id", cacheKey), new XAttribute("isImagePresent", generatedImage.Properties.IsImagePresent), new XAttribute("format", generatedImage.Properties.Format), new XAttribute("colourDepth", generatedImage.Properties.ColourDepth)); if (generatedImage.Properties.Width != null) { itemElement.Add(new XAttribute("width", generatedImage.Properties.Width.Value)); } if (generatedImage.Properties.Height != null) { itemElement.Add(new XAttribute("height", generatedImage.Properties.Height.Value)); } if (generatedImage.Properties.JpegCompressionLevel != null) { itemElement.Add(new XAttribute("jpegCompressionLevel", generatedImage.Properties.JpegCompressionLevel.Value)); } XElement dependenciesElement = new XElement("dependencies"); itemElement.Add(dependenciesElement); foreach (var dependency in dependencies) { dependenciesElement.Add(new XElement("dependency", new XAttribute("text1", dependency.Text1 ?? string.Empty), new XAttribute("text2", dependency.Text2 ?? string.Empty), new XAttribute("text3", dependency.Text3 ?? string.Empty), new XAttribute("text4", dependency.Text4 ?? string.Empty))); } _doc.Root.Add(itemElement); _doc.Save(_docPath); } }
protected void SaveImageToDiskCache(string cacheKey, GeneratedImage generatedImage) { if (!generatedImage.Properties.IsImagePresent) return; HttpContext httpContext = HttpContext.Current; string filePath = httpContext.Server.MapPath(GetDiskCacheFilePath(httpContext, cacheKey, generatedImage.Properties.FileExtension)); using (FileStream fileStream = File.OpenWrite(filePath)) { BitmapEncoder encoder = generatedImage.Properties.GetEncoder(); encoder.Frames.Add(BitmapFrame.Create(generatedImage.Image)); encoder.Save(fileStream); } }
protected void SaveImageToDiskCache(string cacheKey, GeneratedImage generatedImage) { if (!generatedImage.Properties.IsImagePresent) { return; } HttpContext httpContext = HttpContext.Current; string filePath = httpContext.Server.MapPath(GetDiskCacheFilePath(httpContext, cacheKey, generatedImage.Properties.FileExtension)); using (FileStream fileStream = File.OpenWrite(filePath)) { BitmapEncoder encoder = generatedImage.Properties.GetEncoder(); encoder.Frames.Add(BitmapFrame.Create(generatedImage.Image)); encoder.Save(fileStream); } }
public static string GetImageUrl(Composition composition) { string cacheKey = composition.GetCacheKey(); if (DynamicImageCacheManager.Exists(cacheKey)) { return(GetUrl(cacheKey, DynamicImageCacheManager.GetProperties(cacheKey))); } GeneratedImage generatedImage = composition.GenerateImage(); if (generatedImage.Properties.IsImagePresent || DynamicImageCacheManager.StoreMissingImagesInCache) { Dependency[] dependencies = composition.GetDependencies().Distinct().ToArray(); DynamicImageCacheManager.Add(cacheKey, generatedImage, dependencies); } return(GetUrl(cacheKey, generatedImage.Properties)); }
private static void SaveImageStream(GeneratedImage generatedImage, Stream stream) { // setup parameters BitmapEncoder encoder = generatedImage.Properties.GetEncoder(); //encoderParametersTemp.Add(new EncoderParameter(Encoder.ColorDepth, (long)GeneratedImage.Properties.ColourDepth)); // TODO: Use ColorConvertedBitmap to allow configurable colour depth in output image. encoder.Frames.Add(BitmapFrame.Create(generatedImage.Image)); // Write to temporary stream first. this is because PNG must be written to a seekable stream. using (var tempStream = new MemoryStream()) { encoder.Save(tempStream); // Now write temp stream to output stream. tempStream.WriteTo(stream); } }
private static void SaveImageStream(GeneratedImage generatedImage, Stream stream) { // setup parameters BitmapEncoder encoder = generatedImage.Properties.GetEncoder(); //encoderParametersTemp.Add(new EncoderParameter(Encoder.ColorDepth, (long)GeneratedImage.Properties.ColorDepth)); // TODO: Use ColorConvertedBitmap to allow configurable color depth in output image. encoder.Frames.Add(BitmapFrame.Create(generatedImage.Image)); // Write to temporary stream first. this is because PNG must be written to a seekable stream. using (var tempStream = new MemoryStream()) { encoder.Save(tempStream); // Now write temp stream to output stream. tempStream.WriteTo(stream); } }
public async Task <GeneratedImageGetModel> Post(int pGGANId, [FromBody] ControlVariablesModel controlVariablesModel) { /* * ControlVariables controlVariables = new ControlVariables * { * NoiseVector = controlVariablesModel.NoiseVector, * Porosity = controlVariablesModel.Porosity, * ElementsCount = controlVariablesModel.ElementsCount, * MinElementSize = controlVariablesModel.MinElementSize, * MaxElementSize = controlVariablesModel.MaxElementSize, * AvgElementSize = controlVariablesModel.AvgElementSize, * Сohesion = controlVariablesModel.Cohesion, * CavernsVolume = controlVariablesModel.CavernsVolume, * ChanelsVolume = controlVariablesModel.ChanelsVolume, * Permeability = controlVariablesModel.Permeability, * Binarisation = controlVariablesModel.Binarisation, * DeleteNoize = controlVariablesModel.DeleteNoize, * Seed = controlVariablesModel.Seed * };*/ ControlVariables controlVariables = _mapper.Map <ControlVariables>(controlVariablesModel); GeneratedImage generatedImage = await _generationImageService.Generate(pGGANId, controlVariables); GeneratedImageGetModel response = _mapper.Map <GeneratedImageGetModel>(generatedImage); response.PolygonalModel = new PolygonalModelGetModel { RockFaces = Convert.ToBase64String(generatedImage.PolygonalModel.RockFaces) }; /* * var result = new GeneratedImageGetModel * { * AvgElementSize = 0, * CavernsVolume = 0, * ChanelsVolume = 0, * ControlVariables = controlVariables, * CreatedDate = new DateTime() * };*/ return(response); }
public async Task <GeneratedImage> Generate(int pGGANId, ControlVariables controlVariables) { GeneratedImage generatedImage = new GeneratedImage { ControlVariables = controlVariables, CreatedDate = DateTime.Now, GenerationNetworkId = pGGANId }; var client = new RestClient("http://127.0.0.1:5000/"); var request = new RestRequest("predict/raw", Method.POST, DataFormat.Json); request.AddJsonBody(controlVariables); var response = client.Execute(request); dynamic jObject = JObject.Parse(response.Content); generatedImage.VoxelArray = jObject.VoxelArray; generatedImage.DimX = jObject.DimX; generatedImage.DimY = jObject.DimY; generatedImage.DimZ = jObject.DimZ; generatedImage.Porosity = jObject.Porosity; generatedImage.VoxelArrayFormat = "raw"; /*var imageProcessingClient = new RestClient("http://127.0.0.1:5002/"); * var processingRequest = new RestRequest("computeMetadata", Method.POST, DataFormat.Json); * request.AddJsonBody(generatedImage); * var processingResponse = imageProcessingClient.Execute(processingRequest); * * var prob = processingResponse.Content;*/ await _polygonalModelingService.ComputePolygons(generatedImage); await _repository.Create(generatedImage); return(generatedImage); // TODO: переделать в return id. }
public override void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies) { EnsureDocument(); // Save image to disk. SaveImageToDiskCache(cacheKey, generatedImage); lock (_doc) { // Double-check that item hasn't been added to cache since we checked. if (ExistsInCache(cacheKey)) return; var itemElement = new XElement("item", new XAttribute("id", cacheKey), new XAttribute("isImagePresent", generatedImage.Properties.IsImagePresent), new XAttribute("format", generatedImage.Properties.Format), new XAttribute("colourDepth", generatedImage.Properties.ColourDepth)); if (generatedImage.Properties.Width != null) itemElement.Add(new XAttribute("width", generatedImage.Properties.Width.Value)); if (generatedImage.Properties.Height != null) itemElement.Add(new XAttribute("height", generatedImage.Properties.Height.Value)); if (generatedImage.Properties.JpegCompressionLevel != null) itemElement.Add(new XAttribute("jpegCompressionLevel", generatedImage.Properties.JpegCompressionLevel.Value)); XElement dependenciesElement = new XElement("dependencies"); itemElement.Add(dependenciesElement); foreach (var dependency in dependencies) dependenciesElement.Add(new XElement("dependency", new XAttribute("text1", dependency.Text1), new XAttribute("text2", dependency.Text2), new XAttribute("text3", dependency.Text3), new XAttribute("text4", dependency.Text4))); _doc.Root.Add(itemElement); _doc.Save(_docPath); } }
public mQuickComposite(Bitmap B, mModifiers M, wColor BackgroundColor) { image = new ImageImageSource(); layer = new ImageLayer(); CompositionObject = new Composition(); image.Image = new mConvert(B).BitmapToWritableBitmap(); layer.Source = image; foreach (mModifier Modifier in M.Modifiers) { layer.Filters.Add(Modifier.filter); } Fill fill = new Fill(); fill.Type = FillType.Solid; fill.BackgroundColor = new mImageColor(BackgroundColor).ToDynamicColor(); CompositionObject.ColorDepth = 16; CompositionObject.ImageFormat = DynamicImageFormat.Png; CompositionObject.Fill = fill; RectangleShapeLayer rect = new RectangleShapeLayer(); rect.Fill = fill; rect.Width = B.Width; rect.Height = B.Height; //CompositionObject.Layers.Add(rect); CompositionObject.Layers.Add(layer); GeneratedImage genImage = CompositionObject.GenerateImage(); genImage.Properties.ColorDepth = 16; genImage.Properties.Format = DynamicImageFormat.Png; ModifiedBitmap = new mConvert(genImage.Image).SourceToBitmap(); }
internal static void Add(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies) { Provider.AddToCache(cacheKey, generatedImage, dependencies); }
private Control RenderItem(SimpleProductInfo product) { bool showNetPrice = (StoreSettings.Count > 0) && ((string)StoreSettings["ShowNetpriceInCart"] == "0"); decimal unitCost = product.UnitCost; decimal originalUnitCost = product.OriginalUnitCost; decimal taxPercent = product.TaxPercent; decimal price = 0.00m; decimal originalPrice = 0.00m; string tax = ""; if (showNetPrice) { price = unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m); originalPrice = originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m); tax = Localization.GetString("ExcludeTax.Text", this.LocalResourceFile); } else { price = decimal.Round((unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2); originalPrice = decimal.Round((originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2); tax = Localization.GetString("IncludeTax.Text", this.LocalResourceFile); } string template; int imageWidth = 200; TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl; tp.Key = "ProductList"; template = tp.GetTemplate((string)Settings["Template"]); //Template = ProductTemplate; template = template.Replace("[ITEMNO]", product.ItemNo); template = template.Replace("[PRODUCTSHORTDESCRIPTION]", product.ShortDescription); template = template.Replace("[PRODUCTDESCRIPTION]", product.ProductDescription); template = template.Replace("[TITLE]", product.Name); template = template.Replace("[IMAGEURL]", product.Image); if (product.HideCost) { template = template.Replace("[PRICE]", Localization.GetString("AskOffer.Text", this.LocalResourceFile)); } else { template = template.Replace("[PRICE]", String.Format("{0:n2}", price)); } if (originalPrice > price && !product.HideCost) { template = template.Replace("[ORIGINALPRICE]", String.Format("{0:n2} {1}", originalPrice, Currency)); } else { template = template.Replace("[ORIGINALPRICE]", ""); } if (!product.HideCost) { template = template.Replace("[CURRENCY]", Currency); } else { template = template.Replace("[CURRENCY]", ""); } if (taxPercent > 0.00m && !product.HideCost) { template = template.Replace("[TAX]", String.Format(tax, taxPercent)); } else { template = template.Replace("[TAX]", ""); } if (product.UnitId > -1) { UnitInfo unit = Controller.GetUnit(product.UnitId, CurrentLanguage); template = template.Replace("[UNIT]", unit.Symbol); } else { template = template.Replace("[UNIT]", ""); } int linkCnt = 0; while (template.Contains("[LINK]")) { linkCnt++; template = template.ReplaceFirst("[LINK]", "<asp:Literal ID=\"ltrLink" + linkCnt.ToString() + "\" runat=\"server\" />"); } if (template.IndexOf("[IMAGE") > -1) { if (template.IndexOf("[IMAGE:") > -1) { string width = template.Substring(template.IndexOf("[IMAGE:") + 7); width = width.Substring(0, width.IndexOf("]")); if (Int32.TryParse(width, out imageWidth) == false) { imageWidth = 200; } template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />"); } else { template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />"); } } while (template.IndexOf("[RESOURCE:") > -1) { string resKey = template.Substring(template.IndexOf("[RESOURCE:") + 10); resKey = resKey.Substring(0, resKey.IndexOf("]")); template = template.Replace("[RESOURCE:" + resKey + "]", Localization.GetString(resKey, this.LocalResourceFile)); } while (template.IndexOf("[FEATURE:") > -1) { string token = template.Substring(template.IndexOf("[FEATURE:") + 9); token = token.Substring(0, token.IndexOf("]")); string prop = token.Substring(token.IndexOf(".") + 1); token = token.Substring(0, token.IndexOf(".")).ToUpper(); string value = ""; FeatureGridValueInfo fgv = Controller.GetFeatureGridValueByProductAndToken(PortalId, product.SimpleProductId, CurrentLanguage, token); if (fgv != null) { PropertyInfo p = fgv.GetType().GetProperty(prop); if (p != null && p.CanRead) { value = p.GetValue(fgv, null).ToString(); } } template = template.Replace("[FEATURE:" + token + "." + prop + "]", value); } Control ctrl = ParseControl(template); for (int i = 1; i < linkCnt + 1; i++) { Literal ltrLink = FindControlRecursive(ctrl, "ltrLink" + i.ToString()) as Literal; if (ltrLink != null) { int productModuleTabId = Convert.ToInt32(Settings["ProductModulePage"] ?? TabId.ToString()); ltrLink.Text = Globals.NavigateURL(productModuleTabId, "", "productid=" + product.SimpleProductId.ToString()); } } PlaceHolder phimgProduct = FindControlRecursive(ctrl, "phimgProduct") as PlaceHolder; if (phimgProduct != null && product.Image != null) { string fileName = PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") + product.Image.Replace('/', '\\'); imgProduct = new GeneratedImage(); imgProduct.ImageHandlerUrl = "~/BBImageHandler.ashx"; if (imageWidth > 0) { imgProduct.Parameters.Add(new ImageParameter() { Name = "Width", Value = imageWidth.ToString() }); } imgProduct.Parameters.Add(new ImageParameter() { Name = "File", Value = fileName }); // TODO: Watermark //if (false) //{ // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkText", Value = Localization.GetString("Sold.Text", this.LocalResourceFile) }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontFamily", Value = "Verdana" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontColor", Value = "Red" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontSize", Value = "20" }); //} phimgProduct.Controls.Add(imgProduct); } return(ctrl); }
public static void SendImageToHttpResponse(HttpContext context, GeneratedImage generatedImage) { context.Response.ContentType = generatedImage.Properties.MimeType; SaveImageStream(generatedImage, context.Response.OutputStream); context.Response.Flush(); }
public abstract void AddToCache(string cacheKey, GeneratedImage generatedImage, Dependency[] dependencies);
protected void lstProducts_ItemCreated(object sender, ListViewItemEventArgs e) { if (IsConfigured) { int imageWidth = 145; ListView lv = sender as ListView; ListViewDataItem item = e.Item as ListViewDataItem; SimpleProductInfo simpleProduct = item.DataItem as SimpleProductInfo; if (simpleProduct != null) { string template = _template; if (template.IndexOf("[IMAGE") > -1) { if (template.IndexOf("[IMAGE:") > -1) { string width; width = template.Substring(template.IndexOf("[IMAGE:") + 7); width = width.Substring(0, width.IndexOf("]")); if (Int32.TryParse(width, out imageWidth) == false) { imageWidth = 200; } template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />"); } else { template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />"); } } template = template.Replace("[ITEMNO]", simpleProduct.ItemNo); template = template.Replace("[TITLE]", simpleProduct.Name); template = template.Replace("[PRODUCTDESCRIPTION]", simpleProduct.ProductDescription); template = template.Replace("[PRODUCTSHORTDESCRIPTION]", simpleProduct.ShortDescription); template = template.Replace("[DELETE]", "<asp:ImageButton runat=\"server\" id=\"cmdDelete\" CommandName=\"Delete\" CausesValidation=\"False\" IconKey=\"Delete\"></asp:ImageButton>"); Control ctrl = ParseControl(template); PlaceHolder phimgProduct = FindControlRecursive(ctrl, "phimgProduct") as PlaceHolder; if (phimgProduct != null && simpleProduct.Image != null) { string fileName = PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") + simpleProduct.Image.Replace('/', '\\'); GeneratedImage imgProduct = new GeneratedImage(); imgProduct.ImageHandlerUrl = "~/BBImageHandler.ashx"; if (imageWidth > 0) { imgProduct.Parameters.Add(new ImageParameter() { Name = "Width", Value = imageWidth.ToString() }); } imgProduct.Parameters.Add(new ImageParameter() { Name = "File", Value = fileName }); // TODO: Watermark phimgProduct.Controls.Add(imgProduct); } PlaceHolder ph = e.Item.FindControl("productPlaceholder") as PlaceHolder; ph.Controls.Add(ctrl); } } }
protected void lstProductGroups_ItemCreated(object sender, ListViewItemEventArgs e) { if (IsConfigured) { int imageWidth = 200; ListView lv = sender as ListView; ListViewDataItem item = e.Item as ListViewDataItem; productGroup = item.DataItem as ProductGroupInfo; if (productGroup != null) { string template = Template; template = template.Replace("[PRODUCTGROUPNAME]", "<asp:Label ID=\"lblProductGroupName\" runat=\"server\" />"); template = template.Replace("[PRODUCTGROUPSHORTDESCRIPTION]", "<asp:Label ID=\"lblProductGroupShortDescription\" runat=\"server\" />"); template = template.Replace("[PRODUCTGROUPDESCRIPTION]", "<asp:Label ID=\"lblProductGroupDescription\" runat=\"server\" />"); if (template.IndexOf("[IMAGE") > -1) { if (template.IndexOf("[IMAGE:") > -1) { string width; width = template.Substring(template.IndexOf("[IMAGE:") + 7); width = width.Substring(0, width.IndexOf("]")); if (Int32.TryParse(width, out imageWidth) == false) { imageWidth = 200; } template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgProductGroup\" runat=\"server\" />"); } else { template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgProductGroupOri\" runat=\"server\" />"); } } while (template.IndexOf("[RESOURCE:") > -1) { string resKey = template.Substring(template.IndexOf("[RESOURCE:") + 10); resKey = resKey.Substring(0, resKey.IndexOf("]")); template = template.Replace("[RESOURCE:" + resKey + "]", Localization.GetString(resKey, this.LocalResourceFile)); } template = template.Replace("[ICON]", "<asp:Image ID=\"imgIcon\" runat=\"server\" />"); template = template.Replace("[PRODUCTCOUNT]", "<asp:Label ID=\"lblProductCount\" runat=\"server\" />"); int linkCnt = 0; while (template.Contains("[LINK]")) { linkCnt++; template = template.ReplaceFirst("[LINK]", "<asp:Literal ID=\"ltrLink" + linkCnt.ToString() + "\" runat=\"server\" />"); } Control ctrl = ParseControl(template); lblProductGroupName = FindControlRecursive(ctrl, "lblProductGroupName") as Label; if (lblProductGroupName != null) { lblProductGroupName.Text = productGroup.ProductGroupName; } Label lblProductGroupShortDescription = FindControlRecursive(ctrl, "lblProductGroupShortDescription") as Label; if (lblProductGroupShortDescription != null) { lblProductGroupShortDescription.Text = productGroup.ProductGroupShortDescription; } Label lblProductGroupDescription = FindControlRecursive(ctrl, "lblProductGroupDescription") as Label; if (lblProductGroupDescription != null) { lblProductGroupDescription.Text = productGroup.ProductGroupDescription; } PlaceHolder phimgProductGroup = FindControlRecursive(ctrl, "phimgProductGroup") as PlaceHolder; if (phimgProductGroup != null && productGroup.Image != null) { string fileName = PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") + productGroup.Image.Replace('/', '\\'); imgProductGroup = new GeneratedImage(); imgProductGroup.ImageHandlerUrl = "~/BBImageHandler.ashx"; if (imageWidth > 0) { imgProductGroup.Parameters.Add(new ImageParameter() { Name = "Width", Value = imageWidth.ToString() }); } imgProductGroup.Parameters.Add(new ImageParameter() { Name = "File", Value = fileName }); // TODO: Watermark //if (false) //{ // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkText", Value = Localization.GetString("Sold.Text", this.LocalResourceFile) }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontFamily", Value = "Verdana" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontColor", Value = "Red" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontSize", Value = "20" }); //} phimgProductGroup.Controls.Add(imgProductGroup); } PlaceHolder phimgProductGroupOri = FindControlRecursive(ctrl, "phimgProductGroupOri") as PlaceHolder; if (phimgProductGroupOri != null && productGroup.Image != null) { Image imgProductGroupOri = new Image(); imgProductGroupOri.ImageUrl = PortalSettings.HomeDirectory + productGroup.Image; phimgProductGroupOri.Controls.Add(imgProductGroupOri); } imgIcon = FindControlRecursive(ctrl, "imgIcon") as Image; if (imgIcon != null) { imgIcon.ImageUrl = productGroup.Icon; } lblProductCount = FindControlRecursive(ctrl, "lblProductCount") as Label; if (lblProductCount != null) { lblProductCount.Text = productGroup.ProductCount.ToString(); } for (int i = 1; i < linkCnt + 1; i++) { Literal ltrLink = FindControlRecursive(ctrl, "ltrLink" + i.ToString()) as Literal; if (ltrLink != null) { if (productGroup.ProductListTabId != -1) { ltrLink.Text = Globals.NavigateURL(productGroup.ProductListTabId, "", "productgroup=" + productGroup.ProductGroupId.ToString()); } else { int dynamicTab = Convert.ToInt32(Settings["DynamicPage"] ?? TabId.ToString()); ltrLink.Text = Globals.NavigateURL(dynamicTab, "", "productgroup=" + productGroup.ProductGroupId.ToString()); } } } PlaceHolder ph = e.Item.FindControl("productGroupPlaceholder") as PlaceHolder; ph.Controls.Add(ctrl); } } else { lstProductGroups.Visible = false; } }
protected void rotFeatures_DataBound(object sender, RadRotatorEventArgs e) { if (IsConfigured) { string template; int imageWidth = 200; RadRotator rot = sender as RadRotator; RadRotatorItem item = e.Item as RadRotatorItem; FeatureListItemInfo featureListItem = item.DataItem as FeatureListItemInfo; if (featureListItem != null) { PlaceHolder ph = e.Item.FindControl("featurePlaceHolder") as PlaceHolder; template = Template; template = template.Replace("[TITLE]", "<asp:Label ID=\"lblTitle\" runat=\"server\" />"); if (template.IndexOf("[IMAGE") > -1) { if (template.IndexOf("[IMAGE:") > -1) { string width = template.Substring(template.IndexOf("[IMAGE:") + 7); width = width.Substring(0, width.IndexOf("]")); if (Int32.TryParse(width, out imageWidth) == false) { imageWidth = 200; } template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgFeature\" runat=\"server\" />"); } else { template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgFeature\" runat=\"server\" />"); } } Control ctrl = ParseControl(template); Label lblTitle = FindControlRecursive(ctrl, "lblTitle") as Label; if (lblTitle != null) { lblTitle.Text = featureListItem.FeatureListItem; } PlaceHolder phimgFeature = FindControlRecursive(ctrl, "phimgFeature") as PlaceHolder; if (phimgFeature != null && featureListItem.Image != null) { string fileName = PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") + featureListItem.Image.Replace('/', '\\'); GeneratedImage imgFeature = new GeneratedImage(); imgFeature.ImageHandlerUrl = "~/BBImageHandler.ashx"; if (imageWidth > 0) { imgFeature.Parameters.Add(new ImageParameter() { Name = "Width", Value = imageWidth.ToString() }); } imgFeature.Parameters.Add(new ImageParameter() { Name = "File", Value = fileName }); // TODO: Watermark //if (false) //{ // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkText", Value = Localization.GetString("Sold.Text", this.LocalResourceFile) }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontFamily", Value = "Verdana" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontColor", Value = "Red" }); // imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontSize", Value = "20" }); //} phimgFeature.Controls.Add(imgFeature); } ph.Controls.Add(ctrl); } } else { rotFeatures.Visible = false; } }