Announcement

All important changes of my site and my blog will be announced here.

Computer security

This is my hobby. I spend my freetime for it. I am not professional in this area. But I like it very much.

Everything Else

Which doesn’t belong to other categories will land here. It maybe about my daily life, entertainment, music, game … or something like that

Programming

This is my job. That means everyday I must sit before the monitor. Tip something, be annoyed by bugs,… but I simply like it.

Tutorial

When I found something interesting, I would like to share it to everyone. That is the reason for this category comes.

Home » Archive by Tags

Articles tagged with: c#

C# – Create Excel file from DataTable without using Excel Object
Tuesday, 16 Feb, 2010 – 0:00 | 6 Comments

Microsoft Excel is beloved tool to work with tables. Therefore it is really valuable for end user if an application can export its data into Excel. However today a lot of business application are web application which cause a problem with Excel because the Excel is not installed on web server. Export data to Excel with COM Remote Control of Excel Object Model does not always work fast and reliable.
Since Excel 2003 there is a …

C#, WPF – Play swf in wpf application
Sunday, 14 Feb, 2010 – 0:00 | 6 Comments

When I was trying to extract the first frame of SWF file into image I discovered that there is a small problem when we try to host a SWF file in WPF application because WPF does not allow us to integrate ActiveX control directly in its application. To enable interaction through ActiveX control, we must do a walkthrough with WindowsFormsHost. In this small example below I would like to guide you step by step to …

C#, WPF – Hit Testing Example
Friday, 12 Feb, 2010 – 0:00 | One Comment

When we create interactive 2D drawing applications in WPF, we can deal directly with the user’s
interaction with the graphics objects using mouse event handlers. However, WPF provides powerful hit-
testing for graphics objects through the static VisualTreeHelper.HitTest method.
In order to use this advanced hit-testing feature, we need to create a callback. The VisualTreeHelper
will then walk through your visuals from top to bottom. Whenever it finds a match, it calls the callback
with the details. We can then …

C# – Serialize and deserialize data
Monday, 8 Feb, 2010 – 0:00 | No Comment

When I wrote a small application with Client-Server model which sends data over TCP socket, I would like to build an intelligent way which serialize all of my data into stream, send this stream over socket and deserialize it back at server/client site. Using serialization all of data will be stored in stream or byte array and it is completely suitable for communicating over socket. To convert our object into stream using serialization is …

C#, WPF – Fast image resize
Saturday, 6 Feb, 2010 – 0:00 | 6 Comments

Today I read a blog on http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx which introduces a new way to resize image with WPF. This new method does not use GDI+ (Microsoft Windows GDI+ is the portion of the Windows XP operating system or Windows Server 2003 operating system that provides two-dimensional vector graphics, imaging, and typography.) but it uses WPF library for resizing images very fast. You can read more details about this method in that blog. In the code below, …

C# – Notify changes with custom EventHandler
Thursday, 4 Feb, 2010 – 0:00 | No Comment

During my development I must find a way to notify about changes in properties of class during threads are running. To invoke event relevant to properties, we can use available EventHandler delegate or create our own one (you know that if we use our own, we always have flexible way to handle event). In this small example below I would like to demonstrate how we can create our own delegate.
This example creates a class PCProducer …

C# – Use LINQ on .net framework 2.0
Friday, 29 Jan, 2010 – 0:00 | No Comment

When I read a thread on mycsharp.de, I discovered a library which allow us to use LINQ in any application written on .Net Framework 2.0. It’s really great if we have this feature without installing mega framework 3.0. The library can be downloaded from google code http://code.google.com/p/linqbridge/downloads/list . You can download online .cs file or a .dll file as you link but I prefer using a .cs because I don’t have to merge .dll file …

C# – Append byte array to byte array
Thursday, 28 Jan, 2010 – 0:00 | 2 Comments

During my development a tool to download music file through MMS protocol I had to convert a packet to a byte array and send it through socket to the server. Each packet has its own format and therefore the simple way is to implement each class for each packet and insert a function GetBytes() to each class to convert all fields in packet into byte array. The problem is that the fields have various format …