I often run into situations where I’d like to undo all the work I’ve done in a file. Some applications refer to this as Revert-to-saved. Visual Studio 2005 does not seem to have a function to do this. So, I’ve written a couple macros to do this.
The first, RevertToSaved simply calls Undo until it can’t undo anymore. This is much faster than holding the Ctrl-Z key down, and keeps your undo buffer.
While DTE.ActiveDocument.Undo() = True
The second, RevertToSaved2, is a little more brute force–it simply closes the current project item and reopens it, attempting to return to the same cursor location.
Dim projectItem As EnvDTE.ProjectItem = DTE.ActiveDocument.ProjectItem
If Not projectItem Is Nothing Then
Dim activeLine As Integer = DTE.ActiveDocument.Selection.ActivePoint.Line
Dim lineCharOffset As Integer = DTE.ActiveDocument.Selection.ActivePoint.LineCharOffset
Dim window As EnvDTE.Window = projectItem.Open()
If Not window Is Nothing Then
Raymond Chen blogged recently about a disclaimers for a particular prize and it got me thinking about how inane some of these disclaimers are or how inane the circumstances are.
Some disclaimers make sense and should be there: “professional driver on closed course” and “don’t try this at home”. Some examples of the inane disclaimers or circumstances:
“Simulated Image” So, you’re expecting us to accept that your product is so poor that a simulated image on your product (TV, cell phone, etc) in the commercial was necessary?
“Results not typical” Really, you’re bending the truth and concentrating only on the positive superlative results? And people buy into it…
Email disclaimers. There are a special breed of stupid. For example: “This e-mail is intended for the addressee shown. It contains information that is confidential and protected from disclosure. Any review, dissemination or use of this transmission or its contents by persons or unauthorized employees of the intended organisations is strictly prohibited.” If that were truly the case, why did you essentially broadcast the email across the Internet? Do you really think that makes the company devoid of any responsibility? Some of these disclaimers are actually larger than the real content. It would be interesting to see what proportion Internet bandwidth is a result of disclaimers (not including SPAM bandwidth…).
I’ve got a Windows 2000 Server running Routing and Remote Access with the NAT functionality to route my Internet connection through a computer running a firewall, etc.
This works well, I can share my Internet amongst my local network while offering a bit more security.
The problem is, Routing and Remote Access often gets confused and can’t perform DNS lookups and therefore blows Internet connection sharing out of the water. This seems to occur if the radio/modem loses power.
Until recently, the only way I found that rectified the problem (sometimes) is by rebooting the server. As you might understand, this is a real pain. But, recently I happened across a series of actions that seems to get Routing and Remote Access back up and running. I can managed to fix the connection sharing if I perform the following steps in the exact order:
- Stop the Routing and Remote Access service.
- Release the the IP address assigned to the NIC connected to the ISP and used with NAT.
- Renew the IP address of above NIC.
- Start the Routing and Remote Access service.
This turns out to be more reliable than rebooting the server. There’s been a couple of times I’ve had to reboot twice.
Please correct me if there’s a better way or post if this problem doesn’t exist in later version of Windows Server (I don’t have the resources to upgrade at the moment).
I post here for posterity, my own reference, and anyone else you happens to find it.
keywords: Reset NAT RRAS DNS remoteaccess ipconfig net stop start release renew
Abhinaba Basu made a recent post
on his blog regarding a brilliant pipe utility for use in the Command Prompt. Clip.exe
, from various Windows Resource Kits allows you to pipe data (as text) to the clipboard!
I was throwing together some demo code that involved creating a control at runtime, that I wanted docked in a certain way on the parent Form. I could have pre-created the control in the designer and hidden it–to be made visible instead of creating it–but, that’s not the situation I was in. Simply creating the control and setting the Dock property (in this case to DockStyle.Fill) isn’t enough to dock it properly if there are any existing docked controls.
If you’ve ever created a control and runtime and attempted to change the Dock property, you’ve probably noticed it doesn’t dock the way you want. Control docking depends on order of the control in the Controls collection of the parent Form. If you have a Form with a control whose Dock property is DockStyle.top, and you create a new control and set it’s dock to DockStyle.Fill, it fills to the entire form client area, not the the area left over by the other docked controls.
In order to create a control and add it to the form with Dock set to DockStyle.Fill you need to push it to the top of the Controls collection. This can be accomplished with the SetChildIndex() method on the Collections property. For example:
PictureBox pictureBox = new PictureBox();
pictureBox.Image = pictureBox.ErrorImage;
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox.Dock = DockStyle.Fill;
// the magic line:
Technorati Tags: WinForms
On 1-jul-06 I was awarded MVP Visual Development – C#. Microsoft has been so kind as to offer blog space here on msmvps.com; and, I’ve been looking for a better blog, so I’ll be moving my blog here.
I should be a little more prolific with by blog from here on in.
Welcome to my new blog.