public static void ZzSetStandardVisualStyle(this RadDropDownList DDList, SizingMode mode = SizingMode.None) { DDList.DropDownStyle = RadDropDownStyle.DropDownList; DDList.DropDownListElement.ListElement.Font = DDList.Font; DDList.DropDownSizingMode = mode; DDList.PopupOpening += EventPopupOpening; }
public RadGalleryPopupElement(RadItemOwnerCollection items, RadItemOwnerCollection groups, RadItemOwnerCollection filters, RadItemOwnerCollection menuItems, SizeF initialSize, SizeF minimumSize, SizingMode dropDownSizingMode ) { this.galleryItems = items; this.groups = groups; this.menuItems = menuItems; this.newSize = initialSize; this.actualSize = initialSize; this.initialSize = initialSize; this.minimumSize = minimumSize; this.filters = filters; this.dropDownSizingMode = dropDownSizingMode; this.BuildPopupContent();//read groups if any this.menuElement.MinSize = new Size((int)initialSize.Width, 0); this.menuElement.Items.AddRange(this.menuItems); }
internal void Resize(SizingMode mode) { if (!this.Owner.IsActive) { this.Owner.Activate(); } this.Owner.Resize(mode); }
public static SizeSpecification GetForSizingMode(this SizingMode mode) { if (mode == SizingMode.WidthAndAspectRatio) { return(SizeSpecification.WidthAndHeightAspect); } if (mode == SizingMode.HeightAndAspectRatio) { return(SizeSpecification.HeightAndWidthAspect); } if (mode == SizingMode.ShorterDimensionAndAspectRatio) { return(SizeSpecification.ShorterDimensionAndAspect); } return(SizeSpecification.WidthAndHeight); }
public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) { int offset = drawQuietZones ? 0 : 4; int drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2); double pixelsPerModule = Math.Min(viewBox.Width, viewBox.Height) / (double)drawableModulesCount; double qrSize = drawableModulesCount * pixelsPerModule; string svgSizeAttributes = (sizingMode == SizingMode.WidthHeightAttribute) ? $@"width=""{viewBox.Width}"" height=""{viewBox.Height}""" : $@"viewBox=""0 0 {viewBox.Width} {viewBox.Height}"""; // Merge horizontal rectangles int[,] matrix = new int[drawableModulesCount, drawableModulesCount]; for (int yi = 0; yi < drawableModulesCount; yi += 1) { BitArray bitArray = this.QrCodeData.ModuleMatrix[yi + offset]; int x0 = -1; int xL = 0; for (int xi = 0; xi < drawableModulesCount; xi += 1) { matrix[yi, xi] = 0; if (bitArray[xi + offset]) { if (x0 == -1) { x0 = xi; } xL += 1; } else { if (xL > 0) { matrix[yi, x0] = xL; x0 = -1; xL = 0; } } } if (xL > 0) { matrix[yi, x0] = xL; } } StringBuilder svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile=""full"" shape-rendering=""crispEdges"" {svgSizeAttributes} xmlns=""http://www.w3.org/2000/svg"">"); svgFile.AppendLine($@"<rect x=""0"" y=""0"" width=""{CleanSvgVal(qrSize)}"" height=""{CleanSvgVal(qrSize)}"" fill=""{lightColorHex}"" />"); for (int yi = 0; yi < drawableModulesCount; yi += 1) { double y = yi * pixelsPerModule; for (int xi = 0; xi < drawableModulesCount; xi += 1) { int xL = matrix[yi, xi]; if (xL > 0) { // Merge vertical rectangles int yL = 1; for (int y2 = yi + 1; y2 < drawableModulesCount; y2 += 1) { if (matrix[y2, xi] == xL) { matrix[y2, xi] = 0; yL += 1; } else { break; } } // Output SVG rectangles double x = xi * pixelsPerModule; svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(xL * pixelsPerModule)}"" height=""{CleanSvgVal(yL * pixelsPerModule)}"" fill=""{darkColorHex}"" />"); } } } //Render logo, if set if (logo != null) { svgFile.AppendLine($@"<svg width=""100%"" height=""100%"" version=""1.1"" xmlns = ""http://www.w3.org/2000/svg"">"); svgFile.AppendLine($@"<image x=""{50 - (logo.GetIconSizePercent() / 2)}%"" y=""{50 - (logo.GetIconSizePercent() / 2)}%"" width=""{logo.GetIconSizePercent()}%"" height=""{logo.GetIconSizePercent()}%"" href=""{logo.GetDataUri()}"" />"); svgFile.AppendLine(@"</svg>"); } svgFile.Append(@"</svg>"); return(svgFile.ToString()); }
internal void DoubleClick(SizingMode mode) { this.Owner.DoubleClick(mode); }
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) using (var qrCode = new SvgQRCode(qrCodeData)) return(qrCode.GetGraphic(pixelsPerModule, darkColorHex, lightColorHex, drawQuietZones, sizingMode)); }
public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { return(this.GetGraphic(viewBox, ColorTranslator.ToHtml(Color.FromArgb(darkColor.ToArgb())), ColorTranslator.ToHtml(Color.FromArgb(lightColor.ToArgb())), drawQuietZones, sizingMode)); }
public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { var viewBox = new Size(pixelsPerModule * this.QrCodeData.ModuleMatrix.Count, pixelsPerModule * this.QrCodeData.ModuleMatrix.Count); return(this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, sizingMode)); }
public void DoubleClick(SizingMode sizingMode) { User32.PostMessage(this.Handle, (uint)WindowsMessages.WM_NCLBUTTONDBLCLK, (IntPtr)sizingMode, IntPtr.Zero); }
public void Resize(SizingMode sizingMode) { User32.PostMessage(this.Handle, (uint)WindowsMessages.WM_NCLBUTTONDOWN, (IntPtr)sizingMode, IntPtr.Zero); }
public void Resize(SizingMode sizingMode) { User32.PostMessage(this.Handle, _serviceInstance.PseudoNcLButtonDownMessage, (IntPtr)sizingMode, IntPtr.Zero); }
public static void ZzSetClassificatorStandardVisualStyle(this RadDropDownList DDList, SizingMode mode = SizingMode.None) { DDList.DropDownStyle = RadDropDownStyle.DropDown; DDList.DropDownListElement.ListElement.Font = DDList.Font; DDList.DropDownSizingMode = mode; DDList.AutoCompleteMode = AutoCompleteMode.None; DDList.KeyUp += EventDropDownListKeyUp; DDList.TextChanged += EventTextChanged; }
public string GetGraphic(Size viewBox, int pixelsPerModuleX, int pixelsPerModuleY, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { var offset = drawQuietZones ? 0 : 4; var drawableModulesXCount = m_xCodeData.ModuleMatrix[0].Count - (drawQuietZones ? 0 : offset * 2); var drawableModulesYCount = m_xCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2); // var SizeX = drawableModulesXCount * pixelsPerModuleX; var SizeY = drawableModulesYCount * pixelsPerModuleY; // var svgSizeAttributes = sizingMode.Equals(SizingMode.WidthHeightAttribute) ? $@"width=""{viewBox.Width}"" height=""{viewBox.Height}""" : $@"viewBox=""0 0 {viewBox.Width} {viewBox.Height}"""; var svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile=""full"" shape-rendering=""crispEdges"" {svgSizeAttributes} xmlns=""http://www.w3.org/2000/svg"">"); svgFile.AppendLine($@"<rect x=""0"" y=""0"" width=""{CleanSvgVal(SizeX)}"" height=""{CleanSvgVal(SizeY)}"" fill=""{lightColorHex}"" />"); // if( m_bHorizontalOptimization ) { for (int yi = offset; yi < offset + drawableModulesYCount; yi++) { for(int xi = offset; xi < offset + drawableModulesXCount; xi++) { int iWidth=0; while( xi+iWidth < offset + drawableModulesXCount && m_xCodeData.ModuleMatrix[yi][xi+iWidth] ) iWidth++; //if( m_xCodeData.ModuleMatrix[yi][xi+iWidth] ) iWidth++; // if( iWidth > 0 ) { var x = (xi - offset) * pixelsPerModuleX; var y = (yi - offset) * pixelsPerModuleY; //svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(pixelsPerModuleX)}"" height=""{CleanSvgVal(pixelsPerModuleY)}"" fill=""{darkColorHex}"" />"); if( y==0 ) svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" width=""{CleanSvgVal(pixelsPerModuleX*iWidth)}"" height=""{CleanSvgVal(pixelsPerModuleY)}""/>"); else svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(pixelsPerModuleX*iWidth)}"" height=""{CleanSvgVal(pixelsPerModuleY)}""/>"); // xi+=iWidth-1; } } } } else { for(int xi = offset; xi < offset + drawableModulesXCount; xi++) { for (int yi = offset; yi < offset + drawableModulesYCount; yi++) { int iHeight=0; while( yi+iHeight < offset + drawableModulesYCount && m_xCodeData.ModuleMatrix[yi+iHeight][xi] ) iHeight++; // if( iHeight > 0 ) { var x = (xi - offset) * pixelsPerModuleX; var y = (yi - offset) * pixelsPerModuleY; //svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(pixelsPerModuleX)}"" height=""{CleanSvgVal(pixelsPerModuleY)}"" fill=""{darkColorHex}"" />"); if( y==0 ) svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" width=""{CleanSvgVal(pixelsPerModuleX)}"" height=""{CleanSvgVal(pixelsPerModuleY*iHeight)}""/>"); else svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(pixelsPerModuleX)}"" height=""{CleanSvgVal(pixelsPerModuleY*iHeight)}""/>"); // yi+=iHeight-1; } } } } svgFile.Append(@"</svg>"); return svgFile.ToString(); }
/// <summary> /// Returns a QR code as SVG string with custom colors (in HEX syntax), optional quietzone and logo /// </summary> /// <param name="viewBox">The viewbox of the QR code graphic</param> /// <param name="darkColorHex">The color of the dark/black modules in hex (e.g. #000000) representation</param> /// <param name="lightColorHex">The color of the light/white modules in hex (e.g. #ffffff) representation</param> /// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param> /// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param> /// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param> /// <returns>SVG as string</returns> public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) { int offset = drawQuietZones ? 0 : 4; int drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2); double pixelsPerModule = Math.Min(viewBox.Width, viewBox.Height) / (double)drawableModulesCount; double qrSize = drawableModulesCount * pixelsPerModule; string svgSizeAttributes = (sizingMode == SizingMode.WidthHeightAttribute) ? $@"width=""{viewBox.Width}"" height=""{viewBox.Height}""" : $@"viewBox=""0 0 {viewBox.Width} {viewBox.Height}"""; ImageAttributes?logoAttr = null; if (logo != null) { logoAttr = GetLogoAttributes(logo, viewBox); } // Merge horizontal rectangles int[,] matrix = new int[drawableModulesCount, drawableModulesCount]; for (int yi = 0; yi < drawableModulesCount; yi += 1) { BitArray bitArray = this.QrCodeData.ModuleMatrix[yi + offset]; int x0 = -1; int xL = 0; for (int xi = 0; xi < drawableModulesCount; xi += 1) { matrix[yi, xi] = 0; if (bitArray[xi + offset] && (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo((xi + offset) * pixelsPerModule, (yi + offset) * pixelsPerModule, logoAttr, pixelsPerModule))) { if (x0 == -1) { x0 = xi; } xL += 1; } else { if (xL > 0) { matrix[yi, x0] = xL; x0 = -1; xL = 0; } } } if (xL > 0) { matrix[yi, x0] = xL; } } StringBuilder svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile=""full"" shape-rendering=""crispEdges"" {svgSizeAttributes} xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"">"); svgFile.AppendLine($@"<rect x=""0"" y=""0"" width=""{CleanSvgVal(qrSize)}"" height=""{CleanSvgVal(qrSize)}"" fill=""{lightColorHex}"" />"); for (int yi = 0; yi < drawableModulesCount; yi += 1) { double y = yi * pixelsPerModule; for (int xi = 0; xi < drawableModulesCount; xi += 1) { int xL = matrix[yi, xi]; if (xL > 0) { // Merge vertical rectangles int yL = 1; for (int y2 = yi + 1; y2 < drawableModulesCount; y2 += 1) { if (matrix[y2, xi] == xL) { matrix[y2, xi] = 0; yL += 1; } else { break; } } // Output SVG rectangles double x = xi * pixelsPerModule; if (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(x, y, logoAttr, pixelsPerModule)) { svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(xL * pixelsPerModule)}"" height=""{CleanSvgVal(yL * pixelsPerModule)}"" fill=""{darkColorHex}"" />"); } } } } //Render logo, if set if (logo != null) { if (!logo.IsEmbedded()) { svgFile.AppendLine($@"<svg width=""100%"" height=""100%"" version=""1.1"" xmlns = ""http://www.w3.org/2000/svg"">"); svgFile.AppendLine($@"<image x=""{CleanSvgVal(logoAttr.Value.X)}"" y=""{CleanSvgVal(logoAttr.Value.Y)}"" width=""{CleanSvgVal(logoAttr.Value.Width)}"" height=""{CleanSvgVal(logoAttr.Value.Height)}"" xlink:href=""{logo.GetDataUri()}"" />"); svgFile.AppendLine(@"</svg>"); } else { var rawLogo = (string)logo.GetRawLogo(); var svg = System.Xml.Linq.XDocument.Parse(rawLogo); svg.Root.SetAttributeValue("x", CleanSvgVal(logoAttr.Value.X)); svg.Root.SetAttributeValue("y", CleanSvgVal(logoAttr.Value.Y)); svg.Root.SetAttributeValue("width", CleanSvgVal(logoAttr.Value.Width)); svg.Root.SetAttributeValue("height", CleanSvgVal(logoAttr.Value.Height)); svg.Root.SetAttributeValue("shape-rendering", "geometricPrecision"); svgFile.AppendLine(svg.ToString(System.Xml.Linq.SaveOptions.DisableFormatting).Replace("svg:", "")); } } svgFile.Append(@"</svg>"); return(svgFile.ToString()); }
/// <summary> /// Returns a QR code as SVG string with custom colors (in HEX syntax), optional quietzone and logo /// </summary> /// <param name="pixelsPerModule">The pixel size each b/w module is drawn</param> /// <param name="darkColorHex">The color of the dark/black modules in hex (e.g. #000000) representation</param> /// <param name="lightColorHex">The color of the light/white modules in hex (e.g. #ffffff) representation</param> /// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param> /// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param> /// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param> /// <returns>SVG as string</returns> public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) { var offset = drawQuietZones ? 0 : 4; var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule); var viewBox = new Size(edgeSize, edgeSize); return(this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, sizingMode, logo)); }
public string GetGraphic(Size viewBox, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { return(this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, sizingMode)); }
public static string GetSmallImageUrl(string id, SizingMode mode) { return(RestService.Instance.CDSRestUrl + "content/" + id + "/image?size=small&sizingmode=" + (int)mode); }
public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { var offset = drawQuietZones ? 0 : 4; var drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2); var pixelsPerModule = (double)Math.Min(viewBox.Width, viewBox.Height) / (double)drawableModulesCount; var qrSize = drawableModulesCount * pixelsPerModule; var svgSizeAttributes = (sizingMode == SizingMode.WidthHeightAttribute) ? $@"width=""{viewBox.Width}"" height=""{viewBox.Height}""" : $@"viewBox=""0 0 {viewBox.Width} {viewBox.Height}"""; var svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile=""full"" shape-rendering=""crispEdges"" {svgSizeAttributes} xmlns=""http://www.w3.org/2000/svg"">"); svgFile.AppendLine($@"<rect x=""0"" y=""0"" width=""{CleanSvgVal(qrSize)}"" height=""{CleanSvgVal(qrSize)}"" fill=""{lightColorHex}"" />"); for (int xi = offset; xi < offset + drawableModulesCount; xi++) { for (int yi = offset; yi < offset + drawableModulesCount; yi++) { if (this.QrCodeData.ModuleMatrix[yi][xi]) { var x = (xi - offset) * pixelsPerModule; var y = (yi - offset) * pixelsPerModule; svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(pixelsPerModule)}"" height=""{CleanSvgVal(pixelsPerModule)}"" fill=""{darkColorHex}"" />"); } } } svgFile.Append(@"</svg>"); return(svgFile.ToString()); }
public static Task <byte[]> GetSmallImage(string id, SizingMode mode) { return(RestService.Instance.GetDataAsync(new Uri(GetSmallImageUrl(id, mode)))); }
public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute) { return(this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, sizingMode)); }
public static void SetSizingMode(FrameworkElement element, SizingMode value) { element.SetValue(SizingModeProperty, value); }
internal void Resize(SizingMode mode) { this.Owner.Resize(mode); }