Short question here: I have a SVG chart with nodes. Is there a way to be able to have clicking the SVG trigger a function in the page code behind? Specifically, have it be able to tell which node in the chart was clicked. I've noticed that the asp controls have this type of functionality built in, but not the more generic html components.
Well, today I got a solution to work. I will share here for anyone else looking.
My click-event trigger is an asp:ImageMap that has been placed over the SVG using CSS z-index.
Before displaying the SVG, the code-behind in the Page_Load function takes the SVG and parses it into XML so I can read/modify it like an XML document. First the program checks the 'g' element for any transformations and saves the offset to use when plotting coordinates. Then, the program looks at each shape (rect, circle, etc) element in the XML and pulls the x,y coordinates from the shape and creates a corresponding ImageMap HotSpot and adds it to the ImageMap.
Whew!
Related
I'm looking for a way to get the result of an overlay between two pdf documents.
We have a document with a single page and only a header and another document with multiple pages and full content (header and body). We're looking for way to generate an overlay pdf between those documents, so that the resulting document with the content gets its header overwritten in each page with the single page document header. Basically like this:
Is there a opensource c# library, which can handle this and not convert the text to a picture.
I looked at PdfSharp and docnet, but couldn't figure it out with either of them.
So far we are using pdfbox, but we'd like to get rid of the java dependency.
Simple solution with PDFsharp: draw a white rectangle that hides the original header, then draw the new header on top of the rectangle.
Drawback: The old header is still contained in the document.
I'm trying to split and SVG into many different SVG files each one containing one element original file.
My main problem is not the slipt in itself since for each element I have to split, I get the svg element, remove everything else from the original svg, add back the element into the main layer and then save the file with the name I want. This works fine.
The real problem is that each file I create has the view centered and dimensioned as in the original svg file. So usually it's misplaced and wide (since in the original file it would contain all elements that now are split into different files).
So I need to resize the canvas to the element that remains in the file.
This very function is done by inkscape with the command
inkscape --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose
But unfortunally this verb doesn't work in --without-gui mode, so if I call it in the code I see thousands of inkscape instances opening, fitting the canvas and then save and close the windows. It works but it's not good for a batch application (they have this "bug" since quite some years).
So I resorted to use SVG engine (https://github.com/vvvv/SVG) but it has a bug that prevents the right calculation of the element bounds (https://github.com/vvvv/SVG/issues/331), so I cannot change the viewbox or the svg element to the right values.
Any suggestion on how to calculate the right position and size? Or any other library (any language that can run in a batch) that works for that?
I would like to programatically add a shape into the current slide of PowerPoint in C# .NET
So, I have created a VSTO Add-in with a ribbon which has a button "Add Shape".
When this button is clicked, the following code executes:
Globals.ThisAddIn.Application.ActiveWindow.View.Slide.Shapes.AddShape(
Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0, 10, 20);
When this code executes, it correctly adds a rectangle shape into the current slide.
I would like to modify this shape later (for example; change it's width). To be able to do this, I read somewhere that the shape should have a unique identifier and this can be achieved using a Tag?
If so, how do you add a shape and set a tag on the newly added shape, so that I can manipulate it later?
Also, how do you iterate through the collection of shapes on the current slide, so that you can check the tag of the shape to see if that's the one I want to modify?
The .AddShape method can return a reference to the shape you've just added.
You'll want to do that for simplicity's sake.
The shape has a .Tags object
The .Tags object has an .Add method
So assuming a reference to the shape in oShape, you can do (again in VBA, you'll have to translate):
oShape.Tags.Add "MyTagName", "MyTagValue"
For more information and an example (VBA) function that returns a reference to a shape with a given tag value, you can visit this page on my PPT FAQ site:
Working with Tags (and a bit about Functions)
http://www.pptfaq.com/FAQ00815_Working_with_Tags_-and_a_bit_about_Functions-.htm
How (if possible to do so) can I create an SVG image, using C#? I wish to take one SVG, overlay another SVG on it, and save it as a third SVG image.
In my specific case, I allow a module of my software to provide an icon for a folder. I want to overlay a warning or error icon on top of the folder icon when there is an error in the contained data.
I recommend using SVG Rendering Engine to do this. Create a third document, and put the two given svgs one after the other into it. (Nesting svg documents in each other is completely valid):
var icon = SvgDocument.Open(...);
var overlayIcon = SvgDocument.Open(...);
var overlayed = new SvgDocument();
overlayed.Children.Add(icon);
overlayed.Children.Add(overlayIcon);
overlayed.Write(...); // saving
Note: check the overlaying icon's size, viewbox, etc., you may have to change these through SvgDocument.Width, SvgDocument.Height, SvgDocument.ViewBox to get proper result.
SVG is a very simple text format, even simpler than HTML. Overlaying SVGs is a work for XML library. You can just open it and append every node from one file to another file.
Just try taking these two text files:
http://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg
http://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg
Open the first one, copy contents of the the <svg>...</svg>, paste at the end of the other file (just before the ending </svg> tag). You can check in some editor or validator that the result is just a perfectly fine SVG file.
Use System.Xml or System.Xml.Linq for handling it from your C# code. Additionally you can add new nodes, edit attributes like width, height, color, etc... if you want:
<svg width="637" height="637">
<path style="fill:white" d="... "/>
...
</svg>
Have fun.
I am coding a galery in jquery.
I have an image zoom tool that is put on a main image on an image_preload event.
I have smaller images that when clicked swaps the main image out with the one that is clicked. The new image is now the main image.
The problem is that the zoom tool is still picking up the old image even though in firebug it says that the new image was loaded into the zoomer.
I want to remove the code that i have on the main image when the switch is made and then put it back on. I'm thinking this will update the zoomer.
i have
$('.MYCLASS').jqzoom();
so can i do something like
$('.MYCLASS').jqzoom().Remove();
Thanks any help is appreciated
You would have to know what the function does in order to reverse its effects. It might be that the plugin provides a remove function, but I doubt that it would work in your instance.
One suggestion might be to simply clone the $('.MYCLASS') element and delete the original which has been bound with the jqzoom() plugin.