Temporary Modification in a Control During Drag and Drop
-
There are a some rectangular controls on a winform on which a dragdrop can happen. When an item (which has a numeric value) is dragged over any of these controls, the control should show possible result by changing its shape (Increase area by numeric value). This should be temporary. In case i move the item it out of the control without dropping, this change should revert back. Only in case the drop is done, the change should be permanent. Now, this effect can be achieved using DragEnter and DragLeave. Currently, I am making the modification to the Control two times by adding the changes and removing the changes. What I want to know now is whether it is possible to save the state of control so that it can be reverted back to the old state. In reality, the changes are complicated than just adding area into the shape. But the concept remains same. Control needs to change temporarily and a simple method to restore its state needs to be achieved. Is it possible?
-
There are a some rectangular controls on a winform on which a dragdrop can happen. When an item (which has a numeric value) is dragged over any of these controls, the control should show possible result by changing its shape (Increase area by numeric value). This should be temporary. In case i move the item it out of the control without dropping, this change should revert back. Only in case the drop is done, the change should be permanent. Now, this effect can be achieved using DragEnter and DragLeave. Currently, I am making the modification to the Control two times by adding the changes and removing the changes. What I want to know now is whether it is possible to save the state of control so that it can be reverted back to the old state. In reality, the changes are complicated than just adding area into the shape. But the concept remains same. Control needs to change temporarily and a simple method to restore its state needs to be achieved. Is it possible?
Hi, I would derive new Control types that do this, so make a ReshapableButton inheriting from Button, etc. And give them a boolean Reshaped property. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
-
Hi, I would derive new Control types that do this, so make a ReshapableButton inheriting from Button, etc. And give them a boolean Reshaped property. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
OK. This is already there. Whenever there is a DragLeave event, the control checks if it was reshaped and then it draws itself once again after making changes back. My question is how to save the details of control during DragEnter which can be easily resumed at DragLeave. Serialization could be one solution. However implementing that within a class to handle itself, seems a bit tricky. Forms cannot be serialized easily. So, basically I need a control that can save its state by serializing itself. When needed, it resumes from the serialized data. The fact that the control is on UI thread and it has to be a self managed code makes it tricky. I just need a clue how to implement this.