Esempio n. 1
0
        public ProcessSelectionViewModel(ProcessSelectionView view)
        {
            // When window is closed through X button.
            _view     = view;
            Processes = new ObservableCollection <Process>();

            // Close window on when "Set character" is pressed.
            SelectCommand  = new DelegateCommand(OnSelect);
            RefreshCommand = new DelegateCommand(OnRefresh);

            OnRefresh();
        }
        public ProcessSelectionViewModel(ProcessSelectionView view)
        {
            this.view = view;

            // When window is closed through X button.
            view.Closing += (s, e) => OnClosing();

            Sessions           = new ObservableCollection <Process>();
            ToggleButtonHeader = "Show All";

            // Create and start a new process watcher to monitor processes.
            _processWatcher        = new ProcessWatcher(ProcessName);
            _processWatcher.Entry += SessionEntry;
            _processWatcher.Exit  += SessionExit;
            _processWatcher.Start();

            // Close window on when "Set character" is pressed.
            ExitCommand = new DelegateCommand(() => view.Close());

            ToggleFiltering = new DelegateCommand(ChangeFilter);
        }
Esempio n. 3
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;
            }
        }