23 December 2008

Big day that started bad

Today was a really big day for me: I decided to start writing my master thesis!

Here's how the title goes:

Displacement of smooth integers in short intervals and their applications in cryptography.
Sounds great, doesn't it?

So. I found the papers with the stuff I needed to start and downloaded the LaTeX template. Didn't compile. Tried compiling a kinda "Hello, World!" document. Didn't compile. Switched computers. Didn't compile.

Started loading The Sims on one of the computers while fighting with MikTex 2.7 on the other one. The Sims would freeze while loading any lot. Started wondering really hard what was going on with the world.

The Sims were easier to fix. I downloaded Sims2Pack Clean Installer, that showed my add-ons by install date, with a red background if they were suspicious. I got them working after a few tries and build something like a dorm that was in fact an apartment lot. Some old guy moved to my so-called dorm, no girl did and the residents would stay in their bedrooms instead of enjoying the kitchen, study, tv room, swimming pool and other cool stuff I prepared for them. Still, doesn't beat the stupidity of the 51 NPCs that moved into that:

Fixing MikTex was harder. Actually, there was no fixing, but getting the 2.5 version from Daddy from two years ago and getting the required packages from some russian ftp server.

But, I wrote my name on the master thesis template, so I have officially started writing it today!

19 December 2008

Yet another programming language

I blogged about learning Java and C#, and here I am again, learning a new language again: Python.

They made me. At work. First, I was a bit mad: I'm learning Objective Caml at school, C# for the 70-536 exam, can my brain take much more?

But as soon as I tried it, I loved it for the easy syntax and operations on lists. It also supports supports multiple programming paradigms (primarily object oriented, imperative, and functional) - how cool is that?

Okay, so I started learning. First thing I did was, of course, "Hello, World!". Then, my new favourite way of learning programming languages - Project Euler! That was cool - doing something I love, learning and getting paid! Ain't I a lucky geek?

15 December 2008

Silverlight: my app is up!

Yeah, finally! The website I was working on this summer is up (and featured on silverlight.net)! In Polish only, but my boss said we'll get it translated. For now, you can check out the cool animated tree menu and the HTML ovelay iframe that adjusts its height to you browser window (provided that your browser window is tall and you reaload the app) at bcp.softax.pl.

Oh, and did I mention I got engaged? Mmm, yeah, I did.

14 December 2008

I'm engaged!

Great news people - I am engaged! Boyfriend proposed to me yesterday in our new apartment!

As a very professional blogger, I said that I needed a picture to post here, so Boyfriend took a few with the camera in his phone. If you use your imagination look really close, you can see the ring on my finger!

12 December 2008

What is that? The poor man's Wii?

Someone tell me what's going on...

On December the 10th, a new gaming console was released in Poland: the VMAX16. Take a look:

It has 7 sports games and controllers with movement sensors - doesn't it remind you of some other console?

It gets weirder, however: it costs 50(fifty) $! That's like an extra controller for the Wii!

And it gets even weirder: googling for articles in English about it doesn't get you anywhere. Searching for the manufacturer, Speed Link, does get you to the official site, but searching for "vmax 16" on that site returns void.

I'm really curious what that thing will turn out to be. My hope: competition for the Wii that will make it twice cheaper. Let's wait a bit for the reviews.

[Source, picture credit]

10 December 2008

Life geekified: gift paper

Christmas is coming, people need presents ideas, so it's the right moment for a few "Life geekified" posts. I'll start with the end: gift paper.

Geek gift paper... not the most common product around. Think Geek has some beautiful stuff:

Unfortunately, the most beautiful one, Equations, is sold out.

The only other option I came across is this Space Invaders paper from Whimsy:

So, there isn't much competition in his area. So, there are two things to do: produce some geek gift paper and get creative!

09 December 2008

Good news

Two good news tonight, people!

  1. Season 3 of The IT Crowd is good. Watch if you haven't started yet.
  2. You can win a 1000$ shopping spree at Think Geek, and the competition's not restricted to the U.S.!Add Image

Of course, I sold my soul for the tiny chance of getting all the geek stuff I want. Even my phone number! Don't ask what else I could throw in...

Flu Kitteh is in your haus

This is what I looked like these past few days (except for the hair and the soda). For that reason, I was doing what cats do best - laying in bed all day. Instead of blogging. Or studying for my exam, which I may postpone. Or buying Christmas gifts - which I might start regretting soon, as it's a bit late to order anything by mail, and it will be kinda late too to find something in the shops by the time I get good enough to go there. But, I did a bit of research and found a few things for my brothers and tons of stuff for myself. Well, that's an excellent start.

[Picture Source]

04 December 2008

Spend 20 months learning and earning

Yes, you can spend 20 months learning and getting paid! I just came across two serious offers that allow you to do that.

First, you can spend two months learning C/C++ in Samsung's R&D center. Starts on the 5th of January. Full offer here.

Then, you can spend 18 months in an administration school. Starts on the 2nd of March. Full offer here.

(See how the dates match? It must be destiny!)

The catch? It's 18 months of administration school and then you have to work there for five years or give the money back. But hey, isn't it great how many opportunities to learn and earn are there?

27 November 2008

I just registered for the 70-536 exam

Wish me luck, everyone! I'm taking the 70-536 exam (Microsoft .NET Framework - Application Development Foundation) on the 16th of December. So I have a bit less than three weeks to get ready. Maybe the fact that two colleagues from work are doing something isn't reason enough to do it, but I don't care - I'm doing it.

Okay, so how do I get prepared? Boss bought us the training kit:

It's a book with practice tests, so I'm reading it when I can and taking the tests. I really hope it will work. I'm a bit worried as I haven't heard the best opinions about it, but, well, we'll see.

My 6-months programming experience should help too, I recently learned how to use reflexions, for example. Basically, that's what the exam is supposed to measure: your level of experience.

26 November 2008

My new addiction: Project Euler

I've got a new dangerous addiction: Project Euler. It's a website with cool math problems, like:

Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.

These problems are quite easy to solve with a little piece of code, so it's great way of learning a new programming language. I try using that to learn ocaml for my functional programming class, but sometimes I forget about that and succumb to the tentation of writing a C# console application with great ease.

I have solved 12 problems out of 218 so far and when I start solving them, it's hard to stop! Yep, one more addiction...

24 November 2008

New IT Croud season!

Should have told ya guys on Friday but I forgot. Anyway, The IT Crowd 3x01 just aired, and it's good, so go and get it!

21 November 2008

I bought a new laptop!

I bought a new laptop! It's an MSI Wind U100, it's pink and it's as cute as that:

Didn't really have time to test it yet - all I can say is that WinXP SP2 Pro got installed in 12 minutes and boots instantly. Something more like a review should appear here within days.

It's pink! I'm so excited! This was a really spontanious buy: I got the idea of buying a lightweight laptop on Sunday, picked the model on Wednesday, bought it yesterday (Thursday)!

Did I mention it was pink?

[Picture source, source]

15 November 2008

There's a 65% chance that I'm a man

There's a 65% chance that I'm a man.. at least according to Gender Analyzer:

[Update]It was 70% a few days ago and 75% today!

13 November 2008

How much music can you buy in 3 days?

So I was saying I bought half a GB of mp3 recently. Well, there's more.

Two days later, I went shopping for a present for Boyfriend. I didn't get it, but I got 11 albums! Here's the list:

10 November 2008

Remember the world back in 1998?

Remember the world back in 1998? Yeah, that was whole decade ago...

I just watched a movie from these ancient times tonight, called "The inspectors":

There was a great scene when a child showed an inspector his computer with internet:

- Look, here we can search the internet. Give me a subject, any subject you like.
- Darts.
- Look, there are 138 webpages about darts.

Later, that inspector told the story to the other one and asked:
And you, have you ever surfed the internet?

Well, there are over two milion pages about darts today. But you know that very well, as you have already surfed the internet, haven't you?

[Picture credit]

09 November 2008

Silverlight: dynamically finding a storyboard in the VisualStateManager

Okay, I haven't been writing about Silverlight for quite a while, but here I am again!

Today, I'll discuss dynamically finding a storyboard in the VisualStateManager.

Basically, when you want to refer to some object, you set the x:name and there ya go. Here, things aren't half that simple.

In August/September, I used the following code, inspired by something posted on the official forums:

var query = from trans in
(from stateGroup in
where stateGroup.Name == "VisibleStates"
select stateGroup).First().Transitions
where (trans.To == "Visible" && trans.From == "Hidden")
select trans;

Storyboard sb = (Storyboard)query.First().Storyboard;
Ugly like an ugly workaround, but it worked in Silverlight 2 beta 2. But then Silverlight 2 came out and that didn't compile anymore.

I needed to recompile my code fast, so without thinking too much, I wrote a double foreach. Ugly too, but it worked.

And then, one beautiful morning, the SilverlightNews Twitter pointed me to an article just about that. "Great", I said to myself, "I'll see a the right way of doing that." I clicked and saw... a double foreach! I felt smart for a while, but I had a hard time believing that this way was the best. So I asked Boyfriend.

Boyfriend has a bad influence on me because he gives me way better answers than Google - and shouldn't people google instead of bothering others? This time was no different - Boyfriend wrote a single-line solution and posted it in a comment over there.

I decided to follow his advice and rewrite my code the same way. After sweat, tears and another Boyfriend bother, I got this:
Storyboard sb = VisualStateManager.
Where(sg => sg.Name == "VisibleStates").SingleOrDefault().\
Single(t => t.To == "Visible" && t.From == "Hidden").
No doubt it's single-line, no doubt it's shorter. Whether it's nicer, easier to write or more effective than a double foreach, we can discuss. I guess it's easy if you know Linq, which I don't. Wait, I do, I just wrote my first piece of it!

Best interface ever

Great picture, isn't it?

Doesn't it inspire you to make an interface like that?

I unfortunately don't know the source - tell me if you know anything.

[Update] Found! See here for pics of this great pic being made!

02 November 2008

Bought half a GB of music (again!)

I'm a happy geek with a great job and a brand new hard drive. What's to do in such a situation? Buy music!

Since I bought Amy Studt's album on 7digital I got very fond of this shop for its simplicity, wide range of avaliable music and affordable prices. So when I got this new drive I decided to fill it with some new music. So here's what I got back then:

Krystal Meyers - Make Some Noise

Make Some Noise

by Krystal Meyers

Vanessa Carlton - Be Not Nobody

Be Not Nobody

by Vanessa Carlton

Katy Rose - Because I Can

Because I Can

by Katy Rose

7digital indiestore - The Very Best of 7digital indiestore 2008

The Very Best of 7digital indiestore 2008

by 7digital indiestore

And here's what I got today:

Lucie Silvas - Breathe In

Breathe In

by Lucie Silvas

Nerina Pallot - Dear Frustrated Superstar

Dear Frustrated Superstar

by Nerina Pallot

Sandi Thom - Smile...It Confuses People

Smile...It Confuses People

by Sandi Thom

Natasha Bedingfield - Unwritten


by Natasha Bedingfield

Vanessa Carlton - Harmonium


by Vanessa Carlton

Plus a few singles.

All in all, I purchased 157 Tracks that take 1180Mb on the new drive.

01 November 2008

I swear I don't celebrate Halloween

I swear I don't celebrate Halloween. I just was at a party yesterday. And two years ago too. I don't remember about last year, however - does that mean I partied that hard?

Yesterday's party was at Long Unseen Friend's place and had nothing to do with Halloween: he was just back for a few days (he's an exchange student) and wanted to meet his friends. One guy had had his birthday a few days sooner and therefore receive a few gifts and a cake substitute. Besides that, the party consisted of people sitting on the floor, eating (Long Unseen Friend's Mom prepared lots of great food), drinking beer or juice and talking. Talking consisted of people talking about what they do best and others interrupting them with a "Will you stop talking about your master thesis? We're trying to have a party here!". Almost everyone had to be interrupted in such a way at least once.

No matter how much I appreciate people trying to have fun and forget about school, I kinda miss the times where we would play Set, or worse: the differentiable function (people sit in a circle and someone gives a function and n-th person gives its n-th derivative). Well, nothing lasts for ever, not even that great game, although it could if the starting function was smooth.

30 October 2008

Yet another math presentation

The geek life has been a bit harder lately. I spent an entire day and then an entire evening preparing a presentation about the Weil Pairing. Don't ask me what it is - I have been trying to understand it for two years! (Well, I have been trying other things as well during those years, but still, you get the idea.)

"Sweetie, I know you're busy, but I gotta ask you one thing: who's the long unseen friend from the previous post?" messaged me Boyfriend. The brief explanation of Long Unseen Friend being an ex of mine didn't really satisfy him, nor the fact that he missed our appointment and still I set a new one.

But let's not allow the boys to distract us from the Weil Pairing, because I have great news! After those two years, I have finally understood what the Weil Pairing is and how to evaluate it! There's a bad news too: I understood it fully during my presentation. I realized that the example I had picked was by far too simple and I still have a lot of work to do. But hey, I finally got it!

For those of you who speak Polish, know a bit of math and aren't easily scared (anyone still reading?), here are my slides:

29 October 2008

A lovely school day

Today was a totally lovely school day.

First I slept until nine. Ate breakfast watching "Lipstick Jungle", showered, read the daily portion of LifeHacker. Ran out of the house afraid to miss the train and had to wait ten minutes. You know, the usual.

School started for me at twelve with a geometry seminar. Just before, I had an "ooops, I forgot I had a blog again" moment and blogged. But back to the seminar, it was really good. The guy was well-prepared, had read a few different sources, understood the subject very well, published the notes... excellent work.

Then a break, during which I got a free coffee (with a mug) from Citibank. Grateful, I decided to honor them with my presence at a case study, which turned out to be a long talk about career opportunities that convinced me that I was already working at the right place, as they were looking for network people and not programmers. I also got a call from a long unseen friend and set up a meeting for tomorrow.

Next came a law class, where I was distracted by the thought of my coming-up presentation about the Weil Pairing. Whatever that is, the fact that I keep getting the n-th power of one instead of a root is highly disturbing. I'm still working on that now that I'm home - and that's how a typical geek day ends.

The video game industry sucks

I recently came across two things:

  1. an article in LA Times on how unfriendly to women, and people in general, the video game industry is
  2. a booklet by CD Project Red supposed to make people want to work in this industry.
Here are the scans of the first pages:

A picture says a thousand words, so I'll let these speak for themselves.

24 October 2008

The dilmena of updating Windows

Once again, I am confused by Windows. Where's the talking paperclip when you need him to share his wisdom with you?

Updating Windows has always been a tough decision. Once a friend updated Windows and then he could only have three explorer windows opened at the same time. Once a friend updated windows and then he had to recover his data with the help of a company specializing in burned drives. And of course, once you've updated, you'll be constantly nagged to reboot until you reboot.

While none of the above is pleasant, the alternative has just gotten unimaginably worse as a new vulnerability has seen the day:

On Microsoft Windows 2000, Windows XP, and Windows Server 2003 systems, an attacker could exploit this vulnerability without authentication to run arbitrary code.
See the Microsoft Security Bulletin for more details. And update your windows now. Or wait for arbitrary code to be executed on your computer. Or congratulate yourself having chosen a safer operating system.

16 October 2008

Time to set some goals

The good lazy days of holidays are over. School has started, it's just two days a week, but with three days of work, it's hard to catch me home. And it's at least imprudent for me to stay lazy. So it's time to get organized and set some goals.

First goal, of course, it to do all the required schoolwork. That's three exams, one lab and one master paper. School... I've done that ten times already.

Second, professional goals: get my salary up and get certificates. I got a raise recently, but my work speed is still very limited by the need of learning how to do something before actually doing it. Well, it's not like in this job you get to a point where you know everything, but you do get to a point where you know the given technology, you know the available tools, you know which to choose and all that kind of stuff I often have to ask my workmates or Boyfriend.

Third, a personal goal: get rid of as much stuff as possible. I will most probably be moving out next summer and I don't want my first adult flat to be as messy over-stuffed as my room is now. In our society, everyone owns too much stuff anyway. Lifehacker has a lot of advice about that and when I started reading it, I very quickly started watching more what I buy. I want to have control over everything that enters my personal space. I can't just leave a mess at my parent's place, so a lot of things have to go. So, this morning, two dozens of magazines are gone. I also got some ideas about some other stuff.

Things are going good, and I hope it stays that way.

09 October 2008

Preparing a math presentation with Zoho

I had to give a presentation yesterday. A math one. Filled with dirty little symbols, expressions, equations and geometrical figures.

I had done that quite a few times already, but this time, I wanted to try to make slides and see what tools are available out there.

I'm pretty sure there is a proper LaTeX template, but I wanted something more modern and colorful. I was thinking Google Docs, but they don't support any kind of math. There is however a better tool, Zoho, that does. Insert a whole paragraph of praising Zoho here.

Using LaTeX in Zoho is fast and easy: you click on "insert equation" and a little LaTeX editor shows up. Once your equation is ready, an image is inserted in your document. Image, but you can always right-click on it and edit it. All I can wish for is that those images were rendered a little faster.

Okay, I've been a little manipulative here. LaTeX works great, but only in Zoho Writer (the "Word") and not in Zoho Show, the presentation tool. At least officially. I did, however, manage to make a math presentation, not without issues, but I easily found workarounds:

  • First, prepare your whole presentation in Writer. You won't be able to edit much in Show.
  • To make a slide with math, pick a text slide. Put some text you might remove later, then paste your text with math. If it looks good, better not touch.
  • Do not use bullet lists, they don't work. Your text gets parsed and the equations disappear.
  • Sometimes a bug occurs: a slide stays on the screen and seems to overwrite all the others. Close the presentation and reopen it, it should work then.
I'd love to see LaTeX supported in Zoho Show soon, but still, I managed to prepare my presentation, so insert another paragraph of praising Zoho here.

Here's the result (in Polish):

04 October 2008

Hello Kitty releases "Hello World" album

Hell don't know my fury... Hello Kitty released an album called "Hello World" with a song called "Hello World" on it.

Why my fury? Because it was my idea! I released an album called "Programming tutorial" three years ago (in text mode) and it has a song called "Hello, World!" (just like any good programming tutorial should start).

Well, let's just say imitation is the sincerest form of flattery. But why, oh, why, Hello Kitty?

[Official site]

02 October 2008

Happy new year!

Academic year, that is.

School just started again. I am happily surprised to still see may friends here: many people have graduated, and those who have not only have a few classes so it's hard to meet them at school.

So I met a few good old friends. One lend me money when I lost my wallet (it turned out to be under my laptop) and I made his life better by enlightening him about the white-space css property. One friend gave me my beloved algebra notebook back and I lend her three calculus ones.

Friends are old, but classes are new: law, functional programming, geometry and again, my beloved number theory and cryptography. Next week, I'm having a presentation about the Minkowski addition.

School's cool, but since I started working, I prefer my job much more.

27 September 2008

Geek goes lazy

School starts on Wednesday. Or Thursday. (Anyone knows, by the way?) Anyway, I'm making the most of the last days of freedom, which, besides work, includes mainly this:

Yep, I'm playing the Sims with the newest expansion pack, Apartment Life. Here's a short review and a long review.

Oh, did I mention that I have a brand new hard drive? With a brand new Windows installation out-of-the-box annoying as can be. I got my documents, but my beautifully ordered inbox is gone. I had to google my own father's e-mail address today.

24 September 2008

Puppy peeing on laptop

I am so amazed by this recent entry on CuteOverload:

My train of thoughts:

  • The puppy is peeing on the laptop! And I complained when I spilled tea on my laptop.
  • The puppy is peeing on the laptop! And the owner is taking a picture?
  • The puppy is peeing on the laptop! And the laptop is working?
  • The puppy is peeing on the laptop! Do you realize how many P are in this sentence?

23 September 2008

New direction in programming

I had lots of fun learning Silverlight at work, but fun doesn't last forever. I finished the website and joined a big project in asp.net. It's not as easy as Silverlight was, but that's a great thing. Silverlight alone is not much more than a Flash replacement (a good one imho, but still), it's the .net framework that gives it its power.

So I'm not learning Java anymore. I finished the school assignements I had in Java and have no intention of going further in that direction (but let's wait for the semester to begin and see what school brings). I'm learning asp.net.

Does that mean my Silverlight blogging is over? I hope not, but now I will only have my free time for that. And if you know me or have read the colorful paragraph on the right, you know how little free time I have and how much stuff I try to fit in it. Still, I love Silverlight and will do my best.

19 September 2008

Sometimes it's better not to have goals in life.

Dear readers, as much as love motivating stuff (I mean stuff that motivates and not trying to motivate stuff), I will be demotivating you today.

I had a great vacation in Spain. Then I had a few exams at school. Then I went to work for a few days. Basically, I never had any free time to allocate during these days. So I started thinking it was time to set some goals in life, plan some activities for the free time, stuff like that.

I do have a few blurry goals, but I need to figure out the importance hierarchy first. These include blogging, writing about Silverlight, learning asp.net, meeting friends, sewing,... well, lots of random stuff.

And then my laptop crashed. Crashed big time - the hard drive is dammaged and is being low-level formatted at this moment and I'll see if I need to buy a new one. No documents lost, but the systems and applications all need to be reinstalled - that's like two days of work, plus one trying to recover the inconsistent ntfs.

Who likes to have three days wasted? Well, I'm really surprised how little I minded it when I found out. What can I say? I had no plans to cancel. Isn't it a good thing sometimes?

13 September 2008

What [not] to watch: The Hills

MTV just resumed airing "The Hills" for a fourth season and I just resumed school work. This perfect synchronisation lead me to giving the show a try while writing the networks assignment. (I had watched the previous seasons during previous study sessions.)

The show is about young women moving to L.A. to attend courses at the Fashion Institute and start their careers and it's made to look like a reality show. The realism is questionable, but as I'm not interested in those people's private lives, I don't care. (Quite the opposite actually: the more privacy they get to keep, the better for me.) Anyway, what I liked about the show was seeing what the girls did at work. One was a receptionist but two had an internship at Teen Vogue that included various tasks at various places and that was fun to watch.

But one day the girls moved on form Vogue and became stylists which I guess must be as boring as receptionist, judging by how much airtime it gets. So the plot revolves about the personal life. In the personal lives, someone has spread rumors about Lauren so she's not talking to Heidi nor Spencer who is not talking to Brody but Lauren is friends with Spencer's sister who talks to Spencer and at the same time Lauren moves in with her friends Audrina and Lo but Lo is bitchy to Audrina who becomes a bit estranged and when Lo apologies Audrina says they won't be friends - got it? So now and again someone talks to someone he mustn't and someone is offended and that's what is shown. The only quote that made sense to me came from the sister, who tries not to fight with anyone as she has nothing to do with any feud but always get involved against her will: "are we five?".

Well, let me just say, I prefer writing the networks assignment. It's not as much fun, but I least I get to feel that my intellect is appreciated, not insulted.

11 September 2008

LHC launches and girl suicides

If you haven't heard about the LHC launch yesterday, you've been living under a rock.

My family life is going crazy with Dad being on TV every hour. Of course, I'm excited and proud and stuff, but I can't avoid TV like I usually do and therefore I'm forced to watch living proofs of journalists' stupidity. Each time they interview a scientist I'm wondering when they are going to ask about the philosopher's stone and the time machine. All the suggestions of the LHC causing our world to collapse were starting to get boring... until this morning, when I learned a 16-year-old had committed suicide:

A teenage girl in central India killed herself on Wednesday after being traumatized by media reports that a "Big Bang" experiment in Europe could bring about the end of the world, her father said.
How cruel/stupid/I don't know what can these journalists be? Don't they feel the slightest bit of responsibility? Do they wonder about the impact of their words other than the number of viewers/readers?

Okay, enough ranting. There are also many good reports and articles out there, like
"How long would it take the LHC to defrost a pizza?".

06 September 2008

Most useful Silvelight techniques

I have the habit of taking extensive notes when I learn stuff so I know where to find stuff I've read and found interesting. This of course applies to Silverlight, so below are the most interesting Silverlight techniques I noted in the last month (except for the ones mentionned earlier). All or almost all of these came at some point from Silverlight Cream, so if you follow it carefully, you should know all of these already.

So here's how to...

Embed Silverlight in HTML

Navigate between XAML pages
I use HTML overlay instead. Well, "instead" isn't the right word as those different techniques suit different uses. Both are worth knowing anyway.

Make the file smaller

Go full Screen

From my experience, it doesn't work in Firefox.

Show a Splash Screen
(However, the author admits it doesn't always work.)

Resize the Silverlight Application
- two different techniques
I tested the second one and it works great.

So simple and my boss was impressed. Great article.

Create reusable animations
This article helped me when enormously when I was creating animations I had to modify at runtime (thought it's not exactly about it).

Access the HTML DOM from managed code
A must-know for HTML Overlay.

31 August 2008

Random linkage: Cats in Sinks

Here's a cat in a sink:

And another one:

And another one:

Like what you see? There are many many more at CatsInSinks.com.

27 August 2008

Silverlight and text-align:justify.

Silverlight has no such thing as text-align: justify! There is an explanation, but I'm not buying it, but I believe it will be soon fixed, as well as the right-to-left direction.

Okay, the future is bright, Silverlight is still beta, but I want text justified now. As I was saying, I am working on something more like a website than an application, and I chose HTML overlay to display more text. Still, there's one place where there are a few sentences about my company, that I'd prefer to keep in a stylish Silverlight control. Stylish like this:

Doesn't the bit of text just beg to be justified? It does to me and it's fortunately short so I can justify it by hand. So, here are a few tries, read on to learn about my adventures in text justifying or scroll down to the last one to see what finally worked.

First, I manually split the texblock into a few smaller ones, one for each line. Then I just assigned the the right width. Result below:

Well, the texblocks do have the required width, as you see on the framed one, but the text inside doesn't.

Second try: scaling them horizontally with a transformation. Take Blender, type the right thing (1.1) in the right box, like this:

And you get this:

So it's scaled. But: now it goes further on both sides. I just wanted to extend it to the right. We could now push it to the right too, but that would be a mess to find the right values for both transformations. There's a much easier way: move the origin point. It's by default at the center of the obeject, thus the RenderTransformOrigin="0.5,0.5". Setting it to "0,0" will move it to the left top corner. As we're not scaling vertically, we don't care about the top coordinate, so let's just put "0,0". Now all there is to do is find the right scale, I just binary searched between 1 and 1.1. The first line, for instance, got 1.03:

Here's the final result: six delightfully justified lines.
Phew, we're done. So that was a bit of work, but it was okay for such a short text. However, if the width of the frame was to change, I'd have to start all over! Split the textblock in lines again and scale each line again. If someone feels like it, you can try and write a piece of code that would do that programmatically. Yes, MS developers, I'm talking to you.