Beispiel #1
0
        public static bool Load()
        {
            bool ret = true;



            string syncFile = MyFile.EnsureDataFile("sync", Config.settings.exportExt, "sync");

            if (File.Exists(syncFile))
            {
                // load settings
                syncSettings = (SyncSettings)MyDeserialize.FromFile(Config.settings.exportFormat, syncFile, syncSettings);

                if (syncSettings.guid == null || syncSettings.about == null)
                {
                    syncSettings.Initialize();
                }
            }
            else
            {
                syncSettings.Initialize();
            }


            return(ret);
        }
Beispiel #2
0
        protected bool LoadSelectedFilter()
        {
            if (comboBoxFilters.Items.Count == 0)
            {
                return(false);
            }
            if (subFormFilterForm == null)
            {
                return(false);
            }

            string filterName = comboBoxFilters.Text;

            if (filterName.Length == 0)
            {
                return(false);
            }
            if (filterName == "<_reset_>")
            {
                subFormFilterForm.ResetForm();
                return(true);
            }
            if (filterName == "<filter when closed>")
            {
                filterName = "filter when closed";
            }
            else if (filterName == "<last saved filter>")
            {
                filterName = "last saved filter";
            }

            FilterInfo filterInfo = new FilterInfo(); // subFormFilterForm.GetFilterForm();
            string     dataFile   = MyFile.EnsureDataFile("Filter", Config.settings.exportExt, "filters", filterName);

            // MessageBox.Show(dataFile);
            if (File.Exists(dataFile))
            {
                // load filter preset
                filterInfo = (FilterInfo)MyDeserialize.FromFile(Config.settings.exportFormat, dataFile, filterInfo);

                if (filterInfo == null)
                {
                    MessageBox.Show("Unable to load Filter [" + filterName + "]");
                    return(false);
                }

                subFormFilterForm.ResetForm();

                subFormFilterForm.SetFilterForm(filterInfo);
                MyLog.Add("Loaded Filter Preset " + dataFile.Replace(MyFile.exeDirectory, ""));

                return(true);
            }
            return(false);
        }
        public static bool Load()
        {
            bool      ret       = false;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            // MyLog.Add("Loading VideoItemStats");

            string dataFile = MyFile.EnsureDataFile("stats", Config.settings.exportExt, "stats");

            if (dataFile == null)
            {
                return(false);
            }

            // keep a backup of settings
            if (File.Exists(dataFile))
            {
                videoInfoStats = new VideoInfoStats();
                videoInfoStats = (VideoInfoStats)MyDeserialize.FromFile(Config.settings.exportFormat, dataFile, videoInfoStats);

                string   fromFIle = "from " + dataFile.Replace(MyFile.exeDirectory, "");
                FileInfo fileInfo = MyFile.FileInfo(dataFile);
                if (fileInfo != null)
                {
                    fromFIle += " " + MyFile.FormatSize(fileInfo.Length);
                }
                MyLog.Add("Loaded VideoInfoStats " + fromFIle);

                if (videoInfoStats != null && videoInfoStats.year != null && videoInfoStats.year.Count() > 0)
                {
                    ret = true;
                }
            }
            else
            {
                // MyLog.Add("No VideoInfoStats to load ");
            }

            stopWatch.Stop();

            if (ret)
            {
                MyLog.AddElapsed(stopWatch.Elapsed);
            }

            return(ret);
        }
Beispiel #4
0
        /// <summary>
        /// parse the MVE .mve file
        /// </summary>
        /// <param name="mveFile"></param>
        /// <returns></returns>
        public VideoInfo ParseMVE(string mveFile)
        {
            VideoInfo videoInfo = new VideoInfo();

            videoInfo.Initialize();


            if (mveFile.StartsWith("<?xml"))
            {
                videoInfo.videoItem = (VideoItem)MyDeserialize.FromXMLFile(mveFile, videoInfo.videoItem);
            }
            else if (mveFile.StartsWith("{"))
            {
                videoInfo.videoItem = (VideoItem)MyDeserialize.FromJSONFile(mveFile, videoInfo.videoItem);
            }

            return(videoInfo);
        }
Beispiel #5
0
        public static bool Load()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            MyLog.Add("Loading VideoItems -->");

            int      nbrVideoInfos;
            FileInfo fileInfo;

            CreateList();
            foreach (ConfigSettings.Source source in Config.settings.sources)
            {
                string dataFile = MyFile.EnsureDataFile("videos", Config.settings.exportExt, "data", source.alias);
                if (dataFile == null)
                {
                    continue;
                }

                // keep a backup of settings
                if (File.Exists(dataFile))
                {
                    fileInfo = MyFile.FileInfo(dataFile);
                    List <VideoInfo> loadVideoInfos = (List <VideoInfo>)MyDeserialize.FromFile(Config.settings.exportFormat, dataFile, listVideoInfos);
                    if (loadVideoInfos == null)
                    {
                        MyLog.Add("Unable to load VideoInfos from " + dataFile);
                        continue;
                    }
                    AddItems(loadVideoInfos);

                    string fromFile = "from " + dataFile.Replace(MyFile.exeDirectory, "");
                    if (fileInfo != null)
                    {
                        fromFile += " " + MyFile.FormatSize(fileInfo.Length);
                    }

                    if (loadVideoInfos == null)
                    {
                        nbrVideoInfos = 0;
                    }
                    else
                    {
                        nbrVideoInfos = loadVideoInfos.Count();
                    }
                    MyLog.Add("Loaded " + nbrVideoInfos + " VideoItems " + fromFile);
                }
            }

            EnsureVideoInfos();

            stopWatch.Stop();


            if (listVideoInfos == null)
            {
                nbrVideoInfos = 0;
            }
            else
            {
                nbrVideoInfos = listVideoInfos.Count();
            }

            MyLog.AddElapsed("<-- in ", stopWatch.Elapsed);

            bool loaded = nbrVideoInfos > 0 ? true : false;

            return(loaded);
        }
Beispiel #6
0
        public static bool Load(Form mainForm)
        {
            bool ret = true;

            // app non configurable, so far, settings
            settings.exportFormat = "json";
            settings.exportExt    = "json"; // chicken egg


            string configFile    = MyFile.EnsureDataFile("settings", settings.exportExt, "config");
            bool   bLoadDefaults = false;

            if (File.Exists(configFile))
            {
                // load settings
                settings = (ConfigSettings)MyDeserialize.FromFile(settings.exportFormat, configFile, settings);
            }
            else
            {
                bLoadDefaults = true;
                ret           = false;
            }
            if (settings == null || settings.sources == null || settings.window == null || settings.gallery == null)
            {
                bLoadDefaults = true;
                ret           = false;
            }
            else
            {
                if (settings.window.left > 0 &&
                    settings.window.top > 0 &&
                    settings.window.height > 0 &&
                    settings.window.width > 0)
                {
                    // restore position/size
                    mainForm.Left   = settings.window.left;
                    mainForm.Top    = settings.window.top;
                    mainForm.Height = settings.window.height;
                    mainForm.Width  = settings.window.width;
                }

                if (settings.window.maximized == true)
                {
                    // restore to maximized state
                    mainForm.WindowState = FormWindowState.Maximized;
                }
            }

            // could not load settings, so set minimal defaults
            if (bLoadDefaults)
            {
                // meh, check all for defaults
            }

            // ensure other settings exist, else default
            if (settings == null)
            {
                settings      = new ConfigSettings();
                bLoadDefaults = true;
            }
            if (settings.sources == null)
            {
                settings.sources = new List <ConfigSettings.Source>();;
            }

            if (settings.gallery == null)
            {
                settings.gallery = new ConfigSettings.Gallery();
                bLoadDefaults    = true;
            }
            if (settings.gallery.backColor == Color.Empty)
            {
                settings.gallery.backColor = Color.DarkSlateBlue;
            }

            if (bLoadDefaults)
            {
                settings.gallery.enable = false;
                settings.gallery.cachePosterThumbnails = true;
            }

            // app non configurable, so far, settings
            settings.exportFormat = "json";
            settings.exportExt    = "json";

            return(ret);
        }