private void baseList_SelectionChanged(object sender, System.EventArgs e)
 {
     if (baseList.SelectedControl != null)
     {
         if (currentCard != null)
         {
             currentCard.BackColor = DefaultCardColor;
         }
         currentCard           = baseList.SelectedControl as DiagramReport;
         currentCard.BackColor = SelectedCardColor;
     }
 }
        /// <summary>
        /// Loads the given directory in the browser
        /// </summary>
        /// <param name="path"></param>
        /// <param name="showGauge">whether the gauge should be shown</param>
        public void LoadDirectory(string path, bool showGauge)
        {
#if !DEBUG
            mediator.parent.RaiseLoading("Loading diagrams in the diagram browser...");
#endif
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (showGauge)
                {
                    SetUIState(false);
                }
                if (!Directory.Exists(path))
                {
                    return;
                }
                path             = Path.GetFullPath(path);
                browsePath.Text  = path;
                currentDirectory = path;
                baseList.Controls.Clear();
                baseList.Redraw();
                GraphLib.IO.Reporting.BinaryReporter reporter = new Netron.GraphLib.IO.Reporting.BinaryReporter(path);
                reporter.OnReport += new InfoDelegate(OnReport);
                GraphLib.IO.Reporting.BinaryReportCollection col = reporter.Report() as GraphLib.IO.Reporting.BinaryReportCollection;
                DiagramReport card;
                BinaryReport  report = null;
                //stop the layout for a moment until the list is filled

                baseList.BeginUpdate();
                for (int k = 0; k < col.Count; k++)
                {
                    try
                    {
                        card                   = new DiagramReport();
                        report                 = col[k];
                        card.FileName.Text     = new System.IO.FileInfo(report.Path).Name;
                        card.BackColor         = DefaultCardColor;
                        card.ThumbNail.Image   = report.Thumbnail;
                        card.Title             = report.Title == ""? "[Not set]": report.Title;
                        card.FilePath          = report.Path;
                        card.Author.Text       = report.Author == ""?"[Not set]": report.Author;
                        card.Description.Text  = report.Description == ""?"[Not set]":report.Description;
                        card.CreationDate.Text = report.CreationDate == ""? "[Not set]":report.CreationDate;
                        #region Connect events
                        card.LoadDiagram     += new Netron.Cobalt.DiagramReport.PathInfo(card_LoadDiagram);
                        card.SelectDirectory += new EventHandler(card_SelectDirectory);
                        card.ReloadDirectory += new EventHandler(card_ReloadDirectory);
                        card.DeleteDiagram   += new Netron.Cobalt.DiagramReport.PathInfo(card_DeleteDiagram);
                        #endregion
                        baseList.Controls.Add(card);
                        mediator.Output("Found '" + card.FileName.Text + "' in directory.", GraphLib.OutputInfoLevels.Info);
#if !DEBUG
                        mediator.parent.RaiseLoading("...found diagram '" + card.FileName.Text + "'");
                        System.Threading.Thread.Sleep(300);
#endif
                    }
                    catch
                    {
                        mediator.Output("File '" + new System.IO.FileInfo(report.Path).Name + "' seems not to be a valid diagram file.", GraphLib.OutputInfoLevels.Info);
                        continue;
                    }
                    baseList.EndUpdate();
                }
            }
            catch (System.IO.DirectoryNotFoundException e1)
            {
                mediator.Output("The directory was not found", GraphLib.OutputInfoLevels.Exception);
                Trace.WriteLine(e1.Message, "DiagramBrowserTab.LoadDirectory");
            }
            catch (System.IO.FileNotFoundException e2)
            {
                mediator.Output("The file was not found", GraphLib.OutputInfoLevels.Exception);
                Trace.WriteLine(e2.Message, "DiagramBrowserTab.LoadDirectory");
            }
            catch (Exception e)
            {
                mediator.Output(e.Message, GraphLib.OutputInfoLevels.Exception);
                Trace.WriteLine(e.Message, "DiagramBrowserTab.LoadDirectory");
            }
            finally
            {
                this.Cursor = Cursors.Default;
                SetUIState(true);
            }
        }