Supertext Home
Chief of the System Blog

Collection was modified; enumeration operation may not execute

July 29th, 2009 by Remy Blaettler

Ever tried to remove or change something in a C# Enumeration while you iterate over it? Yes, it does not work very well.

But there are ways around it.

foreach (Item item in items.ToArray())
{
    if (item.Visible == false)
    {
        items.Remove(item);
    }
}

The simplest way is to use ToArray(). No much coding, no complicated loops, but obviously not very efficient for larger lists.

A few alternatives are presented by Kevin Ransom.


Float Drop Problem

July 14th, 2009 by Remy Blaettler

For our Orders, Jobs and Documents pages we switched from using tables to using lists (ul/li) with left floating div’s. This is nice in terms of modern CSS driven HTML and is easier to adopt to the iPhone. But it does bring a few issues with it. For example that the div’s tend to drop below the one on their left if the content is too large and they have no size attribute.

I’ve built a page where I tried out different ways to prevent this with example code.

Float Drop Examples

What we used at Supertext is to have the 2nd column with a fixed position. But this is only possible if you have only 2 columns and if the width of the first column is fixed too.

 

<div> <div>Test</div> <div style="position: absolute; left: 40px;"> <b>Long Text and very long Text. Long Text and very long Text. Long Text and very long Text.</b><br /> </div> </div>

Let me know if you have a better solution!


Breadcrumbs to indicate the Checkout Progress

June 18th, 2009 by Remy Blaettler

According to webdesignpractices, about 45% all all major websites use Breadcrumbs in some way. Either to help navigation or to indicate some type of progress.

At Supertext we didn’t do anything like this so far. During the ordering process, we just had a title to tell the user at which step he was and some info about the order on the right column.

Supertext Order Process

So we tried a simple approach by just adding some text breadcrumbs into the title bar this like this:

Process with Breadcrumbs (Bad example)

But this example is bad for multiple reasons:

  1. No indication where the user is at the moment. Address should be highlighted or in a different color.
  2. No information about the following steps
  3. Look and feel is poor

We’ve now decided on something like this:

New Version

Just look at the new part below the title. There some other changes on this mockup too. Just ignore them. They will go online later this year. What do you think? It covers pretty much all issues that I mentioned above. No?

We modeled it after the example from swiss airlines:

image


Here are some other examples we looked at:

image

Doodle with their KISS approach. Not really breadcrumbs, but gives a progress indication too. Just not much more.

image

Did you find them? On the upper right corner. Yeah, I had to search for them too. But it’s all there. Where I am, next step, last step. But it does have some potential for improvments :-)

image

Another nice example is Amazon with the cart indicating where I am. Maybe we could use a pencil for Supertext?

image

Not very surprising, Apple also delivers with a simple yet elegant solution.


Another article that covers some of these topics is 12 Tips For Designing an Excellent Checkout Process on Smashing Magazin.



Using Log4Net for a Windows Console Application

February 11th, 2009 by Remy Blaettler

Most examples with Log4Net are with ASP.NET, but it works perfectly fine with Windows Form and Console Applications too.

What you need is an App.config file that you add to your project.

<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" /> </configSections> <!-- Log4net Logging Setup --> <log4net debug="false"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="C:\\directory\\supertext_outsidetasks.log"/> <param name="AppendToFile" value="true"/> <maxSizeRollBackups value="10"/> <datePattern value="yyyy-MM-dd"/> <rollingStyle value="Date"/> <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/> <layout type="log4net.Layout.PatternLayout"> <header value="Date | Level | SessionID | Logger | Message | &#xA;"/> <param name="ConversionPattern" value="%date{ABSOLUTE}| %-5p | %-30logger| %m|%n"/> </layout> </appender> <root> <priority value="DEBUG"/> <appender-ref ref="RollingLogFileAppender"/> </root> </log4net> </configuration>

Then initialize it in your main() function:

using log4net; using log4net.Config; static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); //your code }

And you can use it like in ASP.NET:

log.Info("Hello Logfile");

The only issue I had was that adding the configSection like this did not work:

<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> </configSections>

I had to add the whole shebang with Version, etc. to it. Then it started working. Anyone else had that problem?

Anyway, are people still using Log4Net? There is not much activity on the project anymore and the last version is getting pretty old.


Change a CSS Control Adapter in Code

November 11th, 2008 by Remy Blaettler

I run into a situation where I needed different CSS Control Adapters for the ASP.NET Menu Control for differnent browsers, in my case a default one and one for the iPhone.

So my first idea was to just put multiple controlAdapters sections into a .browser file, but for whatever reason that did not work (I still think this should work somehow, if you have the answer, let me know). Then I was looking to just change the adapter in my code, but even Scott Guthrie said it’s not possible. Ok, time to call it a day and get a beer (or two).

But who cares if the Corporate Vice President in the Microsoft Developer Division says it’s not possible, lets go at it again. Eventually I found this post. If it is possible to add and remove Adapters at run time, it clearly has to be possible to change them, no? And indeed, it is possible:

protected override void OnPreInit(EventArgs e) { HttpContext.Current.Request.Browser.Adapters["System.Web.UI.WebControls.Menu, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"] = "Supertext.Adapters.iUiMenuAdapter"; base.OnPreInit(e); } protected override void OnUnload(EventArgs e) { base.OnUnload(e); HttpContext.Current.Request.Browser.Adapters["System.Web.UI.WebControls.Menu, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"] = "CSSFriendly.MenuAdapter"; }

Just add the above code to your aspx page and change the key/value pair appropriately. You can iterate through the Adapters list to get a better idea what is in there and how to replace it.

Now, this is not exactly a schoolbook code sample, but it works and it’s just intended to give you kick in the right direction. In that sense, please no of these “this is unmaintainable code” comments. Thanks!


iPhone as a Modem (Finally)

November 10th, 2008 by Remy Blaettler

One of the bigger drawbacks of the iPhone has always been that you could not use it as a modem together with your laptop (also called tethering). Obviously AT&T is not very interested in that, since you pay a flat rate for iPhone data plan. With other phones you always need a special plan if you want to use tethering.

IMG_0004

But now, thanks to PDAnet you can use your Jailbroken iPhone as a modem too! Installation is a breeze, assuming you have Cydia installed and it works fine so far. Obviously, speed is limited if you don’t have the 3G phone, but it’s better than nothing.

We can all be Digital Nomads now!

Apparently even AT&T woke up and said they would offer tethering for the iPhone soon.