Posts

Normalize Until It Hurts

"Normalize until it hurts, denormalize until it works" I read that once about databases and thought it was a nice, pithy saying. I started trying to come up with similar statements about other areas of development. This is what I came up with.  Database Design -- "Normalize until it hurts, denormalize until it works" Programming -- "Write readable code" When you go to change a piece of code, the quicker you understand how it works, the quicker you can make your changes. Of course, your changes should leave the code in a readable state.  Working with Coworkers -- "Build Relationships" Dale Carnegie's "How To Win Friends And Influence People" is a good book and I recommend everyone read it. But I can summarize the contents in one sentence: "Genuinely care about other people."

My Nullable DateTime Picker

Image
I needed to bind a nullable DateTime to a Winforms DateTimePicker control. Unfortunately, the standard DateTimePicker only supports regular DateTime objects. I looked around and found some controls that other people had built, but none of them did exactly what I needed.  I wanted a control where, if the checkbox is unchecked, the value is considered null and the box is blanked out. I couldn’t find one like that, so I built my own. The first one I built was written in VB.Net. In this blog post, we'll create a C# version.  We start by creating a new class and having it inherit from DateTimePicker.  using System.Windows.Forms; namespace NullableSample { public class NullableDateTimePicker : DateTimePicker { } } Then add a nullable DateTime property to hold the binded value.  public class NullableDateTimePicker : DateTimePicker { public DateTime? BindedValue { get; set; } } In the constructor, we set the ShowCheckBox value to true bec...

Restoring Color Icons in Gimp 2.10

Image
When Gimp 2.10 was released, the new icons for the toolbox items were all black and white. If, like me, you'd like to go back to the color versions, here's how:  Select Edit --> Preferences From the Preferences dialog, under the Interface section, select Icon Theme For the icon theme, select Legacy if you want icons like they were in 2.8.  If you'd like color versions of the new icons, select the icon theme named  Color . 

VisualTreeChanged Error when Debugging VSIX

I just had an odd thing happen. I tried to debug a VSIX project in VS 2015. When I ran it, I got an error that said: Message: An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationCore.dll Additional information: The visual tree has been changed during a 'VisualTreeChanged' event. At first, I thought it might be related to the issue VS 2017 caused with VSIX projects . But this was a different error. After Googling, I discovered here that you could fix it by disabling Enable UI Debugging Tools for XAML. Tools --> Options --> Debugging --> General --> Uncheck Enable UI Debugging Tools for XAML.

VSIX Winforms Toolpane

Image
The other day I wanted to create a Visual Studio Toolpane window and I wanted to create it using Winforms (by default, the toolpanes use WPF). After much research, I got it to work. These are the steps I followed: I've tested these steps with Visual Studio 2015 & Visual Studio 2017. Create a new Extensibility project In Visual Studio, from the File menu, select New --> Project. In the New Project dialog, one the left, under Visual C# , select Extensibility . On the right, select VSIX Project . Give the project a name. In this example, I'm calling it MySampleVSIXProject Add a Visual Studio Package Right-click the project in Solution Explorer and select Add --> New Item In the Add New Item dialog, on the left, expand Extensibility and select VSPackage . On the right, select Custom Tool Window . Give the tool window a name. In this example, I'm calling it MySampleToolWindow.cs Add a W...

Visual Studio 2015 VSIX Project Stopped Working

Yesterday I opened up a VSIX project to add a new feature. This is a Visual Studio 2015 project that I hadn't worked on in a few months. It worked fine a few months ago, but now, all of the sudden, it wouldn't build. What's going on? The error message I was getting stated: "Cannot find wrapper assembly for type library "EnvDTE100". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component." After Googling, I found from this site that if you install Visual Studio 2017 on your machine, it will affect your references to the EnvDTE assemblies. I had recently installed VS 2017. Thankfully, the site also contained the solution: "In old VSIX projects: Remove old COM references to EnvDTE, EnvDTE80, EnvDTE90 and EnvDTE100. Add new references using Assemblies | Extensions tab and select EnvDTE, EnvDTE80, EnvDTE90, EnvDTE100. The project should build now." I updated ...

Deleting Files in Visual Studio/TFS Taking a Long Time

I needed to delete some files from source control and noticed that it was taking Visual Studio/TFS about 30 seconds to delete a file (move it to the delete pending list). Since I needed to delete a lot of files, you can imagine how annoying this was. So, I fired up good old Process Monitor and started watching devenv.exe. Then I went into Source Control explorer and deleted a file. Suddenly Process Monitor was full of folder accesses. Dozens of folders were being scanned. After some research, it turned out that when I deleted a file for some reason Visual Studio was looking through all the folders in the same workspace as the file. So, I created a new workspace and put my project and only that project in the workspace. Now when I try to delete a file it happens very quickly. Lesson learned.