public override void DidFinishLaunching(NSNotification notification) { const string FFMPEG_CONFIG_NAME = "ffmpeg.json"; const string TRICYCLE_CONFIG_NAME = "tricycle.json"; const string TEMPLATE_CONFIG_NAME = "templates.json"; var version = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString(); var revision = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString(); AppState.AppName = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleName").ToString(); AppState.AppVersion = Version.TryParse(version, out var a) && int.TryParse(revision, out var b) ? new Version(a.Major, a.Minor, a.Build, b) : new Version(); string resourcePath = NSBundle.MainBundle.ResourcePath; string defaultConfigPath = Path.Combine(resourcePath, "Config"); string ffmpegPath = Path.Combine(resourcePath, "Tools", "FFmpeg"); string ffmpegFileName = Path.Combine(ffmpegPath, "ffmpeg"); string userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string userConfigPath = Path.Combine(userPath, "Library", "Preferences", "Tricycle"); var processCreator = new Func <IProcess>(() => new ProcessWrapper()); var processRunner = new ProcessRunner(processCreator); var fileSystem = new FileSystem(); var jsonSerializer = new JsonSerializer(); var ffmpegConfigManager = new FFmpegConfigManager(fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, FFMPEG_CONFIG_NAME), Path.Combine(userConfigPath, FFMPEG_CONFIG_NAME)); var tricycleConfigManager = new TricycleConfigManager(fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, TRICYCLE_CONFIG_NAME), Path.Combine(userConfigPath, TRICYCLE_CONFIG_NAME)); _templateManager = new FileConfigManager <Dictionary <string, JobTemplate> >( fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, TEMPLATE_CONFIG_NAME), Path.Combine(userConfigPath, TEMPLATE_CONFIG_NAME)); ffmpegConfigManager.Load(); tricycleConfigManager.Load(); _templateManager.Load(); if (tricycleConfigManager.Config.Trace) { EnableLogging(userPath); } _templateManager.ConfigChanged += config => PopulateTemplateMenu(); var ffmpegArgumentGenerator = new FFmpegArgumentGenerator(new ArgumentPropertyReflector()); AppState.IocContainer = new Container(_ => { _.For <IConfigManager <FFmpegConfig> >().Use(ffmpegConfigManager); _.For <IConfigManager <TricycleConfig> >().Use(tricycleConfigManager); _.For <IConfigManager <Dictionary <string, JobTemplate> > >().Use(_templateManager); _.For <IFileBrowser>().Use <FileBrowser>(); _.For <IFolderBrowser>().Use <FolderBrowser>(); _.For <IProcessUtility>().Use(ProcessUtility.Self); _.For <IMediaInspector>().Use(new MediaInspector(Path.Combine(ffmpegPath, "ffprobe"), processRunner, ProcessUtility.Self, jsonSerializer)); _.For <ICropDetector>().Use(new CropDetector(ffmpegFileName, processRunner, ffmpegConfigManager, ffmpegArgumentGenerator)); _.For <IInterlaceDetector>().Use(new InterlaceDetector(ffmpegFileName, processRunner, ffmpegArgumentGenerator)); _.For <IFileSystem>().Use(fileSystem); _.For <ITranscodeCalculator>().Use <TranscodeCalculator>(); _.For <IArgumentPropertyReflector>().Use <ArgumentPropertyReflector>(); _.For <IMediaTranscoder>().Use(new MediaTranscoder(ffmpegFileName, processCreator, ffmpegConfigManager, ffmpegArgumentGenerator)); _.For <IDevice>().Use(DeviceWrapper.Self); _.For <IAppManager>().Use(_appManager); _.For <IPreviewImageGenerator>().Use(new PreviewImageGenerator(ffmpegFileName, processRunner, ffmpegConfigManager, ffmpegArgumentGenerator, fileSystem)); _.For <ILanguageService>().Use <LanguageService>(); }); AppState.DefaultDestinationDirectory = Path.Combine(userPath, "Movies"); Forms.Init(); LoadApplication(new App(_appManager)); PopulateTemplateMenu(); base.DidFinishLaunching(notification); }
public void CoalesceCopiesAudioWhenNull() { _defaultConfig.Audio = new AudioConfig(); _configManager.Load(); Assert.IsNotNull(_configManager.Config?.Audio); }
void InitializeAppState() { const string FFMPEG_CONFIG_NAME = "ffmpeg.json"; const string TRICYCLE_CONFIG_NAME = "tricycle.json"; const string TEMPLATE_CONFIG_NAME = "templates.json"; var asm = Assembly.GetExecutingAssembly(); AppState.AppName = asm.GetCustomAttribute <AssemblyTitleAttribute>()?.Title; AppState.AppVersion = asm.GetName().Version; string appPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string assetsPath = Path.Combine(appPath, "Assets"); string defaultConfigPath = Path.Combine(assetsPath, "Config"); string ffmpegPath = Path.Combine(assetsPath, "Tools", "FFmpeg"); string ffmpegFileName = Path.Combine(ffmpegPath, "ffmpeg.exe"); string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string userConfigPath = Path.Combine(appDataPath, "Tricycle"); var processCreator = new Func <IProcess>(() => new ProcessWrapper()); var processRunner = new ProcessRunner(processCreator); var fileSystem = new FileSystem(); var jsonSerializer = new JsonSerializer(); var ffmpegConfigManager = new FFmpegConfigManager(fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, FFMPEG_CONFIG_NAME), Path.Combine(userConfigPath, FFMPEG_CONFIG_NAME)); var tricycleConfigManager = new TricycleConfigManager(fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, TRICYCLE_CONFIG_NAME), Path.Combine(userConfigPath, TRICYCLE_CONFIG_NAME)); _templateManager = new FileConfigManager <Dictionary <string, JobTemplate> >( fileSystem, jsonSerializer, Path.Combine(defaultConfigPath, TEMPLATE_CONFIG_NAME), Path.Combine(userConfigPath, TEMPLATE_CONFIG_NAME)); ffmpegConfigManager.Load(); tricycleConfigManager.Load(); _templateManager.Load(); if (tricycleConfigManager.Config.Trace) { EnableLogging(); } _templateManager.ConfigChanged += config => PopulateTemplateMenu(); var ffmpegArgumentGenerator = new FFmpegArgumentGenerator(new ArgumentPropertyReflector()); AppState.IocContainer = new Container(_ => { _.For <IConfigManager <FFmpegConfig> >().Use(ffmpegConfigManager); _.For <IConfigManager <TricycleConfig> >().Use(tricycleConfigManager); _.For <IConfigManager <Dictionary <string, JobTemplate> > >().Use(_templateManager); _.For <IFileBrowser>().Use <FileBrowser>(); _.For <IFolderBrowser>().Use <FolderBrowser>(); _.For <IProcessUtility>().Use(ProcessUtility.Self); _.For <IMediaInspector>().Use(new MediaInspector(Path.Combine(ffmpegPath, "ffprobe.exe"), processRunner, ProcessUtility.Self, jsonSerializer)); _.For <ICropDetector>().Use(new CropDetector(ffmpegFileName, processRunner, ffmpegConfigManager, ffmpegArgumentGenerator)); _.For <IInterlaceDetector>().Use(new InterlaceDetector(ffmpegFileName, processRunner, ffmpegArgumentGenerator)); _.For <IFileSystem>().Use(fileSystem); _.For <ITranscodeCalculator>().Use <TranscodeCalculator>(); _.For <IMediaTranscoder>().Use(new MediaTranscoder(ffmpegFileName, processCreator, ffmpegConfigManager, ffmpegArgumentGenerator)); _.For <IDevice>().Use(DeviceWrapper.Self); _.For <IAppManager>().Use(_appManager); _.For <IPreviewImageGenerator>().Use(new PreviewImageGenerator(ffmpegFileName, processRunner, ffmpegConfigManager, ffmpegArgumentGenerator, fileSystem)); _.For <ILanguageService>().Use <LanguageService>(); }); AppState.DefaultDestinationDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Videos"); }