downloads, vs, coderush comments edit

UPDATE: CR_JoinLines has found a new home with theDXCore Community Plugins project. Head over there to get the latest and read more!


I use TextPad for text editing and one of the things I like a lot about TextPad is the Ctrl+J shortcut that allows you to join selected lines to each other. Visual Studio doesn’t offer that line joining capability, so I decided to write it.

CR_JoinLines adds a command (“Join Lines”) that you can bind to a keyboard shortcut (Ctrl+J, Enter is what I use) and will join lines in the code editor. It also allows for an optional delimiter, so if you want a pipe or comma or some other string (yes, string - you’re not limited to a single character) inserted between the joined lines, you can do that.

CR_JoinLines in
action

Installation is as easy as copying a DLL into a folder and adding the keyboard shortcuts you want.

DXCore Shortcuts Menu - Click for larger
version

The included readme.txt outlines installation, usage, and workarounds for known issues.

Requires DXCore 1.1.58 or later (DXCore is a FREE download from Developer Express - go get it!). UPDATE: CR_JoinLines has found a new home with theDXCore Community Plugins project. Head over there to get the latest and read more!

Version History: 1.0.0.0830: First release. 1.1.0.1012: Added ability to provide Delimiter parameter to join lines with a delimiter between each joined line. 1.1.1.0307: Fixed issue where, in later versions of DXCore, joining on selection functioned incorrectly.

General Ramblings comments edit

Well, for all intents and purposes it’s done. I only have to make five more buttonholes (using the automatic buttonhole attachment on the sewing machine) and put on the buttons, so we’ll just call it done.

I spent probably eight hours on it Sunday, fighting with the various pieces to make them line up, adjusting things as needed to make them straight and compensate for my amateur sewing abilities. In the end, it turned out pretty well, and it fits, which is really what I was hoping for. I was gonna be pissed if it was too small or something.

I used McCall’s pattern M2447, a combination of views A and C so I could get the collar without the collar stays in it (so I can flip the collar up like Wonka without the stays falling out) and the French cuffs.

Let’s see if I can remember how much all this cost me…

Pattern: $6.50 Fabric: $16.00 Interfacing: $4.50 Buttons: $3.75 Collar stays I’m not going to use: $2.00 TOTAL: $32.75

And, of course, about 16 hours of my time. Suddenly that $50 shirt at the store isn’t looking so expensive.

I’m pretty pleased with it, though. Mom always said that when you’re done sewing something it should look just as good inside as it does outside, and I’d say I’m there with it - everything inside is nicely put together, the outside looks crisp and clean. Granted, the lines aren’t perfectly straight (pretty close, but if you look you’ll see flaws), the buttonholes aren’t perfectly spaced (making buttonholes is a pain in the ass), and there’s a spot on the front band toward the bottom where it sort of takes a slight… turn… so the bottom of the front isn’t perfectly straight. But that part gets tucked in anyway, so I’m not too bummed about that. All in all, not shabby.

Things I discovered during the making of the shirt:

The chair we have for sewing sucks. It’s one of those foldable “director” chairs with the canvas seat and back. Far from ergonomic. By the end of the day, my back and neck were killing me.

Shirts are a bitch. I made a Neo costume last year

  • a long black trenchcoat thing. It was a piece of cake compared to this shirt. There was a lot of hand-stitching and crap on this shirt, and a hell of a lot more pieces. Of course, the costume I had last year was a costume, not, like, an official piece of clothing, where this shirt is from a pattern where they actually intend you to wear it regularly, so it’s a much higher quality garment. Still, with the plackets and collar pieces and such… shirts are a bitch.

The worst part of the thing is cutting out and marking the pattern. It’s way, way, way too boring. I like it when you get to sewing the pieces together and it starts to take shape, but there’s a lot of prep work in there that I could just do without. (That’s not a new realization, but I thought I’d get it out there anyway.)

Next step is to get the Wonka walking stick going and start in on the vest. I’ll save the coat for last because I think it’s going to cost me a frickin’ arm and a leg with the velvety fabric I’m going to have to buy. It’s also going to be a total pain in the ass, I’m sure, because I actually bought a real trenchcoat pattern (lined and all) and it’s about an inch thick still in the envelope so I can only imagine how much work that’s going to be. Good thing I got started early.

UPDATE 10/02/05: The costume came out well. Here are the details.

General Ramblings comments edit

Redballs Red Wonka
CoatJust got word from Redballs - they’re going to have more of the red Wonka jackets in mid-September. Perfect! I’ll hang on until then (which is closer to my budgetary timeline anyway) and get the 2XL. That should save me hella time and money compared to making the thing.

UPDATE 10/02/05: The costume came out well. Here are the details.

General Ramblings comments edit

Each night I work a little more on my Wonka Halloween costume. Right now I’m trying to make his shirt, a red dress shirt with a blue paisley print (a pretty decent approximation of which I found at the fabric store) and… well, I ran into a bit of a snag last night working on it.

First, it took forever to cut out all the pieces. There are like 25 pieces to this thing.

Once I got that all done, I sewed the first bit together and started wondering why it didn’t look like the picture. Then I searched around and found that one of the pattern pieces had this random “cut on this line if this is the left piece, but don’t cut on it if it’s the right piece” crap on it. I didn’t see that discussed in the instructions. Argh!

Out came the seam ripper, removing all the work I had done. Cut along the line, then re-attached everything. Now it looks like the picture.

That was just the first seam. I have the whole rest of the shirt to go. This is going to be quite the project.

Stu found a good approximation of Wonka’s coat at the local Hot Topic. I went to check it out and tried on an XL. The arms were okay, but the width of the thing left something to be desired - I could barely raise my arms before the back started pulling. I emailed the company to see if they offer a 2XL. The arms might be a little long, but the rest would fit better. Plus, it might be a hell of a lot cheaper and easier than making my own.

I’ve also started working on the cane. I took the bottom of the finial that will serve as the handle and I have slowly started filling it with Shoe Goo to even it out (there are hollow spots in there that need to be solid so I have something to attach the pipe to). Once that’s set up, I’ll bond the pipe to the finial with more Shoe Goo (seems to be pretty good stuff, and it dries clear). I ordered a package of cane tips that fit a 1” diameter cane. The pipe is 1.05” in diameter, so I’m hoping I can fudge the tip on. If all else fails, I can sand down the area the tip needs to fit on until it fits - the pipe walls are pretty thick.

UPDATE 10/02/05: The costume came out well. Here are the details.

gists, csharp, net comments edit

While .NET provides the sorting of collections through things like Array.Sort and the IComparer interface, there’s no real generic ability to filter elements out of a collection based on arbitrary criteria.

dasBlog implements collection-specific filtering in the various strongly-typed collections by adding static methods to the collections that allow you to pass in a collection and a filter criteria delegate and have a new, filtered version of the collection returned to you.

I thought it might be handy to have a more generic version of that ability so you could filter any collection implementing the IList interface. It would allow you to have a single way to filter lists of any type - all you’d have to do is cast the resulting collection back to the type you originally passed in.

Here’s what I came up with:

using System;
using System.Collections;

namespace Paraesthesia.Collections {

  public delegate bool ListFilterCriteria(object obj);

  public sealed class ListFilter {

    private ListFilter(){}

    public static IList Filter(IList toFilter, ListFilterCriteria criteria){
      // Check parameters
      if(toFilter == null){
        throw new ArgumentNullException("toFilter", "The IList to filter must not be null.");
      }
      if(criteria == null){
        throw new ArgumentNullException("criteria", "The collection filter criteria must not be null.");
      }

      // Get the invocation list
      System.Delegate[] invocationList = criteria.GetInvocationList();
      if(invocationList.Length < 1){
        throw new ArgumentException("There must be at least one delegate in the invocation list of the filter criteria.", "criteria");
      }

      // Create the output collection
      IList filtered = null;
      try{
        // Get the input collection type
        Type inputType = toFilter.GetType();

        // Create the new object
        filtered = Activator.CreateInstance(inputType) as IList;
      }
      catch(Exception err){
        throw new NotSupportedException("Error occurred while creating new collection to contain filtered list.", err);
      }
      if(filtered == null){
        throw new NotSupportedException("Unable to create new collection to contain filtered list (constructor invocation returned null).");
      }

      // Perform the filtering
      foreach(object obj in toFilter){
        bool include = true;
        foreach(ListFilterCriteria individualCriteria in invocationList){
          include = include && individualCriteria(obj);
          if(!include){
            break;
          }
        }
        if(include){
          filtered.Add(obj);
        }
      }

      // Filtering complete; return the filtered collection
      return filtered;
    }
  }
}

The idea is that you create a method that takes in an object and returns a Boolean indicating if it should be included in the filtered collection or not. Then pass your collection through the filter with the criteria specified and a filtered version of the collection gets returned to you - cast it back to the appropriate type and continue on your merry way.

Your filter criteria might look like this:

using System;

namespace MyNamespace{
  public class MyCriteriaClass{
    public static bool FilterThreeChars(object obj){
      String toCheck = obj as String;
      if(toCheck == null){
        return false;
      }
      return toCheck.Length == 3;
    }
  }
}

Then your use of the filter might look like this:

using System;
using System.Collections.Specialized;
using Paraesthesia.Collections;

namespace MyNamespace{
  public class MyTestClass{
    public void TestTheFilter(){
      // Create the original collection
      StringCollection coll = new StringCollection();
      coll.Add("a");
      coll.Add("bc");
      coll.Add("def");
      coll.Add("ghij");
      coll.Add("klmno");

      // Set up the filter criteria delegate
      ListFilterCriteria criteria =
        new ListFilterCriteria(MyCriteriaClass.FilterThreeChars);

      // Filter the collection
      StringCollection filtered = ListFilter.Filter(coll, criteria) as StringCollection;

      // The filtered collection only contains "def"
    }
  }
}

I did some performance testing on this versus a similarly structured filtering service that is strongly-typed and the two were comparable. Your mileage may vary.

Note: Code is provided free, but also without support. If it breaks, doesn’t work, isn’t optimized to your liking, etc., feel free to fix it, but I’m not going to actively answer questions on it or help you figure out why it’s not working for you.