コード例 #1
0
        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();
        }
コード例 #2
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public MainWindowViewModel(MacroManagerViewModel macroManager, SettingViewModel setting, IAutoUpdater autoUpdater, TimerToolViewModel timerTool, ResolutionConverterToolViewModel resolutionConverterTool, ScriptGeneratorViewModel scriptGenerator, CustomActionManager customActionManager, AutoLocationViewModel AutoLocation)
        {
            this.MacroManager            = macroManager;
            this.CurrentSettings         = setting;
            this.AutoUpdater             = autoUpdater;
            this.TimerTool               = timerTool;
            this.ScriptGenerator         = scriptGenerator;
            this.CustomActionManager     = customActionManager;
            this.ResolutionConverterTool = resolutionConverterTool;
            this.AutoLocation            = AutoLocation;

            InitializeCommands();


            if (CurrentSettings.IsAutoUpdateEnable == true)
            {
                this.AutoUpdater.CheckForUpdate();
            }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: shadowslasher410/EMM
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            //reset working directory
            Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            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 DependencyDict = new Dictionary <Type, object>()
            {
                { typeof(SimpleAutoMapper), autoMapper },
                { typeof(MessageBoxService), messageBox }
            };

            var scriptApplyDict = new Dictionary <Emulator, IApplyScriptToFolder>()
            {
                { Emulator.Nox, new NoxScriptApply(messageBox) },
                { Emulator.Memu, new MemuScriptApply(messageBox) }
            };

            var viewModelFactory = new ViewModelFactory(DependencyDict);

            var settingVM           = new SettingViewModel(Settings.Default(), autoMapper);
            var macroManagerVM      = new MacroManagerViewModel(dataIO, messageBox, viewModelFactory);
            var scriptApplyFactory  = new ScriptApplyFactory(messageBox, scriptApplyDict);
            var scriptGenerator     = new ScriptGenerator(scriptApplyFactory, settingVM, messageBox);
            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);
            }

            // 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();
        }