CrystalImageGridView Demo
The latest Crystal Toolkit version 0.70 has an early alpha version of classes to help you build image viewers using thumbnails. You may have seen the Microsoft Office Picture Viewer, which has a nice filmstrip view of thumbnails in a splitter like view. I wanted to build an image grid view control that has that nice look and feel, but I also wanted to build it in a classic model-view-controller pattern. And I also wanted to have my control use other tools to automatically thumbnail image folders that I need to browse.

Image Grid Vertical
CrystalImageGridView does all of this, working with CrystalImageGridModel, CrystalFileCollector, and the CrystalThumbnailer to provide all of these features. You can see from the screenshots (this demo is included in the zip file on the Downloads page) that you can view the thumbnails docked in the split container on the bottom. Click on the left hand button on the upper toolbar and the split container expands the thumbnail view to fill the client area.

I'll have more bug fixes, little features, and documentation to write later. If you want to play around with this control, do the following:

1. Build Crystal Toolkit and add a reference to your Form project.
2. Drag CrystalImageGridView from the toolbox to your Form, preferrably to a split container.
3. Hook up the Load event to your Form and add this code to the method:

CrystalFileCollector _collector = 

    new CrystalFileCollector();

_collector = new CrystalFileCollector();

_collector.AddView(crystalImageGridView1);

_collector.CollectImages();


It's that easy. Run this simple form you just made, and the image grid starts previewing images from your MyPictures folder. The CrystalFileCollector spins off a background thread and pops the images into the grid as they are thumbnailed. If you don't like that location, you can modify the ImageLocation property.

More later, much more, I hope. If you have any comments, bug fixes, or whatever, contact me at richard {at} attilan [dot] com.

Crystal Toolkit is a Windows Forms (.NET Framework 2.0) control library written in C#. This is the fourth release and contains the following classes:

New in 0.70: Features.

CrystalImageGridView, CrystalFileCollector, CrystalThumbnailer:

- The Image Grid View class is a C# control that allows you to preview thumbnails in a scrollable grid view. You can dock this view in a split container in Windows Forms. There is a background thread that thumbnails the images from whatever folder you point it at. Don't like the way I thumbnail images or the way I store them? Implement my ICrystalThumbnailer interface and insert your own thumbnail class.

From previous version:

  • CrystalGradientControl: a control that can either have a gradient background or a transparent background.
  • CrystalLabel: a homegrown label control that can have a gradient or transparent background.
  • CrystalTrackBar: a homegrown trackbar that can have a gradient or transparent background.
  • CrystalToolStripTrackBar: a host for CrystalTrackBar that allows it to work in a ToolStrip.

Bonus: if you don't like CrystalTrackBar on a ToolStrip, this library also contains ToolStripTrackBar, which hosts System.Windows.Forms.TrackBar on the ToolStrip.

This release comes in a ZIP file. Simply unzip the contents to your hard drive, navigate to the root Attilan folder, and double click on CrystalDemo.sln. This solution file contains the Crystal Toolkit plus demo programs. Just build the solution (which compiles the CrystalToolkit library first) and run the demo programs to see how they work.

I've tested the demos under Windows XP SP2 and Windows Vista. Needless to say, buyers beware, this is alpha software and it's free open-source code: you get what you pay for! I'd welcome any feedback, bugs (or bug fixes), and thumb-bitmap replacements. Send email to richard [at] attilan {dot} com.

Download: Crystal Toolkit 070 (zip file, 880 kb)

Crystal Toolkit is a Windows Forms (.NET Framework 2.0) control library written in C#. This is the fourth release and contains the following classes:

New in 0.69: Bug fix.

The following bugs were fixed for CrystalTrackBar and CrystalToolStripTrackBar:

- TrackBar, Ticks, and Thumb not visible when TrackBarRenderer.IsSupported returns false. When this occurs, we draw these objects manually using DrawLine. Looks almost the same as the renderer.

From previous version:

  • CrystalGradientControl: a control that can either have a gradient background or a transparent background.
  • CrystalLabel: a homegrown label control that can have a gradient or transparent background.
  • CrystalTrackBar: a homegrown trackbar that can have a gradient or transparent background.
  • CrystalToolStripTrackBar: a host for CrystalTrackBar that allows it to work in a ToolStrip.

Bonus: if you don't like CrystalTrackBar on a ToolStrip, this library also contains ToolStripTrackBar, which hosts System.Windows.Forms.TrackBar on the ToolStrip.

This release comes in a ZIP file. Simply unzip the contents to your hard drive, navigate to the root Attilan folder, and double click on CrystalDemo.sln. This solution file contains the Crystal Toolkit plus demo programs. Just build the solution (which compiles the CrystalToolkit library first) and run the demo programs to see how they work.

I've tested the demos under Windows XP SP2 and Windows Vista. Needless to say, buyers beware, this is alpha software and it's free open-source code: you get what you pay for! I'd welcome any feedback, bugs (or bug fixes), and thumb-bitmap replacements. Send email to richard [at] attilan {dot} com.

Download: Crystal Toolkit 069 (zip file, 820 kb)

BUG: Invisible CrystalTrackBars
A little over a week ago, a user named MG reported a problem that I couldn't duplicate until now. When he ran the demo program CrystalTrackBarDemo.exe, all the CrystalTrackBar objects were invisible. No trackbar, no ticks, no thumb, only the gradient background remained on the non-transparent objects. After a second user reported this bug on the CodeProject article, I suddenly remembered about my usage of TrackBarRenderer.IsSupported in CrystalTrackBar OnPaint:

protected override void OnPaint(PaintEventArgs e)
{
    if (!TrackBarRenderer.IsSupported)
    {
        this.Parent.Text = 
            "CrystalTrackBar Disabled";
        return;
    }

    DrawTrackBar(e.Graphics);
    DrawTicks(e.Graphics);
    DrawThumb(e.Graphics);
}



On the MSDN Forum, Mick Doherty pointed out that TrackBarRenderer.IsSupported == VisualStylesRenderer.IsSupported. According to the documentation, one of the things that can make the VisualStylesRenderer is the VisualStyleInformation.IsEnabledByUser property. Users can enable visual styles in the Appearance tab of the Display option in Control Panel.

Windows Classic Style
I was able to reenact the bug by setting my Appearance setting for Windows and Buttons to Windows Classic Style (on XP: Control Panel->Display->Appearance tab). As some people are addicted to the old Windows NT look and feel, it makes sense this how they ran into the bug. When I ran my application again, TrackBarRenderer.IsSupported returned false and all I got was the rectangles, no trackbar or ticks.

I'll need to draw the TrackBar and Ticks myself if TrackBarRenderer isn't supported. I'm already drawing the Thumb, so this should be an easy bug to fix. I hope to have it posted in a few days.

Crystal Toolkit is a Windows Forms (.NET Framework 2.0) control library written in C#. This is the third release and contains the following classes:

New in 0.68: Bug fixes.

The following bugs were fixed for CrystalTrackBar and CrystalToolStripTrackBar:

- ProcessCmdKey failing to return true in CrystalTrackBar.
- ProcessKeystroke added for Forms using CrystalToolStripTrackBar.
- Various painting issues with both versions of the TrackBar.

From previous version:

  • CrystalGradientControl: a control that can either have a gradient background or a transparent background.
  • CrystalLabel: a homegrown label control that can have a gradient or transparent background.
  • CrystalTrackBar: a homegrown trackbar that can have a gradient or transparent background.
  • CrystalToolStripTrackBar: a host for CrystalTrackBar that allows it to work in a ToolStrip.

Bonus: if you don't like CrystalTrackBar on a ToolStrip, this library also contains ToolStripTrackBar, which hosts System.Windows.Forms.TrackBar on the ToolStrip.

This release comes in a ZIP file. Simply unzip the contents to your hard drive, navigate to the root Attilan folder, and double click on CrystalDemo.sln. This solution file contains the Crystal Toolkit plus demo programs. Just build the solution (which compiles the CrystalToolkit library first) and run the demo programs to see how they work.

I've tested the demos under Windows XP SP2 and Windows Vista. Needless to say, buyers beware, this is alpha software and it's free open-source code: you get what you pay for! I'd welcome any feedback, bugs (or bug fixes), and thumb-bitmap replacements. Send email to richard [at] attilan {dot} com.

Download: Crystal Toolkit 068 (zip file, 820 kb)

Install IIS 7.0 on Vista with Control Panel
If you're using Vista and wondering how to install IIS 7.0, the answer is in the screenshot above. While XP allowed you to install IIS from an Add/Remove programs dialog box, Vista has these features hidden in Control Panel > Programs > Turn Windows features on and off. Clicking on this item pops up a dialog box which contains Internet Information Services.

You have to do a few more things if you're expecting IIS 7.0 to work with the current Visual Studio 2005. VS 2005 needs to be run as an administrator and it communicates with IIS in the 6.0 compatibility mode. I've found a few links here that help get IIS 7.0 working with Visual Studio.

Scott Guthrie: Tip/Trick: Using IIS7 on Vista with VS 2005
Fix problems with Visual Studio F5 debugging of ASP.NET applications on IIS7 Vista
Enabling ASP.NET 2.0 Debugging on Visual Studio 2005, IIS 7.0 and Vista

Designer error
If you've used Visual Studio with Windows Forms objects, you're used to double clicking on a file in the Solution Explorer and seeing the visual representation of the Form object in the designer. This works for controls as well as forms. I ran into a problem when I created the base class CrystalControl. First, I right clicked on the Solution Explorer, clicked Add, New Item, selected Custom Control, named the file CrystalControl.cs, and started working. The problem was that Visual Studio then decided that CrystalControl needed to be displayed in the designer by default, rather than code. (In this case, CrystalControl is a base class that doesn't draw anything and is only useful when inherited.) No doubt many people have seen the nasty error page "The class X can be designed, but is not the first class in the file…"

namespace Attilan.Crystal.Controls
{
    /// <summary>
    /// Base class for all Crystal controls, derives from ScrollableControl.
    /// </summary>
    [System.ComponentModel.DesignerCategory("code")]
    [ToolboxItem(false)]
    public class CrystalControl : ScrollableControl


If you look at the documentation, Visual Studio is supposed to treat a .cs file as a Designer item by the System.ComponentModel.DesignerCategory attribute inside the code. Seeing that I had omitted this, I included it before the class declaration and recompiled.

designer attributes in solution explorer
Unfortunately, I still had the same result: double clicking on CrystalControls.cs resulted in the error page. Even though you can click on the Code button in the Solution Explorer, it's one of those little things that drive me nuts. Looking at the Solution Explorer, I could see that CrystalControls.cs and CrystalLabel.cs had different icons from my other .cs (code only) extension files that behaved correctly. Then I figured out that because of the way I created these .cs files (selecting Custom Control in the Add dialog), extra metadata must have been written to my project files.

Crystal Toolkit project file
Sure enough, on close examination of CrystalToolkit.csproj, I found extra attributes for the c-sharp files with bad behavior and incorrect icon status. Under each of them was the <subtype>Component</subtype> attribute. When I removed these attributes and saved the .csproj file, everything was fine.

correct attributes in solution explorer
All my files reverted to code-only status and the default double-click action was restored, along with my sanity. Just to be clear, you absolutely need to set the DesignerCategory attribute to "code" in order for this to work, but if Visual Studio somehow inserts that metadata, you may be slightly hosed.

CrystalLabel.jpg

One question I often see getting asked on forums is how to make a label transparent on Windows Forms. Since I already had CrystalGradientControl working with the TransparentMode property (setting to true makes the background transparent), I decided to make the CrystalLabel control. As with CrystalTrackBar, you can use this with a gradient background (when TransparentMode is false) also.

The base class does most of the work, all I had to do was to override OnPaint and draw the text:

protected override void OnPaint(PaintEventArgs pe)
{
    // Paint text
    Rectangle rc = new Rectangle(0,0,this.Width,this.Height);
    TextRenderer.DrawText(pe.Graphics,this.Text,this.Font,
        rc, this.ForeColor, Color.Transparent);

    // Calling the base class OnPaint
    base.OnPaint(pe);
}

The control must resize the rectangle with the text changes by overriding OnTextChanged (and OnFontChanged as well):

protected override void OnTextChanged(EventArgs e)
{
    this.Size = TextRenderer.MeasureText(this.Text,this.Font);
    RedrawControl();
    base.OnTextChanged(e);
}

I'm not sure how far I'm going to proceed with Transparent controls. I implemented CrystalTrackBar for a specific application and CrystalLabel was very quick to implement. I would be curious to know which controls would be a good candidate for transparent or gradient properties.

You can download CrystalLabel (and the Crystal Toolkit) in the Downloads section. It comes with full source code and demo programs.

Previous 1 2 3 4 5 6 Next