Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
优化进程选择框,更新textractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Isayama-Kagura committed Jun 27, 2023
1 parent acffc25 commit 846b69e
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\noRT</PublishDir>
<PublishDir>bin\Release\net6.0-windows\publish\win64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
Binary file modified TsubakiTranslator/Resources/Textractor/x64/texthook.dll
Binary file not shown.
Binary file modified TsubakiTranslator/Resources/Textractor/x86/texthook.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion TsubakiTranslator/TsubakiTranslator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
<Company>OTAKU Technology Co., Ltd.</Company>
<PackageProjectUrl>https://github.com/Isayama-Kagura/TsubakiTranslator</PackageProjectUrl>
<Copyright>© 2021 Tsubaki Translator</Copyright>
<Version>1.0.6.1</Version>
<Version>1.0.6.2</Version>
<Product>Tsubaki Translator</Product>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>

</PropertyGroup>

Expand Down
17 changes: 12 additions & 5 deletions TsubakiTranslator/UserGamePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@
Text="{Binding GameName, Mode=OneWay}"
VerticalAlignment="Center" />

<ComboBox x:Name="HistoryGameProcessList" Margin="5"
materialDesign:HintAssist.Hint="游戏进程"
<ComboBox x:Name="HistoryGameProcessList" Margin="5" IsEditable="True"
materialDesign:HintAssist.Hint="游戏进程"
Style="{StaticResource MaterialDesignFloatingHintComboBox}"
IsTextSearchEnabled="True" DisplayMemberPath="ProcessDetail" SelectedValuePath="ProcessName"
SelectedValue="{Binding ProcessName, Mode=OneWay}"
IsTextSearchEnabled="False" DisplayMemberPath="ProcessDetail" SelectedValuePath="ProcessName"
SelectedValue="{Binding ProcessName, Mode=OneWay}"
GotFocus="GameProcessList_GotFocus"
LostFocus="GameProcessList_LostFocus"
KeyUp="GameProcessList_KeyUp"
materialDesign:TextFieldAssist.HasClearButton="True">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
Expand Down Expand Up @@ -99,8 +102,12 @@

<ComboBox x:Name="GameProcessList" Margin="5"
materialDesign:HintAssist.Hint="游戏进程"
LostFocus="GameProcessList_LostFocus"
GotFocus="GameProcessList_GotFocus"
KeyUp="GameProcessList_KeyUp"
Style="{StaticResource MaterialDesignFloatingHintComboBox}"
IsTextSearchEnabled="True" DisplayMemberPath="ProcessDetail" SelectedValuePath="ProcessName"
IsTextSearchEnabled="False" IsEditable="True"
DisplayMemberPath="ProcessDetail" SelectedValuePath="ProcessName"
materialDesign:TextFieldAssist.HasClearButton="True">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
Expand Down
97 changes: 75 additions & 22 deletions TsubakiTranslator/UserGamePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private void DeleteGame_Button_Click(object sender, System.Windows.RoutedEventAr

private void OpenHistoryGame_Button_Click(object sender, RoutedEventArgs e)
{
SetProcessItems();
var list = GetGameProcesses();
HistoryGameProcessList.ItemsSource = list;

GameData item = (GameData)GameListDataGrid.SelectedItem;

Expand Down Expand Up @@ -91,7 +92,8 @@ private void AcceptGame_Button_Click(object sender, System.Windows.RoutedEventAr

private void OpenGameByPid_Button_Click(object sender, RoutedEventArgs e)
{
SetProcessItems();
var list = GetGameProcesses();
GameProcessList.ItemsSource = list;
}

//注入进程打开游戏
Expand Down Expand Up @@ -137,26 +139,6 @@ where data.ProcessName.Equals(gameProcess.ProcessName)

}


private void SetProcessItems()
{
Process[] ps = Process.GetProcesses();
List<GameProcess> list = new List<GameProcess>();

foreach (Process p in ps)
{
GameProcess gameProcess = new GameProcess { PID = p.Id, ProcessName = p.ProcessName, ProcessDetail = $"{p.ProcessName} - {p.Id}" };
list.Add(gameProcess);
}


list.Sort((x, y) => string.Compare(x.ProcessName, y.ProcessName));
ObservableCollection<GameProcess> processStrings = new ObservableCollection<GameProcess>(list);
GameProcessList.ItemsSource = processStrings;
HistoryGameProcessList.ItemsSource = processStrings;
}


private void AddRegexRule_Button_Click(object sender, RoutedEventArgs e)
{
var btn = sender as Button;
Expand Down Expand Up @@ -221,6 +203,77 @@ private void Ocr_Button_Click(object sender, RoutedEventArgs e)
OcrTipsPanel.Children.Add(tb);
}
}

private void GameProcessList_LostFocus(object sender, RoutedEventArgs e)
{
string text = ((ComboBox)sender).Text;
if (!text.Equals(""))
{
bool flag = false;
var list = GetGameProcesses();

foreach (GameProcess gameProcess in list)
{
if (gameProcess.ProcessDetail.Equals(text))
{
flag = true;
break;
}
}

if (!flag)
{
((ComboBox)sender).Text = "";
}
}


}

private void GameProcessList_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
string text = ((ComboBox)sender).Text;
((ComboBox)sender).ItemsSource = null;
var list = GetGameProcesses();
ObservableCollection<GameProcess> processStrings = new ObservableCollection<GameProcess>();
if (!text.Equals(""))
{
foreach (GameProcess gameProcess in list)
{
if (gameProcess.ProcessDetail.Contains(text))
{
processStrings.Add(gameProcess);
}
}
((ComboBox)sender).ItemsSource = processStrings;
}
else
((ComboBox)sender).ItemsSource = list;

((ComboBox)sender).IsDropDownOpen = true;
}


private ObservableCollection<GameProcess> GetGameProcesses()
{
Process[] ps = Process.GetProcesses();
List<GameProcess> list = new List<GameProcess>();

foreach (Process p in ps)
{
GameProcess gameProcess = new GameProcess { PID = p.Id, ProcessName = p.ProcessName, ProcessDetail = $"{p.ProcessName} - {p.Id}" };
list.Add(gameProcess);
}
list.Sort((x, y) => string.Compare(x.ProcessName, y.ProcessName));
ObservableCollection<GameProcess> processProcesses = new ObservableCollection<GameProcess>(list);

return processProcesses;
}

private void GameProcessList_GotFocus(object sender, RoutedEventArgs e)
{
((ComboBox)sender).IsDropDownOpen = true;
}
}


Expand Down

0 comments on commit 846b69e

Please sign in to comment.