Skip to content

Commit 8acc0ff

Browse files
committed
Newed feature pack
1. Added Mute functions 2. Fixed some launch bug 3. Other small functions
1 parent e8a3480 commit 8acc0ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+963
-122
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./*.pdf

README.jp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[English](README.md)[中文](README.zh.md)[日本語](README.jp.md)
22

3+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/total)](https://github.com/emako/genshin-woodmen/releases)
4+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/latest/total)](https://github.com/emako/genshin-woodmen/releases)
5+
36
# 原神伐採君
47

58
> GenshinWoodmen

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[English](README.md)[中文](README.zh.md)[日本語](README.jp.md)
22

3+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/total)](https://github.com/emako/genshin-woodmen/releases)
4+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/latest/total)](https://github.com/emako/genshin-woodmen/releases)
5+
36
# Genshin Woodmen
47

58
This is an automatic tool to obtain woods in Genshin Impact using gadget named "The Boon of the Elder Tree", got from Sumeru City Reputation Level 3.

README.zh.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[English](README.md)[中文](README.zh.md)[日本語](README.jp.md)
22

3+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/total)](https://github.com/emako/genshin-woodmen/releases)
4+
[![GitHub downloads](https://img.shields.io/github/downloads/emako/genshin-woodmen/latest/total)](https://github.com/emako/genshin-woodmen/releases)
5+
36
# 原神伐木姬
47

58
> GenshinWoodmen

assets/image2.en.png

14 KB
Loading

assets/image2.jp.png

8.65 KB
Loading

assets/image2.zh.png

7.21 KB
Loading

build/.gitignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
App.cer
2-
App.msix
3-
App.msixbundle
4-
App_Setup.exe
5-
GenshinWoodmen*Setup*.exe
6-
GenshinWoodmen*.7z
1+
*.cer
2+
*.msix
3+
*.msixbundle
4+
*.exe
5+
*.7z

src/GenshinWoodmen/App.xaml

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@
99
ShutdownMode="OnExplicitShutdown">
1010
<Application.Resources>
1111
<ResourceDictionary>
12+
<ResourceDictionary.MergedDictionaries>
13+
<ui:ThemeResources/>
14+
<ui:XamlControlsResources/>
15+
<ui:ResourceDictionaryEx/>
16+
<ui:ColorPaletteResources/>
17+
<ui:IntellisenseResources/>
18+
<ResourceDictionary Source="/Resources/Languages/zh-cn.xaml"/>
19+
<ResourceDictionary Source="/Resources/Languages/jp.xaml"/>
20+
<ResourceDictionary Source="/Resources/Languages/en-us.xaml"/>
21+
</ResourceDictionary.MergedDictionaries>
1222
<FontFamily x:Key="SegoeFluent">/Resources/segoe-fluent-icons.ttf#Segoe Fluent Icons</FontFamily>
23+
<v:LanguageToBoolConverter x:Key="LanguageToBoolConverter"/>
1324
<v:AddConverter x:Key="AddConverter"/>
1425
<v:ReverseConverter x:Key="ReverseConverter"/>
1526
<tb:TaskbarIcon x:Key="PART_Taskbar"
@@ -31,12 +42,45 @@
3142
<TextBlock Text="&#xf71c;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
3243
</MenuItem.Icon>
3344
</MenuItem>
34-
<Separator/>
3545
<MenuItem Header="{DynamicResource VisitWebsite}" Command="{Binding GitHubCommand}">
3646
<MenuItem.Icon>
3747
<TextBlock Text="&#xe774;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
3848
</MenuItem.Icon>
3949
</MenuItem>
50+
<Separator/>
51+
<MenuItem Header="{DynamicResource LaunchGame1440x900}" Command="{Binding LaunchGame1440x900Command}">
52+
<MenuItem.Icon>
53+
<TextBlock Text="&#xe7fc;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
54+
</MenuItem.Icon>
55+
</MenuItem>
56+
<Separator/>
57+
<MenuItem Header="{DynamicResource Language}">
58+
<MenuItem.Icon>
59+
<TextBlock Text="&#xf2b7;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
60+
</MenuItem.Icon>
61+
<MenuItem.Items>
62+
<MenuItem Header="简体中文" Command="{Binding LanguageZH}" IsCheckable="False" IsChecked="{Binding Language,Converter={StaticResource LanguageToBoolConverter},ConverterParameter=zh-cn}">
63+
<MenuItem.Icon>
64+
<TextBlock Text="&#xe88d;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
65+
</MenuItem.Icon>
66+
</MenuItem>
67+
<MenuItem Header="日本語" Command="{Binding LanguageJP}" IsCheckable="False" IsChecked="{Binding Language,Converter={StaticResource LanguageToBoolConverter},ConverterParameter=jp}">
68+
<MenuItem.Icon>
69+
<TextBlock Text="&#xe7de;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
70+
</MenuItem.Icon>
71+
</MenuItem>
72+
<MenuItem Header="English" Command="{Binding LanguageEN}" IsCheckable="False" IsChecked="{Binding Language,Converter={StaticResource LanguageToBoolConverter},ConverterParameter=en-us}">
73+
<MenuItem.Icon>
74+
<TextBlock Text="&#xf7b5;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
75+
</MenuItem.Icon>
76+
</MenuItem>
77+
</MenuItem.Items>
78+
</MenuItem>
79+
<MenuItem Header="{DynamicResource Restart}" Command="{Binding RestartCommand}">
80+
<MenuItem.Icon>
81+
<TextBlock Text="&#xe777;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
82+
</MenuItem.Icon>
83+
</MenuItem>
4084
<MenuItem Header="{DynamicResource Exit}" Command="{Binding ExitCommand}">
4185
<MenuItem.Icon>
4286
<TextBlock Text="&#xe7e8;" FontSize="8" FontFamily="{StaticResource SegoeFluent}"/>
@@ -45,16 +89,6 @@
4589
</ContextMenu>
4690
</tb:TaskbarIcon.ContextMenu>
4791
</tb:TaskbarIcon>
48-
<ResourceDictionary.MergedDictionaries>
49-
<ui:ThemeResources/>
50-
<ui:XamlControlsResources/>
51-
<ui:ResourceDictionaryEx/>
52-
<ui:ColorPaletteResources/>
53-
<ui:IntellisenseResources/>
54-
<ResourceDictionary Source="/Resources/Languages/zh-cn.xaml"/>
55-
<ResourceDictionary Source="/Resources/Languages/jp.xaml"/>
56-
<ResourceDictionary Source="/Resources/Languages/en-us.xaml"/>
57-
</ResourceDictionary.MergedDictionaries>
5892
</ResourceDictionary>
5993
</Application.Resources>
6094
</Application>

src/GenshinWoodmen/App.xaml.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using GenshinWoodmen.Core;
22
using Hardcodet.Wpf.TaskbarNotification;
33
using System;
4+
using System.ComponentModel;
5+
using System.Diagnostics;
6+
using System.Security.Principal;
47
using System.Threading;
58
using System.Threading.Tasks;
69
using System.Windows;
@@ -11,12 +14,16 @@ public partial class App : Application
1114
{
1215
public static new App? Current { get; protected set; } = null!;
1316
public TaskbarIcon Taskbar { get; protected set; } = null!;
17+
public static bool IsElevated { get; } = GetElevated();
1418

1519
public App()
1620
{
1721
Logger.Info("Startup");
1822
Current = this;
23+
Current.DispatcherUnhandledException += (_, e) => e.Handled = true;
24+
AppDomain.CurrentDomain.UnhandledException += (s, e) => _ = e;
1925
NoticeService.ClearNotice();
26+
EnsureElevated();
2027
CheckSingleInstance();
2128
InitializeComponent();
2229
SetupLanguage();
@@ -36,6 +43,41 @@ protected override void OnExit(ExitEventArgs e)
3643
base.OnExit(e);
3744
}
3845

46+
public void EnsureElevated()
47+
{
48+
if (!IsElevated)
49+
{
50+
RestartAsElevated('r' + 'u' + 'n' + 'a' + 's');
51+
}
52+
}
53+
54+
public static void RestartAsElevated(int? exitCode = null)
55+
{
56+
try
57+
{
58+
_ = Process.Start(new ProcessStartInfo()
59+
{
60+
Verb = "runas",
61+
UseShellExecute = true,
62+
FileName = Process.GetCurrentProcess().MainModule!.FileName,
63+
WorkingDirectory = Environment.CurrentDirectory,
64+
});
65+
}
66+
catch (Win32Exception)
67+
{
68+
return;
69+
}
70+
Current!.Shutdown();
71+
if (exitCode != null) Environment.Exit(exitCode.Value);
72+
}
73+
74+
private static bool GetElevated()
75+
{
76+
using WindowsIdentity identity = WindowsIdentity.GetCurrent();
77+
WindowsPrincipal principal = new(identity);
78+
return principal.IsInRole(WindowsBuiltInRole.Administrator);
79+
}
80+
3981
public void CheckSingleInstance()
4082
{
4183
EventWaitHandle? handle;

0 commit comments

Comments
 (0)