Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

September, 2008

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Fun With Colors

    • 0 Comments

    I’m in the middle of a deep review of some curriculum for developing web pages. (This curriculum was talked about in a previous post.) It’s really good stuff and I think a lot of teachers will find it valuable. During the course of this review I came upon the discussion of colors and how they are represented in web pages. Colors are defined using a mix of red, green and blue specified as a hexadecimal number. These values go from 0 to ff (or 0 to 255 for you decimal people.)

    There are lots of tools on the web and elsewhere that let people pick colors and then supply the hex value they need of course. If you work with web pages on a regular basis you probably even have a favorite. But as a programming geek I decided it would be fun to write my own. Yes, there are people for whom writing a little code while everyone else is watching TV is our idea of fun and relaxing. So I came up with this:

    colorbox

    I like sliders. :-) The user moves the sliders to get the color they want (the code sets the background of a picture box in this case) and the hex value is placed in a text box. I used a text box because it is easy to do a copy and paste from text boxes. The key code looks like:

    ColorBox.BackColor =  Color.FromArgb( iRed,iGreen,iBlue);
    txtHex.Text = iRed.ToString("X2")  + iGreen.ToString("X2")  + iBlue.ToString("X2");

    Yes, that is in C# just to remind Clint that I do use it now and again. Interestingly enough when I made my Visual Basic .NET version I was able to copy/paste much of the code from the C# into the VB. Or course I had to delete all those semi-colons afterwards. In any case it is very nice that the ToString method lets the programmer request that integers be displayed as hexadecimal values. I was toying with the idea of writing a function to do that but a) I like the idea of using built in facilities and b) that is something I might leave for students in an assignment just because I am evil. :-)

    A little side trick that shows the amazing coolness of Visual Studio and .NET, I opened up two copies of Visual Studio with the C# project in one of them. In the second I created a new Visual Basic Windows application project. Then I did a copy of all the objects on the form in the C# project and pasted them into the form of the VB project. Then I just added code. Again some copy paste, removed the semi-colons but with different syntax and stuff for specifying form level variables and functions/sub routines. I also did not have to explicitly initialize the form level variables because Visual Basic does that on its own. I’ll probably do it to make the program more self documenting though. That’s just good practice.

    Hum, I wonder if I should set the color of the words above the slider based only on the value of that particular slider? Not sure how that would look. Left as an exercise for the reader perhaps?

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    NATIONAL MIDDLE SCHOOL SUSTAINABILITY CHALLENGE

    • 0 Comments

    Something for middle school science classes perhaps:

    The Siemens Foundation, Discovery Education and the National Science Teachers Association (NSTA) have partnered on this unprecedented initiative to educate, empower and engage students, teachers and communities to become “Agents of Change” in improving their community. Student teams from sixth through eighth grade, under the mentorship of a teacher or adult supervisor, can register for the Siemens We Can Change the World Challenge at www.wecanchange.com.

    One of the challenges with getting students involved with competitions is the question of does it really fit with the curriculum. From all appearances the partnership that includes the National Science Teachers Association and Discovery Education has worked pretty hard to align this program with national standards. And yes, there are prizes too

    Top prizes will include a chance to appear on Discovery Network's Planet Green, a share in thousands of dollars in cash prizes, a one-in-a-lifetime Discovery Adventure trip and more.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Online Programming Contest for Canadian Students

    • 0 Comments

    The DWITE programming competition for Canadian high school students is ramping up again for the year.

    From their About page:

    The primary purpose of the DWITE Online Computer Programming Contest is to provide an avenue for Canadian secondary school students to practice for more recognized programming contests like CCC and ECOO.

    This is a series of five online events over the course of the school year. One of the great things about it from my point of view is that they allow a wide variety of programming languages. C, C++, Java, both Visual Basic 6 and Visual Basic .NET, PASCAL and even more. Yes, Turing (used a lot more in Canada than in the US) is on the list as well. So if you are in Canada and are a high school student, teach high school students or know high school students you may want to know more about this. Check out their web site here.

Page 3 of 8 (22 items) 12345»