Andrej Tozon's blog

In the Attic

NAVIGATION - SEARCH

01.02.03, 04.05.06

Now it happened local time too :) Last night, two minutes and three seconds past one, the numbers aligned...

Fun with padding and border painting

So you want to build a professional looking UI with Visual Studio 2005… NET 2.0 has made a big move forward in enabling developers to create a rich and customizable user interfaces. Many controls have been improved or completely rewritten, but some remained with the same look and feel. In this article, I’ll try to follow a common scenario and build a very very simple UI, featuring a SplitContainer, a TreeView, TextBox and a RichTextBox.
We’ll begin with new Windows Application and add two SplitContainers to the Form. The left-side panel with contain a TreeView, while the right-side panel will host another SplitContainer, hosting a multiline TextBox in the top, and a RichTextBox in a bottom panel.
The first layout would look like this:

Shown in a Document Outline Window:

We can see that RichTextBox has that old 3D border, while the other two controls paint accordingly to selected XP color scheme. Also, all controls are pushing into form’s border; we’d like to add some space on the inside, so our controls could breath and stand out more.

First, let’s get rid of that 3D Border (BorderStyle = None). Then, add some padding around the controls:

splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(4, 4, 0, 4);
splitContainer1.Panel2.Padding = new System.Windows.Forms.Padding(0, 4, 4, 4);

The form now looks like this:

Better… To add a border around RichTextBox, we’ll add additional, one-pixel padding to the panel that hosts RichTextBox:

splitContainer2.Panel2.Padding = new System.Windows.Forms.Padding(1);

Finally, let’s do some custom border painting:

private void splitContainer2_Panel2_Paint(object sender, PaintEventArgs e)
{
   Rectangle rectangle = richTextBox1.DisplayRectangle;
   rectangle.Offset(splitContainer2.Panel2.Padding.Left,
   splitContainer2.Panel2.Padding.Top);
   using (Pen pen = new Pen(System.Windows.Forms.
VisualStyles.VisualStyleInformation.TextControlBorder, 2))
   {
       e.Graphics.DrawRectangle(pen, rectangle);
   }
}

And if grey just isn’t your color, do this:

public Form1()
{
   InitializeComponent();
   splitContainer1.BackColor = ProfessionalColors.ToolStripContentPanelGradientEnd;
}

That's it. Simple, isn't it?

Default Blue Color Scheme:

Silver Color Scheme:

Olive Green Color Scheme:

CodeZone-SI on Community Server 2.0

Finally found some time to upgrade SLODUG's CodeZone-SI portal on the final Community Server 2.0 release. I also reskinned it so it looks a bit, but not much different.

As I write this, Community Server 2.1 has been announced for July, adding one new major feature - tags. Including tag cloud... [yeah!]

Anthology #1 – Introductory post

This is the introductory post about Anthology, an ongoing content management project, which I’ve been mentioning in some of my previous posts. There is a lot to write about Anthology, so let me cover the basics first. More specific and detailed information will follow in the next posts.

Anthology was conceived as a Content Management System [CMS], which really wasn’t a very appropriate title, since the term CMS is still widely used only in the context of web content management solutions. It’s true that Anthology can be used for managing web content, but it is much more than that. It is also a Document Management System [DMS], your personal photo album, information aggregator or your CD/DVD collection catalogue, to name just a few basic scenarios. The abilities like handling any type of electronic content, preserving the timeline with full history of changes, extending the system with user-defined types of content, powerful, customized searching, intelligent content recognition and analysis, advanced classification and information cataloguing, combined with ‘knowing the user’, make Anthology a special environment – Intelligent Content Environment.

Anthology is user-friendly information system for storing and managing any type of electronic content, putting the user in a total control of the whole content lifecycle: capturing existing data or creating your own document, storing it in a reliable storage, allowing further changes with full versioning support, including linking and interacting with other documents, publishing on the internet or the other media. For example, when used as a document management system, Anthology will help you manage your documents, in a multi-user, workflow-driven environment, from the very first draft, to final publishing, or, if necessary, termination.

What exactly is ‘Content’?

With Anthology, every piece of electronic data is ‘a content’. Microsoft Office documents, text files, images, web pages, Xml, … Different formats, but the information, written in these files carry some important value to us. Anthology offers a common storage for any type of electronic content, treating all types of content the same way. Because of this, I usually refer to Anthology content as ‘Anthology document’ or just plain ‘Document’, instead of ‘Content’. I’ll be using these terms interchangeably in my posts.

I’ll end this first post with slightly more technical information: Anthology is available as a desktop application or a web portal. Both use the same storage options and because they are built on the same code base, they share all common features and functionality. However, at this moment, the desktop part is more suitable for content capturing and system administration, and the portal is oriented more towards content delivery. The whole solution is built from the ground up in .NET Framework 2.0, using the SQL Server 2005 for storage.

Read more about its modular and expandable design, Anthology Content Management Foundation, including all other features and details, in the forthcoming posts.

There is currently more information available on these pages (www.anthology-on.net, in Slovenian language only and a bit outdated). The site will be updated in the near future.

Running on Community Server 2.0

I've just upgraded this blog to Community Server 2.0. Since I'm not hosting this site on my own servers, the upgrading procedure wasn't so trivial. Database updating required some custom table tweaking due to strict [hosting provider's] security policy, but after after a few hours of peeking and poking, the site seems to be back in  business. Got me worried there for a moment....

Loving this Atlas thing...

Lately I'm spending majority of my time in the ASP.NET environment, digging down below the surface of basic classes and controls. And there really is a whole new world down there. It's like you're playing on the sea surface with your GridViews, ObjectSources and basic HttpHandlers, when you suddenly spot something shiny down below and you dive in to pursue it.
And you're down there, working on your custom DataSourceControl, when suddenly, a mermaid called Ajax, swims by, together with her younger sister Atlas, and together they try to lure you with their callback song, to the cave of XMLHttpRequest. It's then when you realize you're out of air, don't know **** a thing about Ajax or Atlas, crawl back to the surface and carefully start re-reading Atlas-related blogs and sites.

And you're hooked... :-)

On a side note... one thing I don't get is why are some classes, even whole concepts, like configuration management, membership/role/profile/... providers (or provider model in general), always mentioned in the context of an ASP.NET application. They work greatly in the Windows Forms apps too. Caching, even...

The Wayback Machine

A friend of mine recently showed be The Wayback Machine, a part of the Internet Archive. It's an online web-site archive, containing more than 55 billion web pages, collected over the internet in the past 10 years. And, like its title says, it really takes you back in time, when web sites were simple and, ... well, ugly ;) The journey through time begins with typing the web address of a web page you want to re-visit. The results show different time slots when that page was archived. And the archive really is huge! I immediately visited all the web pages of the companies I used to work for and author/maintain their web sites, including @kviz, a small web project, which I did for some of my friends. It was an entertainment web site, featuring various quizzes, solving which would get you prizes from sponsor companies etc. The application was written in classic ASP, included membership management, online quiz editing and publishing, polls, backed with the Access MDB database. A project run from 1999 through 2001 and I really enjoyed working on it. Now, looking 5 years back, I can only say... yes, things were so simple back then... :)

Now hurry and rediscover your own past...

Spending some quality time with ASP.NET 2.0

I'm spending majority of my time in the ASP.NET environment lately and I have to admit it's really worth spending some extra time and dig down below the surface of basic classes and controls. For example, after building some CompositeControls, CompositeDataBoundControls and custom DataSourceControls, I feel like I'll never want to write another UserControl, except maybe for prototyping or very basic stuff. Caching with custom dependencies, HttpHandlers for serving image or Rss data streams, HttpModules for Url rewriting and background processing, there's even a VirtualPathProvider which allows you to build really twisted stuff.

The customizable provider model also allows using membership/role/profile/[custom] providers in your windows applications, which is a very powerful feature, if you're developing both windows and web versions of the same application system.