private static FileSystemEntryCollection GetFileSystemEntries(string path, IconSizeType sizeType, Size itemSize, bool getIcons)
 {
     FileSystemEntryCollection col = new FileSystemEntryCollection();
     FileSystemHelper.InitDirectories(path, col, sizeType, itemSize, getIcons);
     FileSystemHelper.InitFiles(path, col, sizeType, itemSize);
     return col;
 }
Beispiel #2
0
        private IconStyle CompileStyle(object asset, PvIconAttribute attr, Rect fullRect)
        {
            IconSizeType sizeType = PvCustomizerUtility.GetSizeType(fullRect);
            Rect         iconRect = PvCustomizerUtility.ItemRectToIconRect(fullRect, sizeType == IconSizeType.TreeView);
            IconStyle    style    = new IconStyle
            {
                IsSet        = true,
                Tint         = attr.Tint,
                CustomValues = attr.CustomData,
                FontStyle    = attr.FontStyle,
                SizeType     = PvCustomizerUtility.GetSizeType(iconRect),
                MaxSize      = attr.MaxSize,
                ScaleMode    = attr.ScaleMode
            };

            //----------complex assignments

            #region Material

            if (string.IsNullOrEmpty(attr.Material))
            {
                style.Material = null;
            }
            else
            {
                ValueableMemberCache.Pair matMember = ValueableMemberCache.GetValueables(asset.GetType()).
                                                      Find(v => v.Member.Name == attr.Material &&
                                                           v.ValueType == typeof(Material));

                style.Material = matMember.Member?.GetMemberValue(asset) as Material;
            }

            #endregion

            if (PvCustomizerUtility.TryParseGridRect(attr.Grid, out int rows, out int cols, out int pos))
            {
                float width  = iconRect.width / cols;
                float height = iconRect.height / rows;

                float x = width * (pos % cols);
                float y = height * (pos / rows);

                style.DrawRect = new Rect(iconRect.x + x, iconRect.y + y, width, height);
            }
Beispiel #3
0
        public static Image GetFileImageFromFile(string path, IconSizeType sizeType, Size itemSize)
        {
            var shfi      = new SHFILEINFO();
            var imageList = SHGetFileInfoAsImageList(path, 0, ref shfi, (uint)Marshal.SizeOf(shfi), (int)SHGFI_SYSICONINDEX);

            if (imageList != null)
            {
                var hIcon = IntPtr.Zero;
                imageList.GetIcon(shfi.iIcon, (int)ILD_TRANSPARENT, ref hIcon);
                Marshal.FinalReleaseComObject(imageList);
                if (hIcon != IntPtr.Zero)
                {
                    var image = Bitmap.FromHicon(hIcon);
                    DestroyIcon(hIcon);
                    return(image);
                }
            }
            return(new Bitmap(itemSize.Width, itemSize.Height));
        }
Beispiel #4
0
        /// <summary>
        /// 提供
        /// </summary>
        /// <param name="schemaObj">一个<see cref="MCS.Library.SOA.DataObjects.SCSimpleObject"/>,或一个<see cref="System.Data.DataRowView"/></param>
        /// <returns></returns>
        public static string CssSpritesFor(object schemaObj, IconSizeType size)
        {
            SCSimpleObject obj = schemaObj as SCSimpleObject;
            System.Data.DataRowView view = schemaObj as System.Data.DataRowView;
            string css = string.Empty;
            string schemaType = null;
            int status = 0;
            if (obj != null)
            {
                schemaType = obj.SchemaType;
                status = obj.Status == SchemaObjectStatus.Normal ? 0 : 1;
            }
            else if (view != null)
            {
                schemaType = (string)view["SchemaType"];
                status = 0;
            }

            if (schemaType != null)
            {
                switch (size)
                {
                    case IconSizeType.Size16:
                        css = "pc-icon16";
                        break;
                    case IconSizeType.Size32:
                        css = "pc-icon32";
                        break;
                    default:
                        break;
                }

                if (status != 0)
                {
                    css += " pc-status-deleted";
                }

                css += " " + schemaType;
            }

            return css;
        }
Beispiel #5
0
        public static Icon GetFileIcon(string path, IconSizeType sizeType, Size itemSize)
        {
            SHFILEINFO shinfo     = new SHFILEINFO();
            IntPtr     retVal     = SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), (int)(SHGFI_SYSICONINDEX | SHGFI_ICON));
            int        iconIndex  = shinfo.iIcon;
            IImageList iImageList = (IImageList)GetSystemImageListHandle(sizeType);
            IntPtr     hIcon      = IntPtr.Zero;

            if (iImageList != null)
            {
                iImageList.GetIcon(iconIndex, (int)ILD_TRANSPARENT, ref hIcon);
            }
            Icon icon = null;

            if (hIcon != IntPtr.Zero)
            {
                icon = Icon.FromHandle(hIcon).Clone() as Icon;
                DestroyIcon(shinfo.hIcon);
            }
            return(icon);
        }
Beispiel #6
0
        private bool FindAndDrawAttributes(Object asset, Rect fullRect, bool selected)
        {
            //get all relevant attributes and member info on which they're declared
            var          triplets = PvIconAttributeCache.GetAttributeTriplets(asset.GetType());
            IconSizeType sizeType = PvCustomizerUtility.GetSizeType(fullRect);

            if (triplets.Exists(t => CanDisplay(t.Attr.Display, sizeType) && !t.Attr.DontEraseDefault))
            {
                Rect iconRect = PvCustomizerUtility.ItemRectToIconRect(fullRect, sizeType == IconSizeType.TreeView);
                PvCustomizerGUI.DrawBackground(iconRect);
            }

            bool drewAtleastOnce = false;

            foreach (var(member, attr, valueType) in triplets)
            {
                object value = member.GetMemberValue(asset);
                drewAtleastOnce |= TryDrawFromValue(asset, value, fullRect, attr, selected);
            }

            return(drewAtleastOnce);
        }
Beispiel #7
0
 public static Image GetFileImage(string path, IconSizeType sizeType, Size itemSize)
 {
     return(IconToBitmap(GetFileIcon(path, sizeType, itemSize), sizeType, itemSize));
 }