tag:blogger.com,1999:blog-64309483136088277322024-03-08T20:03:44.452+05:00Pragmatic view on software techAnonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.comBlogger84125tag:blogger.com,1999:blog-6430948313608827732.post-49883178042953664562013-12-20T05:16:00.003+06:002013-12-20T05:16:57.082+06:00Quick website settings in Google ChromeFor a quick overview of a website settings, click on a website's icon in omnibar.<br />
<br />
You should see the following popup with website settings and cookie information:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-I77WemL080Q/UrN-JY1hIWI/AAAAAAAAAkA/T6dtpd4GJto/s1600/QuickInfo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-I77WemL080Q/UrN-JY1hIWI/AAAAAAAAAkA/T6dtpd4GJto/s1600/QuickInfo.png" /></a></div><br />
Nice featureAnonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-47746160138368768432013-10-11T00:15:00.001+06:002013-10-11T00:15:25.484+06:00Page reload options in Google ChromeRecently, I've found that new feature of Google Chrome browser. Earlier, you had to hit <code>Control+F5</code> (may be multiple times) or go to Settings and clear cache from there.<br />
Now, the things got simplified, after long click on Reload button you'll see the following menu:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-mHJIejcw8_E/UlbtMWarHwI/AAAAAAAAAjQ/WJr2bvhsFSY/s1600/PageReloadOptionsGoogleChrome.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-mHJIejcw8_E/UlbtMWarHwI/AAAAAAAAAjQ/WJr2bvhsFSY/s1600/PageReloadOptionsGoogleChrome.png" /></a></div><br />
An important point: the menu shows up only if Developer Tools are open.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-60525843164223595782012-11-05T04:19:00.000+06:002012-11-05T04:19:28.913+06:00Adding reactivity to NetMonitorIt was long time ago when I last time wrote about updates in the NetMonitor project. I was just using it from time to time to diagnose my network connection and it worked pretty well. However, I wasn't happy with its internals, especially with PingService implementation as it was rather complex for such simple job - it had to deal with entities from System.Threading namespace (e.g. <a href="http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx">Timer</a>) to get called from time to time in background thread and this only added complexity without adding any business value.<br />
<br />
Some time ago I tried playing with <a href="http://msdn.microsoft.com/en-us/library/dd460717.aspx">Task Parallel Library</a>, but eventually it appeared that TPL is not applicable in this scenario.<br />
<br />
This time I've found <a href="http://msdn.microsoft.com/en-us/library/hh242985(v=vs.103).aspx">Rx Extensions</a> and I really liked the approach. My task with sequential background execution is solved with the help of the extensions quite gracefully (here is simplified version):<br />
<br />
<pre>var service = new PingService("google.com");
// Every second the ping service will be called from background thread, producing a sequence of metrics
var metrics = Observable.Interval(TimeSpan.FromSeconds(1))
.Select(i => service.Execute());
// Consuming the sequence of metrics and updating UI
subscription = metrics.Subscribe(
metric => Console.WriteLine(metric.RoundtripTime),
exception => Console.WriteLine(exception.Message));
</pre><br />
Applying Rx Extensions drastically simplified the service itself and program environment as additionally I got rid of events and handlers, I am satisfied with the changes it brought. In my scenario it looks like a simple messaging bus between services and their consumers.<br />
<br />
I'm pretty confident that Reactive Extensions can change your attitude to composing asynchronous and event-based programs (as it once happened with invention of LINQ for data querying). More on Rx can be found on <a href="http://msdn.microsoft.com/en-us/library/hh242985(v=vs.103).aspx">MSDN</a>, <a href="http://rxwiki.wikidot.com/101samples">101 Samples</a>, <a href="http://introtorx.com/">IntroToRx</a>.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-42650563006996845662012-11-04T03:36:00.003+06:002012-11-04T03:38:42.842+06:00Dependency injection for smartiesTill the last week I was thinking that dependency injection is a rather simple thing and mostly is about resolving a component by its interface/base class with some nuances like providing additional information as name, constructor signature, transient/singleton instance, etc. Almost everyone among my friends wrote their own implementation of IoC container, that's not big deal. They differ one from another by name of main method (Get/Resolve/Whatever) and internal implementation, but all they were about was simple component resolving and no more.<br />
<br />
However, last week I was diving deep in autofac IoC container and one thing in their documentation just made me rethink all that I knew about the relationships between the components (actually, I didn't think of anything except the first type from the list). Here is what they call relationships:<br />
<br />
<table style="border: 1px solid #333" align="center"><tbody>
<tr><td style="padding: 5px;"><strong>Relationship</strong> </td><td style="padding: 5px;"><strong>Constructor signature</strong> </td><td style="padding: 5px;"><strong>Meaning</strong> </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs <i>B</i> </td><td style="padding: 5px;"><tt>A(B b)</tt></td><td style="padding: 5px;">Dependency </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs <i>B</i> at some point in the future </td><td style="padding: 5px;"><tt>A(Lazy<B> b)</tt></td><td style="padding: 5px;">Delayed instantiation </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs <i>B</i> until some point in the future </td><td style="padding: 5px;"><tt>A(Owned<B> b)</tt></td><td style="padding: 5px;">Controlled lifetime </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs to create instances of <i>B</i> </td><td style="padding: 5px;"><tt>A(Func<B> b)</tt></td><td style="padding: 5px;">Dynamic instantiation </td></tr>
<tr><td style="padding: 5px;"><i>A</i> provides parameters of types <i>X</i> and <i>Y</i> to <i>B</i> </td><td style="padding: 5px;"><tt>A(Func<X,Y,B></tt><span style="font-family: monospace;"> </span><span style="font-family: monospace;">b)</span></td><td style="padding: 5px;">Parameterisation </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs all the kinds of <i>B</i> </td><td style="padding: 5px;"><tt>A(IEnumerable<B></tt><span style="font-family: monospace;"> </span><span style="font-family: monospace;">b)</span></td><td style="padding: 5px;">Enumeration </td></tr>
<tr><td style="padding: 5px;"><i>A</i> needs to know <i>X</i> about <i>B</i> </td><td style="padding: 5px;"><tt>A(Meta<T></tt><span style="font-family: monospace;"> </span><span style="font-family: monospace;">b) </span>and <span style="font-family: monospace;">A(</span><span style="font-family: monospace;">Meta<B,X> </span><span style="font-family: monospace;">b)</span></td><td style="padding: 5px;">Metadata interrogation </td></tr>
</tbody></table><br />
More on the relationships you can read in the dedicated article <a href="http://nblumhardt.com/2010/01/the-relationship-zoo/">Relationship Zoo</a>, highly recommended. I hope it will make you rethink what DI was meant for you.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-75491436571585603762012-11-02T03:13:00.001+06:002012-11-02T03:13:47.759+06:00Visual Studio 2010, 2012 vs. Inconsolata font, part 3Earlier, I promised to update the status of the fight "<a href="http://dmitrimaximov.blogspot.ru/2010/12/visual-studio-2010-vs-inconsolata-font.html">Visual Studio 2010 vs. Inconsolata</a>" as soon as I have a chance to try the font in Visual Studio 2012. However, I noticed that the font has been updated also and the <a href="http://code.google.com/p/googlefontdirectory/source/browse/ofl/inconsolata">latest version of Inconsolata</a> is available from September, 2012.<br />
<br />
So first, I tried it in Visual Studio 2010, silently hoping that the troubles are gone. And yes, the extra boldness of some symbols is no more the case. Here is how it looks:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-ROkDdHFkg_Q/UJLi5DZZ2pI/AAAAAAAAAgM/ylsBgN1SND8/s1600/VS2010Inconsolata.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-ROkDdHFkg_Q/UJLi5DZZ2pI/AAAAAAAAAgM/ylsBgN1SND8/s1600/VS2010Inconsolata.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Inconsolata in Visual Studio 2010</td></tr>
</tbody></table><br />
After that I switched to Visual Studio 2012. No surprises, the font is rendered perfectly:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-Nk9uFIcWNyg/UJLlJFvabmI/AAAAAAAAAgY/mz177SAIYBo/s1600/Inconsolata12.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-Nk9uFIcWNyg/UJLlJFvabmI/AAAAAAAAAgY/mz177SAIYBo/s1600/Inconsolata12.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Inconsolata in Visual Studio 2012</td></tr>
</tbody></table><br />
So I guess, the confrontation is over. If you love Inconsolata font, just get its latest version from <a href="http://code.google.com/p/googlefontdirectory/source/browse/ofl/inconsolata">google code repository</a> and enjoy!<br />
Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com4tag:blogger.com,1999:blog-6430948313608827732.post-45820084037413888122012-04-03T20:04:00.001+06:002012-04-03T20:05:01.338+06:00Find a differenceHi there.<br />
<br />
Can't help posting two logos:<br />
<br />
<div style="text-align: center;">
<span style="font-size: large;">Blackberry Developer zone</span>
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://bdsc.webapps.blackberry.com/devzone/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="463" src="http://4.bp.blogspot.com/-blxRqx4UJZo/T3sChvA8vCI/AAAAAAAAAdc/frMXZle1M0E/s640/Blackberry%2BDeveloper%2BZone.png" width="640" /></a></div>
<br />
<div style="text-align: center;">
<span style="font-size: large;">JetBrains Resharper 7 announce</span>
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://blogs.jetbrains.com/dotnet/2012/03/resharper-70-eap-visual-studio-11-beta-edition-is-nowopen/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="392" src="http://1.bp.blogspot.com/-_t3j01jObKg/T3sCz8bQxPI/AAAAAAAAAdo/oWW2FbMZJDA/s640/Resharper7.png" width="640" /></a></div>
<br />
How this can be?Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com1tag:blogger.com,1999:blog-6430948313608827732.post-32511959412286142822011-07-15T00:15:00.001+06:002011-07-15T00:17:46.398+06:00Quality of Microsoft Windows UI<p>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! </p> <p>Follow the red line:</p> <p><a href="http://lh5.ggpht.com/-0TnoSlQYZAM/Th8yU4JeBtI/AAAAAAAAAYY/kQswznCei60/s1600-h/Windows%252520Control%252520Panel%25255B4%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Windows Control Panel" border="0" alt="Windows Control Panel" src="http://lh5.ggpht.com/-LFl_AEuzg34/Th8yVlZ_nVI/AAAAAAAAAYc/y3fKdp05uC8/Windows%252520Control%252520Panel_thumb%25255B2%25255D.png?imgmax=800" width="645" height="411" /></a></p> <p>Let’s check vertical margins. Oh, no. The same picture.</p> <p><a href="http://lh4.ggpht.com/-Y2WtIgx45yQ/Th8yWpUGayI/AAAAAAAAAYo/iuzvEOlt3Ww/s1600-h/Windows%252520Control%252520Panel%2525202%25255B5%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Windows Control Panel 2" border="0" alt="Windows Control Panel 2" src="http://lh6.ggpht.com/-PpFFsNHKa10/Th8yXZ6hbeI/AAAAAAAAAYs/TCu_Z3ph3Dw/Windows%252520Control%252520Panel%2525202_thumb%25255B3%25255D.png?imgmax=800" /></a></p> <p>How this can be? The author of UI guidance for applications for Windows doesn’t follow their own rules.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com1tag:blogger.com,1999:blog-6430948313608827732.post-54265854838082129962011-06-21T00:13:00.001+06:002011-06-21T00:13:46.323+06:00Free Online OCR (Optical Character Recognition) tool<p><a href="http://www.free-ocr.com/"><img style="display: inline; float: right" align="right" src="http://www.free-ocr.com/images/logo.png" width="240" height="44" /></a>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: <a href="http://www.free-ocr.com/">http://www.free-ocr.com/</a></p> <p>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. =)</p> <p>Hope this service will be helpful to someone as it was to me.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com4tag:blogger.com,1999:blog-6430948313608827732.post-87202125726436350812011-06-15T00:40:00.001+06:002011-06-15T00:46:51.938+06:00Windows 7 VPN connectivity trouble<p>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:</p> <p><a href="http://lh4.ggpht.com/-sIzsda6FhSE/TferHkJa_JI/AAAAAAAAAXw/pK_MmnOKaYU/s1600-h/InternetTrouble%25255B6%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="InternetTrouble" border="0" alt="InternetTrouble" src="http://lh3.ggpht.com/-TemNssLxBSw/TferIYDSEPI/AAAAAAAAAX0/60qlae-sMgo/InternetTrouble_thumb%25255B4%25255D.png?imgmax=800" width="640" height="399" /></a></p> <p>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.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-18470870851380517062011-05-27T00:42:00.001+06:002011-05-27T00:43:12.817+06:00Thoughts on NetMonitor interface<p>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.</p> <p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="NetMonitor" border="0" alt="NetMonitor" src="http://lh3.ggpht.com/-UnKvl743uFU/Td6fGDH8e3I/AAAAAAAAAWg/65ktdQ5Cal0/NetMonitor%25255B5%25255D.png?imgmax=800" width="200" height="300" /></p> <p>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.</p> <p>For now I have selected the following patterns:</p> <h4>List management</h4> <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="ListManagement" border="0" alt="ListManagement" src="http://lh4.ggpht.com/-_OaiXwik7Sg/Td6fGmqHTFI/AAAAAAAAAWk/owbElBI2dWY/ListManagement%25255B5%25255D.png?imgmax=800" width="211" height="317" /></p> <p>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: <strong>Edit</strong> mode and <strong>Add</strong> mode. No main menu, no toolbar are required. The UI is slick and simple to use. <br />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.</p> <h4>List edit mode</h4> <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="ListEdit" border="0" alt="ListEdit" src="http://lh3.ggpht.com/-fyyQ2NGdjbk/Td6fHLxUvGI/AAAAAAAAAWo/fKymmg0sLMQ/ListEdit%25255B5%25255D.png?imgmax=800" width="211" height="317" /></p> <p>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 <strong>Done</strong> button that saves the result of list editing. However, the <strong>Delete</strong> control doesn’t deletes an item immediately, it displays sort of confirmation, like this:</p> <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="ListDeleteItem" border="0" alt="ListDeleteItem" src="http://lh5.ggpht.com/-LjPLqrCXDlw/Td6fHtx4YlI/AAAAAAAAAWs/JQwKDCLHW4w/ListDeleteItem%25255B5%25255D.png?imgmax=800" width="211" height="317" /></p> <p>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.</p> <h4>Item edit mode</h4> <p>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: <strong>Save</strong> & <strong>Cancel</strong>. </p> <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="ItemEdit" border="0" alt="ItemEdit" src="http://lh4.ggpht.com/-DqpQNtb7mn4/Td6fIKoVn9I/AAAAAAAAAWw/3qvZXBCc30s/ItemEdit%25255B5%25255D.png?imgmax=800" width="211" height="317" /></p> <p>One more observation that might be interesting: if you noticed, the left top button from the main screen named <strong>Edit</strong> opens list management screen and the button <strong>Done</strong> there is located exactly on the same place as the button <strong>Edit</strong>. The same is true for alarm addition screen: button Add opens the <strong>Add alarm</strong> screen and the button <strong>Save</strong> is located right there, where button <strong>Add</strong> was. I think that this was done intentionally, after hundreds options and thorough UI testing.</p> <h4>Windows taskbar & system tray integration</h4> <p>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:</p> <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Networks" border="0" alt="Networks" src="http://lh5.ggpht.com/-2QtFpaoWb48/Td6fIkmgylI/AAAAAAAAAW0/Iq7FcXvE6xQ/Networks%25255B7%25255D.png?imgmax=800" width="279" height="394" /></p> <p>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.</p> <p>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.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-67190162755383900242011-05-11T23:47:00.000+06:002011-05-11T23:47:12.935+06:00Bye, Bye, ReflectorGreedy people from Red Gate Software, who had bought the Reflector tool and promised that it would always be free but failed, meet <a href="http://blogs.jetbrains.com/dotnet/2011/05/free-net-decompiler-is-available-for-early-access/">DotPeek</a>, a free standalone .NET decompiler from JetBrains.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-81126148747109085252011-03-03T01:31:00.001+05:002011-03-03T01:33:08.250+05:00NetMonitor. Discovering network configuration<p>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.</p> <p>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 <a href="http://msdn.microsoft.com/en-us/library/system.management.managementclass(v=VS.100).aspx">System.Management.ManagementClass</a> type which will help. In order to read network adapter’s configuration we will use “<a href="http://msdn.microsoft.com/en-us/library/aa394217.aspx">Win32_NetworkAdapterConfiguration</a>” WMI class.</p> <pre> // Creating the desired WMI class
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
// Getting all instances of the specified WMI class
var items = mc.GetInstances();</pre>
<p>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:</p>
<ul>
<li>DefaultIPGateway </li>
<li>DHCPServer </li>
<li>DNSServerSearchOrder </li>
<li>WINSPrimaryServer </li>
<li>WINSSecondaryServer </li>
</ul>
<p>Here is the code:</p>
<pre> var gateList = new HashSet<string>();
var dnsList = new HashSet<string>();
var dhcpList = new HashSet<string>();
var winsList = new HashSet<string>();
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"));</pre>
<p>Depending on the number and configuration of your network interfaces, the NetMonitor will automatically discover and fill in the list of hosts to monitor. </p>
<p>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.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NetMonitor" border="0" alt="NetMonitor" src="http://lh5.ggpht.com/_iHnCjIZdGL8/TW6pII3aXlI/AAAAAAAAAUM/153Sl3FGrAQ/NetMonitor%5B5%5D.png?imgmax=800" width="224" height="336" /> </p>
<p><a href="https://bitbucket.org/dmitri.maximov/netmonitor/downloads?highlight=23665">Download</a> latest binaries or <a href="https://bitbucket.org/dmitri.maximov/netmonitor/overview">play with the code</a>. </p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-10560959031431313822011-02-04T02:32:00.001+05:002011-02-04T02:32:28.330+05:00NetMonitor. Implementing IDisposable pattern<p>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 <strong>had been</strong> the subject of discussions, but after the exciting and extremely detailed article on the topic <a href="http://www.bluebytesoftware.com/blog/2005/04/08/DGUpdateDisposeFinalizationAndResourceManagement.aspx">was published</a> by fathers of .NET, CLR, etc., the only thing left for us was to follow their wise recommendations. </p> <p>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:</p> <pre> 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);
}</pre>
<p>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.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-24043198247169197092011-01-27T01:52:00.001+05:002011-01-27T01:52:28.737+05:00NetMonitor. Making UI more efficient<p>After releasing the first more-or-less useful version of NetMonitor, I’ve been playing with it in different environments and situations, trying to realize whether the current UI is efficient enough for providing useful information about the network health in a form that can be grasped quickly, without spending noticeable amount of time on data parsing and understanding. Also, I’ve been observing the usage of controls that are located at the main window. </p> <p>Here is how it looked originally:</p> <p> <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NetMonitor UI zones" border="0" alt="NetMonitor UI zones" src="http://lh6.ggpht.com/_iHnCjIZdGL8/TUCJhhkrJ3I/AAAAAAAAATg/Tmd67lhkvUg/NetMonitor-1%5B11%5D.png?imgmax=800" width="422" height="254" /> </p> <p>After a week or two, I’ve made the following observations:</p> <p>1. Buttons “Start” & “Stop” in this tiny application are useless at all. I’ve noticed that while I had to push “Start” button in order to begin the monitoring process, I never pushed “Stop” button when I wanted to stop the monitoring, because closing the application seemed more natural to me as a regular user. Also, I’ve realized that pushing “Start” button is the excess step, I’d prefer an application, at least this simple one, would start functioning immediately, without additional clicks. So, I’m removing the toolbar with the buttons and launching the monitoring right from the start.</p> <p>2. Information that is presented in Data panel was also a subject for the investigation. I realized that some columns are more important and other are less. For example, columns “Host” and “Response time” were those I paid much attention to, while “Address” and “Health” were less convenient for me. As for “Host” vs. “Address”: I think that a human-being prefers to operate with more natural textual names for hosts instead of IPs or internet addresses with those “www”, “com”, etc. Moreover, internet address is required for application only, a user wants to know how much is response time for “my router”, “my vpn server”, “my website”, etc., and not for “192.168.0.1”, “10.0.0.66” or other stuff constructed from weird combination of digits and dots.</p> <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NetMonitor important columns" border="0" alt="NetMonitor important columns" src="http://lh5.ggpht.com/_iHnCjIZdGL8/TUCJiZfDkzI/AAAAAAAAATk/iiY7Oln7X00/NetMonitor-2%5B5%5D.png?imgmax=800" width="422" height="254" /></p> <p>So, first of all I’ve removed the toolbar. That was rather easy and didn’t take much time. The most difficult task was how to reorganize the data presentation to provide better visualization. I’ve been experimenting with various patterns and understood that there couldn’t be a good solution unless I refuse using DataGrid as a presentation pattern. So I began probing with direct item templates for `ListView` control. After a while a fresh new look for NetMonitor was born:</p> <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Fresh new look for NetMonitor" border="0" alt="Fresh new look for NetMonitor" src="http://lh5.ggpht.com/_iHnCjIZdGL8/TUCJi6xVEdI/AAAAAAAAATo/p4dNsIl0oqY/NetMonitor-3%5B5%5D.png?imgmax=800" width="225" height="338" /> </p> <p>This information layout focuses on the important data: human readable host names and response time, while other potentially useful information such as IP address, is less expressed. Moreover, the important pieces of data are located closer to each other and it is more convenient for eyes and brain to grasp the connected pieces of information.</p> <p>The solution was simple. I removed `ListView.View` and nested `GridView` nodes and add a DataTemplate for a ListView. Nothing special:</p> <pre><ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Name}"
FontSize="18.667" Margin="5,0,0,0" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding ResponseTime}"
FontSize="18.667" HorizontalAlignment="Right" Margin="0,0,5,0" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding Address}"
FontSize="10.667" Margin="5,0,0,5" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="ping"
FontSize="10.667" HorizontalAlignment="Right" Margin="0,0,5,5" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate></pre>
<p>After that small achievement I got closer to the point of feeling the dark power of WPF =)</p>
<p>P.S.
<br />The <a href="https://bitbucket.org/dmitri.maximov/netmonitor/overview">repository</a> is updated, binaries are available <a href="https://bitbucket.org/dmitri.maximov/netmonitor/downloads">here</a>, as usual.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-16168765884752757692011-01-20T00:22:00.001+05:002011-01-20T00:22:00.989+05:00Gosh! Someone is damn good at support<p><a href="http://support.x-tensive.com/"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="support.x-tensive.com" border="0" alt="support.x-tensive.com" src="http://lh6.ggpht.com/_iHnCjIZdGL8/TTc514-TIQI/AAAAAAAAATc/bavZdX2yzO4/support%5B7%5D.jpg?imgmax=800" width="800" height="320" /></a></p> <p>Just a funny case, notice the amount of karma =)</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com4tag:blogger.com,1999:blog-6430948313608827732.post-22388049022404737692011-01-14T02:15:00.001+05:002011-01-14T02:16:42.330+05:00NetMonitor. Making application configurable<p>After <a href="http://dmitrimaximov.blogspot.com/2011/01/netmonitor-bringing-together-ui-and.html">we made the application working</a>, the next step is to make it configurable, so a user won’t need to recompile the program when he wants to add or modify a host.</p> <p>This step is rather easy to implement, although personally I don’t like .NET configuration and prefer INI-files based one, in this particular scenario I’m choosing the standard one. So, in order to map a collection of HostViewModel items, I’ve added <a href="https://bitbucket.org/dmitri.maximov/netmonitor/src/afa98d3119ca/Application/NetMonitor/Configuration/HostConfigurationElement.cs">HostConfigurationElement</a>, <a href="https://bitbucket.org/dmitri.maximov/netmonitor/src/afa98d3119ca/Application/NetMonitor/Configuration/HostConfigurationElementCollection.cs">HostConfigurationElementCollection</a> & <a href="https://bitbucket.org/dmitri.maximov/netmonitor/src/afa98d3119ca/Application/NetMonitor/Configuration/MainSection.cs">MainSection</a> types. While working on this task, I’ve found absolutely fabulous and useful <a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx">.NET configuration guide</a>, which I recommend to everyone. The guide consists of 3 big parts: Unraveling, Decoding & Cracking the Mysteries of .NET 2.0 Configuration, don’t miss it.</p> <p>So, having configuration-related types done, I got the ability to move host-related data to application configuration file:</p> <pre><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="NetMonitor.Main" type="NetMonitor.Configuration.MainSection, NetMonitor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<NetMonitor.Main>
<hosts>
<host name="Wi-Fi Router" address="192.168.1.1"/>
<host name="Gate" address="10.1.8.2"/>
<host name="VPN Server" address="10.0.0.66"/>
<host name="DNS Server" address="10.0.0.1"/>
<host name="Google" address="google.com"/>
<host name="Yahoo" address="yahoo.com"/>
</hosts>
</NetMonitor.Main>
</configuration></pre>
<p>After the application has been made configurable, it might become useful not only for me, but for somebody else. Therefore, I’ve built it and uploaded <a href="https://bitbucket.org/dmitri.maximov/netmonitor/downloads">here</a> for those who might be interested in using it. In this public version I removed personal hosts such as wi-fi router, gate, etc., because they don’t make any sense to anyone, except me.</p>
<p>Next time I’m going to make some changes to the UI, as there are tons of tasks to be done to get really useful piece of software, even to this tiny one.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-21949584961916419952011-01-06T04:02:00.001+05:002011-01-06T04:02:31.663+05:00NetMonitor. Bringing together UI and services<p>In <a href="http://dmitrimaximov.blogspot.com/2010/12/netmonitor-pt4.html">the previous part</a> I introduced a Ping service which purpose was to execute Ping command asynchronously, grab results and notify its listeners. Today I’m going to bring together the UI that had been constructed <a href="http://dmitrimaximov.blogspot.com/2010/12/netmonitor-pt3.html">earlier</a> with this service. </p> <p>First of all, let’s connect a class that represents a Host with an instance of Ping service. Here is how HostViewModel was initially designed:</p> <pre> public class HostViewModel : ViewModelBase
{
private string name;
private string health;
private string responseTime;
public string Name
{
get { return name; }
set {
name = value;
RaisePropertyChanged("Name");
}
}
public string Address { // The same logic }
public string Health { // The same logic }
public string ResponseTime { // The same logic }
}</pre>
<p>I’m adding a reference to an instance of Ping service in its constructor, an event listener and 2 methods to control host monitoring from outside:</p>
<pre> public class HostViewModel : ViewModelBase
{
// ...
private readonly PingService ping;
private readonly Queue<pingservicemessage> messageLog;
public void StartMonitor()
{
ping.Start();
}
public void StopMonitor()
{
ping.Stop();
Invalidate();
}
private void PingCompleted(object sender, PingServiceMessage e)
{
if (e.Status != IPStatus.Success) {
Health = e.ErrorMessage;
Invalidate();
return;
}
ResponseTime = GetAverageResponseTime(e).ToString("F1");
Health = "OK";
}
private double GetAverageResponseTime(PingServiceMessage e)
{
messageLog.Enqueue(e);
if (messageLog.Count > 5)
messageLog.Dequeue();
return messageLog.Select(m => m.RoundtripTime).Average();
}
private void Invalidate()
{
messageLog.Clear();
}
public HostViewModel(string address, string name)
{
Address = address;
Name = name;
messageLog = new Queue<pingservicemessage>(8);
ping = new PingService(Address);
ping.PingCompleted += PingCompleted;
}
}
}</pre>
<p>Note that I’ve also added a message queue to calculate average value of response time based on last 5 messages. This might help to avoid dramatic raises and falls of the variable.</p>
<p>The second step is to modify MainViewModel in order to initialize a collection of HostViewModels and bind commands to methods.</p>
<pre> public class MainViewModel : ViewModelBase
{
// ...
private bool isMonitoring;
public ICommand StartCommand
{
get {
if (startCommand == null)
startCommand = new RelayCommand(Start, () => !IsMonitoring); // Binding command to methods
return startCommand;
}
}
public ICommand StopCommand
{
get {
if (stopCommand == null)
stopCommand = new RelayCommand(Stop, () => IsMonitoring); // Binding command to methods
return stopCommand;
}
}
public bool IsMonitoring
{
get { return isMonitoring; }
set {
if (isMonitoring == value)
return;
isMonitoring = value;
RaisePropertyChanged("IsMonitoring");
}
}
// Starting all monitors
private void Start()
{
IsMonitoring = true;
foreach (var host in Hosts)
host.StartMonitor();
}
// Stopping monitors
private void Stop()
{
foreach (var host in Hosts)
host.StopMonitor();
IsMonitoring = false;
}
// Initializing a collection of hosts
public MainViewModel()
{
Hosts = new ObservableCollection<hostviewmodel>
{
new HostViewModel("192.168.1.1", "Wi-Fi Router"),
new HostViewModel("10.1.8.2", "Gate"),
new HostViewModel("10.0.0.66", "VPN Server"),
new HostViewModel("10.0.0.1", "DNS Server"),
new HostViewModel("google.com", "Google")
};
}
public override void Cleanup()
{
// Clean up if needed
if (IsMonitoring)
Stop();
base.Cleanup();
}
}</pre>
<p>That’s it.
<br />Note that in this step as well as in the previous one we don’t touch UI part at all. Nevertheless, the architecture of the application where WPF binding & commands are used, allows us to build an application where  ViewModels don’t know about UI, and Models don’t know about both ViewModels and UI. Good layered architecture, I’d say.</p>
<p>Here is the application. It works just fine, reacts on toolbar buttons’ clicks, refreshing the UI asynchronously without any freezing, using the resources of system ThreadPool:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="NetMonitor" border="0" alt="NetMonitor" src="http://lh4.ggpht.com/_iHnCjIZdGL8/TST4hkl18MI/AAAAAAAAATY/yzgCOygN6AM/NetMonitor%5B5%5D.jpg?imgmax=800" width="561" height="338" /> </p>
<p>As usual, I’ve pushed the modifications to the <a href="https://bitbucket.org/dmitri.maximov/netmonitor/overview">public repository</a>.</p>
<p>In the next post I’ll make the list of hosts configurable from outside the application code.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com5tag:blogger.com,1999:blog-6430948313608827732.post-47078398999372468912011-01-03T02:17:00.000+05:002011-01-03T02:17:58.210+05:00NetMonitor. Making Ping service<a href="http://dmitrimaximov.blogspot.com/2010/12/netmonitor-pt3.html">Earlier</a>, I created a UI prototype for the NetMonitor application, which from my point of view is good enough to do what it is intended to, according to the <a href="http://dmitrimaximov.blogspot.com/2010/12/comprehending-wpf.html">requirements</a>. Now it is time to add some brains to this piece of WPF.<br />
So, I have to create a service that will execute Ping command to the specified host in a background thread and return a message with Ping command results. As I don’t really need to ping the desired host thousand times per second, the service should be taught to take a break for a while between requests. <br />
What information will I need from the service? I guess, the following will be enough:<br />
<pre> public class PingServiceMessage : EventArgs
{
public string ErrorMessage { get; private set; }
public long RoundtripTime { get; private set; }
public IPStatus Status { get; private set; }
}</pre>
The service will have the simplest API one've ever seen:<br />
<pre> public class PingService : IDisposable
{
public event EventHandler<PingServiceMessage> PingCompleted;
public void Start() {}
public void Stop() {}
public void Dispose() {}
}
</pre>
What about the asynchronous implementation? The straightforward solution would be the usage of BackgroundWorker class per Ping service. It would take a delegate, execute it and return a result and then would sleep for a while without releasing its thread. Alex Ilyin & Alexander Nickolaev, my colleagues, would be indignant with such a solution. And you know, they would be definitely right. The solution is obviously resource consuming and is not robust.<br />
A good alternative is System.Threading.Timer class that provides a developer with the possibility to run a given method in a thread, temporarily taken from the ThreadPool. In this case a thread is being taken only for operation execution time and is released immediately after the operation is finished. This strategy is less resource consuming and more stable, because whenever an operation fails, the service won’t suffer and another thread will be taken next time.<br />
So, in order not to be beaten by my vigilant colleagues I’ve chosen the second option and implemented the service with the timer component. The entire implementation could be found in <a href="https://bitbucket.org/dmitri.maximov/netmonitor/src/39e5a0ef2bc4/Application/NetMonitor/Model/PingService.cs">the public repository</a>, I’ve only taken part of it:<br />
<pre> public class PingService : IDisposable
{
private readonly string target;
private readonly Ping ping;
private Timer timer;
public event EventHandler<PingServiceMessage> PingCompleted;
public void Start()
{
timer = new Timer(Run, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
}
public void Stop()
{
if (timer != null)
timer.Dispose();
}
private void Run(object state)
{
PingServiceMessage message;
try {
var result = ping.Send(target, 1000);
message = new PingServiceMessage(result);
}
catch (PingException e) {
message = new PingServiceMessage(e.Message);
}
if (PingCompleted != null) {
PingCompleted(this, message);
}
}
public PingService(string target)
{
this.target = target;
ping = new Ping();
}
}
</pre>
What is interesting here? Timer is created only in Start method. It is given the ‘Run’ method and is told to execute it every 2 seconds and wait for 1 second before the first time. Instance of Ping class is created in PingService constructor. It can be easily reused with a sequence of ping commands providing that Ping command timeout will be less than timer value. In my case, the timeout is set to 1000 ms, while timer value is set to 2 seconds. Seems to be OK. As there is no legal way to stop the timer other than call ‘Dispose’ on it, the ‘Stop’ method does exactly that. ‘Run’ method tries to execute Ping command with timeout set to 1000 ms and catches PingExceptions, if any. Finally, it notifies PingService listeners by sending a new instance of PingServiceMessage that might contain information about Ping command result or an exception message.<br />
<pre></pre>
Let’s check whether the service works. To do so, I’ve added a simple console application and used the service there:<br />
<pre> class Program
{
static void Main(string[] args)
{
var service = new PingService("192.168.1.1");
service.PingCompleted += PingCompleted;
service.Start();
Console.ReadKey();
}
static void PingCompleted(object sender, PingServiceMessage e)
{
var service = sender as PingService;
Console.WriteLine(string.Format("Reply from {0}: time={1} ms", service.Target, e.RoundtripTime));
}
}</pre>
Here is the result:<br />
<img alt="NetMonitorConsole" border="0" height="181" src="http://lh3.ggpht.com/_iHnCjIZdGL8/TRe-kibhjLI/AAAAAAAAAS8/Ql-OgcQmIzY/NetMonitorConsole%5B5%5D.jpg?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="NetMonitorConsole" width="427" /> <br />
Wow, works like a charm! =)<br />
In the next posts I will try connecting all these parts together.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-8281800329931933732010-12-29T12:26:00.001+05:002010-12-29T12:59:33.840+05:00Visual Studio 2010 vs. Inconsolata font, part 2<p>Recently, someone notified me that TTF version of popular Inconsolata font had released and is accessible <a href="http://code.google.com/p/googlefontdirectory/source/browse/inconsolata/?r=fffda675769720a297f4d239e7065f751bbe655f">here</a>. There were <a href="http://dmitrimaximov.blogspot.com/2010/08/visual-studio-2010-vs-inconsolata-font.html">some troubles</a> with the OpenType version of the font, so you had to convert it manually to TTF format in order to use in Visual Studio 2010.</p> <p>So, I’ve downloaded and installed it immediately. The font appeared in Visual Studio 2010 font list. Good. I’ve set it as a default font for text editor and what I’ve seen? Something unexpected:</p> <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Inconsolata in Visual Studio 2010" border="0" alt="Inconsolata in Visual Studio 2010" src="http://lh6.ggpht.com/_iHnCjIZdGL8/TRrirgFZUiI/AAAAAAAAATA/QYpmq7_ejLg/VS2010%5B5%5D.jpg?imgmax=800" width="445" height="143" /> </p> <p>All kind of braces are being rendered in bold, the same goes for semi-colon and comma symbols. But wait, may be the problem is not in VS2010 and the font has troubles? Let’s check the hypothesis and do the same in VS2008:</p> <p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Inconsolata in Visual Studio 2008" border="0" alt="Inconsolata in Visual Studio 2008" src="http://lh6.ggpht.com/_iHnCjIZdGL8/TRrqYhNVwbI/AAAAAAAAATM/WMFK4hony9k/VS2008%5B6%5D.jpg?imgmax=800" width="444" height="143" />  </p> <p>Looks amazing! </p> <p>Checking the hypothesis in Notepad:</p> <p> <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Inconsolata in Notepad" border="0" alt="Inconsolata in Notepad" src="http://lh4.ggpht.com/_iHnCjIZdGL8/TRrqZEMRPXI/AAAAAAAAATQ/vS6EJKScmSo/Notepad%5B6%5D.jpg?imgmax=800" width="441" height="140" /> </p> <p>Again, no problems. The font is really awesome.</p> <p>So what are the problems with that Visual Studio 2010 text editor? What were the reasons to change the bug-free and greatly working component from Visual Studio 2008 to this unreliable child of modern technologies? I don’t know.</p> <p>P.S. <br />If you find a workaround, please, notify me. Thanks.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com30tag:blogger.com,1999:blog-6430948313608827732.post-5151636623151145852010-12-21T01:15:00.002+05:002011-01-03T02:17:09.827+05:00NetMonitor. Choosing MVVM frameworkIn <a href="http://dmitrimaximov.blogspot.com/2010/12/comprehending-wpf-pt2.html">the previous post</a> I created a sketch of my small application with the help of Microsoft Expression Blend 4. Among other great features of the development suite there is a one that makes Blend outstanding -- it produces working XAML files, so every single UI screen in your sketch is represented as a separate UI control and the corresponding XAML is more or less ready for copy-pasting to the real application. This makes Blend the most preferable suite for sketching of WPF applications.<br />
Let’s go further. When we are speaking about WPF we mean MVVM pattern and vice versa. What is MVVM? It is a concept that is derived from Model-View-Presenter (Model-View-Controller) pattern. There are several great articles about it, for example, I’d recommend <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx">this one</a> and <a href="http://weblogs.asp.net/dwahlin/archive/2009/12/08/getting-started-with-the-mvvm-pattern-in-silverlight-applications.aspx">this one</a>. AFAIK, there are two featured MVVM frameworks: <a href="http://mvvmlight.codeplex.com/">GalaSoft MVVMLight</a> & <a href="http://caliburn.codeplex.com/">Caliburn</a>, both of them are targeting WPF & Silverlight. I chose the first one, MVVMLight, as a base for my application because it is said that the framework supports designing in Blend, and that’s what I want.<br />
So, I installed MVVMLight and created a new project based on MVVMLight WPF Template, added HostViewModel class, which describes the required information about a host and its health, and MainViewModel class that contains a collection of HostViewModel instances and a pair of commands, Start & Stop, which are derived from RelayCommand. After that I adapted the above-mentioned “Screen_1.xaml” from the sketch project. Here it is:<br />
<img alt="NetMonitor 02" border="0" height="336" src="http://lh4.ggpht.com/_iHnCjIZdGL8/TQ-5Za-_GcI/AAAAAAAAASw/_ZDD0u-5q24/NetMonitor%2002%5B5%5D.jpg?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="NetMonitor 02" width="560" /><br />
For now, commands do nothing and the hosts information is static rather than live. Nevertheless, after a short period of work I’ve got a prototype that is written on WPF & MVVM and even shows something.<br />
So, the UI part of <a href="http://dmitrimaximov.blogspot.com/2010/12/comprehending-wpf.html">the requirements</a> is almost done. In the next posts I’ll try creating a Ping service and make use of it with the help of Start and Stop commands.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com2tag:blogger.com,1999:blog-6430948313608827732.post-26700005376097919542010-12-17T02:01:00.003+05:002011-01-03T02:16:00.698+05:00NetMonitor. Prototyping with Expression Blend 4In <a href="http://dmitrimaximov.blogspot.com/2010/12/comprehending-wpf.html">the previous part</a> I listed the requirements to the application. According to the good practice of program development, I’ve decided to start with UI and make a sketch of main application window.<br />
Earlier I used to play with 2 superior mockup tools, <a href="http://balsamiq.com/">Balsamiq Mockups</a> and <a href="http://pencil.evolus.vn/en-US/Home.aspx">Evolus Pencil</a>, but today I’ve decided to try Microsoft Expression Blend 4 because it was specifically designed for WPF-based application development. After several tryouts I’ve managed to make a sketch of the application. Main window has 2 buttons and a list with hosts, each of them contains 4 pieces of information (Host name, IP address, Response time and Health). The sketch looks as follows:<br />
<a href="http://lh4.ggpht.com/_iHnCjIZdGL8/TQp-LM6BqvI/AAAAAAAAASQ/ue4HrNzPz-8/s1600-h/NetMonitor%20Sketch%5B16%5D.png"><img alt="NetMonitor Sketch" border="0" height="237" src="http://lh3.ggpht.com/_iHnCjIZdGL8/TQp-MYhTa0I/AAAAAAAAASU/X-MdsL5zCms/NetMonitor%20Sketch_thumb%5B5%5D.png?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="NetMonitor Sketch" width="400" /></a><br />
I know that there are some troubles with text alignment and may be many others but don’t forget that this is only a sketch and the only purpose of it is to show how the application might look like without extra details.<br />
Here is the main window of Expression Blend 4, as it was in the middle of the sketching process:<br />
<a href="http://lh5.ggpht.com/_iHnCjIZdGL8/TQp-MzhHxsI/AAAAAAAAASg/ur_ooNiMHlk/s1600-h/Expression%20Blend%20Full.%5B5%5D.jpg"><img alt="Expression Blend Full." border="0" height="333" src="http://lh5.ggpht.com/_iHnCjIZdGL8/TQp-N1xfbqI/AAAAAAAAASo/Pz3kX4uri7w/Expression%20Blend%20Full._thumb%5B3%5D.jpg?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="Expression Blend Full" width="500" /></a> <br />
As you may notice, in the left lower corner is the structure of the application. I’ve put a DockPanel inside the LayoutRoot and inserted there a ToolBar with Docking=Top & a ListView, which automatically took the rest of space. After that I’ve created a sample data source and bound it to the ListView. That’s it, my sample data immediately appeared in the ListView. During these operations I saw nor XAML neither C# code.<br />
The sketch is ready, it even can be run in special Sketch Player (another great feature of Expression Blend 4) so customers can play with it, make comments and criticize. The next step will be transforming the sketch into a real application and start building network services.<br />
In case anyone is interested in the source code, I’ve opened a <a href="https://bitbucket.org/dmitri.maximov/netmonitor/overview">public repository</a> at the bitbucket.org, so anyone could get the sources, play with them and even add any valuable stuff.Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com2tag:blogger.com,1999:blog-6430948313608827732.post-31135446319193901552010-12-16T00:03:00.001+05:002010-12-16T00:03:58.621+05:00Express Software Releasing Challenge<p>I’ve been thinking that <strong>Chrome browser team</strong> is the champion in super fast release building. According to <a href="http://en.wikipedia.org/wiki/Chrome_(browser)#Release_history">Wikipedia</a>, they managed to deliver 5 major revisions, from 4.0.249 to 8.0.552 within 2010 year, and I’m not sure that they won’t release the 9.0 before the New Year.</p> <p>I’ve been thinking so until I opened my RSS reader today and found out that there is another pretender to this title, and its name is: <strong>Opera browser team</strong>, my congratulations! They managed to deliver 3 Release Candidates within a day. Here is the proof:</p> <p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Opera RC" border="0" alt="Opera RC" src="http://lh3.ggpht.com/_iHnCjIZdGL8/TQkRHR08ILI/AAAAAAAAASM/LT909dLhLrE/Opera%20RC%5B5%5D.jpg?imgmax=800" width="635" height="218" /> </p> <p>Frankly speaking, I’ve never seen anything like this in my whole life. What a speed!</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-79578412236323780412010-12-12T02:28:00.002+05:002010-12-21T01:17:14.604+05:00Comprehending WPF. NetMonitor<p>About a month ago I wrote <a href="http://dmitrimaximov.blogspot.com/2010/10/on-wpf.html">a post</a> about the overall complexity of WPF technology, steep learning curve and other things that might be perceived as roadblocks, especially for novices or old-school WinForms programmers.</p> <p>After that I had several intensive discussions with my colleagues on the subject and they told me one important thing, the main idea was that the technology just <em>seems</em> to be overcomplicated, especially from the first look, when you don’t see the overall picture how it is built, how it works and how it should be used. Another thing that is worth mentioning is that the architecture is reasonable, because it gives a UI designer the required flexibility and power, which WinForms just can’t provide and this very fact can only be seen on complicated UI scenarios, not on simple ones.</p> <p>As a result, they persuaded me to take a closer look on the platform and give it another try. And I did so. They say that abstract theoretical knowledge can’t compare with practical one, so I decided to make something small but more or less useful on WPF and therefore, get some practical knowledge of the technology. </p> <p>I’ve set my choice on a little handy tool that will monitor and report the health of my network. For now the most quick and simple way to check the health is to open several Command Prompt windows and run a Ping command to various hosts in the network starting from my own router, then gate, VPN server, etc. and ending up with globally available hosts like google.com or similar. So you have to look at all those console windows, process and aggregate their logs and make a conclusion where the real problem is. As you might imagine, this way is neither convenient, nor informative, and finally, I’ve decided to create a better solution.</p> <p>I’ve started with requirements. What are they?</p> <p>The most important thing is to invent a codename. I’ve chosen a self-describing name — <strong>NetMonitor</strong>, why not?</p> <p><strong>UI</strong></p> <ul> <li>The main window shows a predefined read-only list of hosts and an average response time from Ping command. </li> <li>Each host has a name and a valid internet address. </li> <li>Two buttons start and stop the process of pinging. </li> </ul> <p><strong>Internals</strong></p> <ul> <li>In order the UI thread not to be frozen while waiting for Ping command response, each host pinging procedure must run in a separate thread. </li> <li>Sending a Ping request once a second will be enough for monitoring tasks. </li> <li>List of hosts for pinging should be configured from outside the application code, say, in app.config file or something. Personally, I don’t like xml configuration files, so i will try using ini file instead. </li> </ul> <p>That will be enough, at least for the first version. </p> <p>In the next posts I’ll write about the process of building the application.</p>Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-32462204435987480092010-11-08T19:39:00.001+05:002010-11-08T19:39:07.031+05:00On ASP.NET<p>As you might suppose, I don’t like ASP.NET also. It adds unnecessary complexity and generates tons of garbage inside webpages (not to mention ViewState), pretending to solve such a simple task as building html application.</p> <p>Take a look at this piece of <strike>shit</strike> code, which represents an ordinary checkbox:</p> <p><code><input id="ctl00_ctl00_ctl00_ContentPlaceHolder_ContentPlaceHolder_ContentPlaceHolder_formProfile_checkBoxSubscription" type="checkbox" name="ctl00$ctl00$ctl00$ContentPlaceHolder$ContentPlaceHolder$ContentPlaceHolder$formProfile$checkBoxSubscription" checked="checked" /></code></p> <p>I’ve found it in a common ASP.NET page, imagine how much pieces of such creepy code in the Internet.</p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com0tag:blogger.com,1999:blog-6430948313608827732.post-42923011658838259032010-10-27T01:30:00.001+06:002010-10-27T01:41:30.338+06:00On WPF<p>Recently, I’ve get interested in practical usage of WPF technology and, as an obvious result, I’ve encountered plenty of obstacles as the technology is not as clear and straightforward as Windows Forms was. </p> <p>I agree that from the theoretical point of view, WPF might be considered as a great step forward, but from practical one it is likely to be 2 steps backward. It is overcomplicated, it requires you to forget the well-known time-proven UI concepts and techniques, and to spend weeks and months on studying the brand new one. And even after that you can’t be sure that you are doing things right just because almost all things could be done in plenty of ways: code, styles, templates, etc. Not to mention the absence of several must-have controls in standard library, such as DataGrid, DateTimePicker, MaskEditBox, etc. on the moment of .NET 3.5 initial release. What are they hoping for? I don’t understand. Frankly speaking, it seems that WPF is bringing much more problems than it tries to solve. Remember blurry fonts and images, long application startup time, etc.</p> <p>Moreover, I’m not alone in these thoughts. The Internet is full of stories on the subject. For example, when I was trying to find a solution for one of problems which could be easily solved in Windows Forms, I’ve bumped into an interesting and rather emotional post, which is titled as “<a href="http://apocryph.org/2007/08/26/what_hell_wrong_wpf/">What the HELL is wrong with WPF?</a>”. Don’t miss it as well as its comments.</p> <p>Some quotes: </p> <p>- <em>“Using WPF I can easily make a button which contains a spinning 3D cube playing videos on each face that turns green when the mouse goes over it, all without any C# code. Unfortunately, no one would ever want to do that, while it’s easy to imagine a situation wherein you’d want toolbar icons to gray themselves (like, I dunno, every Windows application ever made).”</em></p> <p><em>- “I fucking hear ya! I’m also struggling with this shit every day just to discover that MS – again – really went out of their way to accommodate every possibility imaginable but rendering the whole system/concept unusable on the way.”</em></p> <p><em>- “…I mean SERIOUSLY? What the fuck man! Win forms were a beauty, then why the flying fuck you want to release something ENTIRELY different and say that its the way forward especially when winform isnt broken. I mean why fix something when its not broken. <br />I am so sick of MICROSOFT and their policy of shoving their crappy pieces of junk software down our throats. They know people are smart and don’t want their shit, so they start issuing threats of disengaging old software unless you buy the new one.”</em></p> Anonymoushttp://www.blogger.com/profile/07143844311415529548noreply@blogger.com3