Exemple #1
0
        public static String UpdateImageList(IController callingController, ImageList passedList, String imageFilePath, Boolean useConfigPath)
        {
            String fileInfoString = imageFilePath;
            Stream imageStream = null;
            FileStream streamFromFileInfo = null;

            if (useConfigPath)
            {
                if (!imageFilePath.Contains("\\")) // not like "C:\task.png, e.g. "task.png"
                {
                    imageStream = callingController.GetImage(imageFilePath);
                }
                else
                {
                    FileInfo fileInfo = new FileInfo(fileInfoString);
                    streamFromFileInfo = fileInfo.Open(FileMode.Open);
                    imageStream = streamFromFileInfo;
                }
            }

            if (!passedList.Images.ContainsKey(fileInfoString))
            {
                if (imageStream != null)
                {
                    Bitmap bitmap = new Bitmap(imageStream);
                    passedList.Images.Add(fileInfoString, new Bitmap(bitmap)); // key on node ID
                    if (streamFromFileInfo != null)
                    {
                        streamFromFileInfo.Close();
                    }
                    bitmap.Dispose();
                }
            }
            return fileInfoString;
        }