Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
c5d889e4
Commit
c5d889e4
authored
May 16, 2024
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 在客户端设置页 添加语言选择
parent
19187805
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
289 additions
and
29 deletions
+289
-29
FlyLayoutManager.cs
MultiLayout/FlyLayoutManager.cs
+3
-1
MainWindow.xaml.cs
MultiLayout/MainWindow.xaml.cs
+3
-2
PgMenu.xaml
MultiLayout/PgMenu.xaml
+29
-18
Culture.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Culture.cs
+119
-0
UcSectionLanguage.xaml
...se/FLY.Thick.Base.UI/CustomSection/UcSectionLanguage.xaml
+27
-0
UcSectionLanguage.xaml.cs
...FLY.Thick.Base.UI/CustomSection/UcSectionLanguage.xaml.cs
+88
-0
FLY.Thick.Base.UI.csproj
...FLY.Thick.Base/FLY.Thick.Base.UI/FLY.Thick.Base.UI.csproj
+12
-0
PgFlyAd.xaml
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml
+0
-6
StringResource.PgCustomSections.xaml
...emes/StringResources/StringResource.PgCustomSections.xaml
+4
-1
StringResource.PgCustomSections.xaml
...s/StringResources/en/StringResource.PgCustomSections.xaml
+4
-1
No files found.
MultiLayout/FlyLayoutManager.cs
View file @
c5d889e4
...
...
@@ -446,8 +446,10 @@ namespace MultiLayout
}
string
header
=
item
.
Header
;
//通过资源,查询翻译字符串
string
h
=
(
string
)
Application
.
Current
.
TryFindResource
(
header
);
string
res_key
=
"str.H."
+
header
;
string
h
=
(
string
)
Application
.
Current
.
TryFindResource
(
res_key
);
if
(
h
!=
null
)
header
=
h
;
...
...
MultiLayout/MainWindow.xaml.cs
View file @
c5d889e4
...
...
@@ -39,6 +39,9 @@ namespace MultiLayout
viewModel
=
new
WdMainVm
();
this
.
DataContext
=
viewModel
;
//为了隐藏报警条
container
=
new
UnityContainer
();
Application
.
Current
.
Properties
[
"container"
]
=
container
;
}
private
async
void
MainWindow_Loaded
(
object
sender
,
RoutedEventArgs
e
)
...
...
@@ -54,8 +57,6 @@ namespace MultiLayout
await
Task
.
Delay
(
1000
);
//---------------------------------------------------------
//加载 unity
container
=
new
UnityContainer
();
Application
.
Current
.
Properties
[
"container"
]
=
container
;
container
.
RegisterInstance
(
lp
);
UnityConfExt
.
Load
(
container
);
...
...
MultiLayout/PgMenu.xaml
View file @
c5d889e4
...
...
@@ -43,26 +43,37 @@
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" >
<Button Style="{StaticResource
ButtonStyle_back
}" Click="btnBackClick"/>
<Button Style="{StaticResource
Styles.TitleBar.BackButton
}" Click="btnBackClick"/>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" >
<ItemsControl x:Name="itemsControl0" Margin="100,100,0,20">
<ItemsControl.Resources>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_menu}"/>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Background="{Binding Brush}" Click="Button_Click" >
<TextBlock Text="{Binding Title}"/>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<ItemsControl x:Name="itemsControl0" Grid.Column="1">
<ItemsControl.Resources>
<Style TargetType="Button" BasedOn="{StaticResource Styles.PgMenu.ItemButton}"/>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Background="{Binding Brush}" Click="Button_Click" >
<TextBlock Text="{Binding Title}" />
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</ScrollViewer>
</Grid>
</Page>
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Culture.cs
0 → 100644
View file @
c5d889e4
using
System
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Reflection
;
using
System.Windows
;
namespace
FLY.Thick.Base.UI
{
public
class
Culture
:
INotifyPropertyChanged
{
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
string
Language
{
get
;
set
;
}
=
"zh"
;
public
string
filePath
=
"culture.json"
;
string
fileFullPath
=
"culture.json"
;
public
bool
Save
()
{
return
CultureJsonDb
.
Save
(
fileFullPath
,
this
);
}
public
bool
Load
()
{
//记录加载时的路径。 就算用 System.Environment.CurrentDirectory = rootDir; 改变后, 也能保存回加载时的位置
string
path
=
System
.
IO
.
Directory
.
GetCurrentDirectory
();
fileFullPath
=
Path
.
Combine
(
path
,
filePath
);
return
CultureJsonDb
.
Load
(
fileFullPath
,
this
);
}
public
void
LoadCulture
(
Type
appType
)
{
Assembly
asm
=
Assembly
.
GetAssembly
(
appType
);
string
assemblyName
=
asm
.
GetName
().
Name
;
string
language
=
Language
;
if
(
language
==
"zh"
)
return
;
//List<ResourceDictionary> dictionaryList = new List<ResourceDictionary>();
//foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)
//{
// dictionaryList.Add(dictionary);
//}
string
requestedCulture
=
$@"pack://application:,,,/
{
assemblyName
}
;component/Themes/StringResources/
{
language
}
/StringResource.xaml"
;
ResourceDictionary
resourceDictionary
;
try
{
resourceDictionary
=
new
ResourceDictionary
()
{
Source
=
new
Uri
(
requestedCulture
)
};
}
catch
{
return
;
}
//if(resourceDictionary == null)
//{
// requestedCulture = @"Resources\StringResource.xaml";
// resourceDictionary = dictionaryList.FirstOrDefault(d =< d.Source.OriginalString.Equals(requestedCulture));
//}
if
(
resourceDictionary
!=
null
)
{
//Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary);
Application
.
Current
.
Resources
.
MergedDictionaries
.
Add
(
resourceDictionary
);
}
}
}
public
class
CultureJsonDb
{
public
static
bool
Save
(
string
filePath
,
Culture
src
)
{
CultureJsonDb
jsonDb
=
new
CultureJsonDb
()
{
Language
=
src
.
Language
};
try
{
//string dirPath = Path.GetDirectoryName(filePath);
//if (!Directory.Exists(dirPath))
// Directory.CreateDirectory(dirPath);
var
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
jsonDb
);
File
.
WriteAllText
(
filePath
,
json
);
return
true
;
}
catch
{
return
false
;
}
}
public
static
bool
Load
(
string
filePath
,
Culture
src
)
{
if
(!
File
.
Exists
(
filePath
))
return
false
;
try
{
string
json
=
File
.
ReadAllText
(
filePath
);
var
jsonDb
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
CultureJsonDb
>(
json
);
src
.
Language
=
jsonDb
.
Language
;
return
true
;
}
catch
{
return
false
;
}
}
public
string
Language
{
get
;
set
;
}
=
"zh"
;
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/CustomSection/UcSectionLanguage.xaml
0 → 100644
View file @
c5d889e4
<UserControl x:Class="FLY.Thick.Base.UI.CustomSection.UcSectionLanguage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Thick.Base.UI.CustomSection"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Converters.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<StackPanel Orientation="Horizontal" >
<Border Style="{StaticResource Styles.ParamSection.Border}">
<TextBlock Text="{StaticResource str.PgCustomSections.Language}" />
</Border>
<StackPanel >
<StackPanel Orientation="Horizontal">
<ComboBox ItemsSource="{Binding LanguageList}" SelectedValue="{Binding CurrentLanguage}" DisplayMemberPath="Info" Margin="{StaticResource ControlMargin}"
MinWidth="100" FontSize="{StaticResource FontSize.FieldHeader}" FontFamily="{StaticResource FontFamily.Field}"/>
<Button Style="{StaticResource Styles.Button.Square2}" Content="{StaticResource str.PgCustomSections.Apply}" Command="{Binding OkCmd}"/>
</StackPanel>
</StackPanel>
</StackPanel>
</UserControl>
Project.FLY.Thick.Base/FLY.Thick.Base.UI/CustomSection/UcSectionLanguage.xaml.cs
0 → 100644
View file @
c5d889e4
using
CommunityToolkit.Mvvm.Input
;
using
FLY.AppHelper
;
using
Misc
;
using
System.Collections.ObjectModel
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Windows
;
using
System.Windows.Controls
;
namespace
FLY.Thick.Base.UI.CustomSection
{
/// <summary>
/// UcSectionOsk.xaml 的交互逻辑
/// </summary>
public
partial
class
UcSectionLanguage
:
UserControl
{
UcSectionLanguageVm
viewModel
;
public
UcSectionLanguage
()
{
InitializeComponent
();
}
[
Unity
.
InjectionMethod
]
public
void
Init
(
Culture
culture
)
{
viewModel
=
new
UcSectionLanguageVm
();
viewModel
.
Init
(
culture
);
this
.
DataContext
=
viewModel
;
}
}
public
class
UcSectionLanguageVm
:
INotifyPropertyChanged
{
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
LanguageInfo
CurrentLanguage
{
get
;
set
;
}
public
ObservableCollection
<
LanguageInfo
>
LanguageList
{
get
;
}
=
new
ObservableCollection
<
LanguageInfo
>();
public
RelayCommand
OkCmd
{
get
;
private
set
;
}
Culture
culture
;
public
UcSectionLanguageVm
()
{
OkCmd
=
new
RelayCommand
(
Ok
);
LanguageList
.
Add
(
new
LanguageInfo
()
{
Info
=
"中文"
,
Language
=
"ch"
});
LanguageList
.
Add
(
new
LanguageInfo
()
{
Info
=
"English"
,
Language
=
"en"
});
}
public
void
Init
(
Culture
culture
)
{
this
.
culture
=
culture
;
try
{
CurrentLanguage
=
LanguageList
.
First
(
l
=>
l
.
Language
==
culture
.
Language
);
}
catch
{
CurrentLanguage
=
LanguageList
[
0
];
}
}
private
void
Ok
()
{
string
msg
=
(
string
)
Application
.
Current
.
FindResource
(
"str.PgCustomSections.IsSureToReboot"
);
if
(
MessageBox
.
Show
(
msg
,
null
,
MessageBoxButton
.
YesNo
,
MessageBoxImage
.
Question
)
==
MessageBoxResult
.
No
)
{
return
;
}
if
(
culture
.
Language
!=
CurrentLanguage
.
Language
)
{
culture
.
Language
=
CurrentLanguage
.
Language
;
culture
.
Save
();
}
AppJustOne
.
Restart
();
}
}
public
class
LanguageInfo
:
INotifyPropertyChanged
{
public
string
Language
{
get
;
set
;
}
public
string
Info
{
get
;
set
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/FLY.Thick.Base.UI.csproj
View file @
c5d889e4
...
...
@@ -96,11 +96,15 @@
<Compile
Include=
"CtMicroGage.xaml.cs"
>
<DependentUpon>
CtMicroGage.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"Culture.cs"
/>
<Compile
Include=
"CustomMenu\AdrMenu.cs"
/>
<Compile
Include=
"CustomMenu\CustomMenu.cs"
/>
<Compile
Include=
"CustomMenu\UpdateMenu.cs"
/>
<Compile
Include=
"CustomMenu\WarningMenu.cs"
/>
<Compile
Include=
"CustomMenu\PwMenu.cs"
/>
<Compile
Include=
"CustomSection\UcSectionLanguage.xaml.cs"
>
<DependentUpon>
UcSectionLanguage.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"CustomSection\UcSectionScanGraph.xaml.cs"
>
<DependentUpon>
UcSectionScanGraph.xaml
</DependentUpon>
</Compile>
...
...
@@ -245,6 +249,10 @@
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"CustomSection\UcSectionLanguage.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"CustomSection\UcSectionScanGraph.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
...
...
@@ -640,6 +648,10 @@
<Project>
{5bbe76f5-cfd7-4dfa-9ee5-0c47d77d96e6}
</Project>
<Name>
MultiLayout
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Project.FLY.AppHelper\FLY.AppHelper\FLY.AppHelper.csproj"
>
<Project>
{9c46d98f-6500-490b-9e56-c89dfffa05f8}
</Project>
<Name>
FLY.AppHelper
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Project.FLY.ControlLibrary\FLY.ControlLibrary\FLY.ControlLibrary.csproj"
>
<Project>
{119C3ADC-F8E1-4F72-B89B-006236FF8586}
</Project>
<Name>
FLY.ControlLibrary
</Name>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml
View file @
c5d889e4
...
...
@@ -43,12 +43,6 @@
<TextBlock Style="{StaticResource Styles.Card.Title}"
Text="{StaticResource str.PgFlyAd.Param}"/>
<StackPanel >
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="IP:port" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding EP, Converter={StaticResource ipepconv}}" Tag="Full" />
</StackPanel>
</StackPanel>
<WrapPanel Orientation="Horizontal">
<StackPanel Margin="{StaticResource ControlMargin}" >
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Themes/StringResources/StringResource.PgCustomSections.xaml
View file @
c5d889e4
...
...
@@ -22,5 +22,8 @@
<system:String x:Key="str.PgCustomSections.XStep" >X轴间隔</system:String>
<system:String x:Key="str.PgCustomSections.SelectMusicFile" >打开音乐文件</system:String>
<system:String x:Key="str.PgCustomSections.IsSureToReboot">程序必须重启才能执行新的参数, 是否重启?</system:String>
<system:String x:Key="str.PgCustomSections.Language">语言</system:String>
<system:String x:Key="str.PgCustomSections.Apply">应用</system:String>
</ResourceDictionary>
\ No newline at end of file
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Themes/StringResources/en/StringResource.PgCustomSections.xaml
View file @
c5d889e4
...
...
@@ -6,7 +6,7 @@
<!--字符串换行 换行符 -->
<system:String x:Key="str.PgCustomSections.Title">Client App Setting</system:String>
<system:String x:Key="str.PgCustomSections.AutoChangedPage" xml:space="preserve">Auto
Changed
Page</system:String>
<system:String x:Key="str.PgCustomSections.AutoChangedPage" xml:space="preserve">Auto Page</system:String>
<system:String x:Key="str.PgCustomSections.State" >State</system:String>
<system:String x:Key="str.PgCustomSections.Page" >Page</system:String>
<system:String x:Key="str.PgCustomSections.AlarmTip" >Alarm Tip</system:String>
...
...
@@ -22,4 +22,7 @@
<system:String x:Key="str.PgCustomSections.XStep" >X-axis Step</system:String>
<system:String x:Key="str.PgCustomSections.SelectMusicFile" >Select Music File</system:String>
<system:String x:Key="str.PgCustomSections.Language">Language</system:String>
<system:String x:Key="str.PgCustomSections.Apply">Apply</system:String>
</ResourceDictionary>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment