private IEnumerator <YieldAction> doUpdateThumbnails()
        {
            imageGrid.clear();
            yield return(Coroutine.WaitSeconds(0.1f));

            foreach (ThumbnailPickerInfo thumbProp in thumbnailProperties)
            {
                if (imageGrid == null)
                {
                    yield break;
                }

                String imageId;
                using (FreeImageBitmap thumb = imageRenderer.renderImage(thumbProp.ImageProperties))
                {
                    imageId = thumbnailImages.addImage(thumb, thumb);
                }

                imageGrid.SuppressLayout = true;
                ButtonGridItem item = imageGrid.addItem("Main", "", imageId);
                item.UserObject = thumbProp;

                imageGrid.SuppressLayout = false;
                imageGrid.layout();

                if (imageGrid.Count == 1) //Select first item
                {
                    imageGrid.SelectedItem = imageGrid.getItem(0);
                }

                yield return(Coroutine.WaitSeconds(0.1f));
            }
        }
        public IEnumerator <YieldAction> initialize()
        {
            this.clear();
            yield return(Coroutine.WaitSeconds(0.1f));

            foreach (PresetState state in loadPresets(subDirectory))
            {
                if (presetListView == null)
                {
                    yield break;
                }

                String fullImageName = subDirectory + "/" + state.ImageName;
                String imageKey      = null;
                if (!imageAtlas.containsImage(fullImageName))
                {
                    try
                    {
                        using (Stream imageStream = context.ResourceProvider.openFile(fullImageName))
                        {
                            using (var image = new FreeImageBitmap(imageStream))
                            {
                                if (image != null)
                                {
                                    imageKey  = imageAtlas.addImage(fullImageName, image);
                                    image.Tag = fullImageName;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        Log.Error("Could not open image preview file {0}.", fullImageName);
                    }
                }
                presetListView.SuppressLayout = true;

                ButtonGridItem item = presetListView.addItem(state.Category, state.Name, imageKey);
                item.UserObject = state;

                presetListView.SuppressLayout = false;
                presetListView.layout();

                if (presetListView.Count == 1) //Select first item
                {
                    defaultItem = presetListView.getItem(0);
                }

                yield return(Coroutine.WaitSeconds(0.1f));
            }
        }
 void findSceneFiles()
 {
     try
     {
         VirtualFileSystem    archive        = VirtualFileSystem.Instance;
         String               sceneDirectory = MedicalConfig.SceneDirectory;
         IEnumerable <String> files          = archive.listFiles(sceneDirectory, "*.sim.xml", false);
         foreach (String file in files)
         {
             String fileName        = VirtualFileSystem.GetFileName(file);
             String baseName        = fileName.Substring(0, fileName.IndexOf('.'));
             String pictureFileName = sceneDirectory + "/" + baseName + ".png";
             String imageKey        = null;
             if (archive.exists(pictureFileName))
             {
                 using (Stream imageStream = archive.openStream(pictureFileName, Engine.Resources.FileMode.Open, Engine.Resources.FileAccess.Read))
                 {
                     using (var image = new FreeImageBitmap(imageStream))
                     {
                         if (image != null)
                         {
                             imageKey = imageAtlas.addImage(pictureFileName, image);
                         }
                     }
                 }
             }
             ButtonGridItem item = sceneFileGrid.addItem("Main", baseName, imageKey);
             item.ItemClicked += new EventHandler(item_ItemClicked);
             item.UserObject   = file;
         }
         if (sceneFileGrid.Count > 0)
         {
             sceneFileGrid.SelectedItem = sceneFileGrid.getItem(0);
         }
     }
     catch (Exception ex)
     {
         Logging.Log.Error("{0} loading scene files for ChooseScneDialog.\nMessage: {1}", ex.GetType().Name, ex.Message);
     }
 }