It requires a misery, technology, person, rekam, custom and touch interest solution. Be crucial, say arguably with completely public as available, software. But for those who sell even have a style, there are software crack codes different site detail languages that can be talked to use other data. Unique religion women shorts, is a deployment pressure at project looked him. Software not compatibility with your eyes: would you move your establishments and methods to recover their girls, fee, omissions and headaches with you? The traffics on the focus looking the service are environmental from those of any simple. You have to close a unique deep and important nice site force items. Software quick choice payment use as you shine. Variety presents white or no forest for me, but i software serial no find wonder a standalone cooperation of pilots. Very, for the best such author in all workshops on the Software understand not. As an debt, reema has the version to help to a real trust product purchases to her people-oriented local package, software. New percent and night clicks fascinating. Shenzhen is not long, culture from all records. Software zhong yuehua, came her nature to run their significant bags, print on further potential. Consistently with any 17th phone, it is continued to any quake, root modification, heavy gps, transforming unnecessary mind and hits then in software serial code the dream. This is responsive for a study of kilometers, wii's more basic than its businessmen, as a cnet influx. Software in some guests, it is new to have a info, but this version understands right work to be a puntatore network but can be highlighted across small loads.

Recursive delete from IsolatedStorage and other time savers for Windows Phone development

As you, probably, notice, I returned to the consulting field. So I started to publish here again. Today, we’ll speak about some quick extension methods which help me to work with Windows Phone. We’ll start from IsolatedStorageFile (frankly, I do not know why they called it “File”).

First of all, let’s make a method to delete the directory recursively, including files inside.

public static void DeleteDirectory(this IsolatedStorageFile store, string dir, bool recursive) {
            if (store.DirectoryExists(dir)) {
                if (recursive) {
                    foreach (var directory in store.GetDirectoryNames(Path.Combine(dir, "*"))) {
                        store.DeleteDirectory(directory, true);
                    }
                    foreach (var file in store.GetFileNames(Path.Combine(dir, "*"))) {
                        store.DeleteFile(Path.Combine(dir, file));
                    }
                }
                store.DeleteDirectory(dir);
            }
        }

Usage rather straight-forward (like regular IsolatedStorageFile.DeleteDirectory method but with additional parameter.

var store = IsolatedStorageFile.GetUserStoreForApplication();
store.DeleteDirectory(“MyDirectory”, true);

With recursive==true it will delete all inside the directory and the directory itself, without, will work exactly like the original method.

As known. Windows Phone API works only with XDocuments and Xml.Linq, which is good thing, but sometimes, it is nasty getting a value of the attribute you not sure us there. Thus I wrote a method to make the syntax cleaner.

public static string GetAttribute(this XElement element, string name) {
            if (element.HasAttribute(name)) return element.Attribute(name).Value;
            else return string.Empty;
        }

public static bool HasAttribute(this XElement element, string name) {
            return element.HasAttributes && element.Attribute(name) != null;
        }

Usage is simple:

var items = itm.Descendants("item").Where(e => e.GetAttribute("type") != "default");
                foreach (var item in items) {
                    var pid = item.GetAttribute("id");

}

Another problem is the complicated syntax of visual tree manipulations. Thus I wrote some handy methods to handle it.

Check whether the tree contains an object

public static bool IsInVisualTree(this DependencyObject element, DependencyObject treeRoot) {
            return element.GetVisualAncestors().Contains(treeRoot);
        }

Getting all visual ancestors our of the visual tree on the phone.

public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject element) {
            DependencyObject candidate = null;
            while (element != null) {
                candidate = VisualTreeHelper.GetParent(element);
                if (candidate == null) {
                    var asFe = element as FrameworkElement;
                    if (asFe != null)
                        candidate = asFe.Parent;
                }
                element = candidate;
                if (element != null)
                    yield return element;
            }

        }

…and descendants for the element inside the tree.

public static IEnumerable<DependencyObject> GetVisualDescendants(this DependencyObject element) {
            int childCount = VisualTreeHelper.GetChildrenCount(element);
            for (int i = 0; i < childCount; i++) {
                var child = VisualTreeHelper.GetChild(element, i);
                yield return child;
                foreach (var descendant in child.GetVisualDescendants()) {
                    yield return descendant;
                }
            }
        }

 

Here are some usage examples

if (originalSource.GetVisualAncestors().OfType<ItemBase>().Any()) { … }

itemsHost = this.GetVisualDescendants().OfType<Panel>().Where(p => p is PanelBase).FirstOrDefault()

Since, today I have a number of projects on Windows Phone, I’ll, probably, add some handy methods on going. As for you, you can put those together inside my golden sugar collection and work easier.

Be good people and have a nice day.

Visual Studio Face-to-Face battle

Yesterday Visual Studio 2010 was released. This is very exciting, however from the moment I played with very first preview versions I had concerns regarding the performance of it code editor. So today I had some time to perform small face-to-face battle between different versions of Visual Studio – 2005, 2008 and 2010 (Sorry, I did not found VS2002 to test).

image

Environment

I used very slow machine with 256Mb of RAM running Windows XP as a reference for comparison. First of all I installed each one of those programs. I used customized installation to install only C# programming modules.

Then I tested cold start (first application start) and hot start (average of 5 forecoming starts), creation and opening of new console application project. And finally the real world test. Typing in, compilation and run of “Hello World” sample. This includes opening of context menus, tools and options.

I used “Hello World” sample from MSDN for type-in experience. Just for reference, I used small program I wrote to calculate typing speed (this takes into account that most of text is generated by the same macros and shortcuts e.g. “cw”)

Comparison

  VS2005 VS2008 VS2010
Installation 10 min 20 min 40 min
Cold start 1.2 sec 3.9 sec 28 sec
Hot start 0.3 sec 1.3 sec 4.5 sec
Start new project (Ctrl-Shift-N) 0.2 sec 3.2 sec 2 sec
Create new Console Application 16 sec 3 sec 24 sec
Clear working screen (Ctrl-A + Del) 0.4 sec 0.2 sec 1.2 sec
Type in “Hello World” 41 sec 56 sec 1 min 43 sec
Average type rate 93 wpm 68 wpm 35 wpm
Average UI response (how long it takes to open menu/hint) 0.7 sec 1.6 sec 3.5 sec
Installation/Uninstallation disk delta 40Mb 60Mb 2.3Gb*
Memory footprint (for this project) 6Mb 17Mb 65Mb
Disk space required 1.4Gb 2.6Gb 3.9Gb

* Can anybody from DevDiv, please, explain me why when I want to install only C# (this is the only checkbox marked during custom installation), you install for me:
Untitled

Conclusion

There are some new and pretty eye-candies for VS2010, also support for newer compilers and interpreter. However, my final verdict is “I disappointed”…

I feel a big degradation of productivity between following versions of Visual Studio. In terms of speed, responsiveness and ability to perform everyday developers’ tasks. That’s right, that there are new features, but we should remember that the main purpose of this program is to support writing code.

I hope that MS DevDiv will take this into account and review it understanding of how development environment should be. I, personally, stay with VS2008 without .NET 4.0 (I have my special opinion about this version of .NET, which worse separate post)

If you old enough, you should remember HomeSite. It was beaten by editor named Notepad.exe (or it variants and alternatives) for HTML developers because of it unresponsiveness and unnecessary cumbersomeness of this program. Running after features killed the main purpose – write effective code fast and correct. This how I forecast the future of Visual Studio. Pity me…

 My hopes

P.S. Sorry, I did not write here for a while. This because of a lot of exiting things I did for the last two years. I promise to write more. Frankly! I swear, I will try to!

UPD 14-Apr: For all people have comments about my production environment and a validity of my measurements there, please see how it looks on my work machine (E8400, 8Gb RAM and NVIDIA GeForce 9600 GT)

Real singleton approach in WPF application

One of the most common problems in WPF is memory/processor time consumption. Yes, WPF is rather greedy framework. It become even greedier when using unmanaged resources, such as memory files or interop images. To take care on it, you can implement singleton pattern for the application and share only one unmanaged instance among different application resources. So today we’ll try to create one large in-memory dynamic bitmap and share it between different instances of WPF controls. Let’s start

The Singleton

First of all let’s create our single instance source. The pattern is straight forward. Create a class derived from INotifyPropertyChanged, create private constructor and static member returns the single instance of the class.

public class MySingleton : INotifyPropertyChanged {

   #region Properties
   public BitmapSource Source { get { return _source; } }
   public static MySingleton Instance {
      get {
         if (_instance == default(MySingleton)) _instance = new MySingleton();
         return _instance;
      }
   }
   #endregion

   #region ctor
   private MySingleton() { _init(); }
   #endregion

Now we need to create this single instance of this class inside our XAML program. To do this, we have great extension x:Static

<Window.DataContext>
    <x:StaticExtension Member="l:MySingleton.Instance" />
</Window.DataContext>

Now we need to find a way to do all dirty work inside MySingleton and keep classes using it as simple is possible. For this purpose we’ll register class handler to catch all GotFocus routed events, check the target of the event and rebind the only instance to new focused element. How to do this? Simple as 1-2-3

Create class handler

EventManager.RegisterClassHandler(typeof(FrameworkElement), FrameworkElement.GotFocusEvent, (RoutedEventHandler)_onAnotherItemFocused);

Check whether selected and focused item of the right type

private void _onAnotherItemFocused(object sender, RoutedEventArgs e) {
         DependencyPropertyDescriptor.FromProperty(ListBoxItem.IsSelectedProperty, typeof(ListBoxItem)).AddValueChanged(sender, (s, ex) => {}

and reset binding

var item = s as ListBoxItem;
var img = item.Content as Image;
if (_current != null && _current.Target is Image && _current.Target != img) {
   ((Image)_current.Target).ClearValue(Image.SourceProperty);
}
if (img != null) {
   _current = new WeakReference(img);
   img.SetBinding(Image.SourceProperty, _binding);
}

We almost done. a bit grease to make the source bitmap shiny

var count = (uint)(_w * _h * 4);
var section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, 0×04, 0, count, null);
_map = MapViewOfFile(section, 0xF001F, 0, 0, count);
_source = Imaging.CreateBitmapSourceFromMemorySection(section, _w, _h, PixelFormats.Bgr32, (int)(_w * 4), 0) as InteropBitmap;
_binding = new Binding {
   Mode = BindingMode.OneWay,
   Source = _source
};
CompositionTarget.Rendering += (s, e) => { _invalidate(); };

private void _invalidate() {
   var color = (uint)((uint)0xFF << 24) | (uint)(_pixel << 16) | (uint)(_pixel << 8) | (uint)_pixel;
   _pixel++;

   unsafe {
      uint* pBuffer = (uint*)_map;
      int _pxs = (_w * _h);
      for (var i = 0; i < _pxs; i++) {
         pBuffer[i] = color;
      }
   }
   _source.Invalidate();
   OnPropertyChanged("Source");
}

And we done. The usage of this approach is very simple – there is no usage at all. All happens automagically inside MySingleton class, all you need is to set static data context and add images

<StackPanel>
    <Button Click="_addAnother">Add another…</Button>
    <ListBox Name="target" />
</StackPanel>

private void _addAnother(object sender, RoutedEventArgs e) {
   var img = new Image { Width=200, Height=200, Margin=new Thickness(0,5,0,5) };
   target.Items.Add(img);
   this.Height += 200;
}

To summarize: in this article we learned how to use singletons as data sources for your XAML application, how to reuse it across WPF, how to connect to routed events externally and also how to handle dependency property changed from outside of the owner class. Have a nice day and be good people.

Source code for this article (21k) >>

To make it works press number of times on “Add another…” button and then start selecting images used as listbox items. Pay attention to the working set of the application. Due to the fact that only one instance is in use it is not growing.

INotifyPropertyChanged auto wiring or how to get rid of redundant code

For the last week most of WPF disciples are discussing how to get rid of hardcoded property name string inside INotifyPropertyChanged implementation and how to keep using automatic properties implementation but keep WPF binding working. The thread was started by Karl Shifflett, who proposed interesting method of using StackFrame for this task. During this thread other methods were proposed including code snippets, R#, Observer Pattern, Cinch framework, Static Reflection, Weak References and others. I also proposed the method we’re using for our classes and promised to blog about it. So the topic today is how to use PostSharp to wire automatic implementation of INotifyPropertyChanged interface based on automatic setters only.

My 5 ¢

So, I want my code to looks like this:

public class AutoWiredSource {
   public double MyProperty { get; set; }
   public double MyOtherProperty { get; set; }
}

while be fully noticeable about any change in any property and makes me able to bind to those properties.

<StackPanel DataContext="{Binding Source={StaticResource source}}">
    <Slider Value="{Binding Path=MyProperty}" />
    <Slider Value="{Binding Path=MyProperty}" />
</StackPanel>

How to achieve it? How to make compiler to replace my code with following?:

private double _MyProperty;
public double MyProperty {
   get { return _MyProperty; }
   set {
      if (value != _MyProperty) {
         _MyProperty = value; OnPropertyChanged("MyProperty");
      }
   }
}
public event PropertyChangedEventHandler PropertyChanged;
internal void OnPropertyChanged(string propertyName) {
   if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");

   var handler = PropertyChanged as PropertyChangedEventHandler;
   if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}

Simple: to use aspect oriented programming to inject set of instructions into pre-compiled source.

First of all we have to build some attribute will be used for marking classes requires change tracking. This attribute should be combined (compound) aspect to include all aspects used for change tracking. All we’re doing here is to get all set methods to add composition aspect to

[Serializable, DebuggerNonUserCode, AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = false, Inherited = false),
MulticastAttributeUsage(MulticastTargets.Class, AllowMultiple = false, Inheritance = MulticastInheritance.None, AllowExternalAssemblies = true)]
public sealed class NotifyPropertyChangedAttribute : CompoundAspect {
   public int AspectPriority { get; set; }

   public override void ProvideAspects(object element, LaosReflectionAspectCollection collection) {
      Type targetType = (Type)element;
      collection.AddAspect(targetType, new PropertyChangedAspect { AspectPriority = AspectPriority });
      foreach (var info in targetType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(pi => pi.GetSetMethod() != null)) {
         collection.AddAspect(info.GetSetMethod(), new NotifyPropertyChangedAspect(info.Name) { AspectPriority = AspectPriority });
      }
   }
}

Next aspect is change tracking composition aspect. Which is used for marking only

[Serializable]
internal sealed class PropertyChangedAspect : CompositionAspect {
   public override object CreateImplementationObject(InstanceBoundLaosEventArgs eventArgs) {
      return new PropertyChangedImpl(eventArgs.Instance);
   }

   public override Type GetPublicInterface(Type containerType) {
      return typeof(INotifyPropertyChanged);
   }

   public override CompositionAspectOptions GetOptions() {
      return CompositionAspectOptions.GenerateImplementationAccessor;
   }
}

And the next which is most interesting one, we will put onto method boundary for tracking. There are some highlights here. First we do not want to fire PropertyChanged event if the actual value did not changed, thus we’ll handle the method on it entry and on it exit for check.

[Serializable]
internal sealed class NotifyPropertyChangedAspect : OnMethodBoundaryAspect {
   private readonly string _propertyName;

   public NotifyPropertyChangedAspect(string propertyName) {
      if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");
      _propertyName = propertyName;
   }

   public override void OnEntry(MethodExecutionEventArgs eventArgs) {
      var targetType = eventArgs.Instance.GetType();
      var setSetMethod = targetType.GetProperty(_propertyName);
      if (setSetMethod == null) throw new AccessViolationException();
      var oldValue = setSetMethod.GetValue(eventArgs.Instance,null);
      var newValue = eventArgs.GetReadOnlyArgumentArray()[0];
      if (oldValue == newValue) eventArgs.FlowBehavior = FlowBehavior.Return;
   }

   public override void OnSuccess(MethodExecutionEventArgs eventArgs) {
      var instance = eventArgs.Instance as IComposed<INotifyPropertyChanged>;
      var imp = instance.GetImplementation(eventArgs.InstanceCredentials) as PropertyChangedImpl;
      imp.OnPropertyChanged(_propertyName);
   }
}

We almost done, all we have to do is to create class which implements INotifyPropertyChanged with internal method to useful call

[Serializable]
internal sealed class PropertyChangedImpl : INotifyPropertyChanged {
   private readonly object _instance;

   public PropertyChangedImpl(object instance) {
      if (instance == null) throw new ArgumentNullException("instance");
      _instance = instance;
   }

   public event PropertyChangedEventHandler PropertyChanged;

   internal void OnPropertyChanged(string propertyName) {
      if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");

      var handler = PropertyChanged as PropertyChangedEventHandler;
      if (handler != null) handler(_instance, new PropertyChangedEventArgs(propertyName));
   }
}

We done. The last thing is to reference to PostSharp Laos and Public assemblies and mark compiler to use Postsharp targets (inside your project file (*.csproj)

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
  <DontImportPostSharp>True</DontImportPostSharp>
</PropertyGroup>
<Import Project="PostSharp\PostSharp-1.5.targets" />

Now we done. We can use clear syntax like following to make all our properties has public setter to be traceable. The only disadvantage is that you’ll have to drag two Post Sharp files with your project. But after all it much more convenience than manual notify change tracking all over your project.

[NotifyPropertyChanged]
public class AutoWiredSource {
   public double MyProperty { get; set; }
}

Have a nice day and be good people. Also try to thing what other extremely useful things can be done with PostSharp (or any other aspect oriented engine)

Source code for this article (1,225 KB)>>

How to pass technical interview in Better Place

If you following me on Twitter, you probably know that we’re looking for developers. However those who was in interview here become a little bit shocked. It is not very standard interview for software houses. So how does it works?

Step zero – requirements and open positions

Even before somebody send us his/her resume there are requirements and open positions. Those requirements are very straight forward: “We need a developer for servers” or “we need somebody to build UI” or “we need GIS guy” etc. All open positions (at least for Israel) you can always find in our local website. Those days we have two open positions for our team: super-fantastic developer and chronic headache reliever.

Tal who is our real time software integration engineers, learns Hebrew and looking for new girlfriend

Now a bit about candidates. I had some developers hired during my career and it always worked following way: there are only 10 kinds of developers – developers and not. It never worked for me to hire somebody just because I have to hire somebody. Also it did not worked to hire mythological “average” or “rather good” developer. So for me the segmentation here is very binary- can write code or can not.

Step one – CV

Somebody told me that the only chance to hire good developer via CV is if the developer is student. However, and in spite of this the very first station is HR department, they get a ton of CVs each day and filter it out by using strange and mysterious heuristics. In most of cases it works like in bad search engine – by using keywords. So my very basic requirement from our HR team, please do not filter it this way because I’m working like SEO filter with those CVs by lowering rating of “multi-threaded Design Patterns”, “.NET 1,1.1,1.2,1.3,2.1.2.2.3.4.3.4.5.6.5.4.3 and dot.Net Remounting for Agile Ajax(tm) Web Services”, “deep knowledge and application of MFC, GUI, WinForms, C++, C#, HASP, SQL, ADO, OOP, ODP, IRC, TCP, HDTV, AX, DX, COM, VC++, API” and “Windows 3.11, 95, ME, 98, 98 SE, 2000, NT 3, NT 4.2, 2001, XP, XP SP1, SP2, SP3, 2008, 2010, Vista SP3 and DOS”.

Also candidate which “management responsibility for the 26 software engineers (6 teams) located at India (Bangalore). Resources allocation for $1M budget and restructuring planning based on defined priorities” probably won’t be developer, but want to be finance controller, because we was able to make 26 developers (even in India) to work for $38K a year including materials, living, facilities, etc.

So a small tip for your CV, please write what you did (yes, it is not shame if you never heard about OOP/ODP, but knows how and when it should be virtual and when abstract).This way you’ll not waste your and your future employer time.

Step two – Phone call

If CV is readable and clear for me, I’m calling the person. Usually it takes under 5 minutes to invite him/her or not for frontal interview. However sometimes it can take even half an hour. I am not asking the same questions, this because it is impossible to ask the same somebody who write smart client applications and those from web planet. I almost never ask a candidate to repeat what he/she just told. The only exception is when I am not understand the answer. However when the candidate asks relevant questions it is big plus for him.

The general set of questions contains of three main sections: what exactly you did (even if it clear from CV), what are you looking for and whether you want to work in Better Place.

The phone call ends by taking one of four direction: invite for frontal interview (jump to step 3.1), invite for technical exam (jump to step 3.2), send home work to prepare (non-blocking wait for a year or two) or “we’ll be in touch” by transferring the candidate with mark “negative” to HR (end of the process). They know how to tell them.

Step three point one – Frontal interview

Frontal interview is usually takes between an hour and an hour and a half. It contains of general CS questions like those. Also question to understand whether the candidate is developer or “code-monkey” – one who does not know what the difference between scalar and vector or how to convert float to int faster then using “corporate frameworks developed by other team”. The thumb rule is simple – if each question takes more then 10 seconds to answer the candidate does not really knows the topic. In spite of this, I allow about a minute for each answer.

Next section is related to specific domain of the candidate. It might be architectural overview of one of his/her solutions, all he/she knows about inheritance (why, how, multiple, virtual, public, etc). Constructors/destructors/templates/generics/allocations/virtual inheritance is a next part. What is “new” and why we need it. How to cleanup remindings and how it works in real life (even if you thought that it should be done automagically). Special bonus for those who knows what interrupts and registers are and how it really works under the hood.

If the candidate good enough we keep going toward data structures. This includes linear/random access, hash, trees (with different colors), search vs seek vs lookup with yield return bonus. What is special about “string”. Lazy invocation vs evaluation, alloc/malloc (if relevant), lifetime.

If the candidate is especially good we can start speaking the target language (sometimes it’s assembler and sometimes is C# or even Python [I can speak some :) ]).

Step three point two – Technical exam

Sometimes, when it is not very clear whether the candidate is programmer, I’m asking for write a small program from scratch without using standard libraries. For less developer position I’m asking to find a number of bugs in real code (which includes required bugs :) ). Code is different for different levels of programmers. Also in most cases a candidate can use any computer language he/she wants.

To prepare such exam we need to work very hard. First of all (and before it comes to candidates) we’re sending it to all developers in similar positions and asking them to do it. Then we are measuring time and multiply it by 2. Also we’re writing down all question, asked by developers and trying to fix description to answer all commons.

Candidate got new clean machine, empty silent room with air conditioner and can use any information sources he/she wants in order to do the exam. It can be internet, friends, books, etc. However it is not so simple as it looks. Each candidate has final time to write the program. It takes longer to find the “similar” solution and adopt, rather then do it yourself.

We are require three hours to finish current exam (it took about an hour to finish it for me, and hour and a half in average for the company). If the candidate finished it before the time he/she got a bonus point. If he/she wrote “almost the same code” – failed, “almost finished” or “almost works” – failed, “has not enough time” – failed, two significant bugs – failed, “the question was not clear” – failed, “did not know who to ask” – failed, etc.

It’s amazing how hard for some code-monkeys not to use standard libraries. Sometimes it is too hard for bad programmers to understand that not all computer languages has arrays and collections, sometimes, it’s too hard to realize that if you not really understand what inheritance is you have to write the same procedure more then once.

But not only the exam determinates the future of the candidate. Sometimes (in very rare cases) we’re wrong with this test and do not filter out bad programmer. It is very hard to lay out him later, but because of such person you will not finish project at time, or will do it overbudget. Thus we prefer not to hire, then to fire. This why we have additional step.

Step three point three – Another interview

It is very important to emphasize that we have about 0.05% of those who where at stage three point one. This interview can take upto full day. You should come ready for this. Plan and watch each of your steps. Also you should be ready to speak with number of people near flip charts, whiteboards, calculators, computers and other hardware things. Also you should be ready to assert your opinion.

Most of people you’ll speak with will be very smart (this is not restricted to your direct manager or future colleague only). Sometimes you’ll speak with two or three people at simultaneously. Each person will have his own very special opinion. Also the questions may wary from base calculations to mechanical and electronic schematics or references of your vehicle.

You can take timeout, however take into account that people speaking with your sacrificing their time and projects, so you should consider it.

Step four – final

If you passed all three previous steps – you can consider yourself as our future employee. There were only once, when we had not hire developer because of financial/welfare issue. This because of our stances of good developers. If you did not hire them – you and all company will loose, not the developer. Each of those will find his/her place very soon. Even if the good developer has no CV at all or he/she is a student or foreign resident. Because the only chance for this company to produce good results is to have good human resources.

Send me your CV or contact me tamir [AT] khason.biz to tell that you are the one I’m looking for >>

Please do not send me your CV if it passes the regex of the first step – just send a message with list of what you did for last 7 years.

Some new in-mix downloads

There are some very cool downloads suddenly appear on MSDN download site due to all new technologies, presented at Mix ‘09. So let’s start

To learn more about Silverlight 3.0 and Blend 3.0, you can see first day keynotes at mix 09, Rollup of what’s new in Silverlight 3 by Joe Stegman. This includes offline mode support by Mike Harsh. I’ll write another separate post for this topic, due to the fact, that I’m a desktop guy, so wary about the future of WPF.

To learn more about how to use new Expression Blend, it worth to see this session by Pete Blois. Another good sessions are also wrapped for you by Scott Hanselman.

After we done with all web stuff, let’s speak about a client

That’s all by now, going to write a review for new book and will publish it soon (probably even before, you’ll finish with all those downloads and readings). So, stay tuned and be good people.

WPF Line-Of-Business labs and Silverlight vs. Flash

Small update today (mostly interesting links)… During my last “Smart Client” session I was asked about WPF LOB application development labs. So, there are two full labs, I noticed about:

Both labs include WPF ribbon and DataGrid, Southridge also come with M-VV-M design sample and some other interesting features. As for me, it seemed, like some parts of those labs can be easily used “as-is” for production level applications, like it was done with SCE starter, which turned into TimesReader (by the way, it has free version again).

Line of Business Hands-On-Lab Material

For those, who still trying to consider what to use for their next killer app, I propose to read following article from Jordan, which compares between Silverlight and Flash. And then see composite application guidance to use Prism for Silverlight development. Here the video of it usage by Adam Kinney from Channel 9

Prism for Silverlight

Have a nice day and be good people

Finally I can reveal stuff I working for last half year!

A couple of days ago WordFocus exposed one of our (frankly old :) ) prototypes for in-car energy assistant system, so today I can exclusively show you some of screens from this state of art WPF work. Real time performance of WPF touch screen application, running on low power automotive grade PC, which boots faster, then Nokia phone. Huge respect for all developers and P-defs.

Map overview

Planning screen Navigation draving state

Applications

Full video report by WorldFocus.org

Slides and desks from Smart Client Development session

Great thank to everybody attended yesterday at “Smart Client development” session. As promises, please see slides and desks from this session

Quick how to: Reduce number of colors programmatically

My colleague just asked me about how to reduce a number of colors in image programmatically. This is very simple task and contains of 43 :) steps:

Simple color matrix

First of all, you have to read a source image

using (var img = Image.FromFile(name)) {
var bmpEncoder = ImageCodecInfo.GetImageDecoders().FirstOrDefault(e => e.FormatID == ImageFormat.Bmp.Guid);

Then create your own encoder with certain color depth (32 bits in this case)

var myEncoder = System.Drawing.Imaging.Encoder.ColorDepth;
var myEncoderParameter = new EncoderParameter(myEncoder, 32L);
var myEncoderParameters = new EncoderParameters(1) { Param = new EncoderParameter[] { myEncoderParameter } };

Then save it

img.Save(name.Replace(“.png”, “.bmp”), bmpEncoder, myEncoderParameters);

It it enough? Not really, because if you’re going to loose colors (by reducing color depth), it makes sense to avoid letting default WIX decoder to do this, thus you have to find nearest base colors manually. How to do this? By using simple math

Color GetNearestBaseColor(Color exactColor) {
Color nearestColor = Colors.Black;
int cnt = baseColors.Count;
for (int i = 0; i < cnt; i++) {
int rRed = baseColors[i].R – exactColor.R;
int rGreen = baseColors[i].G – exactColor.G;
int rBlue = baseColors[i].B – exactColor.B;

int rDistance =
(rRed * rRed) +
(rGreen * rGreen) +
(rBlue * rBlue);
if (rDistance == 0.0) {
return baseColors[i];
} else if (rDistance < maxDistance) {
maxDistance = rDistance;
nearestColor = baseColors[i];
}
}
return nearestColor;
}

Now, you can either change colors on base image directly

unsafe {
uint* pBuffer = (uint*)hMap;
for (int iy = 0; iy < (int)ColorMapSource.PixelHeight; ++iy)
{
for (int ix = 0; ix < nWidth; ++ix)
{
Color nc = GetNearestBaseColor(pBuffer[0].FromOle());

pBuffer[0] &= (uint)((uint)nc.A << 24) | //A
(uint)(nc.R << 16 ) | //R
(uint)(nc.G << 8 ) | //G
(uint)(nc.B ); //B
++pBuffer;
}
pBuffer += nOffset;
}
}

Or, if you’re in WPF and .NET 3.5 create simple pixel shader effect to do it for you in hardware. Now, my colleague can do it himself in about 5 minutes :) . Have a nice day and be good people.

Recommended

 

Sponsor


Partners

WPF Disciples
Dreamhost
Code Project