Example #1
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);
        }
 /// <summary>
 /// Initialises a new instance of the OrganisingMediaItemPart class
 /// </summary>
 /// <param name="mediaItem">Media item the part being organised belongs to</param>
 /// <param name="partIndex">Index in the media item's collection of the part being organised</param>
 /// <param name="organisedPath">Path the part will be moved to</param>
 /// <param name="requiresMove">Value determining whether the part needs to be moved</param>
 public OrganisingMediaItemPart(MediaItem mediaItem, int partIndex, IntelligentString organisedPath, Boolean requiresMove)
 {
     this.mediaItem     = mediaItem;
     this.part          = mediaItem.Parts[partIndex];
     this.organisedPath = organisedPath;
     this.progress      = 0;
     this.status        = OrganisingMediaItemPartStatus.Waiting;
     this.errors        = new Dictionary <IntelligentString, Exception>();
     this.timeTaken     = TimeSpan.FromSeconds(0);
     this.requiresMove  = requiresMove;
 }