예제 #1
0
        /// <summary>
        /// Handles the Click event of the ProceedButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void ProceedButton_Click(object sender, RoutedEventArgs e)
        {
            if (SourceTextBox.Text.Any() && DestinationTextBox.Text.Any() && Directory.Exists(System.IO.Path.GetDirectoryName(DestinationTextBox.Text)) && File.Exists(SourceTextBox.Text))
            {
                this.NavigationService.Navigate(new ExtractProcess(new ExtractConfig()
                {
                    SourceFilePath      = SourceTextBox.Text,
                    DestinationFilePath = DestinationTextBox.Text
                }));

                RecentFileManager.AddRecentFile(new RecentFile()
                {
                    OperationType       = "/assets/images/extract.png",
                    Name                = System.IO.Path.GetFileNameWithoutExtension(SourceTextBox.Text),
                    SourceFilePath      = System.IO.Path.GetDirectoryName(SourceTextBox.Text),
                    DestinationFilePath = DestinationTextBox.Text
                });
            }
            else
            {
                MessageBox.Show(Application.Current.MainWindow,
                                "An error prohibited the loading of the files. Either the source file or the destination path does not exist. \n\nKindly check on your input file and destination path.",
                                "Selecting files");
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Home"/> class.
        /// </summary>
        public Home()
        {
            InitializeComponent();

            App.Current.MainWindow.Title = "Home";

            var recentFilesList = RecentFileManager.GetRecentFilesList();

            if (recentFilesList.Count() > 0)
            {
                RecentFilesListView.ItemsSource = recentFilesList.Skip(Math.Max(0, recentFilesList.Count() - 3)).Take(3);;
            }
            else
            {
                RecentFilesPanel.Visibility = Visibility.Collapsed;
            }
        }
예제 #3
0
        /// <summary>
        /// Handles the Click event of the ProceedButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void ProceedButton_Click(object sender, RoutedEventArgs e)
        {
            if (SourceTextBox.Text.Any() && File.Exists(SourceTextBox.Text))
            {
                this.NavigationService.Navigate(new ViewList(SourceTextBox.Text));

                RecentFileManager.AddRecentFile(new RecentFile()
                {
                    OperationType  = "/assets/images/view.png",
                    Name           = System.IO.Path.GetFileNameWithoutExtension(SourceTextBox.Text),
                    SourceFilePath = System.IO.Path.GetDirectoryName(SourceTextBox.Text),
                });
            }
            else
            {
                MessageBox.Show(Application.Current.MainWindow,
                                "An error prohibited the loading of the file. The source file does not exist. \n\nKindly check on your input file.",
                                "Selecting file");
            }
        }
예제 #4
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();
        }