/// <summary>
        /// build a collection of pup screens, read from a "screens.pup" file
        /// screens.pup format:
        ///  - csv file
        ///  - 1 line of header (ScreenNum,ScreenDes,PlayList,PlayFile,Loopit,Active,Priority,CustomPos)
        ///  - 1 line per screen (usually 10)
        ///  - Example of CustomPos field: "2,0,23.2,100,49.83"
        ///      - Screen ref index
        ///      - X position of screen (%) relatively to ref screen
        ///      - Y position of screen (%) relatively to ref screen
        ///      - Width position of screen (%) relatively to ref screen
        ///      - Height position of screen (%) relatively to ref screen
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="transparentByDefault"></param>
        /// <param name="refScreens"></param>
        /// <returns></returns>
        public static PupScreens GetPupScreensFromPupFile(string fileName, bool transparentByDefault, List <PupScreen> refScreens, ref string errors)
        {
            string[] lines     = System.IO.File.ReadAllLines(fileName);
            int      lineIndex = 0;

            errors = "";
            PupScreens pupScreens = new PupScreens();

            foreach (string line in lines)
            {
                if (lineIndex > 0 && line.Trim() != "")
                {
                    PupScreen pupScreen = new PupScreen(transparentByDefault, Color.Yellow, refScreens);
                    try
                    {
                        pupScreen.LoadFromCsv(line);
                        pupScreen.CalculateRealPos();
                        pupScreens.Add(pupScreen);
                    }
                    catch
                    {
                        errors += "Error in definition of screen line #" + lineIndex + Environment.NewLine;
                    }
                }
                lineIndex++;
            }
            return(errors == "" ? pupScreens : null);
        }
        public static PupScreens GetPupScreenFromIniFile(string fileName, bool transparentByDefault)
        {
            PupScreens pupScreens = new PupScreens();

            try
            {
                IniManager ini = new IniManager(fileName);
                for (int t = 0; t <= 10; t++)
                {
                    PupScreen pupScreen = new PupScreen(transparentByDefault, null, null);
                    pupScreen.ScreenIndex = t;
                    pupScreen.X           = ini.ReadInt("ScreenXPos", "INFO" + (t == 0 ? "" : t.ToString()));
                    pupScreen.Y           = ini.ReadInt("ScreenYPos", "INFO" + (t == 0 ? "" : t.ToString()));
                    pupScreen.W           = ini.ReadInt("ScreenWidth", "INFO" + (t == 0 ? "" : t.ToString()));
                    pupScreen.H           = ini.ReadInt("ScreenHeight", "INFO" + (t == 0 ? "" : t.ToString()));
                    if (pupScreen.X == -1)
                    {
                        throw(null);
                    }
                    pupScreen.Window.Visible = false;
                    pupScreens.Add(pupScreen);
                }
                if (pupScreens.Count == 0)
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
            return(pupScreens);
        }
        /// <summary>
        /// load values from PinUpPlayer.ini (dimensions and locations of ref PuP screens, to be used as references)
        /// </summary>
        private void loadReferenceScreens()
        {
            string iniFile = PupTools.FindPuPIniFile();

            try
            {
                refScreens = PupTools.GetPupScreenFromIniFile(iniFile, useTransparentPupFrames);
                refScreens.Add(PupScreens.CreateSpecial99Screen()); // add the virtual "99" screen, used for a screen to refer to itself
                cboRefScreen.Items.Add("");
                foreach (PupScreen ps in refScreens)
                {
                    cboRefScreen.Items.Add(ps.ScreenIndex.ToString());
                }
                cboRefScreen.Items.Add(PupScreens.OTHER_SCREENINDEX);
            }
            catch
            {
                MessageBox.Show(this, "Cannot open/read PinUpPlayer.ini... Exiting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }