public AEMG SetupMainWindow() { //reset working directory Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //set culture Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var dataIO = new DataIO(); var autoMapper = new SimpleAutoMapper(); var messageBox = new MessageBoxService(); var repository = new AERepository(); var mtpManager = new MTPManager(); var saverepo = new AESavedSetupRepository(); var actionProvider = new ActionProvider(autoMapper, messageBox); var aeActionFactory = new AEActionFactory(actionProvider); var DependencyDict = new Dictionary <Type, object>() { { typeof(SimpleAutoMapper), autoMapper }, { typeof(MessageBoxService), messageBox }, { typeof(ViewModelClipboard), new ViewModelClipboard() }, }; var viewModelFactory = new ViewModelFactory(DependencyDict); var appSettingVM = new ApplicationSettingViewModel(actionProvider, viewModelFactory); SetupWindowInit(appSettingVM, out IWindowInitlizer windowinit); (new ScriptGenerateBootstrap()).SetUp(out IActionToScriptFactory actionToScriptFactory, out IEmulatorToScriptFactory emulatorToScriptFactory); var scriptApply = new ScriptApplyBootStrap(messageBox, mtpManager).GetScriptApplyFactory(); var scanner = new MacroScanner(dataIO, aeActionFactory); var macroManager = new AEMacroManager(scanner); var macroManagerVM = new AEMacroManagerViewModel(scanner, messageBox, macroManager, windowinit); var aESettingVM = new AESettingViewModel(new AESetting(), mtpManager); var aeScriptGenerator = new AEScriptGenerator(scriptApply, aESettingVM, messageBox, autoMapper, emulatorToScriptFactory, actionToScriptFactory, dataIO, actionProvider); var autoUpdater = new AutoUpdater(messageBox); var actionList = new AEActionListViewModel(macroManager, repository, messageBox); var savemanager = new AEMacroSaveManagerViewModel(saverepo, macroManager); return(new AEMG { DataContext = new AEMGViewModel(macroManagerVM, actionList, aESettingVM, aeScriptGenerator, messageBox, autoUpdater, savemanager, macroManager) }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //reset working directory Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //set culture Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var autoMapper = new SimpleAutoMapper(); var dataIO = new DataIO(); var messageBox = new MessageBoxService(); var mouseHook = new MouseHook(); var timerTool = new TimerTool(); var autoUpdater = new AutoUpdater(messageBox); var clipboard = new ViewModelClipboard(); var recent = new RecentFileManager(); var mtpManager = new MTPManager(); var DependencyDict = new Dictionary <Type, object>() { { typeof(SimpleAutoMapper), autoMapper }, { typeof(MessageBoxService), messageBox }, { typeof(ViewModelClipboard), clipboard }, }; var viewModelFactory = new ViewModelFactory(DependencyDict); (new ScriptGenerateBootstrap()).SetUp(out IActionToScriptFactory actionToScriptFactory, out IEmulatorToScriptFactory emulatorToScriptFactory); var settingVM = new SettingViewModel(Settings.Default(), autoMapper, mtpManager); var macroManagerVM = new MacroManagerViewModel(dataIO, messageBox, viewModelFactory, recent); var scriptApplyFactory = new ScriptApplyBootStrap(messageBox, mtpManager).GetScriptApplyFactory(); var scriptGenerator = new ScriptGenerator(scriptApplyFactory, settingVM, messageBox, emulatorToScriptFactory, actionToScriptFactory); var scriptGeneratorVM = new ScriptGeneratorViewModel(macroManagerVM, scriptGenerator, messageBox); var customActionManager = new CustomActionManager(macroManagerVM, viewModelFactory, dataIO, messageBox); var timerToolVM = new TimerToolViewModel(mouseHook, timerTool); var resulutionTool = new ResolutionConverterTool(viewModelFactory); var resolutionToolVM = new ResolutionConverterToolViewModel(resulutionTool, macroManagerVM, messageBox); var autoLocationVM = new AutoLocationViewModel(new MouseHook(), new AutoLocation(), macroManagerVM); var mainWindowViewModel = new MainWindowViewModel(macroManagerVM, settingVM, autoUpdater, timerToolVM, resolutionToolVM, scriptGeneratorVM, customActionManager, autoLocationVM); MainWindow = new MainWindow { DataContext = mainWindowViewModel }; //Handle arguments var agrs = Environment.GetCommandLineArgs(); if (agrs.Length > 1) { var filepath = agrs.Where(s => s.Contains(".emm")).First(); macroManagerVM.SetCurrentMacro(filepath, agrs.Any(s => s.Equals(StaticVariables.NO_SAVE_AGRS))); } // Select the text in a TextBox when it receives focus. EventManager.RegisterClassHandler(typeof(TextBox), TextBox.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyIgnoreMouseButton)); EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent, new RoutedEventHandler(SelectAllText)); EventManager.RegisterClassHandler(typeof(TextBox), TextBox.MouseDoubleClickEvent, new RoutedEventHandler(SelectAllText)); MainWindow.Show(); }