Microsoft loves programmers

I’ve just read a blog about a few new additions to C# 3.0 and in the context of what we’ve already learned about the whole “Orcas” project that is the simplest conclusion.

Microsoft .Net Framework designers and coders are just a bunch of programmers who you can clearly see enjoy hat they do. I can’t stress enough how many times I’ve been annoyed to be forced to wrap some private variables in the obvious public properties. No longer!

Instantiating a class followed by a bunch of setting of properties? Now done in one line. Shweet.

One may argue that C# is a set of such syntactic sugar. But then again, I am sure that’s why so many programmers really like it. Even some of the most Java oriented programmers (Yes Albert I’m looking at you!) in our company are looking forward to work on .Net.

It is the general perception here that, comparing to Eclipse, Visual Studio is a weak IDE in terms of pure code-writing-helpers, refactoring, and discovery of code dependencies. Only the next version will even be able to target more than 1 .net framework version… Please fix that crap… But the language designers are continually doing a great job.

Have a read on some:

Microsoft ,may be the most annoying company in any other context, though you can’t help but to feel that sweet and sticky loving goo leftover on your cursor avery time you flip a page….

Skype GeoLocation Tool

Download source files – 103 Kb
Download the Skype Geo Location tool – 52 Kb

Application GUI

Introduction

It’s a real joy to work in a international company, the problem we face are hardly ever matched by some locally based endeavours…

As some of our friends here at work, you may choose to reveal your current location to your skype buddies. This is nice and easy since you can just put it in your name or description and everyone will see where you are.This poses a problem should you really travel frequently, it is more likely than not, that your location tag will be out of sync.

As this is a something that happens for them once in a while I found it an interesting concept, fun enough to be worth solving it :)

So how does one establish his location? Short of installing a GPS on your machine, I would suggest checking your IP address and translating it based on one of the available databases.

The thought process goes as follows… [Read about the technical guts of the application in my article at Code Project]

The Convergence – The Application

The application helps you maintain your location tag in your name so that whenever you travel to a different town your skype name/description will reflect it.

Disclaimer: The application uses GeoIPTool as its source of IP and geo-location. Visit GeoIPTool for a wide variety of web based geo-location tools.

It does not contain either any kind of tracking abilities other than it letting you to maintain your location tag. The application will not even change your location tag by itself but rather it will notify you that your location has changed and will allow you to change your tag with a simple press of a button.

Usage
In your skype account set your name or description so that it has [] in it or press “Add location tab to…” in the application. Whenever the application will find those it will check if the text in the parenthesis matches your current location., if it does not it will suggest a new one and will highlight the relevant field red. You may set for this operation to be performed on every boot, you will however only be notified when/if your location actually changed.

Posted in .Net Framework, C#, Downloadable, Lifestyle, Software, Software Development, Web applications
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...
| 102 Comments »

My first meaningful EPiServer control… z Biedronki* :)

The challenge – The site that we will be coding will have its pages tagged with episerver categories. Implement a control that will list all the pages tagged with a specific category.
The control aspx code seems looks pretty straightforward and is derivative of some other controls that are defined in the EPiServer sample site:

<%@ Control Language=”C#” AutoEventWireup=”false” CodeFile=”CategoryListing.ascx.cs” Inherits=”development.templates.Units.CategoryListing” TargetSchema=”http://schemas.microsoft.com/intellisense/ie5″ %>

<%@ Register TagPrefix=”EPiServer” Namespace=”EPiServer.WebControls” Assembly=”EPiServer” %>

 

<div id=”rightmenudivStartPage”>                       

    <div class=”listheadingcontainer”>

        <div class=”listheadingleftcorner”></div>

        <a class=”listheading leftfloating” href=”<%=EventRootPage.LinkURL%>“><%= EventRootPage.PageName %></a>

        <div class=”listheadingrightcorner”></div>

    </div>

 

    <EPiServer:PageList runat=”server” ID=”PageList1″>

        <ItemTemplate>

            <div class=”startpagecalendaritem”>

                <span class=”datelistingtext”>

                <episerver:property ID=”Property1″ runat=”server” PropertyName=”PageLink” CssClass=”StartCalendar” />

                <span class=”Normal”><episerver:property ID=”Property3″ runat=”server” PropertyName=”MainIntro” /></span>

            </div>

        </ItemTemplate>

    </EPiServer:PageList>

    <br/><br/>

</div>

The wirst thing you will notice after looking at the code is that PageList is pretty much a standard ASP.NET reinvented and rehashed. GREAT! Sounds like we can use the Data binding, right? That’s also true:

private void Page_Load(object sender, System.EventArgs e)

{

    if (!IsPostBack)

    {

        PageList1.DataSource = CategoryPages;

        DataBind();

    }

}

Does the trick of binding the data to the repeater… uh… oh… sorry… I mean PageList.

Now comes the hard and non-obvious part.

How does one actually find the pages assigned to a category? Short of calling the database directly to query the tblCategorypage table that comes to mind at first, it looks like EPiServer has a really cool page finding module that allows for simple yet fairly effective discovery of pages conforming to some developer defined criteria. Those criteria are defined by means of forming any necessary number of instances of PropertyCriteria class provided as a PropertyCriteriaCollection to Global.EPDataFactory. The result is handed to us back as a PageDataCollection. The fetching of the pages looks like this:

public PageDataCollection GetCategoryPages()

{

    PropertyCriteria criteria = null;

 

    CategoryList categories = ((PropertyCategory)(CurrentPage.Property[“AggregatedCategory”])).Category;

 

    criteria = new PropertyCriteria();

    criteria.Condition = CompareCondition.Equal;

    criteria.Type = PropertyDataType.Category;

    criteria.Value = categories.ToString();

    criteria.Name = “PageCategory”;

    criteria.Required = true;

 

    PropertyCriteriaCollection col = new PropertyCriteriaCollection();

    col.Add(criteria);

 

    PageDataCollection pdc = new PageDataCollection();

    pdc = Global.EPDataFactory.FindPagesWithCriteria(EPiServer.Global.EPConfig.StartPage, col);

 

    return pdc;

}

For this to work though, one has to define some more stuff in the web admin part of the site. the usual task is to define the Page Template for the control. In this case when you define the Page Template make sure to put the “AggregatedCategory” property in that should be of type Category selection. This property defines what categories you want your control to aggregate, and you can provide one or more of those. the other property that is required for this very control is “CategoryContainer” of type Page. This is solely for the purpose of having a master page that you define as the “main page” for the chosen category selection. It serves as a clickable header in the control. Unnecessary maybe but one would have to define a caption for the control anyway so why not make it meaningful.

The usage of the said control is trivial. A sample usage on the default EPiServer site looks like this:

<%@ Page language=”c#” Codebehind=”CategorySummary.aspx.cs” AutoEventWireup=”false” Inherits=”development.Templates.CategorySummary” %>

<%@ Register TagPrefix=”EPiServer” Namespace=”EPiServer.WebControls” Assembly=”EPiServer” %>

<%@ Register TagPrefix=”development” TagName=”CategoryListing”  Src=”~/templates/Units/CategoryListing.ascx”%>

<%@ Register TagPrefix=”development” TagName=”DefaultFramework”    Src=”~/templates/Frameworks/DefaultFramework.ascx”%>

 

<development:DefaultFramework ID=”DefaultFramework” runat=”server”>

    <EPiServer:Content ID=”Content1″ Region=”fullRegion” runat=”server”>

        <development:CategoryListing  ID=”CategoryContent” runat=”server”/>

    </EPiServer:Content>

</development:DefaultFramework>

Out of which really only the <development:CategoryListing  ID=”CategoryContent” runat=”server”/> part is meaningful.

For the record… It looks like THE place to go to solve that kind of dilemas fast is the EpiServer “Developer to Developer” forums.

*)… couldn’t ressist with the title joke :) For those not in subject… It’s a reference to a silly commercial of one of the market chain (Biedronka) in Poland that advertises recently with “My first *something*… from Biedronka*

Cognifide
The article is based on the knowledge I’ve gathered and work I’ve performed for Cognifide. Cognifide is an official partner EPiServer and the real contributor of the the control.

Posted in ASP.NET, C#, EPiServer, Internet Information Services
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...
| 21 Comments »

Most of us here use Pandora for the listening to the music with their headphones.

The keyboards we have at the office do not have any sound volume adjusting keys.

It’s mildly annoying that you need to take off your headphones every time someone talks to you or click the system tray every time the musinc is too quiet or too loud. But hey! What do we have CodeProject and Visual Studio for?

Quick investigation on CP allows to determine that there is a way for a DotNet app to both control the system volume and hook the keyboard events fairly easily.

Half an hour later…

We have a little tray application for adjusting the system volume control

The only visual indication of the app running is a tray icon. While it is running you can:

  • Ctrl + Alt + Up Arrow – Volume up
  • Ctrl + Alt + Down Arrow – Volume down
  • Ctrl + Alt + Scroll Lock – Mute / Unmute
  • Click the icon to het a baloon tooltim with those hints
  • Right click the tray icon to close the app.

The icon has been taken from the Dement?con icon pack by MindlessPuppet.

Posted in .Net Framework, C#, Downloadable
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
| 3 Comments »

Linkage

I’ve done some research about Visual studio plugins recently, just so that I can close the tabs and move on here are some links that I cound to contain some useful information:

UpTime.Net

PerformanceCounter pc = new PerformanceCounter(“System”,
    “System Up Time”);

 

//Normally starts with zero. do Next Value always.

pc.NextValue();

TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());

MessageBox.Show(Environment.MachineName +

    ” has been up for \n\n” +

    (ts.Days < 1 ? “” : ts.Days + ” days, “) +

    (ts.Hours < 1 ? “” : ts.Hours + ” hours, “) +

    (ts.Minutes < 1 ? “” : ts.Minutes + ” minutes “) +

    ” and “ + ts.Seconds + ” seconds.”);

Nice, neat and simple.

Get a compiled executable here

Posted in .Net Framework, C#, Downloadable
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
| 30 Comments »

How to get Website Thumbnail in C#

[Edit: I’ve posted it on CodeProject and there are some greatl people commenting on it that did the investigation on ho to wrap it in a STA Thread and make it a part of your ASP.Net solution – really cool stuff!]

An interesting use case. Darek (our beloved sys admin – we all bow to him and worship his skills) has recently asked if it?s possible to write a .net application to make a thumbnail of a website. Which is pretty trivial with Windows forms actually.

All you really need to do is drop a WebBrowser on your form and once it?s loaded the page call:

webBrowser.DrawToBitmap(bitmap, bitmapRect);

When it gets tricky is when you want to do it in a console application is a way that can take a shot of multitude of websites provided in a batch file. There is a dirty way of instantiating a whole form, making it show (or not), doing the work and then exiting the Winforms app. Which might probably be enough for a quick solution, but I wanted to publish this piece of code, so I would actually NOT take a pride in something like that.

How is it done the proper way then? Read the rest of this article »

Posted in .Net Framework, C#, Downloadable, Software Development, Web applications
1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 4.29 out of 5)
Loading...
| 150 Comments »

ClickOnce

The new project is really exciting. Not that we didn’t expect that, the number of new technologies we get to explore is incredible.

I’ve just finished setting up an automatic build and deployment (of a desktop application) environment consisting of SVN+Nant+CruiseControl+ClickOnce. The system is centered around CruiseControl which detects any commit in the trunk in the SVN repository and every time it’s changed, it calls Nant to pull source code from our SVN, at which point it compiles the source into binary artifacts and put them up on our release server. This means that every time you change anything and commit it to the repository – a minute or two later – any tester can get a working copy of your build to look at, without any intervention on your part, but there’s more…

The app can check on every start whether there is a new build available, so you can basically be pretty sure the tester has the latest copy of your app rather than wondering if they failed to update it. This alone takes a lot of pain off of the testing. It should also help out customers in the deployment of the highly distributed system that we’re working on.

It even installs a shortcut on the user’s Start Menu.

One caveat, which should not be much of a problem once we have the release page properly implemented is that even though you may get an initial feeling that it should work in your preferred browser, unless the preferred browser is Interned Explorer or derivative (or one of multiple of wrappers around IBrowser). The biggest problem as I see it now is that the bootstrap setup app looks like it should work but is broken on the server, while this is not the case.

You may also need to alleviate security restrictions on the site that you’re pulling the app form since it looks like it has a problem even with IE for one of our co-developers.

Some links I’ve gathered while implementing it:

Posted in .Net Framework, C#, Software Development
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
| 3 Comments »

Learning C#

I?m about to help a few guys here with their transition from Java to .Net, namely to C#. 

I thought it may actually be a good idea to gather a few helpful links together for you. Stuff I found useful while I was phasing into the joys of the .Net framework a while ago.

The official stuff

First and foremost C# is an ECMA regulated standard. And as such is pretty well documented. ECMA allows you to download PDF e-books regarding the standardized part of the language:

The books are a free download, you could theoretically request the books in printed form (for free) which I did back in my time when I was learning C# but it looks like they have a strict publications ordering form with a combo box of publications which? surprisingly do not list entries 334, 335 or 372. I suppose there was a big number of those smart guys who smelled free books? and the trees were crying.

There is also a good explanation (although highly redundant) on MSDN pages.

Hint: I highly suggest that you read the Garbage collection part of that. It REALLY helps in your day-to-day problems.

I have to say I?m really impressed by the official documentation. I was initially trying to shop around for some C# books back in my days of learning but since there seemed to be none that were both accessible here without waiting for a month or so for delivery and worthwhile I reverted to official docs. And I can tell you, THEY ROCK.

For all your ASP.NET need visit? surprise, surprise? ASP.NET official page.

You may also want to read up on the IIS official page for getting accustomed with IIS. For what it?s worth, there are some articles here.

I would say? don?t buy any books for it, it?s all there and it?s written really well.

All in all, I?m really impressed at how well this stuff is documented, Microsoft really did a great job here. Makes me feel taken care of. But after all? when in doubt – throw money at it.

The good stuff

It looks like for almost every problem you may have there is a simple, clean and not-quite-accurate solution out there.

For those I usually look at CodeProject. Amazing how many of those unique problems you may have, are not so unique. Just put up a proper filter (C#, .Net, ASP.NET) and fill in a few words. Amazing stuff there.

.Net framework does not fully cover all the old stuff of the WinAPI. I do not suspect we will need much of it here, but if you ever needed to use some legacy windows DLL access for stuff not directly supported by the platform (like e.g. speedy reading INI files, or manipulation of Windows handles to get a per-pixel translucent windows ) there is a cool site that helps, which is called exactly like the gears that are used to do it – Pinvoke. There are other marginally useful sites like CodeGuru, DevX or C#Corner but I don?t use them nearly as much as CodeProject or Google.

Hint: when on Google try to use Google Groups rather than just the Google Web search engine.

Posted in .Net Framework, ASP.NET, C#, Software Development
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
| 18 Comments »

It?s the era of XBOX 360. Is Playstation 3 stillborn?

Those that met me more than once know what a geek I am, my eyes basically glow on a sight of a cool new gadget. My wife on the other hand, couldn’t care less, she is as far from a geek as it gets. An email? Something needs to be found on The Web? Why learn anything when you have a guy next to you doing it all for you when you need it, and being hapy about it too!

That’s probably the essence of the presence of an Xbox in our house. This little toy (ok it’s not quite little, in fact it’s huge when you compare it to any other console on the market) is basically a fully featured computer connected to a TV. But you won’t see us gaming on it, nor enjoying any Xbox live action. With a little help of google and some creative hacking you can turn your Xbox into a fully fledged media center for the family. Why should I juggle the DVD’s when I can have them conveniently stored on the Xbox (it’s got its tine 8GB hard disk replaced with a 120GB one) when you can conveniently lay on a couch with a remote in your hand and enjoy your whole DVD and music collection being just a remote control click away?

Check out the cool things they’ve done with the old Xbox.
And a review on Tom’s Hardware.
It’s got my music, it stores all my digital photos and I even ripped a few movies to it. And the most important thing that was actually the key for the purchase of it is – it’s completely maintainable by all of my girls! Heck even the youngest (2.5 year) play cartoons on it.

The key was to make the XBMC the dashboard (meaning it’s the app that’s shown when you start your Xbox).

And although the original Xbox was protected against using third party code by means of only running an MS signed code, this protection was quickly removed and there seems to be a galore of semi-legal apps being available for it.

Now it’s essential to mention that MS really seemed to have little incentive to let us do it. The Xbox division has been a total money sink for them since day 1. They literally lost billions on the deal. The model was to make money on licensing the platform to game developers and take a cut out of any game that’s being sold for it. Obviously it didn’t work. The division had only a single quarter profitable (when they shipped the highly succesful Halo2).

Now it turns out that they no longer intend to go with that model (at least for the moment) as reported in those articles:
XNA game development platform will be free for Windows, $99 for Xbox (Tom’s Hardware)
Microsoft Opens Up Xbox 360 Game Development to Everyone (Paul Thurot)
Play your own Xbox game (ZDNet)

Tom’s hardware says:

Microsoft developers report the first beta of XNA Game Studio Express will be made available on 30 August, with a final edition released – still for free download – before the holidays. The product requires Visual C# Express, but that’s also free.

Now how cool is THAT!?

Microsoft is no longer going to limit the development of the games to the few chosen but rather will open it to anyone. Is is bad for giants like EA or Vivendi? Not likely, the indies don’t really have the capital to give them any serious competition in the supper production games like halo2 or NBA stuff. It is however great for the wide range of developers that used to make PC games. The PC games marked has been on decline for quite a while. While console games sell in hundrets of copies, a PC game is lucky to sell a few thousand. If Microsoft will not charge them a hefty price for distribution, this may be a great move for XboX 360 since they can still make a lot by the volume of sales for the platform and it’s good for the platform since it will make lots of new titles made available for it.

Let’s see whom else does it benefit… how about the other most succesful to date gaming platform from Microsoft? Yes – Windows. I think one of the not so many true platform locks for Windows users are games. while people buy computers for their home to work and browse and send emails they definitely want to be able for their kids to be able to play on them, or actually, since the target audience for the majority of games seems to actually be people in their 30’s, they buy them to game themselves. Let’s see… how many big game titles got released for linux last year? Anyone? If any you would probably be able to count them on the fingers of one hand. That definitely locks quite a few people in the Windows platform. And if that’s going to be a platform majority owns at home, they will actually demand them at work, so the circle closes.

But whom is it targeted against? I would say the whole push has been engineered to hurt Playstation 3.

There is no way Sony can pull a stunt like this. They have absolutely nothing to gain from opening their APIS and even if they did… Xbox OS is basically a fork off of Windows 2000, while PS3 is a totally different infrastructure, if it was even possible, it surely would not be fun. Add to that the stupid things Sony does with their DRM and the patent they filed on tieing a game you bought to a specific console and you’ve got the picture. The Playstation series is dead. DEAD!

So, up till today it was hard (and not-quite-legal) to make any unauthorized software for the Xbox, and as far as I know impossible to make it on Xbox 360. This is going to change, and soon enough we will have things like XBMS available for the x360

I guess what I wanted to say in the end is – I cannot wait to replace the old and clunky Xbox with a new shiny 360 one… and there are rumours that for only an additional $200 I can get a HD-DVD for it soon enough!

Posted in .Net Framework, C#, Lifestyle, Software Development
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
| 17 Comments »