Example #1
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length != 6 || !(values[0] is PackageItemType) || !(values[1] is string) || !(values[2] is bool) || !(values[3] is double) || !(values[4] is double) || !(values[5] is DependencyObject))
            {
                return(null);
            }

            int x = (int)(double)values[3];
            int y = (int)(double)values[4];

            if (x < 1)
            {
                x = 1;
            }

            if (y < 1)
            {
                y = 1;
            }

            PackageItemType type = (PackageItemType)values[0];

            if (type == PackageItemType.Folder)
            {
                bool         isExpanded = (bool)values[2];
                ImageMoniker moniker    = isExpanded ? KnownMonikers.FolderOpened : KnownMonikers.FolderClosed;
                return(WpfUtil.ThemeImage((DependencyObject)values[5], WpfUtil.GetIconForImageMoniker(moniker, x, y)));
            }

            string      name = (string)values[1];
            bool        isThemeIcon;
            ImageSource source = WpfUtil.GetIconForFile((DependencyObject)values[5], name, out isThemeIcon);

            return(source);
        }
Example #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length != 4 || !(values[0] is FileTreeModel) || !(values[1] is double) || !(values[2] is double) || !(values[3] is DependencyObject))
            {
                return(null);
            }

            int x = (int)(double)values[1];
            int y = (int)(double)values[2];

            if (x < 1)
            {
                x = 1;
            }

            if (y < 1)
            {
                y = 1;
            }

            FileTreeModel model = (FileTreeModel)values[0];

            if (!model.IsFile)
            {
                bool         isExpanded = model.IsExpanded;
                ImageMoniker moniker    = isExpanded ? KnownMonikers.FolderOpened : KnownMonikers.FolderClosed;
                return(WpfUtil.ThemeImage((DependencyObject)values[3], WpfUtil.GetIconForImageMoniker(moniker, x, y)));
            }

            string      name = model.Name;
            bool        isThemeIcon;
            ImageSource source = WpfUtil.GetIconForFile((DependencyObject)values[3], name, out isThemeIcon);

            return(source);
        }