load – Owl's Blog on .NET development http://www.componentowl.com/blog Component Owl codes Better ListView control all night so you don't have to. Tue, 04 Sep 2018 13:10:05 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 Better Thumbnail Browser Component Released http://www.componentowl.com/blog/better-thumbnail-browser-component-released/ http://www.componentowl.com/blog/better-thumbnail-browser-component-released/#comments Sat, 01 Dec 2012 18:26:16 +0000 http://www.componentowl.com/blog/?p=823  

We have released a whole new WinForms component called Better Thumbnail Browser. This control is useful for anyone developing photo management software or any kind of image database:

Better Thumbnail Browser Overview

Better Thumbnail Browser Overview

The control is capable of loading image thumbnails on background and does all the dirty job of threading and synchronization for you.

My motivation to make such component as lead developer at ComponentOwl.com was to have something that can smoothly integrate in my photo management software.

Since we already have Better ListView component, which is quite mature (three major releases over two years of development), I decided to build upon it and finally make control for image thumbnails that is both extensible and powerful and have native look and feel.

Better Thumbnail Browser inherits most of its functionality from Better ListView (multi column sorting, custom paddings and spacings, multi-line text and groups to name a few). It adds image loading logic on top of it, which can handle various scenarios:

  • Load images from a folder, database or custom source automatically
  • Load thumbnails with arbitrary sizes on background while progressively displaying them
  • Handle zooming thumbnails on the fly
  • Loading thumbnail items in multiple passes (e.g. load meta-data, then low quality image, then high quality image)
  • Loading thumbnails in custom order
  • Loading visible thumbnails first, then all other (and do this even though the user is scrolling the view)
  • Manage updating individual thumbnails or their count on the fly
  • Support showing loading progress

The component is fully customizable and by default inherits native Windows theme. We tested it on Windows 8 with success:

Better Thumbnail Browser with Windows 8 Theme

Better Thumbnail Browser with Windows 8 Theme

 

Better Thumbnail Browser contains default implementation for loading thumbnail images from disk. If you want to gather all images from a given folder (say “c:\images”), display them in Better Thumbnail Browser and load them on background, the code is particularly simple:

thumbnailBrowser.Path = "c:\\images";

And that’s it!

Better Thumbnail Browser will be our third component which is used in end-user consumer-level software package. This ensures future development, improvements and support.

 

 

]]>
http://www.componentowl.com/blog/better-thumbnail-browser-component-released/feed/ 1
How to Store Better ListView Content in a String (User Request) http://www.componentowl.com/blog/how-to-store-better-listview-content-in-a-string-user-request/ http://www.componentowl.com/blog/how-to-store-better-listview-content-in-a-string-user-request/#respond Sat, 04 Aug 2012 00:03:49 +0000 http://www.componentowl.com/blog/?p=796 Is it possible to store entire Better ListView content (items with hierarchy and sub-items, columns and groups) in a single string?

Better ListView already supports saving and loading its content using SaveContent and LoadContent methods. These methods support either XML or binary format.

I chose binary format for storing data in string  because it is more compact than XML. Binary representation (basically an array of bytes) can be converted to Base64 string. Loading the content from string work similarly, the steps are performed in opposite direction:

C#

[csharp gutter=”false” toolbar=”false”]
// SAVE
// create MemoryStream to hold binary data
MemoryStream stream = new MemoryStream();
// store Better ListView content in memory stream
this.listView.SaveContentBinary(stream);
// copy content of MemoryStream to byte array
byte[] contentBinary = new byte[stream.Length];
stream.Seek(0, SeekOrigin.Begin);
// convert byte array to Base64 string
stream.Read(contentBinary, 0, (int)stream.Length); // move to beginning of the stream
string contentStringBase64 = Convert.ToBase64String(contentBinary);
// close stream
stream.Close();
stream.Dispose();

// CLEAR
this.listView.Clear();

// LOAD
// create MemoryStream to hold binary data
stream = new MemoryStream();
// convert Base64 string to byte array
contentBinary = Convert.FromBase64String(contentStringBase64);
// write byte array to stream
stream.Write(contentBinary, 0, contentBinary.Length);
stream.Seek(0, SeekOrigin.Begin); // move to beginning of the stream
// load content of Better ListView from memory stream
this.listView.LoadContentBinary(stream);
[/csharp]

Visual Basic

[vb gutter=”false” toolbar=”false”]
‘ SAVE
‘ create MemoryStream to hold binary data
Dim stream As New MemoryStream()
‘ store Better ListView content in memory stream
Me.listView.SaveContentBinary(stream)
‘ copy content of MemoryStream to byte array
Dim contentBinary As Byte() = New Byte(stream.Length – 1) {}
stream.Seek(0, SeekOrigin.Begin)
‘ convert byte array to Base64 string
stream.Read(contentBinary, 0, CInt(stream.Length))
‘ move to beginning of the stream
Dim contentStringBase64 As String = Convert.ToBase64String(contentBinary)
‘ close stream
stream.Close()
stream.Dispose()

‘ CLEAR
Me.listView.Clear()

‘ LOAD
‘ create MemoryStream to hold binary data
stream = New MemoryStream()
‘ convert Base64 string to byte array
contentBinary = Convert.FromBase64String(contentStringBase64)
‘ write byte array to stream
stream.Write(contentBinary, 0, contentBinary.Length)
stream.Seek(0, SeekOrigin.Begin)
‘ move to beginning of the stream
‘ load content of Better ListView from memory stream
Me.listView.LoadContentBinary(stream)
[/vb]

 

Although saving and loading data this way is convenient, please consider the following drawback:

  • Standard serialization mechanism of .NET is used for converting classes and structures to XML or binary representation – hence the serialized data may not be possible to deserialize on different version of Better ListView if any public members of the serialized class have been changed.
  • The generated string is very long (few kilobytes for just two items).
  • Lots of data are stored which are not related to content itself (e.g. item colors).
  • The serialized representation is considered read-only – any changes can cause problems with deserialization; if you really want flexible way of storing ListView content, consider building a model or data layer that supports storing the data you need the way you need.

On the other hand, using this way may be convenient when you want to transfer or copy ListView content between controls on even across application domain (Better ListView itself uses this mechanism to allow Drag and Drop between two applications – this “tour de force” kind of Drag and Drop is not avaiable in regular .NET ListView).

]]>
http://www.componentowl.com/blog/how-to-store-better-listview-content-in-a-string-user-request/feed/ 0