Skip to content

Replies

0
Brian Fallon
Brian Fallon answered on Oct 21, 2008 2:48 PM

See UltraTreeNode.Override.NodeAppearance.FontData

0
Brian Fallon
Brian Fallon answered on Oct 6, 2008 2:57 PM

The settings for each of the iconic view styles (Icons, Tiles, Thumbnails) exposes an 'Alignment' property, which determines whether the items are laid out from left to right or top to bottom.

Example:
this.ultraListView1.ViewSettingsIcons.Alignment = ItemAlignment.TopToBottom;

For the 'List' view, the only way to get a vertical scrollbar is to set the MultiColumn property to false.

0
Brian Fallon
Brian Fallon answered on Oct 1, 2008 8:09 PM

Thumbnails view intentionally leaves considerable padding around the image to make it easier to  emulate Windows Explorer's thumbnails view. The draw filter example I posted here makes use of that.

0
Brian Fallon
Brian Fallon answered on Sep 30, 2008 4:12 PM

No, the ImageSize property applies to all items for that view. If you are trying to emulate the Windows Explorer thumbnails view, you might want to use the IUIElementDrawFilter interface.

The following code sample demonstrates how to use the IUIElementDrawFilter interface to draw "photo" type images at a larger size and at the correct aspect ratio. Note that performance is not optimal with this approach, since drawing large images takes time and resources, so this example is for demonstrative purposes. This example also assumes that the item's Tag property is set to a System.IO.FileInfo instance, as is the case with the 'Infragistics File Explorer' sample that ships with the product.

Assign an instance of the following class to the control's DrawFilter property, and set the View to 'Thumbnails'.

#region UltraListViewThumbnailDrawFilter
/// <summary>
/// IUIElementDrawFilter interface implementor used to draw photographic
/// images larger and at the correct aspect ratio.
/// </summary>
public class UltraListViewThumbnailDrawFilter : IUIElementDrawFilter
{
    UltraListView listView = null;

    public UltraListViewThumbnailDrawFilter( UltraListView listView, Size imageSize )
    {
        this.listView = listView;
        this.listView.ViewSettingsThumbnails.ImageSize = imageSize;
    }

 #region IUIElementDrawFilter interface implementation

 public Infragistics.Win.DrawPhase GetPhasesToFilter( ref UIElementDrawParams drawParams )
 {
  // If the element is the UIElement which represents the item's image area,
  // return DrawPhase.BeforeDrawImage to signify that we want to handle the
        //  drawing for this element.
  UltraListViewIconicImageAreaUIElement imageAreaElement = drawParams.Element as UltraListViewIconicImageAreaUIElement;
  UltraListViewItemUIElement itemElement = imageAreaElement != null ?
             imageAreaElement.GetAncestor( typeof(UltraListViewItemUIElement) ) as UltraListViewItemUIElement :
             null;

  UltraListViewItem item = itemElement != null ? itemElement.Item : null;

  if ( item != null && item.Tag is System.IO.FileInfo )
   return DrawPhase.BeforeDrawImage;

  return DrawPhase.None;
 }

 public bool DrawElement( DrawPhase drawPhase, ref UIElementDrawParams drawParams )
 {
  UltraListViewIconicImageAreaUIElement imageAreaElement = drawParams.Element as UltraListViewIconicImageAreaUIElement;

  if ( imageAreaElement != null )
  {
            //  Get the FileInfo with which this item is associated
   UltraListViewItem item = imageAreaElement.GetContext( typeof(UltraListViewItem) ) as UltraListViewItem;
            System.IO.FileInfo fileInfo = item.Tag as System.IO.FileInfo;
            if ( fileInfo == null )
                return false;
           
            //  For the sake of simplicity, we will consider anything with a jpg or bmp
            //  extension to be a "photo" type image, and we will draw such images at
            //  a larger size and with the correct aspect ratio. Windows Explorer uses
            //  more sophisticated methods to make that determination, which are beyond
            //  the scope of this demonstration.
            bool isPhoto =
                string.Equals(fileInfo.Extension, ".jpg", StringComparison.InvariantCultureIgnoreCase) ||
                string.Equals(fileInfo.Extension, ".bmp", StringComparison.InvariantCultureIgnoreCase);

            //  Get the image
            System.Drawing.Image bmp = isPhoto ?
                Image.FromFile(fileInfo.FullName) as Bitmap :
                null;

            if ( bmp == null )
                return false;

            //  TODO: This should really be done using IUIElementCreationFilter,
            //  so the child elements never get created in the first place
            imageAreaElement.ChildElements.Clear();

            //  Calculate the new image size, so it is scaled but still
            //  maintains the same aspect ratio.
            Size newSize = Size.Empty;
            Rectangle rect = imageAreaElement.Rect;
            rect.Inflate( -4, -4 );

            Size actualSize = bmp.Size;
            double aspectRatio = (double)actualSize.Width / (double)actualSize.Height;
            bool landscape = aspectRatio > 1f;

            if ( landscape )
            {
                newSize.Width = rect.Width;
                newSize.Height = (int)( (double)rect.Height / aspectRatio);
            }
            else
            {
                newSize.Height = rect.Height;
                newSize.Width = (int)( (double)rect.Width * aspectRatio);
            }

            //  Calculate the new location
            Rectangle newRect = imageAreaElement.RectInsideBorders;
            Point newLocation = newRect.Location;
            newLocation.X += (newRect.Width / 2) – (newSize.Width / 2);
            newLocation.Y += (newRect.Height / 2) – (newSize.Height / 2);
            Rectangle drawRect = new Rectangle( newLocation, newSize );

         // Draw the image at the new size/location
            if ( bmp != null )
            {
             drawParams.Graphics.DrawImage( bmp, drawRect );

                if ( isPhoto )
                    bmp.Dispose();
            }

   return true;
  }

        return false;
    }
 #endregion IUIElementDrawFilter interface implementation

}
#endregion UltraListViewThumbnailDrawFilter

0
Brian Fallon
Brian Fallon answered on Sep 26, 2008 3:26 PM

UltraTreeNode exposes an Expanded property and an ExpandAll method. The former expands only that node, where the latter expands it and all descendants.

0
Brian Fallon
Brian Fallon answered on Sep 23, 2008 3:12 PM

void ultraTree1_AfterSelect(object sender, SelectEventArgs e)
{
    UltraTreeNode node = e.NewSelections.Count == 1 ? e.NewSelections[0] : null;
    if ( node != null )
    {
        List<UltraTreeNode> descendants = this.GetAllDescendants( node );
        bool stop = true;
    }
}

private List<UltraTreeNode> GetAllDescendants( UltraTreeNode node )
{
    List<UltraTreeNode> retVal = new List<UltraTreeNode>();
    this.GetAllDescendants( node.Nodes, retVal );
    return retVal;
}

private void GetAllDescendants( TreeNodesCollection nodes, List<UltraTreeNode> descendants )
{
    foreach ( UltraTreeNode node in nodes )
    {
        descendants.Add( node );

        if ( node.HasNodes )
            this.GetAllDescendants( node.Nodes, descendants );
    }
}

0
Brian Fallon
Brian Fallon answered on Sep 2, 2008 2:24 PM

UltraListViewItem.Appearance.Image