Skip to content

Commit

Permalink
为外部接口做准备
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakoyu authored and Hakoyu committed Dec 30, 2022
1 parent 67e053f commit f533568
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 9 deletions.
18 changes: 18 additions & 0 deletions Langs/Windows/MainWindow/MainWindow_I18n.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Langs/Windows/MainWindow/MainWindow_I18n.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,10 @@ It may affect the normal operation of the software, so it is recommended to chec
<data name="GlobalException" xml:space="preserve">
<value>Global Exception</value>
</data>
<data name="OfficialExpansion" xml:space="preserve">
<value>Official expansion</value>
</data>
<data name="CommunityExpansion" xml:space="preserve">
<value>Community Expansion</value>
</data>
</root>
6 changes: 6 additions & 0 deletions Langs/Windows/MainWindow/MainWindow_I18n.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,10 @@
<data name="GlobalException" xml:space="preserve">
<value>全局异常</value>
</data>
<data name="OfficialExpansion" xml:space="preserve">
<value>官方拓展</value>
</data>
<data name="CommunityExpansion" xml:space="preserve">
<value>社区拓展</value>
</data>
</root>
5 changes: 3 additions & 2 deletions Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ private void ClearMenu()
foreach (var lazyPage in menuList.Values)
ClosePage(lazyPage.Value);
menuList.Clear();
ListBox_Menu.Items.Clear();
while (ListBox_Menu.Items.Count > 2)
ListBox_Menu.Items.RemoveAt(0);
}

private void ClosePage(Page page)
Expand Down Expand Up @@ -130,7 +131,7 @@ private void AddMemu(string icon, string name, string tag, Lazy<Page> lazyPage)
};
contextMenu.Items.Add(menuItem);
item.ContextMenu = contextMenu;
ListBox_Menu.Items.Add(item);
ListBox_Menu.Items.Insert(ListBox_Menu.Items.Count - 2, item);
menuList.Add(tag, lazyPage);
STLog.Instance.WriteLine($"{I18n.AddMenu} {icon} {name}");
}
Expand Down
54 changes: 50 additions & 4 deletions Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,56 @@
<ListBox
x:Name="ListBox_Menu"
Margin="0,0,0,60"
HorizontalAlignment="Center"
HorizontalContentAlignment="Stretch"
FontSize="16"
PreviewMouseRightButtonDown="ListBox_Menu_PreviewMouseRightButtonDown"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
SelectionChanged="ListBox_Menu_SelectionChanged"
Style="{StaticResource ListBox_Style}" />
Style="{StaticResource ListBox_Style}">
<ListBoxItem Padding="0">
<Expander
Padding="0"
Header="{x:Static I18n:MainWindow_I18n.OfficialExpansion}"
IsExpanded="True"
Style="{StaticResource Expander_Style}">
<ListBox
x:Name="ListBox_OfficialExpansion"
HorizontalContentAlignment="Stretch"
pu:IconHelper.Margin="0,0,10,0"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
PreviewMouseWheel="ListBox_PreviewMouseWheel"
SelectionChanged="ListBox_Menu_SelectionChanged"
Style="{StaticResource ListBox_Style}">
<ListBoxItem Style="{StaticResource ListBoxItem_Style}">
<pu:ListBoxItemHelper.Icon>
<emoji:TextBlock Text="🌟" />
</pu:ListBoxItemHelper.Icon>
</ListBoxItem>
</ListBox>
</Expander>
</ListBoxItem>
<ListBoxItem Padding="0">
<Expander
Padding="0"
Header="{x:Static I18n:MainWindow_I18n.CommunityExpansion}"
IsExpanded="True"
Style="{StaticResource Expander_Style}">
<ListBox
x:Name="ListBox_CommunityExpansion"
HorizontalContentAlignment="Stretch"
pu:IconHelper.Margin="0,0,10,0"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
PreviewMouseWheel="ListBox_PreviewMouseWheel"
SelectionChanged="ListBox_Menu_SelectionChanged"
Style="{StaticResource ListBox_Style}">
<ListBoxItem Style="{StaticResource ListBoxItem_Style}">
<pu:ListBoxItemHelper.Icon>
<emoji:TextBlock Text="🌟" />
</pu:ListBoxItemHelper.Icon>
</ListBoxItem>
</ListBox>
</Expander>
</ListBoxItem>
</ListBox>
<Button
x:Name="Button_Settings"
Height="30"
Expand All @@ -148,9 +193,10 @@
Padding="0,0,5,0"
VerticalAlignment="Bottom"
HorizontalContentAlignment="Left"
Click="Button_Info_Click"
Content="{x:Static I18n:MainWindow_I18n.Info}"
FontSize="16"
Style="{StaticResource Button_Style}" Click="Button_Info_Click">
Style="{StaticResource Button_Style}">
<pu:ButtonHelper.Icon>
<emoji:TextBlock FontSize="16" Text="" />
</pu:ButtonHelper.Icon>
Expand Down
18 changes: 15 additions & 3 deletions Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.DirectoryServices;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand Down Expand Up @@ -52,9 +53,9 @@ public MainWindow()
//{
//}
//Assembly assembly = Assembly.LoadFrom(@"C:\Users\HKW\Desktop\WpfLibrary1.dll");
//Type type = assembly.GetType("WpfLibrary1.Page1");
//Type type = assembly.GetType("WpfLibrary1.Page1")!;
//MethodInfo mi = type.GetMethod("MehtodName")!;
//object obj = assembly.CreateInstance(type.FullName)!;
//object obj = assembly.CreateInstance(type.FullName!)!;
//Frame_MainFrame.Content = obj;

STLog.Instance.WriteLine(I18n.InitializationCompleted);
Expand Down Expand Up @@ -160,7 +161,7 @@ private void Frame_MainFrame_ContentRendered(object sender, EventArgs e)
STLog.Instance.WriteLine($"{I18n.ShowPage} {Frame_MainFrame.Content}");
}

private void ListBox_Menu_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
private void ListBox_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
// 禁止右键项时会选中项
e.Handled = true;
Expand All @@ -179,5 +180,16 @@ private void Button_Info_Click(object sender, RoutedEventArgs e)
Frame_MainFrame.Content = infoMenu;
ListBox_Menu.SelectedIndex = -1;
}
private void ListBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = MouseWheelEvent,
Source = sender,
};
if (sender is Control control && control.Parent is UIElement ui)
ui.RaiseEvent(eventArg);
e.Handled = true;
}
}
}

0 comments on commit f533568

Please sign in to comment.