DCSIMG
July 2007 - Posts - Ariel's Remote Data Center

July 2007 - Posts

WPF, "The American Dream"

Posted Jul 23 2007, 12:42 AM by Ariel Ben Horesh  

You gotta love WPF, it's an amazing technology frightfully overwhelming but so overwhelming powerful as well.

You can create applications which are so elegant that it's make you wanna cry.

 Well, I guess all this opening is pretty nosense to you all, I didn't add anything new to you, even if you don't code with WPF (which most chances you don't, but that for another post), you could probably recite the same sentences word by word, Power to the media!.

So obviously I'm not going to tell you things you already know I just wrote down one of the lesser pieces of elegant code for WPF app, that I had to share it with you.

It's all started with a pretty reasonable scenario :

I have a parent custom control and a child custom control, each are doing important things at OnRender.

<Style x:Key="{x:Type local:MyDeck}" TargetType="{x:Type local:MyDeck}"> 
 
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type local:MyDeck}">
        <local:MyCard x:Name="myCard" Width="50" Height="50"/>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style> 
 

So you see? we have our parent MyDeck and the child MyCard.

Now, something in MyDeck is happening and it's need to render itself (for the novices, now it's time to remember that rendering doesn't occur all the time like in Winforms but just when it needed to be done).

So everything is good, and everybody's happy, right? WRONG.

What about MyCard?

If MyDeck got rendered isn't it implied that all his children need to be rerendered as well? apparently not.

"Interesting..." I tell myself, let's try to search for it, to my surprise what I thought to be a rather common scenario and something starters to WPF get themselves bumped into all the time, turn out to bring rather scarce output.

After I overcome my fear of being laughed upon for raising such a "noob" question I asked the legendary Tamir for help.

Tamir told me to try to call render manually.

Sounds pretty bad, such a common scenario and a solution which break down all kind sophisticated mechanisms build into WPF.

But after I found out no other solution I went down this road.

Brute Force? it is then. Let's use WPF's ramming device, walking trough the Visual Tree.

Let's consider the next code:

protected override void OnRender(DrawingContext drawingContext)
{ 
 
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(this); i++)
 
{
    DependencyObject visual = VisualTreeHelper.GetChild(this, i);
    if (visual is FrameworkElement)
    {
      FrameworkElement element = (FrameworkElement)visual;
      element.InvalidateVisual();
    }
}
 
...
 
...
 
}
 

Ain't pretty right? 

So what we are doing here is going on to all children and one by one telling them to render, mission accomplished, everything is Shiny now.

I don't know, disappointed a bit, does anybody knows better solutions to this problem? maybe something more elegant?

Ariel

P.S, I couldn't finish with such a dark mood, I gotto recommend you Snoop, which is a must have tool for all WPF writers out there! right along with Reflector.

Technorati Tags:
תגים:

Opening Post @ Agile - Israel

Posted Jul 22 2007, 11:35 PM by Ariel Ben Horesh  

I defiantly wanna be a part of Agile-Israel community.

So this is my first post who will be making it's way to AgileIsrael.

I'll probably be talking about TFS and Scrum and maybe add some knowledge to the human race public storage of data.

This one is short, next time, more interesting stuff.

Ariel

 

Technorati Tags:
תגים:

New Tidings

Posted Jul 16 2007, 11:43 PM by Ariel Ben Horesh  

Hello to all  fellow Citizens,

I will be using this short post to update you on some of my personal affairs.

First, today is my birthday, I'm feeling much older than yesterday, thank you very much for wondering.

The celebrate my special day I went paragliding with my girlfriend.

presta-violet-netanya

(Pictures will be published soon, although I've just found out that I accidentally forgot to reset the ISO so I took them with ISO400 and overcooked my pictures, damn).

Second, I am joining Sela as a consultant. So wish me another luck dragon (those who are still thinking "what the hell  I'm talking about" should read this, but only after you read all the prerequisites : Ender's Game and Ender's Shadow).

Third, Another month from now, I will be on a plane going on a "short" vacation to South America!

You are all welcome to my trip planner, and add suggestions and tips.

When you will be talking about silverlight 1.1 RC, I still be writing strange posts about Machu Picchu :).

Fourth, a shiny product I've been working on for a year now with my friend Benny, will soon be available to a very limited group of people for a early alpha testing.

We will soon have our back-end deployment site up and running.

Interested? stay tuned for more info later on.

C-YA

Ariel

P.S : I'm not working/writing posts on my birthday, how lame can one become? ssssigh, oh well... I'm. So what? :)

All we need is just a little patience...

Posted Jul 12 2007, 09:37 PM by Ariel Ben Horesh  

Prologue

I am using Vista, Yes I am, defying and ignoring all those saying "Wait till SP1" or "What's wrong with XP?" guys, I'm sure you all know those and can relate.

My main excuse was that I need to program WPF apps, and in vista it will look much better, oh well, whatever.

Anyway I was and still very open minded about each and every innovation, I think I'm one of a soon to be extinct group that uses UAC in its' default configuration, yes it bogs me to approve every rename I do, but I see the reasoning around this subject, and I feel safer to know that nobody renames files without my consent.

I am NOT a vista expert, I don't know all it's features, but I trust the maturity of vista to let me know when something that I am used to will not work the way I think it does.

Part 1

For the last few weeks I've been using SSCE which has the potential to become ass' kicking product in your arsenal.

Yesterday I needed to rewrite all my tables at my SSCE file (long story...), I made a copy of that file and erased to original.

Went to my Sql management studio and created a new sdf file in the same location of my previous files.

I don't know why, but somehow something went wrong and the file was created not in the right place. The management studio gave no warning and I unaware went straight to the fun part of rebuilding my tables.

I rebuilt my first table and wanted to check it, happy I went to my VS, and started looking for my new file....

hmm.... not where I expected it to be, funny.

Silly me, I went back to management studio, and started playing hide and seek with that file, where are you? I asked my dear friend mr.studio?

the answer is here right under my nose:

damnVista

Well of course ,  c:\windows\system32... what the hell. never mind...

Start->Run->c:\windows\system32

start pressing H franticly, "found you... you can come out now..."  nothing... I must be more fatigued than I realize, Was it c:\windows\system ???

Strange, going to back to management, let's try to reconnect...

damnVista2

well it WORKS, haa, Start->Run->C:\Windows\system32\HumanClientDb.sdf->Enter

Message opening: "Windows cannot find 'C:\Windows\system32\HumanClientDb.sdf'. Make sure you typed the name correctly, and then try again." I'm starting to lose my balance here, I'm a "uber programmer" can't find a damn file?!

One of the coolest features in vista is new build in index based search, let's give it a try... surprisingly still nothing. 

OK, OK you win I'll go do something else...

Part 2

New day, new energies, new threats,  I'll find you you little *** and will gut you, Yes I will.

Your honor I call "ProcessMontior", do your magic. And finally.... (building tension...)

damnVista3

Shiny, I fount it, residing in... what the hell? VirtualStore?

Epilogue

Well Vista guys, Microsoft Evangelists, it will be very nice, I think that next time please let me know, a hint, a clue, small feature in Explorer something!!!!

Funny, A tune just popped out from my memory and I began to whistle it.

...little patience, mm yeah, ooh yeah,
Need a little patience, yeah
Just a little patience, yeah
Some more pati... (ence, yeah)
I've been walking these streets at night
Just trying to get it right (Need some patience, yeah)
It's hard to see with so many around
You know I don't like being stuck in a crowd (Could use some patience, yeah)
And the streets don't change but maybe the name
I ain't got time for the game
'Cause I need you (Patience, yeah)
Yeah, yeah well I need you
Oh, I need you (Take some patience)
Whoa, I need you (Just a little patience is all we need)
Ooh, this ti- me....

The End.

Till next time, Adios.

Ariel

A new race!

Posted Jul 02 2007, 04:48 PM by Ariel Ben Horesh  

Everybody, meet Blubber Bot, a new intelligent life form, or an Alav. (Autonomous Light Air Vessels)

It looks like a big balloon with light bulbs, but it's promises are allot more:

  • They can fly around responding to lights, sounds and cellphones.
  • They communicate one with each other, resembling a flock like behavior.
  • And... they can sing! whale like singing.

544919941_e0152d9119

Well, I find it awesome, and it's only 100$

Anybody wanna chip in?

Ariel

More Links :

http://www.alavs.com/index.html

http://store.makezine.com/ProductDetails.asp?ProductCode=MKBLIMPKIT

Technorati Tags: ,
תגים: