예제 #1
0
        /// <summary>
        ///     Selects a process to user for this application.
        /// </summary>
        private void SelectProcess()
        {
            // Let user select ffxi process
            var selectionView = new ProcessSelectionView();

            selectionView.ShowDialog();

            // Grab the view model with the game sessions.
            var viewModel = selectionView.DataContext as ProcessSelectionViewModel;

            // If the view has a process selection view model binded to it.
            if (viewModel != null)
            {
                // Get the selected process.
                var process = viewModel.SelectedProcess;

                // User never selected a process.
                if (process == null || !viewModel.IsProcessSelected)
                {
                    LogViewModel.Write("Process not found");
                    AppServices.InformUser("No valid process was selected.");
                    return;
                }

                // Log that a process selected.
                LogViewModel.Write("Process found");

                // Get memory reader set in config file.
                var fface = MemoryWrapper.Create(process.Id);

                // Set the fface Session.
                SetSession(fface);

                // Tell the user the program has loaded the player's data
                AppServices.InformUser("Bot Loaded: " + fface.Player.Name);

                // Set the main window's title to the player's name.
                MainWindowTitle = "EasyFarm - " + fface.Player.Name;
            }
        }
        public async Task Handle(SelectProcessRequest message, CancellationToken cancellationToken)
        {
            // Let user select ffxi process
            var selectionView = new SelectProcessDialog();
            var viewModel     = new SelectProcessViewModel(selectionView);

            selectionView.DataContext = viewModel;

            // Show window and do not continue until user closes it.
            await window.ShowMetroDialogAsync(selectionView);

            await selectionView.WaitUntilUnloadedAsync();

            // Get the selected process.
            var process = viewModel.SelectedProcess;

            // User never selected a process.
            if (process == null || !viewModel.IsProcessSelected)
            {
                LogViewModel.Write("Process not found");
                AppServices.InformUser("No valid process was selected.");
                return;
            }

            // Log that a process selected.
            LogViewModel.Write("Process found");

            // Get memory reader set in config file.
            var fface = MemoryWrapper.Create(process.Id);

            // Set the EliteApi Session.
            ViewModelBase.SetSession(fface);

            // Tell the user the program has loaded the player's data
            AppServices.InformUser("Bot Loaded: " + fface.Player.Name);

            // Set the main window's title to the player's name.
            AppServices.UpdateTitle("EasyFarm - " + fface.Player.Name);
        }