XAML

From: THERE IS NO GOD BUT (RENDLE)21 Jun 2009 07:35
To: ALL1 of 10
Working on a little personal project at the moment, and playing with WPF/XAML a bit more than I can at work. It's really rather good. I needed to create an animated timer, basically a circle with a line inside it that spins like a stopwatch hand. In any previous Windows GUI framework, that would have been a complete pain in the arse, involving GDI drawing and sin/cos tables. In XAML, it's half a dozen lines of declarative code, without any C# code-behind at all.
From: 99% of gargoyles look like (MR_BASTARD)22 Jun 2009 09:44
To: THERE IS NO GOD BUT (RENDLE) 2 of 10
That's because Bill Gates and Steve Ballmer love you so much and they just want to see you happy.
From: THERE IS NO GOD BUT (RENDLE)22 Jun 2009 10:27
To: 99% of gargoyles look like (MR_BASTARD) 3 of 10
That makes up for Steve Jobs hating me.
From: andy22 Jun 2009 12:15
To: THERE IS NO GOD BUT (RENDLE) 4 of 10
.....and the code is?
From: Manthorp22 Jun 2009 12:55
To: andy 5 of 10
quote:
.....and the code is?


It translates as: Jesus is Audrey Tatou's great grandad.
From: 99% of gargoyles look like (MR_BASTARD)22 Jun 2009 15:42
To: THERE IS NO GOD BUT (RENDLE) 6 of 10
He doesn't hate you, he just doesn't think you're funny. Besides, he has a lot going on at the moment.
From: Manthorp22 Jun 2009 19:06
To: THERE IS NO GOD BUT (RENDLE) 7 of 10
It was no reason to eat his liver though, with or without Fava Beans.
From: THERE IS NO GOD BUT (RENDLE)23 Jun 2009 06:49
To: andy 8 of 10
The code to draw the Timer is
XAML code:
<Grid Width="16" Height="16" Name="Grid" Margin="2">
  <Ellipse Stroke="#FF000000" StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeThickness="1.5" Fill="#44FFFFFF"/>
  <Path Stretch="Fill" Stroke="#FF000000" StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeThickness="2" Margin="6,3,6,6" Data="M48,24 L48,19.25" Name="Path">
    <Path.RenderTransform>
      <RotateTransform x:Name="Rotator" Angle="0" CenterX="1" CenterY="5"/>
    </Path.RenderTransform>
  </Path>
</Grid>
 


and the code to animate it is

XAML code:
<Storyboard>
  <DoubleAnimation Storyboard.TargetName="Rotator"
     Storyboard.TargetProperty="(RotateTransform.Angle)"
     From="0" To="360" Duration="0:0:4" RepeatBehavior="Forever"/>
</Storyboard>
 


OK, so a dozen lines. It's still a hell of a lot better than GDI.
From: Voltane23 Jun 2009 16:22
To: THERE IS NO GOD BUT (RENDLE) 9 of 10
It's still a hell of a lot better than GDI.


NOD Rules!!!!

< /End Derail>
From: THERE IS NO GOD BUT (RENDLE)24 Jun 2009 06:38
To: Voltane 10 of 10
Was that a C&C joke in my ever-so-serious coding thread? :{