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.
Related
Nothing much to it, just a general question. I've searched for ages on the web but I can't find anything that answers my question.
is this possible? I want to parent one picturebox to another (which is below the one I want to parent) to allow the transparency to work properly for the top picturebox. But the picturebox's location changes off to somewhere off screen which is what I don't want.
If there is nothing like that, then are there any suggestions?
Currently I'm working with very small pictureboxes and I've tried everything to get the top image to be in the same place, including things like this code:
Btn_Close2.Location = New Point(Btn_Close2.Location.X - Btn_Close.Left, Btn_Close2.Location.Y - Btn_Close.Top)
But the top picturebox just wonder's off somewhere.
I have a panel (with autoscrolling) that contains randomly placed UserControls, I want to save the locations of these controls and load them back at a later time so they are placed exactly where they were before.
What's the proper way to do this in .NET? At the moment this is what I'm saving to the database as X,Y:
X: Math.Abs(panel.AutoScrollPosition.X) + control.Location.X;
Y: Math.Abs(panel.AutoScrollPosition.Y) + control.Location.Y;
And when I load the control I do:
control.Location = new System.Drawing.Point(X, Y);
But I think I'm missing something, because of the way the AutoScroll behaves in .NET. Sometimes I find the controls misplaced (unlike their old position) after loading.
Been boggling my mind for a while now, I really hope I'd find some information here.
Not sure on all the configuration you are using, but make sure the incremental steps for the scroll bars are whole numbers. Next make sure that the controls are getting added back to the panel control tree instead of the parent form and set the location.
You could use a app.config file to save those settings, so when you need them back you just make a call to the settings for the key inside app.config.
I think there is not a proper way, whatever you feel better it works, but if you are going to have dynamically created controls you could have a database as you have now. But, if there are going to be just a few of them, a app.config file will work better.
I presume you want to restore the controls to their current visual position after scrolling and that is why you take account of the auto-scroll? When you say the controls are misplaced, have they moved relative to each other, or are the whole lot 'scrolled' to the wrong position?
Are you sure about the Math.Abs? This seems somewhat odd; I would try with just adding Location.X and AutoScrollPosition.X (or use -AutoScrollPosition.X)
I would also check on restore that the AutoScrollPosition is currently 0.
I would have thought this was a common desire, but I'll be damned if I can find this.
I simply want to Animate an image by swapping two images back and forth. I tried StoryBoard, but apparently you can't change the source in a storyboard. The only answer I can come up with is a Timer, which I don't think is the best way.
Edit: How do I animate image content in WPF? Came up in the "Similiar Questions" window. And while this will do what I want, it is "hackish" as the OP of it says, and it only swaps two images, what if I wanted a whole sequence of 10 or 20 or 100.
I found another post here on SO whose answer sounds like it could solve your problem: Change an image during animation using storyboard
The problem with this approach is that it also doesn't satify your request for supporting an arbitrary number of images.
I was going to propose a different method that involves databinding the Image Source to the image path, and then in code behind simply changing the path, but I haven't gotten it to work yet.
Here's an article that seems to have an elegant way to handle your requirements: http://www.codeproject.com/Articles/364529/Animation-using-Storyboards-in-WPF
Hopefully that will work for you.
I am trying to write a simple program that lets me overlay a dot on top of an image when the image is clicked. I can save the X and Y data back to my database but then I will want to be able to call that information back at a later date and overlay the dots again via code unlike the first time when the user had to click the image.
I got as far as capturing the X and Y of the click no problem but I am having trouble finding examples specifically for what I am trying to do. All of the examples online seem to be for saving the image with the added graphic but I do not need to do that as it will be the same image every time.
Once I can do this, I also need to work out a way that I can detect what area of the image has been clicked. The areas I need to mark out vary in shape and size so I need to try and work out a way to 'map' these areas and then cross reference with the co-ordinates of the users click (I assume that I may need to do some clever geometry stuff for that?)
If anyone has any suggestions of what subjects/classes/methods etc. to research for either of my queries, I would very grateful.
Thanks in advance
You can use the System.Drawing namespace to achieve this.
Create a control and override OnPaint and OnPaintBackground. Store your clicks in a List
In OnPaintBackground, draw the image using DrawImageUnscaled using the graphics object which is passed to you as a parameter.
In OnPaint, loop through your points array and call graphics.FillElipse or similar to draw a little dot.
Because this isnt a retained mode graphics system, you need to keep drawing these items so this may not suit a large number of dots. In that case, you can create an in memory bitmap and get a graphics drawing object using graphics.FromImage.
In normal C# it is easy to draw to a bitmap using the Grpahics.DrawString() method. Silverlight seems to have done away with Bitmap objects and Graphics is no longer available either. So...How am I meant to manipulate/create a bitmap when using Silverlight? If it helps, I am using Silverlight 3.
Let me tell you what I am doing. I am being given a template, basically a pre-rendered image. The user is then able to select from multiple images and enter the deisred text. I then render it to the image, adjusting size etc... within bounds and centering it in the pre-defined area of the image. If I can calculate the size (as in the MeasureString method) and then draw the string (as in the Graphics.DrawString method) that would be fine. The real question, no matter why I want to be able to do this, is can it be done?
The question is: why do you want to? Why not just use a TextBlock?
If you are trying to dynamically generate an image, use standard Silverlight/WPF controls (including TextBlock) and render them to a WritableBitmap.
Edit:
Ok, you've updated and expanded, which gives me more to go on. Unfortunately, you're not going to like the answer. First, keep in mind that Silverlight and WPF in general are vector based, and intended to be used as such. Although the Canvas allows you to do pseudo-pixel manipulations, you cannot be nearly as pixel-accurate as old-school GDI. This is a factor of your medium. If you absolutely have to measure things the way you want to measure them, I suggest you build your images on a remote server and transmit them to your Silverlight app.
You can calculate the size on-screen of the text rendered via a TextBlock using the ActualWidth and ActualHeight properties. But it only works on an already rendered control. Something like MeasureString is simply not available in Silverlight. Based on your description of your app, some user interaction could accomplish what you want. The user selects the image, enters the text, and is shown a preview. The user can then adjust the width and height of the various text areas until satisfied, at which point you can take a snapshot using the render method I liked to above.
The following may work, its a bit nebulous because I haven't tried yet myself.
The object you are looking for is the WritableBitmap.
You create a Visual tree, for example create your self a Grid or Canvas (you're not adding this to the UI). Add to it the selected image and a TextBlock positioned and sized as you prefer.
Create a new WritableBitmap either of a specific size or using the selected image to initialize it.
Use the WritableBitmap Render method passing the above root Grid or Canvas to it.
Now you have a bitmap which you should able to use to do whatever its you needed to do that required all this hoop jumping in the first place.