/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="bitmap" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="eplContainer" /> is <see langword="null" />.</exception> protected override void StoreGraphics(SvgImage svgImage, string variableName, Bitmap bitmap, EplContainer eplContainer) { if (svgImage == null) { throw new ArgumentNullException(nameof(svgImage)); } if (variableName == null) { throw new ArgumentNullException(nameof(variableName)); } if (bitmap == null) { throw new ArgumentNullException(nameof(bitmap)); } if (eplContainer == null) { throw new ArgumentNullException(nameof(eplContainer)); } var pcxByteArray = this.EplTransformer.ConvertToPcx(bitmap); eplContainer.Header.Add(this.EplCommands.DeleteGraphics(variableName)); eplContainer.Header.Add(this.EplCommands.DeleteGraphics(variableName)); eplContainer.Header.Add(this.EplCommands.StoreGraphics(variableName, pcxByteArray.Length)); eplContainer.Header.Add(pcxByteArray); }
public static ImageDrawable Create(SvgImage svgImage, SKRect skViewport, DrawableBase?parent, IAssetLoader assetLoader, HashSet <Uri>?references, DrawAttributes ignoreAttributes = DrawAttributes.None) { var drawable = new ImageDrawable(assetLoader, references) { Element = svgImage, Parent = parent, IgnoreAttributes = ignoreAttributes }; drawable.IsDrawable = drawable.CanDraw(svgImage, drawable.IgnoreAttributes) && drawable.HasFeatures(svgImage, drawable.IgnoreAttributes); if (!drawable.IsDrawable) { return(drawable); } var width = svgImage.Width.ToDeviceValue(UnitRenderingType.Horizontal, svgImage, skViewport); var height = svgImage.Height.ToDeviceValue(UnitRenderingType.Vertical, svgImage, skViewport); var x = svgImage.Location.X.ToDeviceValue(UnitRenderingType.Horizontal, svgImage, skViewport); var y = svgImage.Location.Y.ToDeviceValue(UnitRenderingType.Vertical, svgImage, skViewport); var location = new SKPoint(x, y); if (width <= 0f || height <= 0f || svgImage.Href is null) { drawable.IsDrawable = false; return(drawable); } var uri = SvgExtensions.GetImageUri(svgImage.Href, svgImage.OwnerDocument); if (references is { } && references.Contains(uri))
public static async Task <Bitmap> GetBitmapAsync(SvgImage svgImage, int width, int height) { Bitmap result = null; Stream svgStream = await SvgService.GetSvgStreamAsync(svgImage).ConfigureAwait(false); await Task.Run(() => { var svgReader = new SvgReader(new StreamReader(svgStream)); var graphics = svgReader.Graphic; var scale = 1.0; if (height >= width) { scale = height / graphics.Size.Height; } else { scale = width / graphics.Size.Width; } var canvas = new AndroidPlatform().CreateImageCanvas(graphics.Size, scale); graphics.Draw(canvas); var image = (BitmapImage)canvas.GetImage(); result = image.Bitmap; }); return(result); }
void InitEditors() { colPaymentStatus.ImageOptions.SvgImage = SvgImage.FromResources(statusResourcePath + "Payment.svg", GetType().Assembly); colPaymentStatus.ColumnEdit = EditorHelpers.CreatePaymentStatusImageComboBox(LookAndFeel, null, gridControl.RepositoryItems); colShipmentStatus.ImageOptions.SvgImage = SvgImage.FromResources(statusResourcePath + "Shipment.svg", GetType().Assembly); colShipmentStatus.ColumnEdit = EditorHelpers.CreateShipmentStatusImageComboBox(LookAndFeel, null, gridControl.RepositoryItems); }
public RingProgress() { RowSpacing = 0; ColumnSpacing = 0; var back = new SvgImage { Svg = "res:images.0GoldMirror", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start }; Children.Add(back); var cercleDegrade = new SvgImage { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start }; svgTemplate = XamSvg.Shared.Utils.ResourceLoader.GetEmbeddedResourceString(typeof(App).GetTypeInfo().Assembly, "images.templates.ring.svg"); cercleDegrade.Svg = BuildSvgRing(back); Children.Add(cercleDegrade); PropertyChanged += (sender, args) => { if (args.PropertyName == ProgressProperty.PropertyName) { cercleDegrade.Svg = BuildSvgRing(back); } }; }
public static void Run() { Console.WriteLine("Running example DrawRasterImageOnSVG"); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages(); // Load the image to be drawn using (RasterImage imageToDraw = (RasterImage)Image.Load(dataDir + "asposenet_220_src01.png")) { // Load the image for drawing on it (drawing surface) using (SvgImage canvasImage = (SvgImage)Image.Load(dataDir + "asposenet_220_src02.svg")) { // Drawing on an existing Svg image. Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D graphics = new Aspose.Imaging.FileFormats.Svg.Graphics.SvgGraphics2D(canvasImage); // Draw a rectagular part of the raster image within the specified bounds of the vector image (drawing surface). // Note that because the source size is equal to the destination one, the drawn image is not stretched. graphics.DrawImage( new Rectangle(0, 0, imageToDraw.Width, imageToDraw.Height), new Rectangle(67, 67, imageToDraw.Width, imageToDraw.Height), imageToDraw); // Save the result image using (SvgImage resultImage = graphics.EndRecording()) { resultImage.Save(dataDir + "asposenet_220_src02.DrawImage.svg"); } } } Console.WriteLine("Finished example DrawRasterImageOnSVG"); }
public static async Task <Stream> GetSvgStreamAsync(SvgImage svgImage) { Stream stream = null; //Insert into Dictionary if (!SvgStreamByPath.ContainsKey(svgImage.SvgPath)) { if (svgImage.SvgAssembly == null) { throw new Exception("Svg Assembly not specified. Please specify assembly using the SvgImage Control SvgAssembly property."); } stream = svgImage.SvgAssembly.GetManifestResourceStream(svgImage.SvgPath); if (stream == null) { throw new Exception(string.Format("Not able to retrieve svg from {0} make sure the svg is an Embedded Resource and the path is set up correctly", svgImage.SvgPath)); } SvgStreamByPath.Add(svgImage.SvgPath, stream); return(await Task.FromResult <Stream> (stream)); } //Get from dictionary stream = SvgStreamByPath [svgImage.SvgPath]; //Reset the stream position otherwise an error is thrown (SvgFactory.GetBitmap sets the position to position max) stream.Position = 0; return(await Task.FromResult <Stream> (stream)); }
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="bitmap" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="zplContainer" /> is <see langword="null" />.</exception> protected override void StoreGraphics(SvgImage svgImage, string variableName, Bitmap bitmap, ZplContainer zplContainer) { if (svgImage == null) { throw new ArgumentNullException(nameof(svgImage)); } if (variableName == null) { throw new ArgumentNullException(nameof(variableName)); } if (bitmap == null) { throw new ArgumentNullException(nameof(bitmap)); } if (zplContainer == null) { throw new ArgumentNullException(nameof(zplContainer)); } var rawBinaryData = this.ZplTransformer.GetRawBinaryData(bitmap, false, out var numberOfBytesPerRow); zplContainer.Header.Add(this.ZplCommands.DownloadGraphics(variableName, rawBinaryData, numberOfBytesPerRow)); }
void DesignMdiController_DesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) { XRToolboxService ts = (XRToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); ts.AddToolboxItem(new ToolboxItem(typeof(MyCustomLabel)), "Standard Controls"); // change icon of the XRLabel control if (radioGroup1.SelectedIndex == 1) { Stream stream = typeof(CustomLabel.MyCustomLabel).Assembly.GetManifestResourceStream("CustomLabel.StandardLabel.svg"); SvgImage svg = SvgImage.FromStream(stream); ts.AddToolBoxSvgImage(typeof(XRLabel), svg); } else { Stream stream = typeof(CustomLabel.MyCustomLabel).Assembly.GetManifestResourceStream("CustomLabel.StandardLabel16.bmp"); Image img = Image.FromStream(stream); ts.AddToolBoxImage(typeof(XRLabel), ImageSize.Size16, img); stream = typeof(CustomLabel.MyCustomLabel).Assembly.GetManifestResourceStream("CustomLabel.StandardLabel24.bmp"); img = Image.FromStream(stream); ts.AddToolBoxImage(typeof(XRLabel), ImageSize.Size24, img); stream = typeof(CustomLabel.MyCustomLabel).Assembly.GetManifestResourceStream("CustomLabel.StandardLabel32.bmp"); img = Image.FromStream(stream); ts.AddToolBoxImage(typeof(XRLabel), ImageSize.Size32, img); } }
protected internal virtual void LoadIcons() { Assembly asm = typeof(Appointment).Assembly; this.recurringSvgImage = ResourceImageHelper.CreateSvgImageFromResources(SchedulerSvgImageNames.NewRecurringAppointment, asm); this.normalSvgImage = ResourceImageHelper.CreateSvgImageFromResources(SchedulerSvgImageNames.NewAppointment, asm); }
public EmployeeView() : base(typeof(SynchronizedEmployeeViewModel)) { InitializeComponent(); gvTasks.SetViewFontSize(2, 1); gvEvaluations.SetViewFontSize(2, 1); BindCommands(); ViewModel.EntityChanged += ViewModel_EntityChanged; officeTabFilter.SelectedItemChanged += OfficeTabFilter_SelectedItemChanged; tvEvaluations.ItemCustomize += tvEvaluations_ItemCustomize; tvTasks.ItemCustomize += tvTasks_ItemCustomize; gcTasks.SizeChanged += (s, e) => { if (gcTasks.MainView == tvTasks) { tvTasks.RefreshData(); } }; var asm = typeof(MainForm).Assembly; svgYes = SvgImage.FromResources("DevExpress.DevAV.Resources.EvaluationYes.svg", asm); svgNo = SvgImage.FromResources("DevExpress.DevAV.Resources.EvaluationNo.svg", asm); priorityImages = SVGHelper.CreateTaskPriorityImages(LookAndFeel, "DevExpress.DevAV.Resources.Tasks."); buttonPanel.UseButtonBackgroundImages = false; }
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="zplContainer" /> is <see langword="null" />.</exception> protected override void PrintGraphics(SvgImage svgImage, Matrix sourceMatrix, Matrix viewMatrix, int horizontalStart, int verticalStart, int sector, string variableName, ZplContainer zplContainer) { if (svgImage == null) { throw new ArgumentNullException(nameof(svgImage)); } if (sourceMatrix == null) { throw new ArgumentNullException(nameof(sourceMatrix)); } if (viewMatrix == null) { throw new ArgumentNullException(nameof(viewMatrix)); } if (variableName == null) { throw new ArgumentNullException(nameof(variableName)); } if (zplContainer == null) { throw new ArgumentNullException(nameof(zplContainer)); } zplContainer.Body.Add(this.ZplCommands.FieldTypeset(horizontalStart, verticalStart)); zplContainer.Body.Add(this.ZplCommands.RecallGraphic(variableName)); }
public static DrawObject Create(SvgImage svg) { try { DrawImage dobj; if (string.IsNullOrEmpty(svg.Id)) { dobj = new DrawImage(svg.HRef, ParseSize(svg.X, Dpi.X), ParseSize(svg.Y, Dpi.Y), ParseSize(svg.Width, Dpi.X), ParseSize(svg.Height, Dpi.Y)); } else { var di = new DrawImage(); if (!di.FillFromSvg(svg)) { return(null); } dobj = di; } return(dobj); } catch (Exception ex) { ErrH.Log("DrawImage", "Create", ex.ToString(), ErrH._LogPriority.Info); return(null); } }
/// <summary> /// Returns a binary stream from the given SVG Image /// </summary> /// <param name="image">SVG image that has to be converted into a binary object.</param> /// <returns></returns> public static System.Data.Linq.Binary GetBinaryFromSvgImage(SvgImage image) { // If the input image is null, nothing has to be done if (image == null) { return(null); } System.Data.Linq.Binary binary = null; try { // Convert the image into a binary object using a MemoryStream and the SvgSerializer from DevExpress using (MemoryStream ms = new MemoryStream()) { SvgSerializer.SaveSvgImageToXML(ms, image); binary = new System.Data.Linq.Binary(ms.GetBuffer()); } } catch { binary = null; } return(binary); }
public static bool Run(bool print = false) { // The input domain. var r = new Rectangle(0d, 0d, 10d, 10d); var mesh = GetScatteredDataMesh(r); //var mesh = GetStructuredDataMesh(r); // Generate function values for mesh points. double[] data = GetFunctionValues(mesh.Vertices); if (print) { SvgImage.Save(mesh, "example-11.svg", 500); } // The points to interpolate. var xy = Generate.RandomPoints(50, r); var xyData = InterpolateData((Mesh)mesh, data, xy); double error = xy.Max(p => Math.Abs(xyData[p.ID] - F(p))); // L2 error //double error = Math.Sqrt(xy.Sum(p => Math.Pow(xyData[p.ID] - F(p), 2))); // Define tolerance dependent on mesh dimensions and size. double tolerance = 0.5 * Math.Max(r.Width, r.Height) / SIZE; return(error < tolerance); }
private async void FlashImageButton_Tapped(object sender, EventArgs e) { await HideFlashModesPanel(); string toastMessageText = string.Empty; SvgImage button = sender as SvgImage; if (button.StyleId.Equals("FlashDisabled")) { CameraView.CameraOptions.FlashMode = FlashMode.Off; toastMessageText = "Flash: Off"; } else if (button.StyleId.Equals("FlashEnabled")) { CameraView.CameraOptions.FlashMode = FlashMode.On; toastMessageText = "Flash: On"; } else if (button.StyleId.Equals("FlashAuto")) { CameraView.CameraOptions.FlashMode = FlashMode.Auto; toastMessageText = "Flash: Auto"; } else if (button.StyleId.Equals("FlashTorch")) { CameraView.CameraOptions.FlashMode = FlashMode.Torch; toastMessageText = "Flash: Torch"; } FlashButton.ResourceName = button.ResourceName; await DependencyService.Get <IToast>().Show(toastMessageText, false); }
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="eplContainer" /> is <see langword="null" />.</exception> protected override void PrintGraphics(SvgImage svgImage, Matrix sourceMatrix, Matrix viewMatrix, int horizontalStart, int verticalStart, int sector, string variableName, EplContainer eplContainer) { if (svgImage == null) { throw new ArgumentNullException(nameof(svgImage)); } if (sourceMatrix == null) { throw new ArgumentNullException(nameof(sourceMatrix)); } if (viewMatrix == null) { throw new ArgumentNullException(nameof(viewMatrix)); } if (variableName == null) { throw new ArgumentNullException(nameof(variableName)); } if (eplContainer == null) { throw new ArgumentNullException(nameof(eplContainer)); } eplContainer.Body.Add(this.EplCommands.PrintGraphics(horizontalStart, verticalStart, variableName)); }
public bool FillFromSvg(SvgImage svg) { try { float x = ParseSize(svg.X, Dpi.X); float y = ParseSize(svg.Y, Dpi.Y); float w = ParseSize(svg.Width, Dpi.X); float h = ParseSize(svg.Height, Dpi.Y); RectangleF = new RectangleF(x, y, w, h); _fileName = svg.HRef; _id = svg.Id; try { _image = Image.FromFile(_fileName); return(true); } catch (Exception ex) { ErrH.Log("DrawImage", "FillFromSvg", ex.ToString(), ErrH._LogPriority.Info); return(false); } } catch (Exception ex0) { ErrH.Log("DrawImage", "FillFromSvg", ex0.ToString(), ErrH._LogPriority.Info); return(false); } }
public static BarButtonItem initMenuBtnItem(int strId, string strName, string strText, RibbonItemStyles eStyle, string strFilePathSvg, ItemClickEventHandler oCallback4Click, RibbonControl oParentSuper, PopupMenu oParent4MenuBtnItemContainer) { var oMenuItem = new BarButtonItem(); //set props oMenuItem.Id = strId; oMenuItem.Name = strName; var strLan = I18nUtilsEx.getStrFromApp(strName); oMenuItem.Caption = String.IsNullOrEmpty(strLan) ? strText : strLan; oMenuItem.RibbonStyle = eStyle; oMenuItem.ImageOptions.SvgImage = SvgImage.FromFile(strFilePathSvg); oMenuItem.ItemClick += oCallback4Click; //add to parent oParentSuper.Items.Add(oMenuItem); oParent4MenuBtnItemContainer.ItemLinks.Add(oMenuItem); return(oMenuItem); }
public static BarButtonItem initComplexBtnItem(int strId, string strName, string strText, RibbonItemStyles eStyle, string strFilePathSvg, ItemClickEventHandler oCallback4Click, RibbonControl oParentSuper, BarSubItem oParent4ComplexBtn) { var oComplexBtnItem = new BarButtonItem(); //set props oComplexBtnItem.Id = strId; oComplexBtnItem.Name = strName; var strLan = I18nUtilsEx.getStrFromApp(strName); oComplexBtnItem.Caption = String.IsNullOrEmpty(strLan) ? strText : strLan; oComplexBtnItem.RibbonStyle = eStyle; oComplexBtnItem.ImageOptions.SvgImage = SvgImage.FromFile(strFilePathSvg); oComplexBtnItem.ItemClick += oCallback4Click; //add to parent oParentSuper.Items.Add(oComplexBtnItem); oParent4ComplexBtn.LinksPersistInfo.Add(new LinkPersistInfo(oComplexBtnItem)); return(oComplexBtnItem); }
public static BarButtonItem initSimpleBtn(int strId, string strName, string strText, RibbonItemStyles eStyle, string strFilePathSvg, ItemClickEventHandler oCallback4Click, RibbonControl oParentSuper, RibbonPageGroup oParent4Group) { var oButton = new BarButtonItem(); //set props oButton.Id = strId; oButton.Name = strName; var strLan = I18nUtilsEx.getStrFromApp(strName); oButton.Caption = String.IsNullOrEmpty(strLan) ? strText : strLan; oButton.RibbonStyle = eStyle; oButton.ImageOptions.SvgImage = SvgImage.FromFile(strFilePathSvg); oButton.ItemClick += oCallback4Click; //add to parent oParentSuper.Items.Add(oButton); oParent4Group.ItemLinks.Add(oButton); return(oButton); }
public static bool Run(bool print = false) { var poly = new Polygon(); // Generate the input geometry. poly.Add(Generate.Rectangle(0.0, 0.0, 1.0, 1.0)); // Set user test function. var quality = new QualityOptions() { UserTest = MaxEdgeLength }; // Generate mesh using the polygons Triangulate extension method. var mesh = (Mesh)poly.Triangulate(quality); // Validate. foreach (var e in EdgeIterator.EnumerateEdges(mesh)) { double length = Math.Sqrt(DistSqr(e.GetVertex(0), e.GetVertex(1))); if (length > MAX_EDGE_LENGTH) { return(false); } } if (print) { SvgImage.Save(mesh, "example-8.svg", 500); } return(true); }
public static bool Run(bool print = false) { const int N = 50; // Generate point set. var points = Generate.RandomPoints(N, new Rectangle(0, 0, 100, 100)); // We use a polygon as input to enable segment insertion on the convex hull. var poly = new Polygon(N); poly.Points.AddRange(points); // Set the 'convex' option to enclose the convex hull with segments. var options = new ConstraintOptions() { Convex = true }; // Generate mesh. var mesh = poly.Triangulate(options); if (print) { SvgImage.Save(mesh, "example-2.svg", 500); } return(CheckConvexHull(mesh.Segments)); }
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="bitmap" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="fingerPrintContainer" /> is <see langword="null" />.</exception> protected override void StoreGraphics(SvgImage svgImage, string variableName, Bitmap bitmap, FingerPrintContainer fingerPrintContainer) { if (svgImage == null) { throw new ArgumentNullException(nameof(svgImage)); } if (variableName == null) { throw new ArgumentNullException(nameof(variableName)); } if (bitmap == null) { throw new ArgumentNullException(nameof(bitmap)); } if (fingerPrintContainer == null) { throw new ArgumentNullException(nameof(fingerPrintContainer)); } var buffer = this.FingerPrintTransformer.ConvertToPcx(bitmap); fingerPrintContainer.Header.Add(this.FingerPrintCommands.RemoveImage(variableName)); fingerPrintContainer.Header.Add(this.FingerPrintCommands.ImageLoad(variableName, buffer.Length)); fingerPrintContainer.Header.Add(buffer); }
public void TestDefaultCtor() { // run var image = new SvgImage(); // check Assert.IsNull(image.Source, "default constructed SvgImage object must have null Source"); }
private void LoadSplashImageFromResource() { Assembly assembly = Assembly.GetExecutingAssembly(); Stream svgStream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".Images.SplashScreenImage.svg"); svgStream.Position = 0; pictureEdit2.SvgImage = SvgImage.FromStream(svgStream); }
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="variableName" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="container" /> is <see langword="null" />.</exception> protected abstract void PrintGraphics([NotNull] SvgImage svgImage, [NotNull] Matrix sourceMatrix, [NotNull] Matrix viewMatrix, int horizontalStart, int verticalStart, int sector, [NotNull] string variableName, [NotNull] TContainer container);
/// <exception cref="ArgumentNullException"><paramref name="svgImage" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="container" /> is <see langword="null" />.</exception> protected abstract void GraphicDirectWrite([NotNull] SvgImage svgImage, [NotNull] Matrix sourceMatrix, [NotNull] Matrix viewMatrix, float sourceAlignmentWidth, float sourceAlignmentHeight, int horizontalStart, int verticalStart, [NotNull] TContainer container);
/// <summary> /// Shows an alert window. /// </summary> /// <param name="caption">The caption of the alert window.</param> /// <param name="message">The message to display in the alert window.</param> /// <param name="svgImage">The image to display in the alert window. /// Must meet the size specified in <see cref="ImageWidth"/> and <see cref="ImageHeight"/> if /// <see cref="EnforceImageSize"/> is true. /// Can be null.</param> /// <remarks>Will invoke on the main thread if needed.</remarks> public static void ShowAlert(string caption, string message, SvgImage svgImage) { var svgBitmap = new SvgBitmap(svgImage); var image = svgBitmap.Render(new Size(ImageWidth, ImageHeight), null); var bitmap = new Bitmap(image); ShowAlert(caption, message, bitmap, null); }
/// <summary> /// Renders the specified matrix. /// </summary> /// <param name="matrix">The matrix.</param> /// <param name="format">The format.</param> /// <param name="content">The content.</param> /// <param name="options">The options.</param> /// <returns></returns> public SvgImage Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) { var result = new SvgImage(); Create(result, matrix, format, content, options); return(result); }
private void ExportSvg(Mesh mesh, string filename, int width, bool compress) { var svg = new SvgImage(); svg.Export(mesh, filename, width); if (compress) { CompressFile(filename, true); } }
public RingProgress() { RowSpacing = 0; ColumnSpacing = 0; Children.Add(new SvgImage { Svg = "res:images.greyCircle", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start }); var cercleDegrade = new SvgImage { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start }; svgTemplate = XamSvg.Shared.Utils.ResourceLoader.GetEmbeddedResourceString(typeof(App).GetTypeInfo().Assembly, "images.templates.ring.svg"); cercleDegrade.Svg = BuildSvgRing(); Children.Add(cercleDegrade); PropertyChanged += (sender, args) => { if (args.PropertyName == ProgressProperty.PropertyName) cercleDegrade.Svg = BuildSvgRing(); }; }
public ListenPageRelativeLayout() { this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0); Icon = "ListenIcon"; Title = "Listen"; BackgroundColor = Color.Olive; RelativeLayout relativeLayout = new RelativeLayout(); SvgImage whiteTower = new SvgImage { Svg = "res:Images.WhiteTower", BackgroundColor = Color.Red, HorizontalOptions = LayoutOptions.Start }; Image launchSettingsImage = new Image { Source = "SettingsIcon", BackgroundColor = Color.Lime }; // Image listenPageLogo = new Image // { // Source = "ListenPageLogo", // BackgroundColor = Color.Green // }; SvgImage listenPageLogo = new SvgImage { Svg = "res:Images.ListenPageLogoSVG-outlined", BackgroundColor = Color.Fuchsia, HorizontalOptions=LayoutOptions.Start, VerticalOptions=LayoutOptions.Start }; Button playStopBtn = new Button { Text = "▶︎", TextColor = Color.FromHex("#007AFF"), FontSize = 48, BackgroundColor = Color.Lime, HorizontalOptions=LayoutOptions.Start }; relativeLayout.Children.Add(whiteTower, Constraint.Constant(0), Constraint.Constant(0) ); relativeLayout.Children.Add(launchSettingsImage, Constraint.RelativeToParent((parent) => { Debug.WriteLine("whiteTower.Width = {0}", whiteTower.Width); Debug.WriteLine("whiteTower.Height = {0}", whiteTower.Height); return parent.Width - 30; }), Constraint.RelativeToParent((parent) => { var y = 15; Debug.WriteLine("listenPageLogo y = {0}", y); return y; } )); relativeLayout.Children.Add(listenPageLogo, Constraint.RelativeToParent((parent) => { return parent.Width * 0.45; }), Constraint.RelativeToParent((parent) => { var y = 0.4 * parent.Height - listenPageLogo.Height / 2; Debug.WriteLine("listenPageLogo y = {0}", y); return y; }), Constraint.RelativeToParent((parent) => { return parent.Width * 0.5; } )); relativeLayout.Children.Add(playStopBtn, Constraint.RelativeToView(listenPageLogo, (parent, sibling) => { var x = sibling.X + sibling.Width / 2; Debug.WriteLine("playStopBtn.Width: {0}", playStopBtn.Width); Debug.WriteLine("playStopBtn x = {0}", x); return x; }), Constraint.RelativeToView(listenPageLogo, (parent, sibling) => { var y = sibling.Y + sibling.Height + 40; Debug.WriteLine("playStopBtn y = {0}", y); return y; } )); this.Content = relativeLayout; }
public SvgImageSamplePage () { _ViewModel = new SvgImageSamplePageViewModel(); var insetLabel = new Label(); insetLabel.SetBinding(Label.TextProperty, nameof(SvgImageSamplePageViewModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}"); var resourcePicker = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand, }; foreach (var resourceName in SvgImageSamplePageViewModel.AvailableResourceNames) { resourcePicker.Items.Add(resourceName); } resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(SvgImageSamplePageViewModel.SvgResourceIndex), BindingMode.TwoWay); var insetSlider = new Slider() { Minimum = 0, Maximum = 35, Value = _ViewModel.AllSidesInset, }; insetSlider.SetBinding(Slider.ValueProperty, nameof(SvgImageSamplePageViewModel.AllSidesInset), BindingMode.TwoWay); var slicingSvg = new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, WidthRequest = 300, HeightRequest = 300, }; slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(SvgImageSamplePageViewModel.SvgInsets)); slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(SvgImageSamplePageViewModel.SvgResourcePath)); var svgButton = new Button() { WidthRequest = 300, HeightRequest = 300, BackgroundColor = Color.Transparent, }; // The root page of your application Title = "9-Slice SVG Scaling"; Content = new ScrollView { Content = new StackLayout { VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, Children = { insetLabel, resourcePicker, insetSlider, new AbsoluteLayout() { WidthRequest = 300, HeightRequest = 300, Children = { slicingSvg, svgButton, }, }, new Label () { Text = "Using TwinTechsForms.SvgImage", }, new Label () { Text = "Proportional Scaling", }, new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", WidthRequest = 50, HeightRequest = 50, }, new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", WidthRequest = 100, HeightRequest = 100, }, new Label () { Text = "9-Slice Scaling", }, new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new ResizableSvgInsets (18), WidthRequest = 50, HeightRequest = 50, HorizontalOptions = LayoutOptions.Start, }, new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new ResizableSvgInsets (18), WidthRequest = 100, HeightRequest = 100, HorizontalOptions = LayoutOptions.Start, }, new SvgImage() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new ResizableSvgInsets (18), WidthRequest = 300, HeightRequest = 300, HorizontalOptions = LayoutOptions.Start, }, new Label () { Text = "Using TwinTechsForms.NControl.SvgImageView", }, new Label () { Text = "Proportional Scaling", }, new SvgImageView() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", WidthRequest = 50, HeightRequest = 50, }, new SvgImageView() { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", WidthRequest = 100, HeightRequest = 100, }, new Label () { Text = "9-Slice Scaling", }, new SvgImageView () { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18), WidthRequest = 50, HeightRequest = 50, HorizontalOptions = LayoutOptions.Start, }, new SvgImageView () { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18), WidthRequest = 100, HeightRequest = 100, HorizontalOptions = LayoutOptions.Start, }, new SvgImageView () { SvgAssembly = typeof(App).GetTypeInfo().Assembly, SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg", SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18), WidthRequest = 300, HeightRequest = 300, HorizontalOptions = LayoutOptions.Start, }, }, BindingContext = _ViewModel, }, }; svgButton.Clicked += (sender, e) => { DisplayAlert("Tapped!", "SVG button tapped!", "OK"); }; }