Example #1
0
        private void InitAvisynth()
        {
            avsrepo.SetPortableMode(true); // avsrepo should always be called with -p since it doesn't know anything about avisynth plugin folders
            var settings = new PortableSettings().LoadLocalFile("avsrepogui.json");

            var avsrepo_files     = new string[] { "avsrepo.exe", "avsrepo-32.exe", "avsrepo-64.exe" };
            var found_avrespo_bin = false;

            foreach (var avs_file in avsrepo_files)
            {
                if (File.Exists(avs_file))
                {
                    avsrepo.python_bin = avs_file;
                    found_avrespo_bin  = true;
                }
            }

            if (!found_avrespo_bin)
            {
                MessageBox.Show("Can't find avsrepo.exe, avsrepo-32.exe or avsrepo-64.exe", "AVSRepo not found");

                if (MessageBox.Show("Open download page for avsrepo?", "AVSRepo not found", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Process.Start("https://github.com/theChaosCoder/avsrepo/releases");
                }
                System.Environment.Exit(1);
            }

            if (!is7zipCallable())
            {
                MessageBox.Show("You need to either place 7z.exe & 7z.dll next to avsrepo.exe OR install 7zip and make sure it is in PATH", "7z.exe not found");
                if (MessageBox.Show("Open 7z download page?", "7z.exe not found", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Process.Start("https://www.7-zip.org/download.html");
                }

                System.Environment.Exit(1);
            }

            if (settings is null)
            {
#if !DEBUG
                TabablzControl.Items.RemoveAt(TabablzControl.Items.Count - 1);
#endif


                AppIsWorking(true);
                avsrepo.SetArch(Environment.Is64BitOperatingSystem);
                avspackages_file = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\avspackages.json"; // That means avsrepo.exe needs to be near avsrepogui
                if (Avs32Paths != null)
                {
                    avsrepo.SetPaths(false, new Paths()
                    {
                        Binaries = Avs32Paths.Plugin, Scripts = Avs32Paths.Script, Definitions = avspackages_file
                    });
                }
                if (Avs64Paths != null)
                {
                    avsrepo.SetPaths(true, new Paths()
                    {
                        Binaries = Avs64Paths.Plugin, Scripts = Avs64Paths.Script, Definitions = avspackages_file
                    });
                }

                //Quickfix: turns out that the paths command can't be run without a package definitions file :-(
                if (!File.Exists(avspackages_file))
                {
                    avsrepo.Update();
                }



                //Trigger GetPaths for 32/64 bit, they are cached in VsApi class anyway
                _ = avsrepo.GetPaths(true).Definitions; _ = avsrepo.GetPaths(false).Definitions;
            }
            else // Portable mode, valid avsrepogui.json found
            {
                //TabablzControl doesn't support hiding or collapsing Tabitems. Hide "Settings" (last) tab if we are in avisynth portable mode
#if !DEBUG
                TabablzControl.Items.RemoveAt(TabablzControl.Items.Count - 1);
#endif
                LabelPortable.Visibility = Visibility.Visible;
                avsrepo.SetPortableMode(true);
                avsrepo.python_bin = settings.Bin;
                avspackages_file   = Path.GetDirectoryName(settings.Bin) + "\\avspackages.json";

                // Set paths manually and DONT trigger Win64 onPropertyChanged yet
                avsrepo.SetPaths(true, new Paths()
                {
                    Binaries = settings.Win64.Binaries, Scripts = settings.Win64.Scripts, Definitions = avspackages_file
                });
                avsrepo.SetPaths(false, new Paths()
                {
                    Binaries = settings.Win32.Binaries, Scripts = settings.Win32.Scripts, Definitions = avspackages_file
                });

                // Triggering  Win64 is now safe
                //Win64 = Environment.Is64BitOperatingSystem;
            }

            try
            {
                Plugins.All = LoadLocalAvspackage();
                avsrepo.Update();
            }
            catch
            {
                MessageBox.Show("Could not read (or download) avspackages.json.");
                System.Environment.Exit(1);
            }
        }
Example #2
0
        private void InitAvisynth()
        {
            avsrepo.SetPortableMode(true); // avsrepo should always be called with -p since it doesn't know anything about avisynth plugin folders
            var settings = new PortableSettings().LoadLocalFile("avsrepogui.json");

            var avsrepo_files     = new string[] { "avsrepo.exe", "avsrepo-32.exe", "avsrepo-64.exe" };
            var found_avrespo_bin = false;

            foreach (var avs_file in avsrepo_files)
            {
                if (File.Exists(avs_file))
                {
                    avsrepo.python_bin = avs_file;
                    found_avrespo_bin  = true;
                }
            }

            if (!found_avrespo_bin)
            {
                MessageBox.Show("Can't find avsrepo.exe, avsrepo-32.exe or avsrepo-64.exe");
                System.Environment.Exit(1);
            }


            if (settings is null)
            {
                AppIsWorking(true);
                avsrepo.SetArch(Environment.Is64BitOperatingSystem);
                vspackages_file = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\avspackages.json"; // That means avsrepo.exe needs to be near avsrepogui
                if (Avs32Paths != null)
                {
                    avsrepo.SetPaths(false, new Paths()
                    {
                        Binaries = Avs32Paths.Plugin, Scripts = Avs32Paths.Script, Definitions = vspackages_file
                    });
                }
                if (Avs64Paths != null)
                {
                    avsrepo.SetPaths(true, new Paths()
                    {
                        Binaries = Avs64Paths.Plugin, Scripts = Avs64Paths.Script, Definitions = vspackages_file
                    });
                }
                //Trigger GetPaths for 32/64 bit, they are cached in VsApi class anyway
                _ = avsrepo.GetPaths(true).Definitions; _ = avsrepo.GetPaths(false).Definitions;
            }
            else // Portable mode, valid avsrepogui.json found
            {
                //TabablzControl doesn't support hiding or collapsing Tabitems. Hide "Settings" (last) tab if we are in avisynth portable mode
                TabablzControl.Items.RemoveAt(TabablzControl.Items.Count - 1);

                LabelPortable.Visibility = Visibility.Visible;
                avsrepo.SetPortableMode(true);
                avsrepo.python_bin = settings.Bin;
                vspackages_file    = Path.GetDirectoryName(settings.Bin) + "\\avspackages.json";

                // Set paths manually and DONT trigger Win64 onPropertyChanged yet
                avsrepo.SetPaths(true, new Paths()
                {
                    Binaries = settings.Win64.Binaries, Scripts = settings.Win64.Scripts, Definitions = vspackages_file
                });
                avsrepo.SetPaths(false, new Paths()
                {
                    Binaries = settings.Win32.Binaries, Scripts = settings.Win32.Scripts, Definitions = vspackages_file
                });

                // Triggering  Win64 is now safe
                //Win64 = Environment.Is64BitOperatingSystem;
            }

            try
            {
                Plugins.All = LoadLocalVspackage();
                avsrepo.Update();
            }
            catch
            {
                MessageBox.Show("Could not read (or download) avspackages.json.");
                System.Environment.Exit(1);
            }
        }