Wednesday, August 31, 2005

Check out my Flickr photo page: http://www.flickr.com/photos/stevenrockarts/

Tons of pictures, Cec you will like this!

Wednesday, August 31, 2005 7:06:36 PM (GMT Standard Time, UTC+00:00)  #    Comments [3]  | 

I am not American but anyone American Should vote for Macgyver as the President in 2008. Think about it, he could fix the situation in Iraq by using just a paper clip, a rubber band, and the Moon's gravitational pull. Maybe we could get him to become a Canadian citizen and run in our next election.

Fun
Wednesday, August 31, 2005 5:57:53 PM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 

I have been sick the last couple of days. It is a weird type of sickness. I don't have a cold and I don't have a cough (well not a big one). I just have a really really sore throat. I had a lot of trouble talking yesterday although it did get better with a couple of doses of coffee and tea. The only problem with that was that I found I had trouble falling asleep.

I have been trying to figure out how I got sick. Maybe it was that incredibly long drive to and from Kelowna that wore me out or maybe it was taking care of a friend's pug named Twiggy who seemed to have energy 24 hours a day.

Of course now there is the dilemma of trying to find something to do during the day. The only thing on TV right now isthe US Open. I like Tennis, but 5, 6 hours of it gets boring. I ended up watching Pirates Of Silicon Valley which is kind of a movie/documentary of the history of Apple/Microsoft and Steve Jobs/Bill Gates. I recommend it to people who aren't really into computers so they can get an idea of why they are running Windows. I also watched The Brothers Grimm it wasn't as good as I thought it would be.

I think today maybe I will write up another tutorial on coding or continue working on an object model for a personal project I am doing. I would post pictures of our Kelowna trip but Catherine's camera broke right before we could get them off so those might be awhile.

Wednesday, August 31, 2005 5:47:28 PM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Tuesday, August 30, 2005

I had to laugh at this white paper on COBOL: http://www.thinkphp.de/XUL_Study_en.pdf

My favorite quote: "Cobol is still the most important program language in many areas of application development. The Gartner Group estimates a worldwide volume of 180 billion lines of Cobol code. Even in 2005, about 15 percent of all new applications, corresponding to about 5 billion lines of code, will be written in this stone-age language."

I think they are way off on judginging COBOL's success by using lines of code considering it takes about 180 billion lines of COBOL code to write 1 program. Can you really judge a programming language's success by how many lines of code it has in production?

I do think however, that a lot of people programming in the newer languages are pretty ignorant to how valuable a skill it is to be able to write both COBOL code and .NET or Java code.

Tuesday, August 30, 2005 9:06:59 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

Opening folders with C# is easy, sometimes you just want the path to the folder so you can read, write or access files but sometimes you want to open the folder for the user to see visually.

To open the Program Files folder for the user you would use the following code:

//Use the Environment.SpecialFolder.ProgramFiles

//to get the path to Program Files in case it

//isn't stored on the C: drive.

string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

//Get the Windows directory

string windir = Environment.GetEnvironmentVariable("WINDIR");

System.Diagnostics.Process prc = new System.Diagnostics.Process();

//Use the Windows Explorer to view the Program Files directory

prc.StartInfo.FileName = windir + @".exe";

prc.StartInfo.Arguments = path;

prc.Start();

 

A couple notes about the preceeding code:

Explorer.exe is located in the Windows directory which on my computer is located in C:\WINDOWS

The first line gets the path to the Program Files directory:

string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

The second line gets the Windows directory using the System Environment variable. You can look at where this is set

1. Go to the Desktop and right click on My Computer, go to properties.

2. Click the Advanced tab.

3. On the Advanced tab click on the Environment Variables button

4. It is located in the System Variables section:

 

Then using the System.Diagnostics.Process namespace the code creates a process to start Windows Explorer from the Windows directory and passes the path to Program Files as an argument:

System.Diagnostics.Process prc = new System.Diagnostics.Process();

//Use the Windows Explorer to view the Program Files directory

prc.StartInfo.FileName = windir + @".exe";

prc.StartInfo.Arguments = path;

prc.Start();

 

You can essentially replace the Program Files directory with any directory your computer to open up that directory.

Tuesday, August 30, 2005 8:24:07 PM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Thursday, August 25, 2005

While in Kelowna, Catherine and I saw a report on the "world's ugliest dog" well....here is his website: http://samugliestdog.com/ 

Even though he is ugly I still have a soft spot for him.

I will be posting on our trip when I get some spare time, which should be tonight. In the meantime enjoy the ugly dog.

Fun
Thursday, August 25, 2005 8:54:26 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Tuesday, August 16, 2005

The Internet Explorer Blog explains: http://blogs.msdn.com/ie/archive/2005/08/15/452006.aspx

Did you know that:

A URI consists of multiple components, each of which helps the browser and server to retrieve the requested file.

For example, given the URI http://search.msn.com/results.aspx?q=ie7#listings

  • The scheme component is http
  • The hostname component is search.msn.com
  • The path component is /results.aspx
  • The query component is q=ie7
  • The fragment component is listings

The following URIs are all equivalent:

  • http://www.example.com/sample/
  • http://www.EXAMPLE.com/sample/#
  • Http://www.ex%41mple.com/s%61mple/
  • http://www.example.com/sample/arbitrary/.%2e/
Tuesday, August 16, 2005 7:19:55 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Sunday, August 14, 2005

This weekend I was pretty procductive. Yesteday I spent the day working on my old truck and getting it running again. It turned out the battery was dead so I bought a new one and the old girl is running like a charm.

Now today, I may clean out the inside and wash the outside and get it ready to be sold. This was my first vehicle and it will be sad to sell it but it can't just sit around here forever! I will probably take a picture with it before I sell it.

You may have already noticed but I finally got around to upgrading my blog to Dasblog version 1.8. I guess the release candidate before this one had some problems so I waited a couple days until the gold release was out.

I also got a Super Nintendo emulator up and running on my Sony PSP. I love playing the same games I did when I was a kid, they were so simple and fun back then!

Sunday, August 14, 2005 8:05:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Thursday, August 11, 2005

Sorry about the bad picture but there was a passed out drunk guy in my usual picture taking spot.

Notice we have Heman working on our condo in the lower left corner so it's bound to turn out ok!

Thursday, August 11, 2005 4:25:42 AM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Tuesday, August 09, 2005

I am upgrading my blog from Dasblog 1.6 to 1.8 tonight so if you notice any weird occurrences please be patient. Thanks.

Tuesday, August 09, 2005 4:37:26 AM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Monday, August 08, 2005
Monday, August 08, 2005 5:40:13 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Friday, August 05, 2005

Introduction

If you read MSDN you will be hard pressed to find out how to bind a business object to a datagrid. I thought to make up for the lack of business object documentation; I would write a simple tutorial on how to bind an object to a datagrid.

First Create Your Class

First let’s create a normal class nothing fancy:

using System;

namespace Employee
{

 public class Employee
 {
  public Employee()
  {   
  }
  
  #region Employee Accessors
  
  private string _firstName;
  private string _lastName;
  private int _employeeNumber;
  
  public string FirstName
  {
   get
   {
    return _firstName;
   }
   set
   {
    _firstName = value;
   }
  }
  
  
  public string LastName
  {
   get
   {
    return _lastName;
   }
   set
   {
    _lastName = value;
   }
  }
  
public int EmployeeNumber
  {
   get
   {
    return _employeeNumber;
   }
   set
   {
    _employeeNumber = value;
   }
  }
  #endregion
 }
}

Create a collection of your Business Object

The MSDN documentation doesn't give you a concrete example of binding using a business object but they do say that a datagrid is able to bind to anything that implements the IList (single dimension arrays implement the IList interface), IListSource, or IBindingList interfaces.

Reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskbindingthedatagridcontroltoanadodataset.asp

So we will make a collection class of Employee objects that implement the IList interface:

using System;

using System.Collections;

namespace Employee

{

      public class EmployeeCollection : CollectionBase

      {

            public Employee this[int index]

            {

                  get

                  {

                        return (Employee)List[index];

                  }

                  set

                  {

                        List[index] = value;

                  }

            }

            public int Add(Employee value)

            {

              return (List.Add(value));

            }

            public int IndexOf(Employee value)

            {

              return (List.IndexOf(value));

            }

            public void Insert(int index, Employee value)

            {

              List.Insert(index, value);

            }

            public void Remove(Employee value)

            {

              List.Remove(value);

            }

            public bool Contains(Employee value)

            {

              return (List.Contains(value));

            }

      }

}

 

Binding to the Employee collection

 

Now you can use the collection and bind to the grid. Using a windows form, here is the code to add an employee to the grid and also to the employee collection:

 

private void btnAddToGrid_Click(object sender, System.EventArgs e)

{

                  Employee Employee = new Employee();

                  Employee.FirstName = txtFirstName.Text;

                  Employee.LastName = txtLastName.Text;

                  Employee.EmployeeNumber = Convert.ToInt32(txtEmployeeNumber.Text);

                  EmployeeCollection.Add(Employee);

                  //Bind to grid here.

                  dataGrid1.DataSource = EmployeeCollection;

                  CurrencyManager cm =

                        (CurrencyManager) this.dataGrid1.BindingContext[EmployeeCollection];

                  if (cm != null)

                  {

                        cm.Refresh();

                  }

            }

 

Here is the code to remove the employee object from the grid and also from the employee collection:

 

                        private void btnRemoveFromGrid_Click(object sender, System.EventArgs e)

            {                       EmployeeCollection.RemoveAt(dataGrid1.CurrentCell.RowNumber);

                  //Bind to grid here.

                  dataGrid1.DataSource = EmployeeCollection;

                  CurrencyManager cm =

                        (CurrencyManager) this.dataGrid1.BindingContext[EmployeeCollection];

                  if (cm != null)

                  {

                        cm.Refresh();

                  }

            }

A good article explaining the pros and cons of datasets can be found at:

http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/CustEntCls.asp

Also the book Expert C# Business Objects goes into more depth than my code example and is a great read.

http://www.lhotka.net

 

Friday, August 05, 2005 3:19:35 PM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Tuesday, August 02, 2005

I read this from the Make website today. Apparently by pressing the “close door” button and the button of the floor you want to go to, you can make certain elevators go into “express” mode where they will take you directly to your floor without any stops bypassing anyone else who may be waiting.

I am going to try this at work today and in any other elevator I get in. I won't really know if this works unless the elevator stops then I know it doesn't work. I love little secrets like this that not a lot of people are aware of.

Tuesday, August 02, 2005 6:13:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

Steve Yzerman signed a 1 year deal with the Wings!!! This means he will have at least 1 more year until he will retire. I will have to make sure I go to all the games when the Wings are in town.

Tuesday, August 02, 2005 6:01:40 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: