示例#1
0
        /// <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);
        }
示例#2
0
        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);
        }
示例#3
0
 public MainForm()
 {
     InitializeComponent();
     // load reference screen definition (ini file)
     loadReferenceScreens();
     pupScreens = new PupScreens();
     TopMost    = true;
 }
示例#4
0
        public PupScreen AddOne(int screenIndex, bool transparent, PupScreens refScreens)
        {
            PupScreen ps = new PupScreen(transparent, null, refScreens);

            ps.ScreenIndex = screenIndex;
            ps.SetRefScreen(BACKGLASS_SCREENINDEX);
            ps.HasCustomPos = true;
            ps.CustPosX     = 25;
            ps.CustPosY     = 25;
            ps.CustPosW     = 50;
            ps.CustPosH     = 50;
            ps.CalculateRealPos();
            ps.Description = "PuP screen #" + screenIndex;
            ps.Window.SetCaption(DEFAULT_SCREEN_CAPTION + screenIndex);
            ps.Active         = DEFAULT_ACTIVE_MODE;
            ps.Window.Visible = true;
            this.Add(ps);
            return(ps);
        }
示例#5
0
        /// <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();
            }
        }
示例#6
0
        /// <summary>
        /// Create a .res file, used to define custom positioning of a B2S
        /// </summary>
        /// <param name="pupScreen"></param>
        /// <param name="refScreens"></param>
        /// <returns></returns>
        public static string BuildResFile(PupScreen pupScreen, PupScreens refScreens)
        {
            string content = "";

            content += refScreens[3].W.ToString() + Environment.NewLine;
            content += refScreens[3].H.ToString() + Environment.NewLine;
            content += pupScreen.W.ToString() + Environment.NewLine;
            content += pupScreen.H.ToString() + Environment.NewLine;
            content += "@" + refScreens[2].X.ToString() + Environment.NewLine;
            content += (pupScreen.X - refScreens[2].X).ToString() + Environment.NewLine;
            //content += (pupScreen.Y - refScreens[2].Y).ToString() + Environment.NewLine;
            content += (pupScreen.Y - 0).ToString() + Environment.NewLine;
            content += refScreens[1].W.ToString() + Environment.NewLine;
            content += refScreens[1].H.ToString() + Environment.NewLine;
            content += (refScreens[1].X - refScreens[2].X).ToString() + Environment.NewLine;
            content += (refScreens[1].Y - 0).ToString() + Environment.NewLine;
            content += "0" + Environment.NewLine;
            content += (pupScreen.X - refScreens[2].X).ToString() + Environment.NewLine;
            content += (pupScreen.Y - 0).ToString() + Environment.NewLine;
            content += pupScreen.W.ToString();
            content += pupScreen.H.ToString();
            content += "" + Environment.NewLine;
            return(content);
        }
示例#7
0
        /// <summary>
        /// load the PuP screens info from a "screens.pup" file
        /// </summary>
        private void loadScreensPupFile()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "PuP file|*.pup";
            openFileDialog1.Title  = "Please pick a screens.pup file to open";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                screensPupFile = openFileDialog1.FileName;
                killAllWindows(); // in case it's not the first time a file is loaded
                dataGridView1.DataSource = null;
                string errors = "";
                pupScreens = PupTools.GetPupScreensFromPupFile(screensPupFile, useTransparentPupFrames, refScreens, ref errors);
                if (pupScreens == null)
                {
                    MessageBox.Show(this, "Not a valid screens.pup file" + Environment.NewLine + errors, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    // add the invalid ref screens to the drop down list
                    List <int?> invalidScreens = new List <int?>();
                    foreach (PupScreen screen in pupScreens)
                    {
                        if (screen.InvalidScreenReference != null)
                        {
                            bool found = false;
                            foreach (string item in cboRefScreen.Items)
                            {
                                if (item == screen.InvalidScreenReference.ToString())
                                {
                                    found = true;
                                }
                            }
                            if (!found)
                            {
                                invalidScreens.Add(screen.InvalidScreenReference);
                                cboRefScreen.Items.Add(screen.InvalidScreenReference.ToString());
                            }
                        }
                    }
                    if (invalidScreens.Count != 0)
                    {
                        string list = String.Join(", ", invalidScreens.ToArray());
                        MessageBox.Show(this,
                                        "Warning: your screens.pup file contains some definitions using unknown references screens (" + list + ")"
                                        + Environment.NewLine
                                        + "These screens are not defined in your PinUpPlayer.ini file",
                                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    pupScreenBindingList     = new BindingList <PupScreen>(pupScreens);
                    pupScreensSource         = new BindingSource(pupScreenBindingList, null);
                    dataGridView1.DataSource = pupScreensSource;

                    foreach (PupScreen pupScreen in pupScreens)
                    {
                        pupScreen.Window.Visible   = pupScreen.Active != "off";
                        pupScreen.PropertyChanged += PupScreenPropertiesChanged;
                        pupScreen.Window.UnauthorizedActivation += UnauthorizedActivationOfPupScreen;
                    }
                    updateAllCustomPosInGrid();

                    enablePropertyControls();

                    if (dataGridView1.Rows.Count > 0)
                    {
                        dataGridView1.Rows[0].Selected = true;
                        selectedPupScreen.Highlight(true);
                        updateScreenPropertiesFields();
                    }
                }
            }
            Focus();
        }