コード例 #1
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Length == 3)
            {
                if (values[0] is Boolean)
                {
                    Boolean isValidPath = (Boolean)values[0];

                    if (isValidPath)
                    {
                        if (values[1] is Int64)
                        {
                            double usedSpace = (Int64)values[1];

                            if (values[2] is Int64)
                            {
                                double totalSpace = (Int64)values[2];

                                double percentage = usedSpace / totalSpace;

                                return("Used " + IntelligentString.FormatSize(usedSpace).Value + " of " + IntelligentString.FormatSize(totalSpace).Value + " (" + percentage.ToString("0.00%") + ")");
                            }
                        }
                    }
                    else
                    {
                        return("Path does not exist");
                    }
                }
            }

            return(String.Empty);
        }
コード例 #2
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is Int64)
            {
                return(IntelligentString.FormatSize((Int64)value).Value);
            }

            return(String.Empty);
        }
コード例 #3
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IntelligentString summary     = IntelligentString.Empty;
            String            strShowSize = "True";
            Boolean           showSize    = true;

            if (parameter != null)
            {
                strShowSize = parameter.ToString();
                Boolean.TryParse(strShowSize, out showSize);
            }

            if (value is IEnumerable <MediaItem> )
            {
                MediaItem[] mediaItems = (value as IEnumerable <MediaItem>).ToArray();

                int      numberOfItems = mediaItems.Length;
                Int64    size          = 0;
                TimeSpan duration      = new TimeSpan();

                String type = "Media Item";

                if (numberOfItems > 0)
                {
                    type = mediaItems[0].Type.ToString();
                }

                foreach (MediaItem mediaItem in mediaItems)
                {
                    size     += mediaItem.Parts.Size;
                    duration += mediaItem.Parts.Duration;

                    if (type != mediaItem.Type.ToString())
                    {
                        type = "Media Item";
                    }
                }

                if (numberOfItems == 1)
                {
                    summary += "1 " + type + " - ";
                }
                else
                {
                    summary += numberOfItems.ToString() + " " + type + "s - ";
                }

                if (showSize)
                {
                    summary += IntelligentString.FormatSize(size) + " - ";
                }

                summary += IntelligentString.FormatDuration(duration, false);
            }

            return(summary);
        }
コード例 #4
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Length == 4)
            {
                if (values[0] is Int64)
                {
                    Int64 progress = (Int64)values[0];

                    if (values[1] is Int64)
                    {
                        Int64 size = (Int64)values[1];

                        if (values[2] is OrganisingMediaItemPartStatus)
                        {
                            OrganisingMediaItemPartStatus status = (OrganisingMediaItemPartStatus)values[2];

                            if (values[3] is Int32)
                            {
                                Int32 errorCount = (Int32)values[3];

                                switch (status)
                                {
                                case OrganisingMediaItemPartStatus.Waiting:
                                    return("Waiting...");

                                case OrganisingMediaItemPartStatus.Organising:
                                    return(IntelligentString.FormatSize(progress).Value + " / " + IntelligentString.FormatSize(size).Value);

                                case OrganisingMediaItemPartStatus.Error:
                                    return("Not organised");

                                case OrganisingMediaItemPartStatus.Organised:
                                    if (errorCount == 0)
                                    {
                                        return("Successfully organised");
                                    }
                                    else
                                    {
                                        if (errorCount == 1)
                                        {
                                            return("Organised with 1 error");
                                        }
                                        else
                                        {
                                            return("Organised with " + errorCount.ToString() + " errors");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(String.Empty);
        }