It's A Programmer's Life
A guide to what's happening in the life of this budding programmer...
Friday, December 23, 2011
Sims 3 possibilities
This morning I had half a mind to create a Sims family based on my own after reading this post on The Sims 3 forum. In the past I've always given my "me" Sim a Painting-related Lifetime Wish, even though I'm not the most Artistic person in real life. The Artistic trait has always been a standard trait for every single Sim I've created. Early on, my Sim's Lifetime Wish was to be a Celebrated 5-Star Chef. So do I make my Sim a martial artist, artist, nectar-maker or photographer?
Friday, December 16, 2011
My week with a dodgy knee
It seems that I now have a fortnightly quota of accidents to fill... Last month, I rolled my ankle (which I brought on myself - my nose was buried in my iPad at the time). And last week my left knee met the pavement - and came off second best. For the best part of the week, I was trying to not move my knee too much and largely confined to the house.
To more positive news, one of my closest friends will be getting married tomorrow. I can't wait to see what her dress will look like. It will be the first time I've been to a Western-style wedding - I've already experienced enough traditional Vietnamese ones.
To more positive news, one of my closest friends will be getting married tomorrow. I can't wait to see what her dress will look like. It will be the first time I've been to a Western-style wedding - I've already experienced enough traditional Vietnamese ones.
Friday, December 09, 2011
Procastination or Creative Block?
There are a few things that I've been meaning to do: make a case for my journal and get back into journalling, crochet, drawing, sewing, etc. Things I've been meaning to do but just haven't been bothered with... yet. Every time I want to start a new project in one of these categories, it usually ends up as either "it's already been done" or "I'm too chicken to try it". Cue the angry bunny.
Cateogries:
Creative things
Sunday, November 27, 2011
Countdown Timer
A while back I posted some pictures of a WPF countdown timer that was inspired by the DevDays countdown timer. After noticing how many times my WPF countdown timer cropped up in Google searches, I decided to post a tutorial on how I made it.
For the purposes of this tutorial, I'll be using Visual Studio.
Creating the Project
First things first, we need to create a new project. So go to File > New > Project and from Visual C# > Windows, select the WPF Application. Name it CountdownTimer and click OK.
Adding the controls
Set the height and width of the form to 540 and 450 respectively. Create 5 RowDefitions each with a height of 100. Your code and design views should look something like the following:
The first control we're going to add is a label which is going to display what we're counting down to. So, add a Label to the form with the following properties (Blogger won't let me paste the code directly):
Styling the Controls
Now that the controls are all in place, we're going to add some styling to them. Click the "Add New Item" icon and choose the ResourceDictionary from the WPF category. Keep the default filename of Dictionary1.xaml. In order for the styles to be used in the form, we need to attach the ResourceDictionary. Add a ResourceDictionary reference to the window's resources. It should look like the following:
We're going to create a Style for a round label. In Dictionary1.xaml, add the following code:
What this does is set the shape of the label to be an ellipse with a cornflower blue background and a black border. To draw the content of the label, we use a ContentPresenter. You can see here that I've set the font as "Courier New" and the font size as 50 (px).
Now that we have the style for the round label, we need to attach it to the timer labels with the following line of code:
Style="{StaticResource ResourceKey=baseRoundLabel}"
Do this for lblDaysTimer, lblHoursTimer, lblMinutesTimer and lblSecondsTimer. Once you're done, your window code should look something like this:
For lblDaysTag, lblHoursTag, lblMinutesTag and lblSecondsTag create the following style in the resource dictionary:
and attach it to those labels in the same fashion. By now, your code would look like this:
I've also tidied up some of the other labels.
The Code Behind
To access the form's Loaded event, double-click anywhere on the form's frame. Declare the following global variables:
In the Window_Loaded event, add the following code:
It might be tidier to just set the days, hours, minutes and seconds directly to their respective labels instead of via integers, but then we wouldn't be able to do this next bit...
If the days, hours, minutes, and seconds are equal to zero, the timer stops. Otherwise, the timer continues to to tick.
For the purposes of this tutorial, I'll be using Visual Studio.
Creating the Project
First things first, we need to create a new project. So go to File > New > Project and from Visual C# > Windows, select the WPF Application. Name it CountdownTimer and click OK.
Adding the controls
Set the height and width of the form to 540 and 450 respectively. Create 5 RowDefitions each with a height of 100. Your code and design views should look something like the following:
The first control we're going to add is a label which is going to display what we're counting down to. So, add a Label to the form with the following properties (Blogger won't let me paste the code directly):
- Content: [name of the event]
- Grid.Row="0"
- FontFamily = "Courier New"
- FontSize="28"
- VerticalContentAlignment="Center"
- HorizontalAlignment="Center"
Styling the Controls
Now that the controls are all in place, we're going to add some styling to them. Click the "Add New Item" icon and choose the ResourceDictionary from the WPF category. Keep the default filename of Dictionary1.xaml. In order for the styles to be used in the form, we need to attach the ResourceDictionary. Add a ResourceDictionary reference to the window's resources. It should look like the following:
We're going to create a Style for a round label. In Dictionary1.xaml, add the following code:
What this does is set the shape of the label to be an ellipse with a cornflower blue background and a black border. To draw the content of the label, we use a ContentPresenter. You can see here that I've set the font as "Courier New" and the font size as 50 (px).
Now that we have the style for the round label, we need to attach it to the timer labels with the following line of code:
Style="{StaticResource ResourceKey=baseRoundLabel}"
Do this for lblDaysTimer, lblHoursTimer, lblMinutesTimer and lblSecondsTimer. Once you're done, your window code should look something like this:
For lblDaysTag, lblHoursTag, lblMinutesTag and lblSecondsTag create the following style in the resource dictionary:
and attach it to those labels in the same fashion. By now, your code would look like this:
I've also tidied up some of the other labels.
The Code Behind
To access the form's Loaded event, double-click anywhere on the form's frame. Declare the following global variables:
private static DateTime date;
private TimeSpan daysTilEvent;
private int days, hours, minutes, seconds;
private DispatcherTimer timer;
date is the DateTime object which will hold the date of the event we're counting down to. daysTilEvent holds the difference between the current date and time and the date and time of the event.private TimeSpan daysTilEvent;
private int days, hours, minutes, seconds;
private DispatcherTimer timer;
In the Window_Loaded event, add the following code:
It might be tidier to just set the days, hours, minutes and seconds directly to their respective labels instead of via integers, but then we wouldn't be able to do this next bit...
Monday, November 21, 2011
Balancing old with new
In between studying for Extreme Programming tomorrow (reflective extended response Q&A) and thinking up new programming projects, I came across a couple of interesting articles by Michael Hyatt.
The links are here if you want to check them out yourself:
Before I brought my iPad, I used to take a notebook everywhere with me. Even on short trips to the local shopping centre. If I saw a nice looking sketchbook at the art store, I'd get it - even though my current sketchbook might still have several pages left.
In the first couple of months after buying my iPad, I used to take it everywhere with me. As with my iPod Touch, I was prolifically downloading app in the first couple of weeks.
At this point in time, the "shininess" of the iPad has worn off and it doesn't seem like the cool gadget it was when I first got it. It's starting to feel more like a useful tool, like a necessity of sorts. I miss my old sketchbooks: I miss using them as a repository for my ideas. At the same time, I'm equally concerned about the durability of sketchbooks - mine get dog-eared quite easily.
As to what I use the iPad for these days, its mostly internet browsing on the go, music, YouTube, casual gaming and task management.
The links are here if you want to check them out yourself:
- Using a traditional paper notebook with Evernote
- Three questions you should ask before buying an iPad 2
- Recovering the lost art of notetaking
Before I brought my iPad, I used to take a notebook everywhere with me. Even on short trips to the local shopping centre. If I saw a nice looking sketchbook at the art store, I'd get it - even though my current sketchbook might still have several pages left.
In the first couple of months after buying my iPad, I used to take it everywhere with me. As with my iPod Touch, I was prolifically downloading app in the first couple of weeks.
At this point in time, the "shininess" of the iPad has worn off and it doesn't seem like the cool gadget it was when I first got it. It's starting to feel more like a useful tool, like a necessity of sorts. I miss my old sketchbooks: I miss using them as a repository for my ideas. At the same time, I'm equally concerned about the durability of sketchbooks - mine get dog-eared quite easily.
As to what I use the iPad for these days, its mostly internet browsing on the go, music, YouTube, casual gaming and task management.
Cateogries:
Creative things,
Daily life,
iPad
Sunday, November 20, 2011
Culinary Experiments: Crumbed Chicken Strips
Made these chicken strips for lunch today. I marinated the chicken yesterday - nothing too fancy, just some garlic, salt and pepper. I remember reading somewhere that slicing across the grain of meat is supposed to make it more tender or something like that. The breadcrumbs I got from Coles. In hindsight, I probably should have gotten a brand other than White Wings or made my own breadcrumbs.
Cateogries:
food
Monday, November 07, 2011
More Android apps
Now that I'm a sleep away from handing in my Mobile Applications Development assignment, I'm looking for more project ideas. I want to try doing apps that haven't been done yet or, if there are similar ones out there, haven't been done well. Previously, I was looking through the Android Market app reviews and picking out those that were rated 3 stars or less and seeing what the users thought could be done better.
I found a couple of things that I wanted to try in an Android Community forum post. In the past I've just put together a series of controls and not really done anything to make them look prettier. This time around, I need to try and put as much effort into the aesthetics as the back-end code.
I found a couple of things that I wanted to try in an Android Community forum post. In the past I've just put together a series of controls and not really done anything to make them look prettier. This time around, I need to try and put as much effort into the aesthetics as the back-end code.
Cateogries:
Android,
Creative things,
Mobile Applications Development
Subscribe to:
Posts (Atom)