Friday, July 15, 2011

Quality of Microsoft Windows UI

Recently I was investigating Microsoft Windows Control Panel applets and found an unexpected issue. Although most of contemporary applets look like they have identical look’n’feel properties, it is not true. Moreover, I suspect that there was no any common UI guidance for them. Look here, I took 3 random Control Panel Applets, placed them into a stack and compared left margin of main title. It is different in all applets!

Follow the red line:

Windows Control Panel

Let’s check vertical margins. Oh, no. The same picture.

Windows Control Panel 2

How this can be? The author of UI guidance for applications for Windows doesn’t follow their own rules.

Tuesday, June 21, 2011

Free Online OCR (Optical Character Recognition) tool

In case you need to quickly recognize a text from an image file and don’t have ABBYY FineReader installed, there is an online analogue. Moreover, it is completely free. It is called Free OCR and is located here: http://www.free-ocr.com/

One thing made me laugh: they have to use Captcha technology to protect the website from spammers who used it for captcha breaking! This argument is enough to prove the service efficiency. =)

Hope this service will be helpful to someone as it was to me.

Wednesday, June 15, 2011

Windows 7 VPN connectivity trouble

Sometimes Windows 7 rejects my attempts to open a VPN connection, saying that my computer is not connected to the Internet while it is. I don’t know the reason why this happens, may be someone can explain such a weird behavior when one part of the system doesn’t know what happen in another one. Here is how it looks:

InternetTrouble

I marked the regions that are important on the screenshot. So, while I’m writing and publishing this post VPN networks are still unavailable. Damn Windows. If anyone knows how to sort this out without logging out, plz, let me know.

Friday, May 27, 2011

Thoughts on NetMonitor interface

Just to remind, here is the look of the current version of NetMonitor. There is no UI for managing the list of hosts, adding a new one or configuring the existing ones. The list of hosts are set in the application configuration file.

NetMonitor

I keep thinking on NetMonitor’s user interface, especially on editing screens. Moreover, I’m trying to imagine good system tray icon, that won’t be annoying but informative. During my life as a computer user I tried thousands of software programs, lot’s of them had really crappy UI while only several were more or less usable.

For now I have selected the following patterns:

List management

ListManagement

This is Alarms page from Clock application from iOS. The window shows a list of alarms, activation checkbox for each of them and 2 buttons on top that switch the screen: Edit mode and Add mode. No main menu, no toolbar are required. The UI is slick and simple to use.
The only question left is whether to keep those checkboxes on this screen or to move them to the host edit screen. As for alarms, the placement is right, so people could switch alarms on and off with ease, but what about hosts? How often users will enable and disable monitoring a host? The monitoring won’t wake you up early in the morning just because you forgot to switch it off. So, I tend to decide that the checkboxes should be put on the host configuration screen.

List edit mode

ListEdit

This window shows the same list of alarms but with different controls for each of them. Left red circle deletes an alarm, right arrow switches the window to the alarm configuration mode. Left top button is replaced with Done button that saves the result of list editing. However, the Delete control doesn’t deletes an item immediately, it displays sort of confirmation, like this:

ListDeleteItem

Note that the Delete button appear instead of right arrow. This proves that Apple software developers and interface engineers took into account every little detail so a customer feel comfortable with the UI.

Item edit mode

The screen that provides configuration details for an alarm. Here you can’t switch it on or off, just set up the alarm time, repeat mode, alarm name and snooze mode. Top buttons are: Save & Cancel.

ItemEdit

One more observation that might be interesting: if you noticed, the left top button from the main screen named Edit opens list management screen and the button Done there is located exactly on the same place as the button Edit. The same is true for alarm addition screen: button Add opens the Add alarm screen and the button Save is located right there, where button Add was. I think that this was done intentionally, after hundreds options and thorough UI testing.

Windows taskbar & system tray integration

NetMonitor is extremely lightweight, it is more like a tiny utility than a ordinary windows application, that’s why I suppose that it should sit in the system tray rather than in Windows taskbar. If so, then there is one utility which behavior I like -- network information popup window that shows currently available networks. It looks like this:

Networks

It is displayed after clicking on its tray icon and disappears after loosing the focus or after the second click on the icon. The elements I like here are: support of groups of items (collapsing and expanding groups, see up arrows), and network signal strength icon. The icon is displayed only for Wireless connections, so you might not be able to see it on your connected to a LAN computer. The only problem is that usage of similar icon is not a good idea, not only because the icon is the property of Microsoft, but mostly because users might get confused for 2 identical icons in their system trays. Another option to use a traffic light icon in the system tray, but I doubt whether this will be that informative.

Having described the future UI changes, I could proceed with the implementation. As soon as I have something to show, I’ll share the results.

Wednesday, May 11, 2011

Bye, Bye, Reflector

Greedy people from Red Gate Software, who had bought the Reflector tool and promised that it would always be free but failed, meet DotPeek, a free standalone .NET decompiler from JetBrains.

Thursday, March 3, 2011

NetMonitor. Discovering network configuration

It’s time to add some value to the project. For a long time I’ve been thinking about the UI for adding/editing/removing hosts and I’m still not sure which one will be good enough. As a  result, I’ve delayed this interface for further steps, today I’ll show how to discover network configuration of a computer and find out IP addresses of gateway, DNS servers, etc. to fill in the list of hosts.

The Base Class Library (BCL) doesn’t contain any network configuration-related classes mostly because it must be platform independent. So we have to interoperate somehow with machine-dependent components such as Windows Management Instrumentation (WMI). Luckily, BCL provides the System.Management.ManagementClass type which will help. In order to read network adapter’s configuration we will use “Win32_NetworkAdapterConfiguration” WMI class.

        // Creating the desired WMI class
        var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
        // Getting all instances of the specified WMI class
        var items = mc.GetInstances();

Having fetched all instances of WMI class we read the required properties and form the list of hosts. The properties that are interesting for us are:

  • DefaultIPGateway
  • DHCPServer
  • DNSServerSearchOrder
  • WINSPrimaryServer
  • WINSSecondaryServer

Here is the code:

        var gateList = new HashSet();
        var dnsList = new HashSet();
        var dhcpList = new HashSet();
        var winsList = new HashSet();

        foreach (var item in items) {
          // Skipping devices that are not IP-enabled
          if (!((bool)item["ipEnabled"]))
            continue;

          var addresses = (string[])item["DefaultIPGateway"];
          if (addresses != null && addresses.Length > 0)
            foreach (var gw in addresses)
              gateList.Add(gw);

          addresses = (string[])item["DNSServerSearchOrder"];
          if (addresses != null && addresses.Length > 0)
            foreach (var dns in addresses)
              dnsList.Add(dns);

          string dhcp = (string)item["DHCPServer"];
          if (!string.IsNullOrEmpty(dhcp))
            dhcpList.Add(dhcp);

          string wins1 = (string)item["WINSPrimaryServer"];
          if (!string.IsNullOrEmpty(wins1))
            winsList.Add(wins1);

          string wins2 = (string)item["WINSSecondaryServer"];
          if (!string.IsNullOrEmpty(wins2))
            winsList.Add(wins2);
        }

        foreach (var address in gateList)
          Hosts.Add(new HostViewModel(address, "Gateway"));
        foreach (var address in dnsList)
          Hosts.Add(new HostViewModel(address, "DNS"));
        foreach (var address in dhcpList)
          Hosts.Add(new HostViewModel(address, "DHCP"));
        foreach (var address in winsList)
          Hosts.Add(new HostViewModel(address, "WINS"));

Depending on the number and configuration of your network interfaces, the NetMonitor will automatically discover and fill in the list of hosts to monitor.

Here are my automatically discovered hosts. As you see, my Wi-Fi router also acts like a DNS server & a DHCP server, the other two DNS servers (10.0.0.x) are provided by additional VPN connection. BTW, it might be a good idea to remove duplicate entries from the list.

NetMonitor

Download latest binaries or play with the code.

Friday, February 4, 2011

NetMonitor. Implementing IDisposable pattern

The `IDisposable` pattern and its correct usage often are the subject of flaming discussions. At least among those developers, who are aware of its existence. Oh, sorry. Truth be told, the pattern had been the subject of discussions, but after the exciting and extremely detailed article on the topic was published by fathers of .NET, CLR, etc., the only thing left for us was to follow their wise recommendations.

And so did I, because `NetMonitor.PingService` uses `Threading.Timer` & `NetworkInformation.Ping` types which implement `IDisposable` by themselves. Here is how the canonic `IDisposable` implementation looks like, applying for `PingService` class:

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    private void Dispose(bool disposing)
    {
      if (isDisposed)
        return;

      if (!disposing)
        return;

      if (IsRunning)
        Stop();

      if (timer != null)
        timer.Dispose();
      if (ping != null)
        ping.Dispose();

      isDisposed = true;
    }

    ~PingService()
    {
      Dispose(false);
    }

Note the presence of a finalizer, 2 working modes of Dispose method, etc. All this stuff is explained with uncompromising details in the above-mentioned article. Great reading, don’t miss it.