|
i am developing one eform designer project..the main object of this project is there a form in this controls are drag and drop.moving and deleting and editing the properties ..it's like a our .net designer how we drag and drop the controls ..so in my project i need to implement undo/Redo functionality..please give me the basic idea of this..(Please think like a our .net Designer (UNDO/REDO))
Thanks & regadrs
Dilip
|
|
|
|
|
Take a look at this blog[^], and see if it meets your needs.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I would personally have a structure which a) describes what the user did, or b) describes the state of the control before the user interacted. Then I would use a Stack, and just push or pop the structures whenever the user clicks Redo or Undo respectively (I think)
|
|
|
|
|
You may want to do some research into the "command pattern".
|
|
|
|
|
I have to add one functionality in my Windows application. When user presses X key, it should do some function by calling routine. However when user is typing something on a form(ex. in textbox), this event should not be fired.
Currently due to this event handler code, user is unable to type X key becoz it is calling X key routine.
Any solution of this problem?
Thanks.
|
|
|
|
|
Maybe you could set a boolean flag which gets toggled when the user enters/leaves the textboxes on your form. The x key routine would then check the state of the boolean flag which would determine if the event should go ahead or not.
|
|
|
|
|
Thanks Liqz,
The situation is there is one main form and depending on menu items selection, it is loading user controls on main form, which comes from multiple solutions. So there are many solutions and lots of user controls are taking part here.
I do not want to change all the user controls but I want to change only main form.
Thanks.
|
|
|
|
|
Take a look at Tom's post below, it is actually a better solution than mine, I was unaware of the ActiveControl method.
Using that method you can get the type of the active control, then if the type of active control is a text box, don't do the x key function.
|
|
|
|
|
Use alt+x ?
Other than that in your function (that is called by the event handler on pressing x) check if the current active control is one where the user can type in (textbox, richtextbox,...)
This might be off help:
form.ActiveControl
|
|
|
|
|
Thanks Tom,
I looked for X key combination with Alt key but it is returning me only Alt key and not with combination of other key with Alt so i am unable to trap event for Alt+X key combination.
Also I looked on ActiveControl but the deal is I have layers of controls like this:
Bottom to top
Form
User Control
Split control
User control
Textbox and other controls.
When I tried to get active control, it returns me "System.Windows.Forms.SplitContainer" and not individual controls.
Any help please?
Thanks.
|
|
|
|
|
Hi,
the KeyDown event offers a KeyEventArgs object containing information about the most recent key, but also the current state of the modifier keys such as Alt, Control, Shift.
|
|
|
|
|
If the alt+x way is a valid way to go for you I would do it that way, since you have usercontrols the activecontrol will most likly never be to accurate.
This code works fine for me:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Alt = True And e.KeyCode = Keys.X Then
MessageBox.Show("success")
End If
End Sub
Property 'Keypreview' from the form set to true
If you don't get it working like that I suggest you create a menustrip on the form, add a dummy menu, in the properties of that menu add a shortcut (alt + x), set the property 'visible' from the menustrip to false and do your function in the click event of the menu. (always works that way)
|
|
|
|
|
I am currently writing a program which allows users to crop an image by drawing a box on the displayed image. The control I am using is picture box. Now, the crop function is acheived by defining a rectangle and pass through Bitmap.Clone. all the cropping and saving function works fine, but the biggest problem I am having is the users I am working with deals with very high resolution images, somewhere in the lines of 2500 x 3500. Therefore to display the whole image onto the screen I am using either a SizeMode of Zoom or StretchImage, however this causes a problem when cropping the image. When the image is cropped it is not at the region specified by the rectangle, it ends up cropping a different portion of the image.
I cannot use SizeMode AtouSize either as the user must be able to see the entire image and the cropped area of the image must come from the original high resolution image. If anyone knows a solution to this problem or can point me to the right direction I would be most grateful.
Thanks in advance.
|
|
|
|
|
Hi,
the problem basically is that the PictureBox is doing things (panning, zooming, resizing, ...) to your image, and not to whatever you draw on top of it.
There are two solutions:
1. mimic the PictureBox logic for everything you are drawing on top of it.
2. don't use a PictureBox at all; use a Panel instead, show the image by painting it with Graphics.DrawImage; now implement the panning, zooming, resizing,... whatever you want yourself and apply them equally to the image and the other parts drawn (best use one or some of the Transform methods which manipulate coordinates and scales).
I always do (2), there is no benefit in trying to mimic a PictureBox when it works against you.
|
|
|
|
|
Thanks for the reply, but I think using Graphics.DrawImage to paint the image on the panel isn't going to work for me, perhaps I should explain my intention more clearly. What I want to do is allow the user to crop their high resolution image, but the entire image must be displayed on the form without parts of it cutting off, in order to do this I have scale down the image to best fit the picture box and keeping the SizeMode to Normal. However, when the user crops the image the crop must come from the high resolution image itself but not the scale down version displayed in the picture box. I have managed to achieved cropping the right portion of the scale down version of the image, but obviously cropping the scale down version will mean that I will lose the original resoultion and keeping the high resolution is an absolute requirement for this application.
Correct me if I am approaching this the wrong way, but my thinking is that as the user draws the rectangle on the scale down version of the image, instead of the passing the scale down version through Image.Clone or Grahics.DrawImage, the orignal high resolution version is passed through instead and there needs to be some sort of code that proportionately scale up the rectangle drawn so that what ever section that the user crop on the scale down version will match the high resolution version. I don't know if it is possible to acheive this nor do I have any idea how to approach this, any help will be much appreciated.
Hope all this make sense, thanks in advance.
|
|
|
|
|
Hi,
First of all anything a PictureBox can do you can do wiith a Panel, the difference is when drawing yourself you are in charge.
look carefully at the Graphics class; its DrawImage method will paint an image and its DrawRectangle will paint a rectangle. Both will use the same coordinate system, which you can freely choose.
If you apply a transformation (TranslateTransform, ScaleTransform) it will:
1. apply to everything you draw afterwards
2. allow you to position and scale everything so that e.g. part of your image falls outside the panel.
So you can scale down a 1000*1000 picture and a 900*900 rectangle to a 100*100 panel; have the arrow keys move the (unscaled) rectangle move by 1 pixel in real coordinates (hence 0.1 px on the screen), etc.
|
|
|
|
|
I suspect that Luc is probably correct in his reply to your question.
I have been caught out in the past when doing this sort of thing, and you might like to bear in mind, that not all images are saved at the same resolution as your screen. I use 96 ppi and have had problems with images saved at 72 ppi. Of course stretching/zooming the image will cause more problems, but this might become relevant when the selected region is small enough to display in its entirety.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I suspect that Luc is probably correct
Thanks for the endorsement.
|
|
|
|
|
I want to list security groups of several folders in my windows 2003 server.
Is there anyway that i can do this without doing manually?
dsquery can do this ,,please someone post the query ?
modified on Tuesday, April 28, 2009 8:07 AM
|
|
|
|
|
What does this have to do with VB.NET??
|
|
|
|
|
"Steve Ballmer will deliver the keynote at Microsoft Tech-ed India 2009 Conference in Hyderabad. There will be announcements related to Windows 7, Silverlight 3, Microsoft Surface Computer, Tata Nano, IPL, etc. and Microsoft will also provide free certification to all onsite attendees.
What: Microsoft Tech-ed India 2009
Where: Hyderabad
When: May 13-15, 2009
Register: http://www.microsoft.com/india/teched2009
There is also a ""Top Architect"" contest being organized. http://virtualtechdays.com/toparchitect/default.aspx
|
|
|
|
|
Will you please stop friggin' spamming the forums?!?
|
|
|
|
|
I am connecting an access mdb format and cannot display the values from the database table onto a form in vb . I need also to enter values to the same database. I appreciate any help anyone can provide as I am new to all this.
I did the same exercise as from
http://www.homeandlearn.co.uk/NET/nets12p4.html
but did not help a lot.
thanks
|
|
|
|
|
Choose an easier task and do that first, buy a book and work through it.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: buy a book and work through it
Illegally download a book and work through that.
------------------------------------
"Children today are tyrants. They contradict their parents, gobble their food and tyrannize their teachers. I despair for the future."
Socrates 400BC
|
|
|
|