Esempio n. 1
0
        private void FillPropertyBox(VolumeItem item)
        {
            ItemProperty[] properties;
            Dictionary <string, string> nameProperty;

            switch (item.GetVolumeItemType())
            {
            case VolumeItemType.FileVolumeItem:
            case VolumeItemType.DirectoryVolumeItem:

                ItemProperty.GetFSItemProperties((FileSystemVolumeItem)item,
                                                 out properties,
                                                 out nameProperty);
                break;

            case VolumeItemType.AudioTrackVolumeItem:

                ItemProperty.GetAudioCdItemProperties((AudioTrackVolumeItem)item,
                                                      out properties,
                                                      out nameProperty);
                break;

            default:
                throw new NotImplementedException("Iteminfo has not been implemented for this itemtype yet");
            }

            propertyBox.SetProperties(properties);

            string tmp;

            if (nameProperty.TryGetValue("title", out tmp))
            {
                // title found (e.g. html or doc file)
                // may be followed optionally by artist and/or album (audio file)
                StringBuilder sbName    = new StringBuilder();
                StringBuilder sbTooltip = new StringBuilder();

                sbName.AppendFormat("<b>{0}</b>", Util.Escape(tmp));
                sbTooltip.Append(tmp);

                if (nameProperty.TryGetValue("artist", out tmp))
                {
                    sbName.AppendFormat(" <i>{0}</i> {1}", STR_BY, Util.Escape(tmp));
                    sbTooltip.AppendFormat(" {0} {1}", STR_BY, tmp);
                }

                if (nameProperty.TryGetValue("album", out tmp))
                {
                    sbName.AppendFormat(" <i>{0}</i> {1}", STR_FROM, Util.Escape(tmp));
                    sbTooltip.AppendFormat(" {0} {1}", STR_FROM, tmp);
                }

                propertyBox.SetNameProperty(sbName.ToString(), sbTooltip.ToString());
            }
            else
            {
                // name expected
                if (!nameProperty.TryGetValue("name", out tmp))
                {
                    throw new ArgumentException("Name expected");
                }

                propertyBox.SetNameProperty(string.Format("<b>{0}</b>", Util.Escape(tmp)), tmp);
            }
        }