Razan Paul Blog

Explaining thoughts and findings is a great way to learn

  • How can we get the first IP4 Address of the local machine in c#?

    When we write client server or peer to peer application, a frequent task is to find the first IP4 address of local machine. A machine has multiple types of addresses besides IP4 and IP6. For this reason, we will first get the address list of the machine then will loop through all the addresses to check whether there is an IP4 address. If found then we will return the first address. Otherwise will  return null.

  • A WPF Radio Button Control Template for Touch Screen Application

    I love the WPF’s ability to completely restyle a standard control. Each WPF Control has a default Control Template that contains the visual tree of that control to define how it displays itself and its contents. We can change the structure and appearance of a control by modifying the ControlTemplate of that control. We can override the default control template to make it appear exactly as we want. It will only replace the visual tree of the control not the behavior of the control.

  • How can we make a deep copy of a WPF object?

    We can make a deep copy of  a WPF object using XamlWriter and XamlReader. Here the XamlWriter.Save is used to serialize the contents of a WPF object into xaml string.  XamlReader.Load is used to parse XAML string into a WPF object. To make deep copy of an wpf UIelement , you can use the following method.

  • Testing whether two IP addresses are in the same network using c#.

    IPv4 address has two basic parts:  the network part and the host part. As we know, if network potions of two IPs are same, they are in the same network. By performing and operation between subnet mask and IP address, we can get the network portion of an IP. By this way, we have found the network portions of two IPs. Then just check whether the network portions are equal or not. For this the following code is written:

  • IP address spoofing in c# using P/Invoke

    According to Wiki, the term IP (Internet Protocol) address spoofing refers to the creation of IP packets with a forged (spoofed) source IP address with the purpose of concealing the identity of the sender or impersonating another computing system. For one of my project, I needed IP spoofing. According to a requirement, I need to commutate with a device over crossover cable for configuring it. But the problem is , when device boots  up , it gets an arbitrary IP when it is operating  over crossover connection as it cannot contract with DHCP Server. My PC is in a different network from the device. So i cannot communicate with that device thru socket programming. But one thing I can do, i can search the device using some proprietary protocol and find its information like its IP.

  • JavaScript VS C# threading model

    We were developing an application, which emulates the functionality of a real time device. In this application, we need real time event; we pool the service by a certain time interval and need to send some key presses. Moreover, we have a large number of timers to show real time effects of device by manipulating DOM elements.

  • Remora Pattern by Ben Constable

    According to Ben Constable, Remora Pattern allows you to attach a chunk of logic to any existing element that you have. This pattern can be implemented using an Attached Dependency Property in WPF. Here an Attached Dependency Property is attached with an object. When the object is initiated, it goes to set the value of the Attached Dependency Property, which results in calling an Attached Dependency Property Change event. In the event handler, you can add your intended functionality, which is the additional functionality of the object.