Exemple #1
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (string.IsNullOrEmpty(location))
                {
                    return;
                }
                var uiPath = Path.Combine(location, "captura.exe");

                if (File.Exists(uiPath))
                {
                    Process.Start(uiPath);

                    return;
                }
            }

            User32.SetProcessDPIAware();

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new FakesModule());

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFmpegCmdOptions, ListCmdOptions>(args)
            .WithParsed((ListCmdOptions options) =>
            {
                Banner();

                var lister = ServiceProvider.Get <ConsoleLister>();

                lister.List();
            })
            .WithParsed((StartCmdOptions options) =>
            {
                Banner();

                using (var manager = ServiceProvider.Get <ConsoleManager>())
                {
                    manager.CopySettings();

                    manager.Start(options);
                }
            })
            .WithParsed((ShotCmdOptions options) =>
            {
                Banner();

                using (var manager = ServiceProvider.Get <ConsoleManager>())
                {
                    manager.Shot(options);
                }
            })
            .WithParsed((FFmpegCmdOptions options) =>
            {
                Banner();

                FFmpeg(options);
            });
        }
Exemple #2
0
        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += (S, E) =>
            {
                var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");

                Directory.CreateDirectory(dir);

                File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), E.ExceptionObject.ToString());

                if (E.ExceptionObject is Exception e)
                {
                    Current.Dispatcher.Invoke(() => new ExceptionWindow(e).ShowDialog());
                }

                Shutdown();
            };

            ServiceProvider.LoadModule(new CoreModule());

            Parser.Default.ParseArguments <CmdOptions>(Args.Args)
            .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            if (!CmdOptions.Reset)
            {
                settings.Load();
            }

            if (settings.UI.DarkTheme)
            {
                AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
            }

            var accent = settings.UI.AccentColor;

            if (!string.IsNullOrEmpty(accent))
            {
                AppearanceManager.Current.AccentColor = WpfExtensions.ParseColor(accent);
            }

            if (!string.IsNullOrWhiteSpace(settings.UI.Language))
            {
                var matchedCulture = LanguageManager.Instance.AvailableCultures.FirstOrDefault(M => M.Name == settings.UI.Language);

                if (matchedCulture != null)
                {
                    LanguageManager.Instance.CurrentCulture = matchedCulture;
                }
            }

            LanguageManager.Instance.LanguageChanged += L => settings.UI.Language = L.Name;
        }
Exemple #3
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                var uiPath = Path.Combine(ServiceProvider.AppDir, "captura.exe");

                if (File.Exists(uiPath))
                {
                    Process.Start(uiPath);

                    return;
                }
            }

            User32.SetProcessDPIAware();

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new FakesModule());

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFmpegCmdOptions, ListCmdOptions>(Args)
            .WithParsed((ListCmdOptions Options) =>
            {
                Banner();

                var lister = ServiceProvider.Get <ConsoleLister>();

                lister.List();
            })
            .WithParsed((StartCmdOptions Options) =>
            {
                Banner();

                using (var manager = ServiceProvider.Get <ConsoleManager>())
                {
                    manager.CopySettings();

                    manager.Start(Options);
                }
            })
            .WithParsed((ShotCmdOptions Options) =>
            {
                Banner();

                using (var manager = ServiceProvider.Get <ConsoleManager>())
                {
                    manager.Shot(Options);
                }
            })
            .WithParsed((FFmpegCmdOptions Options) =>
            {
                Banner();

                var ffmpegManager = ServiceProvider.Get <FFmpegConsoleManager>();

                // Need to Wait instead of await otherwise the process will exit
                ffmpegManager.Run(Options).Wait();
            });
        }
Exemple #4
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                var uiPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                          "captura.exe");

                if (File.Exists(uiPath))
                {
                    Process.Start(uiPath);

                    return;
                }
            }

            User32.SetProcessDPIAware();

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new FakesModule());

            // Hide on Full Screen Screenshot doesn't work on Console
            ServiceProvider.Get <Settings>().UI.HideOnFullScreenShot = false;

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFmpegCmdOptions, ListCmdOptions>(Args)
            .WithParsed((Action <ListCmdOptions>)(Options => List()))
            .WithParsed((Action <StartCmdOptions>)(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    CopySettings(vm.Settings);

                    Start(vm, Options);
                }
            }))
            .WithParsed((Action <ShotCmdOptions>)(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    Shot(vm, Options);
                }
            }))
            .WithParsed((Action <FFmpegCmdOptions>)(Options =>
            {
                Banner();

                FFmpeg(Options);
            }));
        }
Exemple #5
0
        //void ShowSplashScreen()
        //{
        //    var splashScreen = new SplashScreen("Images/Logo.png");
        //    splashScreen.Show(true);
        //}

        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainOnUnhandledException;

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            var settings = ServiceProvider.Get <Settings>();

            InitTheme(settings);
        }
Exemple #6
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                Process.Start(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                           "Captura.UI.exe"));

                return;
            }

            // Hide on Full Screen Screenshot doesn't work on Console
            ServiceProvider.Get <Settings>().UI.HideOnFullScreenShot = false;

            ServiceProvider.LoadModule(new FakesModule());

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFMpegCmdOptions, ListCmdOptions>(Args)
            .WithParsed <ListCmdOptions>(Options => List())
            .WithParsed <StartCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    // Load settings dummy
                    var dummySettings = new Settings();
                    dummySettings.Load();

                    vm.Settings.WebcamOverlay = dummySettings.WebcamOverlay;
                    vm.Settings.Clicks        = dummySettings.Clicks;
                    vm.Settings.Keystrokes    = dummySettings.Keystrokes;

                    Start(vm, Options);
                }
            })
            .WithParsed <ShotCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    Shot(vm, Options);
                }
            })
            .WithParsed <FFMpegCmdOptions>(Options =>
            {
                Banner();

                FFMpeg(Options);
            });
        }
Exemple #7
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                Process.Start(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                           "Captura.UI.exe"));

                return;
            }

            ServiceProvider.LoadModule(new FakesModule());

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFMpegCmdOptions, ListCmdOptions>(Args)
            .WithParsed <ListCmdOptions>(Options => List())
            .WithParsed <StartCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    // Remove Custom overlays
                    vm.CustomOverlays.Reset();

                    Start(vm, Options);
                }
            })
            .WithParsed <ShotCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    Shot(vm, Options);
                }
            })
            .WithParsed <FFMpegCmdOptions>(Options =>
            {
                Banner();

                FFMpeg(Options);
            });
        }
Exemple #8
0
        static void Main(string[] Args)
        {
            User32.SetProcessDPIAware();

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new FakesModule());
            ServiceProvider.LoadModule(new VerbsModule());

            var verbTypes = ServiceProvider
                            .Get <IEnumerable <ICmdlineVerb> >()
                            .Select(M => M.GetType())
                            .ToArray();

            Parser.Default.ParseArguments(Args, verbTypes)
            .WithParsed((ICmdlineVerb Verb) =>
            {
                // Always display Banner
                Banner();

                Verb.Run();
            });
        }
Exemple #9
0
        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainOnUnhandledException;

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            Parser.Default.ParseArguments <CmdOptions>(Args.Args)
            .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            InitTheme(settings);

            BindLanguageSetting(settings);

            BindKeymapSetting(settings);
        }
Exemple #10
0
 static ServiceLocator()
 {
     ServiceProvider.LoadModule(new MainModule());
 }
Exemple #11
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                var uiPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                          "captura.exe");

                if (File.Exists(uiPath))
                {
                    Process.Start(uiPath);

                    return;
                }
            }

            User32.SetProcessDPIAware();

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new FakesModule());

            // Hide on Full Screen Screenshot doesn't work on Console
            ServiceProvider.Get <Settings>().UI.HideOnFullScreenShot = false;

            Parser.Default.ParseArguments <StartCmdOptions, ShotCmdOptions, FFmpegCmdOptions, ListCmdOptions>(Args)
            .WithParsed <ListCmdOptions>(Options => List())
            .WithParsed <StartCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    // Load settings dummy
                    var dummySettings = new Settings();
                    dummySettings.Load();

                    vm.Settings.WebcamOverlay       = dummySettings.WebcamOverlay;
                    vm.Settings.MousePointerOverlay = dummySettings.MousePointerOverlay;
                    vm.Settings.Clicks     = dummySettings.Clicks;
                    vm.Settings.Keystrokes = dummySettings.Keystrokes;
                    vm.Settings.Elapsed    = dummySettings.Elapsed;

                    // FFmpeg Path
                    vm.Settings.FFmpeg.FolderPath = dummySettings.FFmpeg.FolderPath;

                    foreach (var overlay in dummySettings.Censored)
                    {
                        vm.Settings.Censored.Add(overlay);
                    }

                    foreach (var overlay in dummySettings.TextOverlays)
                    {
                        vm.Settings.TextOverlays.Add(overlay);
                    }

                    foreach (var overlay in dummySettings.ImageOverlays)
                    {
                        vm.Settings.ImageOverlays.Add(overlay);
                    }

                    Start(vm, Options);
                }
            })
            .WithParsed <ShotCmdOptions>(Options =>
            {
                Banner();

                using (var vm = ServiceProvider.Get <MainViewModel>())
                {
                    vm.Init(false, false, false, false);

                    Shot(vm, Options);
                }
            })
            .WithParsed <FFmpegCmdOptions>(Options =>
            {
                Banner();

                FFmpeg(Options);
            });
        }
Exemple #12
0
        private void Application_Startup(object sender, StartupEventArgs args)
        {
            AppDomain.CurrentDomain.UnhandledException += (o, unhandledExceptionEventArgs) =>
            {
                var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");

                Directory.CreateDirectory(dir);

                File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), unhandledExceptionEventArgs.ExceptionObject.ToString());

                if (unhandledExceptionEventArgs.ExceptionObject is Exception e)
                {
                    Current.Dispatcher.Invoke(() => new ExceptionWindow(e).ShowDialog());
                }

                Shutdown();
            };

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            Parser.Default.ParseArguments <CmdOptions>(args.Args)
            .WithParsed(cmdOptions => CmdOptions = cmdOptions);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            if (!CmdOptions.Reset)
            {
                settings.Load();
            }

            if (settings.Ui.DarkTheme)
            {
                AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
            }

            var accent = settings.Ui.AccentColor;

            if (!string.IsNullOrEmpty(accent))
            {
                AppearanceManager.Current.AccentColor = WpfExtensions.ParseColor(accent);
            }

            if (!string.IsNullOrWhiteSpace(settings.Ui.Language))
            {
                var matchedCulture = LanguageManager.Instance.AvailableCultures.FirstOrDefault(cultureInfo => cultureInfo.Name == settings.Ui.Language);

                if (matchedCulture != null)
                {
                    LanguageManager.Instance.CurrentCulture = matchedCulture;
                }
            }

            LanguageManager.Instance.LanguageChanged += cultureInfo => settings.Ui.Language = cultureInfo.Name;

            var keymap = ServiceProvider.Get <KeymapViewModel>();

            if (!string.IsNullOrWhiteSpace(settings.Keystrokes.KeymapName))
            {
                var matched = keymap.AvailableKeymaps.FirstOrDefault(keymapItem => keymapItem.Name == settings.Keystrokes.KeymapName);

                if (matched != null)
                {
                    keymap.SelectedKeymap = matched;
                }
            }

            keymap.PropertyChanged += (o, e) => settings.Keystrokes.KeymapName = keymap.SelectedKeymap.Name;
        }