Exemplo n.º 1
0
        void TestLoad()
        {
            PS8 ps8 = PS8Reader.Read(Application.StartupPath + @"/playlist2.txt");

            Console.WriteLine(ps8.Files[0].filename + ":" + ps8.Files[0].path);
            Console.WriteLine(ps8.Speed);
        }
Exemplo n.º 2
0
        public static bool Save(PS8 content, string filename)
        {
            string str = string.Empty;

            foreach (var item in content.Files)
            {
                str += item.filename + "|" + item.path + "|" + item.extension + Environment.NewLine;
            }
            using (StreamWriter writer = new StreamWriter(filename)) {
                try{
                    /*
                     * Format
                     * PS8|<speed>
                     * <file_name 1>|<path 1>|<exention 1>
                     * <file_name 2>|<path 2>|<exention 2>
                     * ...
                     * ...
                     * <file_name 99>|<path 99>|<exention 99>
                     */
                    writer.Write("PS8|" + content.Speed + Environment.NewLine + str);
                }
                catch (Exception) {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        void TestSave()
        {
            PS8 ps8 = new PS8();

            ps8.Speed = 500;
            for (int i = 1; i <= 3; i++)
            {
                ps8.AddPhoto("this is a test" + i, "path" + i);
            }
            PS8Writer.Save(ps8, Application.StartupPath + @"/playlist2.txt");
        }
Exemplo n.º 4
0
        public static PS8 Read(string ps8file)
        {
            string ps8strnig = PS8String(ps8file);

            using (StringReader reader = new StringReader(ps8strnig)) {
                try{
                    PS8      ps8    = new PS8();
                    string[] header = reader.ReadLine().Split('|');

                    if (header[0] != "PS8")
                    {
                        throw new PS8Exception("Invalid Photo Slide playlist format.");
                    }
                    else
                    {
                        if (header[1] == string.Empty)
                        {
                            throw new PS8Exception("Invalid Photo Slide playlist format. Interval not defined");
                        }
                        else
                        {
                            if (Convert.ToInt32(header[1]) <= 100)
                            {
                                ps8.Speed = 1000;
                            }
                            else
                            {
                                ps8.Speed = Convert.ToInt32(header[1]);
                            }
                        }
                        while (reader.Peek() != -1)
                        {
                            string[] d = reader.ReadLine().Split('|');
                            ps8.AddPhoto(d[0], d[1], d[2]);
                        }
                        return(ps8);
                    }
                }
                catch (Exception ex) {
                    throw new PS8Exception("Invalid Photo Slide playlist format\n" + ex.Message);
                }
            }
        }
Exemplo n.º 5
0
        void LoadPlaylist(string _playlistfile, bool append)
        {
            try
            {
                imageList.Files.Clear();

                imageList = PS8Reader.Read(_playlistfile);

                this.timer1.Interval        = imageList.Speed;
                this.toolStriptxtSpeed.Text = this.timer1.Interval.ToString();
                ListFiles();

                //set the default delay
                defaultDelay = imageList.Speed;
                fileIndex    = 0;
            }
            catch (PS8Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            GC.Collect();
        }