Exemple #1
0
        /// <summary>
        /// Finds the index of a given sheet (worksheet or chart sheet)
        /// in the Sheets collection.
        /// </summary>
        /// <param name="sheet">Worksheet or chart sheet</param>
        /// <returns>Index of the sheet in the Sheets collection</returns>
        public int IndexOf(dynamic sheet)
        {
            string         name = sheet.Name;
            SheetViewModel svm  = Sheets.FirstOrDefault(s => s.DisplayString == name);

            if (svm == null)
            {
                // If the sheet was not found, rebuild the sheet list.
                // Maybe the sheet was just added, before the watch timer got active.
                BuildSheetList();
                svm = Sheets.FirstOrDefault(s => s.DisplayString == name);
            }
            if (svm != null)
            {
                Logger.Info("IndexOf: Found view model for this sheet");
                return(Sheets.IndexOf(svm));
            }
            else
            {
                Logger.Warn("IndexOf: Requested sheet not found in collection!");
                return(-1);
            }
        }