private void FindProcess() { List <ProcessLooker.Game> GameList = new List <ProcessLooker.Game>(); Process[] processlist = Process.GetProcesses(); int Processcheck = 0; foreach (Process theprocess in processlist) { if (theprocess.ProcessName.ToLower().Contains("ffxiv_dx11")) { Processcheck++; GameList.Add(new ProcessLooker.Game() { Process = theprocess, ProcessName = theprocess.ProcessName, ID = theprocess.Id, StartTime = theprocess.StartTime, AppIcon = Extensions.IconToImageSource(System.Drawing.Icon.ExtractAssociatedIcon(theprocess.MainModule.FileName)), GameDirectory = Path.GetFullPath(Path.Combine(theprocess.MainModule.FileName, "..", "..")).ToString() }); } } if (Processcheck > 1) { ProcessLooker A = new ProcessLooker(GameList); A.Topmost = true; A.WindowStartupLocation = WindowStartupLocation.CenterScreen; A.ShowDialog(); if (A.Choice == null) { Application.Current.Shutdown(); return; } GamePath = A.Choice.GameDirectory; GameProcessd = A.Choice.Process; } else if (Processcheck == 1) { GamePath = GameList[0].GameDirectory; GameProcessd = GameList[0].Process; } else if (Processcheck <= 0) { ProcessLooker B = new ProcessLooker(GameList); B.Topmost = true; B.WindowStartupLocation = WindowStartupLocation.CenterScreen; B.ShowDialog(); if (B.Choice == null) { Application.Current.Shutdown(); return; } GamePath = B.Choice.GameDirectory; GameProcessd = B.Choice.Process; } }
public MainWindow() { List <ProcessLooker.Game> GameList = new List <ProcessLooker.Game>(); Process[] processlist = Process.GetProcesses(); Processcheck = 0; foreach (Process theprocess in processlist) { if (theprocess.ProcessName.Contains("ffxiv_dx11") || theprocess.ProcessName.Contains("ffxiv")) { Processcheck++; GameList.Add(new ProcessLooker.Game() { ProcessName = theprocess.ProcessName, ID = theprocess.Id, StartTime = theprocess.StartTime, AppIcon = IconToImageSource(System.Drawing.Icon.ExtractAssociatedIcon(theprocess.MainModule.FileName)) }); } } if (Processcheck > 1) { ProcessLooker f = new ProcessLooker(GameList); f.ShowDialog(); if (f.Choice == null) { Close(); return; } MainViewModel.gameProcId = f.Choice.ID; } if (Processcheck == 1) { MainViewModel.gameProcId = GameList[0].ID; } if (Processcheck <= 0) { ProcessLooker f = new ProcessLooker(GameList); f.ShowDialog(); if (f.Choice == null) { Close(); return; } MainViewModel.gameProcId = f.Choice.ID; } InitializeComponent(); }
private void FindProcess_Click(object sender, RoutedEventArgs e) { List <ProcessLooker.Game> GameList = new List <ProcessLooker.Game>(); Process[] processlist = Process.GetProcesses(); Processcheck = 0; foreach (Process theprocess in processlist) { if (theprocess.ProcessName.Contains("ffxiv_dx11") || theprocess.ProcessName.Contains("ffxiv")) { Processcheck++; GameList.Add(new ProcessLooker.Game() { ProcessName = theprocess.ProcessName, ID = theprocess.Id, StartTime = theprocess.StartTime, AppIcon = IconToImageSource(System.Drawing.Icon.ExtractAssociatedIcon(theprocess.MainModule.FileName)) }); } } if (Processcheck > 1) { ProcessLooker f = new ProcessLooker(GameList); f.ShowDialog(); if (f.Choice == null) { return; } MainViewModel.ShutDownStuff(); MainViewModel.gameProcId = f.Choice.ID; DataContext = new MainViewModel(); } if (Processcheck == 1) { MainViewModel.ShutDownStuff(); MainViewModel.gameProcId = GameList[0].ID; DataContext = new MainViewModel(); } }