Exemplo n.º 1
0
        /// <summary>
        ///     Loads easyfarm settings from file.
        /// </summary>
        private void Load()
        {
            try
            {
                // Load the settings.
                var settings = _settingsManager.TryLoad <Config>();

                // Did we fail to load the settings?
                if (settings == null)
                {
                    AppServices.InformUser("Failed to load settings.");
                    return;
                }

                // Inform the user of our success.
                Config.Instance = settings;
                AppServices.SendConfigLoaded();
                AppServices.InformUser("Settings have been loaded.");
                LogViewModel.Write("Settings loaded");
            }
            catch (InvalidOperationException ex)
            {
                AppServices.InformUser("Failed to load settings.");
                Logger.Log(new LogEntry(LoggingEventType.Error, $"{GetType()}.{nameof(Load)} : Failed to load settings", ex));
            }
        }
Exemplo n.º 2
0
 private void StopEngine()
 {
     LogViewModel.Write("Bot now paused");
     AppServices.InformUser("Program paused.");
     StartPauseHeader = "St_art";
     GameEngine.Stop();
 }
Exemplo n.º 3
0
        private void StartEngine()
        {
            LogViewModel.Write("Bot now running");
            AppServices.InformUser("Program running.");
            var isStarted = GameEngine.Start();

            if (!isStarted)
            {
                return;
            }
            StartPauseHeader = "P_ause";
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Saves the player's data to file.
 /// </summary>
 private void Save()
 {
     try
     {
         _settingsManager.TrySave(Config.Instance);
         AppServices.InformUser("Settings have been saved.");
         LogViewModel.Write("Settings saved");
     }
     catch (InvalidOperationException ex)
     {
         AppServices.InformUser("Failed to save settings.");
         Logger.Log(new LogEntry(LoggingEventType.Error, $"{GetType()}.{nameof(Save)} : Failure on save settings", ex));
     }
 }
Exemplo n.º 5
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);
        }