Ryan Dawson on Longhorn

The software we think, but do not write

February 2004 - Posts

  • Draw

    Filed under:

     

    Draw is an application that I created in one night as a demo for a design firm.  While, there is nothing in particular that I wanted to show with this application, I thought it would be useful to post the code for others.  If anything, this program is a reaffirmation that a program can look good and have functionality with a minimal time investment.

     

     

    Code can be found here

     

    Areas of interest:

     

    • Floating Toolbar can be dragged around the screen for preference placement

     

     

    • Guideline and control points on all shapes for resizing and reshaping
    • Reposition control anywhere on the design surface after they have been drawn
    • Draw infinite number of shapes with the highest z-order control taking immediate focus after being clicked
    • Right click will toggle between the selection tool (first tool on palette) and the current drawing tool (pen, rectangle, ellipse).  The selection tool allows one the resize and move a shape, while the other tools will create a new shape upon click.
    • Bezier Line

     

     

    • Rectangle

     

     

    • Ellipse

     

     

    PostTypeIcon
    2,883 Views
  • Indigo brightens Wallstreet Article

    Filed under:

     

    The article can be found here

     

     

    This article focuses on Indigo holistically, such that by the time beta rolls around, everyone will be ready for the next generation of communication.  That is not to say that it is not built around today’s communication architecture and the WS specs.  We will cover everything from the simple set-up of a service and a client to different types of messaging, and then dive into features like security and reliability.

     

     

     

    PostTypeIcon
    1,823 Views
  • Spell Checked Text Box

    Filed under:

     

     

    Source Code can be found here

     

    Spell Checking is an extremely helpful utility.  I have actually come to rely on it greatly, which in no way helps the problem (of me learning to spell the word correctly).  Anyway, there is no turning back, and I like to know that everything is spelled correctly.  It reflects poorly on a person when they have misspelled a word, anyone at that, easy or hard.

     

    I think every text input area should have some form of help.  Here are some common examples:

    • Intellisense – No one can, or should try to memorize the Framework Class Library.  But, I would be in trouble if I didn’t have something to help me find it quick.
    • Outlook email – When you start to type the person’s name, it will bring up a list of contacts that match the current text.  Then, you select the person you want, without having to type the whole thing, or trying to remember the email, since the name is more intuitive.
    • Spell Checking / Grammar Checking

     

    The list goes on, but the point is that it is easier on everyone if the text area is monitored and suggestions are made depending on the current text and the desired content.

     

     

     

    I am not going to cover the creation of a custom control, but if you want to know, just look at the code, which is in C#.  I will be covering the Natural Language classes provided by Longhorn, though.

     

     

    Starting Out

     

    There are 2 objects that one needs to process text (both of which are under the System.NaturalLanguageServices namespace and dll):

     

    1.      Context - Essentially the reference to the main engine, and analogous to the ItemContext in WinFS.  Here is what a Context initialization looks like:

     

                      Context context = new Context();

                      context.SpellingSuggestions = true;

                      context.ComputeLemmas = false;

                      context.CharacterNormalization = false;

                      context.NamedEntities = false;

                      context.WordNormalization = false;

                      context.Compounds = false;

                      context.SpellingAlwaysSuggest = true;

                      context.SpellingIgnoreAllUpperCase = true;

                      context.SpellingIgnoreWordsWithNumbers = true;

                      context.SpellingStrict = true;

       context.SpellingSuggestions = true;

     

    There are a number of properties which modify the engine, and allow for different usage scenarios.

    2.      TextChunk – The text collection and localization add-on to Context.  You need an instance of TextChunk for each language you intend to process.

     

                      TextChunk textChunk = new TextChunk(context);

    textChunk.Locale = textChunk.Locale = new System.Globalization.CultureInfo(1033);

     

    In case you didn’t know, 1033 is the integer constant that identifies English in the Unites States.

     

     

    Processing

     

    The brute of the code is very small.  Obviously there are more options, but in essence, it is not that hard of a concept to program against.  Here is what the processing looks like:

     

          textChunk.InputText = theTextToProcess;

     

          foreach (Sentence sentence in textChunk)

          {

                foreach (Token token in sentence)

                {

                      IList list = token.Suggestions;

     

                      if (list != null && list.Count > 0)

                      {

                            foreach (object o in list)

                            {

                                  // ...

                            }

                      }

                }

    }

     

               

    ·         First, we pass in the text we wanted processed (theTextToProcess).  So, we set the InputText of the TextChunk to theTextToProcess.

    ·         Iterate through every Sentence that the engine recognizes

    ·         Iterate through each Token in the Sentence (look at every word)

    ·         Get a list of the Suggestions for the word.  You will only get suggestions for misspelled words, obviously.  The dictionary is very up-to-date, and contains many acronyms, so be careful when thinking the engine is not working correctly (Because it is probably just a weird word.  For example, I was testing the word Fram at first, trying to act like I had misspelled From.  I fired up Microsoft Word to see if it the engine was correct, and to my surprise, Word said it was not a word.  So, then, I fired up Dictionary.com, which revealed that Fram is an acronym for ferroelectric random access memory.).

    ·         Each object in the list is a suggestion, so you can invoke the ToString() method to get the string representation.

     

    PostTypeIcon
    5,927 Views
  • WinFS does Customer Relations Management Article

    Filed under:

    In this sample, we will delve into the topic of WinFS.  We will be covering everything from Relationships, Contexts, Folders, and various schema objects such as Person, Document, Author, and Event.  Hopefully, this article will persuade the doubters who still remain that WinFS is here to stay.

     

    The Article can be found here

     

     

    PostTypeIcon
    1,840 Views