Author Archives: klimmass - Page 2

iphone.klimczyk.pl website launch

I’m proudly to announce launch of my iphone games website. Website is located under: http://iphone.klimczyk.pl.
We run this website together with my wife.

If you are interested in some iphone games and apps please visit us there ;)

Using different .config file in .NET application

In .NET world executable files using by default configuration file with special name. Microsoft has implemented following pattern: executable: program.exe and corresponding configuration file program.exe.config. In many scenarios this pattern is fitting well, but there are some cases when something else necessary. In my situation common configuration file was desirable! One configuration file with shared app settings, configuration strings, etc.

First solution I found was sharing AppSettings section between configuration files. This can be easily achieved by adding file attribute in appSettings tag. Like this:

<appSettings file=”commonSettings.config>

But this doesn’t solve problem with connections string and custom sections… damn…

The solution that I end up with is:

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"commonConfig.config");
 
FieldInfo fiInit = typeof(ConfigurationManager).GetField("s_initState", BindingFlags.NonPublic | BindingFlags.Static);
 
if (fiInit != null)
{
fiInit.SetValue(null, null);
}
 
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

The AppDomain.CurrentDomain.SetData() method changes properties for current domain. So I simply change the APP_CONFIG_FILE property value to point to another config file. Rest of the code is necessary to re-read the configuration. With this solution I able to force .NET to use one configuration file between multiple executables.

dotPeek – Free .NET decompile from JetBrains is now available in EAP

Today I’ve received an email from JetBrains with short information saying that an alternative to ReflectorPro is available! Since Reflector since version 7 will be not free any more I was looking here and there for some alternatives… Few weeks ago I’ve been looking at ILSpy, but it doesn’t fit my needs. I find it little bit hard to use. Today I’ve started to test dotPeek and I’m pretty impressed with the tool.

Some features that I find useful:
-easy in use;
-integrates with R#;
-free.

Here are some screenshots:

I really recommend everyone to try it.

cheers!

Remember! Check code changed before commiting to repository.

This is often daily scenario in programmers work. Work day is about to end, You are in a hurry with finishing coding, just final commit and go home :) Looks natural. Save your work somewhere. Not so fast my friend!

Evolus Pencil – freeware mockup tool

On the market there is number of Mockup tools. All of them are providing similar functionality. Some allow import external graphics or exporting to pdf files out of the box. But for my needs all those additional features are not necessary. The most important factor is that the tool should provide standard mock-up functionality and by relatively cheap or freeware ;) . That’s why I was looking for tool that will meet that criteria:

  • standard functionality
  • relatively cheap/ freeware

After some research I found great tool ! It’s called Evolus Pencil. It is distributed on GNU license ;) and provides all the functionality I need.

The authors of the project are open for new contributors that will help in developing this great tool. So if you are an open-source developer and want to participate simply contact them ;)

WPF – How to show ToolTip when control is disabled

By default tooltip is hidden when control is disabled. There is simple way to enable it. Code below show how to do that:

ToolTipService.SetShowOnDisabled(uxSampleButton, true);

So, as you can see the solution is not complicated :) and I hope this note will save some time other coders.

Download sample code: DisabledTooltipExample.zip

WPF – BrushConverter HTML (Hexadecimal) colors

Assigning HTML like colors (i.e. #318D38) in WPF application directly in XAML is very easy and smooth.

For example code:

<Setter Property="Background" Value="#318D38" />

works pretty well.

It is worse to assign HTML color in C# code…. Solutions like:

panel.Background = "#318D38";

or

panel.Background = (Brush)"#318D38";

does not work….

Solution for this issue is BrushConverter class. With BrushConverter coder can do something like this:

BrushConverter bc = new BrushConverter();
Brush brush = (Brush)bc.ConvertFrom("#318D38");
panel.Background = brush;

or even this:

BrushConverter bc = new BrushConverter();
Brush brush = (Brush)bc.ConvertFrom("Red");
panel.Background = brush;

Small class but helps a lot ;)

SnippetCompiler

SnippetCompiler is another useful tool for C# developers. Is quite similar to FastSharp. Both allow you to write and compile sample code very quickly. SnippetCompiler has IntelliSense support (missing in Fast Sharp), that gives benefits. Unfortunately, last version is from year 2008… supports .NET up to 3.5….

There are always pros and cons when a tool provides something extra (IntelliSense here) and miss something else (.NET 4.0). I personally use SnippetCompiler to test sample code.

[Quick News] .Net 3.0 and 3.5 out of support April 12th, 2011

Today I found a quite important information about supporting .NET 3.0 and 3.5 by Microsoft. it seems that those .NET Framework versions will be supported till April 12th, 2011. So by that date we should migrate to, at least, 3.5 SP1.More information.
Important is that support for .NET 1.1 and 2.0 remains as it was.

It is good time for little digression here. Should we consider using Microsoft products after they have SP1 available? Are the first versions “unfinished products/public betas” ? :) I remember the same story with Vista, Visual Studio 2005/2008.

WPF – TextBlock StringFormat

This post is not a hot news, but it may help somebody ;)

Before .NET 3.5 SP1 when I wanted to display formated informations in TextBlock i had to do some workarounds…
For example to display coordinates (int x, int y) there were two possibilities (at least):

  1. Create readonly property in the model and bind to it (public string Coordinates {get{ return String.Format(“X:{0} Y:{0}”,x,y);}})
  2. User couple of Label control to show the intended “line”.

Both approaches sux :)  But, since .NET 3.5 SP1 there a better solution to that problem :D
You can write code like this:

<TextBlock Text="{Binding Date, StringFormat={}{0:MM/dd/yyyy hh:mm tt}}" />

or this:

<TextBlock>
    <TextBlock.Text>
        <MultiBinding StringFormat="X:{0} Y:{1}">
            <Binding Path="X" />
            <Binding Path="Y" />
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

Last sample solves my problem. I don’t add additional