public IViewComponentResult Invoke(ImageListType type, string caption, object data)
        {
            this.ViewBag.Caption = caption;
            List <ImageListViewModel> images = null;

            if (type == ImageListType.Album)
            {
                var id = data as Guid?;
                images = this.imageService.GetAllReqursive().Where(x => x.AlbumId == id).To <ImageListViewModel>()
                         .OrderBy(x => x.DateTaken).ToList();
            }
            else if (type == ImageListType.Date)
            {
                var date = (data as DateTime?).Value.Date;

                images = this.imageService.GetAllReqursive()
                         .Where(x => x.DateTaken != null && x.DateTaken.Value.Date == date).To <ImageListViewModel>()
                         .OrderByDescending(x => x.DateTaken).ToList();
            }
            else if (type == ImageListType.Location)
            {
                var location = data as string;

                images = this.imageService.GetAllReqursive()
                         .Where(x => x.ImageGpsData != null && x.ImageGpsData.LocationName == location)
                         .To <ImageListViewModel>().OrderByDescending(x => x.DateTaken).ToList();
            }

            return(this.View(images));
        }
Пример #2
0
        /// <summary>
        /// Sets the image list.
        /// </summary>
        /// <param name="this">The list view instance.</param>
        /// <param name="imageListType">Type of the image list.</param>
        /// <param name="imageListHandle">The image list handle.</param>
        public static void SetImageList(this ListView @this, ImageListType imageListType, IntPtr imageListHandle)
        {
            //  If we're using the group header image list (not wrapped by .NET),
            //  just go straight to the Win32 API - we'll be using it from there
            //  anyway.
            if (imageListType == ImageListType.GroupHeader)
            {
                //  Set the image list.
                User32.SendMessage(@this.Handle, LVM_SETIMAGELIST, (uint)imageListType, imageListHandle);

                //  That's all we need to do.
                return;
            }

            //  Get the image list details.
            int cx, cy;

            ComCtl32.ImageList_GetIconSize(imageListHandle, out cx, out cy);
            var imageCount = ComCtl32.ImageList_GetImageCount(imageListHandle);

            //  This isn't actually enough for a Winforms list view - we actually need to create a copy of the
            //  image list.
            var imageList = new ImageList();

            imageList.ImageSize = new Size(cx, cy);

            for (int i = 0; i < imageCount; i++)
            {
                //  Get the icon.
                var hIcon = ComCtl32.ImageList_GetIcon(imageListHandle, i, 0);

                //  Create it.
                var icon = Icon.FromHandle(hIcon);

                //  Add it.
                imageList.Images.Add(icon);
            }

            //  Set the image list.
            switch (imageListType)
            {
            case ImageListType.Normal:
                @this.LargeImageList = imageList;
                break;

            case ImageListType.Small:
                @this.SmallImageList = imageList;
                break;

            case ImageListType.State:
                @this.StateImageList = imageList;
                break;

            default:
                throw new ArgumentOutOfRangeException("imageListType");
            }
        }
Пример #3
0
 /// <summary>
 /// Gets the image list.
 /// </summary>
 /// <param name="this">The tree view instance.</param>
 /// <param name="imageListType">Type of the image list.</param>
 /// <returns>The image list handle.</returns>
 public static IntPtr GetImageList(this TreeView @this, ImageListType imageListType)
 {
     //  Set the image list.
     return(new IntPtr(User32.SendMessage(@this.Handle, TVM_GETIMAGELIST, (uint)imageListType, IntPtr.Zero)));
 }
Пример #4
0
 /// <summary>
 /// Sets the image list.
 /// </summary>
 /// <param name="this">The tree view instance.</param>
 /// <param name="imageListType">Type of the image list.</param>
 /// <param name="imageListHandle">The image list handle.</param>
 public static void SetImageList(this TreeView @this, ImageListType imageListType, IntPtr imageListHandle)
 {
     //  Set the image list.
     User32.SendMessage(@this.Handle, TVM_SETIMAGELIST, (uint)imageListType, imageListHandle);
 }
 public TreeNodeImageIndexer(TreeNode node, ImageListType imageListType)
 {
     this.owner = node;
     this.imageListType = imageListType;
 }
Пример #6
0
 public TreeNodeImageIndexer(TreeNode node, ImageListType imageListType)
 {
     owner = node;
     this.imageListType = imageListType;
 }
Пример #7
0
 /// <summary>
 /// Gets the image list.
 /// </summary>
 /// <param name="this">The tree view instance.</param>
 /// <param name="imageListType">Type of the image list.</param>
 /// <returns>The image list handle.</returns>
 public static IntPtr GetImageList(this TreeView @this, ImageListType imageListType)
 {
     //  Set the image list.
     return new IntPtr(User32.SendMessage(@this.Handle, TVM_GETIMAGELIST, (uint)imageListType, IntPtr.Zero));
 }
Пример #8
0
 /// <summary>
 /// Sets the image list.
 /// </summary>
 /// <param name="this">The tree view instance.</param>
 /// <param name="imageListType">Type of the image list.</param>
 /// <param name="imageListHandle">The image list handle.</param>
 public static void SetImageList(this TreeView @this, ImageListType imageListType, IntPtr imageListHandle)
 {
     //  Set the image list.
     User32.SendMessage(@this.Handle, TVM_SETIMAGELIST, (uint)imageListType, imageListHandle);
 }
Пример #9
0
        public ImageListPage(string title, ImageListType imageListType)
        {
            Title = title;

            _FollowType = imageListType;
        }
 public TreeNodeImageIndexer(TreeNode node, ImageListType imageListType)
 {
     Debug.Assert(node is not null, $"{nameof(node)} should not be null.");
     _owner         = node;
     _imageListType = imageListType;
 }