예제 #1
0
        public void AddFile(FileInfo fileInfo)
        {
            // Only add .dft files.
            if (!fileInfo.Extension.Equals(".dft", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // If the file has already been added, ignore it.
            if (Items.ContainsKey(fileInfo.FullName))
            {
                return;
            }

            // Add the icon to the image list if it's not there.
            if (!SmallImageList.Images.ContainsKey(fileInfo.Extension))
            {
                // Note: GetSmallIcon() is an extension method.
                Icon icon = fileInfo.GetSmallIcon();
                SmallImageList.Images.Add(fileInfo.Extension, icon);
            }


            // Add the list view item.
            ListViewItem listViewItem = Items.Add(
                key: fileInfo.FullName,
                text: fileInfo.FullName,
                imageKey: fileInfo.Extension);

            // Make a clone of the DraftPrintUtility settings for this individual item.
            listViewItem.Tag = DraftPrintUtilityOptions.Clone();
        }