AjaxToolkit ModalPopup, how to dynamically set x and y coordinates? - c#

I have used Modal Pop-up extender in an image gallery project which shows the actually size of images when somebody click's on thumbnail inside a datalist.
Everything works fine, beside the location on ModalPop-up is appears at the random location on the screen and sometimes push the image off the screen to right side, If I hard code x and y coordinates then the small image appears and extreme right not in sync.
If I click, re-size or change the scroll position then it re positions to the center of the page but not otherwise.
Kindly suggest a work around to either change the scroll bar position as soon as ModalPop-up is shown (using client script), or an CSS property which I can use to set it.
Thanks a lot in advance.

Related

Send to back object that created at run time

I have a page that in this page i have one image and at run time i add 3 buttons but these button come to front of image. how can i send these button to back. i use Panel.SetZindex but not works. thank you.
Have you also used Panel.SetZindex for image control? I think you would have used it just for buttons not for image thats why buttons are still coming in front of image control.
You should set z-index of buttons to least possible value and the z-index of image to highest possible value so that image would comes in front.
Use following code:
Panel.SetZindex(button1,0);
Panel.SetZindex(button2,1);
Panel.SetZindex(button3,2);
Panel.SetZindex(image,3);
Set buttons z-index property to lowest possible number and then add it at run time.

Make image slideshow in wpf

I'm trying to create an image slideshow just like this one on this page: http://forum.xda-developers.com/forumdisplay.php?f=1914
If you mouseover the image of the tablet, two arrows appear and you may slide through these images.
How to achieve this with wpf?
I want to create it just like on the page, I press the right arrow and the current image moves left out of sight and the new image comes to the center from the right.
The application should be resolution independet, so working with a canvas isn't possible I guess.
To give a general answer to that question without writing the code for you(, which is your task):
Create a Grid with the size of one image. Create a Canvas with the HeightProperty set to the height of the images and the WidthProperty to the sum of the width*amount of images.
Next thing, add two images for the arrows and the canvas as children to your grid and position them correctly.
Second last thing. Create an event for the grid MouseEnter to change the IsVisible property of the arrows to true and one for MouseLeave where it is set to false.
Last thing. Create events for LeftMouseButtonDown for the two arrow images that will trigger a animation that changes the Margin.Left property of the canvas by the width of one image.

C# Image over another image

I have a picturebox with a fixed sized image (256x256) generated by the program. I have another smaller image as a resource. What I want to do is when my cursor is over the image and I hold down the mouse button, the smaller image "anchors" with the mouse pointer so it moves around with it. If I let go of the mouse button, the smaller image will stay in that position on top of the bigger image. The smaller image is basically a marker, something like an X or O.
I was thinking of having a second picturebox on top of the first picturebox but I can't make it transparent. Or redrawing the image with the smaller image on top of it and reloading the image into the picturebox, but I'm not sure how to do that and I think it's going to be pretty slow redrawing it each time I move the mouse.
So how can I have a marker image move around on top of a bigger image and have it stay there?
Create your control for this instead of using PictureBox. PictureBox should be used ONLY for fixed images on the form, nothing else.
Instead, derive your control from UserControl. Turn on double buffering for it. In OnPaint method, first draw your background picture, then your marker picture after it. Don't worry, it WON'T be slow and it WILL work as it should.
When you release the mouse, update background picture by drawing your marker picture on it.
Since every sentence here is a little discovery by itself, hope you'll have a good time coding your little game :)

Convert screen coordinates to picture coordinates

I have the following problem: A program displays a picture using a PictureBox. The picture contains two rectangles A and B that are drawn after the image is loaded.
The image inside the picture box is zoomed and the rectangles A and B are painted using the Graphics object of the loaded image. Is there a simple method to determinate if a user clicked the area inside these rectangles e.g. converting screen coordinates to picture coordinates.
Edit: No longer relevant, found another solution.
Edit 2: My solution was to use two picture boxes at the A and B location instead of modifying the image directly. It has some minor disadvantages specific to my solution, but I had to finish the project in time
This SO post discusses the zoom factor of a picture box and that you cannot determine it.
Therefore I think, without getting the zoom factor, you may not be able to calculate the position.

WinForms (.NET) Button Anchoring when Maximized

Ok, I have googled, but maybe I put my search in weirdly. :/
I have a VB.NET WinForms application. I have the anchor properties set for all the controls so that it will resize all the controls to look decent when the form is maximized. (Haven't gotten around to manual resizing yet however).
Anyway, the problem:
I go to set the same properties for a button (testing with a single button for now) on the main GUI form/picture. When I go to run the program via F5, it looks decent. But when I maximize the form, the entire button covers up more than it should.
I've taken screenshots of the form so you can see a visual of what I'm talking about. :/
Before: http://zack.scudstorm.com/before.png
After: http://zack.scudstorm.com/after.png
What other propert(y|ies) do I need to set for the buttons to show up correctly? :/ (The buttons go over the boxes that say, for example, "1-1", "2-3", etc.
Thanks,
-Zack
Seems like you have anchored top-left and bottom-right when what you want is just top-left.
Edit: If it's just an image that does not change when the winform changes, then don't anchor your buttons at all. Just put them where they go. If you are scaling the image, then I would either detect the clicks on the image and do the scaling math or do the scaling math and set my buttons in code in the Form.OnResize event.
As it appears that your goal is just to be able to handle clicks on the "computers"...
One option that can be useful for this sort of task is to create an "overlay" bitmap (not displayed, but which is the exact same size as your source bitmap) which uses different colors to represent all the clickable regions. (e.g. (R=0,G=0,B=0) for computer 0, (0,0,1) for computer 1, etc)
You could even generate this bitmap somewhat automatically without too much trouble (If you have a mode where you can click the top left and then bottom right corners of the image to define a new region)
When the mouse is clicked, you can check the pixel at the scaled coordinates of the mouse position in the overlay and determine what their click corresponds to. This can be a lot easier than creating loads of controls, and makes it a lot easier to have clickable regions that aren't rectangular.

Categories

Resources