lang support for binding
This commit is contained in:
1 parent
95f35c7366
commit
1680858455
20 files changed
+274
-117
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
|
||||||
namespace HandyControlDemo.Properties.Langs
|
namespace HandyControlDemo.Properties.Langs
|
||||||
@@ -24,6 +26,13 @@ namespace HandyControlDemo.Properties.Langs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
|
||||||
|
BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
|
||||||
|
{
|
||||||
|
Source = Instance,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
|
||||||
private void UpdateLangs()
|
private void UpdateLangs()
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(About));
|
OnPropertyChanged(nameof(About));
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#>
|
#>
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
|
||||||
namespace HandyControlDemo.Properties.Langs
|
namespace HandyControlDemo.Properties.Langs
|
||||||
@@ -43,6 +45,13 @@ namespace HandyControlDemo.Properties.Langs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
|
||||||
|
BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
|
||||||
|
{
|
||||||
|
Source = Instance,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
|
||||||
private void UpdateLangs()
|
private void UpdateLangs()
|
||||||
{
|
{
|
||||||
<#foreach(var item in propertyNameList){#>
|
<#foreach(var item in propertyNameList){#>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Net;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
|
using HandyControlDemo.Properties.Langs;
|
||||||
using HandyControlDemo.Tools.Converter;
|
using HandyControlDemo.Tools.Converter;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ namespace HandyControlDemo.Service
|
|||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
for (var i = 1; i <= 9; i++)
|
for (var i = 1; i <= 9; i++)
|
||||||
{
|
{
|
||||||
list.Add($"{converter.Convert(Properties.Langs.Lang.Text, null, i, CultureInfo.CurrentCulture)}{i}");
|
list.Add($"{converter.Convert(Lang.Text, null, i, CultureInfo.CurrentCulture)}{i}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -279,23 +280,23 @@ namespace HandyControlDemo.Service
|
|||||||
{
|
{
|
||||||
new StepBarDemoModel
|
new StepBarDemoModel
|
||||||
{
|
{
|
||||||
Header = $"{Properties.Langs.Lang.Step}1",
|
Header = LangKeys.Step,
|
||||||
Content = Properties.Langs.Lang.Register
|
Content = LangKeys.Register
|
||||||
},
|
},
|
||||||
new StepBarDemoModel
|
new StepBarDemoModel
|
||||||
{
|
{
|
||||||
Header = $"{Properties.Langs.Lang.Step}2",
|
Header = LangKeys.Step,
|
||||||
Content = Properties.Langs.Lang.BasicInfo
|
Content = LangKeys.BasicInfo
|
||||||
},
|
},
|
||||||
new StepBarDemoModel
|
new StepBarDemoModel
|
||||||
{
|
{
|
||||||
Header = $"{Properties.Langs.Lang.Step}3",
|
Header = LangKeys.Step,
|
||||||
Content = Properties.Langs.Lang.UploadFile
|
Content = LangKeys.UploadFile
|
||||||
},
|
},
|
||||||
new StepBarDemoModel
|
new StepBarDemoModel
|
||||||
{
|
{
|
||||||
Header = $"{Properties.Langs.Lang.Step}4",
|
Header = LangKeys.Step,
|
||||||
Content = Properties.Langs.Lang.Complete
|
Content = LangKeys.Complete
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -374,7 +375,7 @@ namespace HandyControlDemo.Service
|
|||||||
foreach (var item in jsonObj)
|
foreach (var item in jsonObj)
|
||||||
{
|
{
|
||||||
var titleKey = (string) item.title;
|
var titleKey = (string) item.title;
|
||||||
var title = Properties.Langs.Lang.ResourceManager.GetString(titleKey);
|
var title = titleKey;
|
||||||
var list = Convert2DemoItemList(item.demoItemList);
|
var list = Convert2DemoItemList(item.demoItemList);
|
||||||
infoList.Add(new DemoInfoModel
|
infoList.Add(new DemoInfoModel
|
||||||
{
|
{
|
||||||
@@ -393,7 +394,7 @@ namespace HandyControlDemo.Service
|
|||||||
|
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
var name = Properties.Langs.Lang.ResourceManager.GetString((string)item[0]);
|
var name = (string)item[0];
|
||||||
string targetCtlName = item[1];
|
string targetCtlName = item[1];
|
||||||
string imageName = item[2];
|
string imageName = item[2];
|
||||||
var isNew = !string.IsNullOrEmpty((string)item[3]);
|
var isNew = !string.IsNullOrEmpty((string)item[3]);
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ namespace HandyControlDemo.Tools.Extension
|
|||||||
{
|
{
|
||||||
public class LangExtension : HandyControl.Tools.Extension.LangExtension
|
public class LangExtension : HandyControl.Tools.Extension.LangExtension
|
||||||
{
|
{
|
||||||
public override object LangSource => LangDecorator.Instance;
|
public LangExtension()
|
||||||
|
{
|
||||||
|
Source = LangDecorator.Instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,13 +7,13 @@
|
|||||||
Background="{DynamicResource RegionBrush}">
|
Background="{DynamicResource RegionBrush}">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<StackPanel Margin="32" Width="400">
|
<StackPanel Margin="32" Width="400">
|
||||||
<hc:OutlineText TextWrapping="Wrap" Fill="{DynamicResource PrimaryTextBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=20}"/>
|
<hc:OutlineText TextWrapping="Wrap" Fill="{DynamicResource PrimaryTextBrush}" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=20}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" FontSize="30" Fill="{DynamicResource SuccessBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=8}"/>
|
<hc:OutlineText Margin="0,10,0,0" FontSize="30" Fill="{DynamicResource SuccessBrush}" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=8}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" Fill="{DynamicResource PrimaryTextBrush}" FontSize="30" FontStyle="Italic" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=8}"/>
|
<hc:OutlineText Margin="0,10,0,0" Fill="{DynamicResource PrimaryTextBrush}" FontSize="30" FontStyle="Italic" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=8}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" FontSize="50" StrokeThickness="2" Fill="{DynamicResource DangerBrush}" Stroke="{DynamicResource PrimaryBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
<hc:OutlineText Margin="0,10,0,0" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" FontSize="50" StrokeThickness="2" Fill="{DynamicResource DangerBrush}" Stroke="{DynamicResource PrimaryBrush}" Text="ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
<hc:OutlineText Margin="0,10,0,0" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" StrokePosition="Outside" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
<hc:OutlineText Margin="0,10,0,0" StrokePosition="Outside" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
||||||
<hc:OutlineText Margin="0,10,0,0" StrokePosition="InSide" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
<hc:OutlineText Margin="0,10,0,0" StrokePosition="InSide" FontSize="80" FontWeight="Bold" StrokeThickness="4" Fill="{DynamicResource PrimaryBrush}" Stroke="{DynamicResource DangerBrush}" Text="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -7,14 +7,14 @@
|
|||||||
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
|
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||||
<hc:RunningBlock Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
<hc:RunningBlock Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||||
<hc:RunningBlock Runaway="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="100" Runaway="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Duration="0:0:2" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="100" Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Duration="0:0:2" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoReverse="True" AutoRun="True" Width="100" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoReverse="True" AutoRun="True" Width="100" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="200" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="200" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
<hc:RunningBlock Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock AutoReverse="True" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
<hc:RunningBlock AutoReverse="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock Orientation="Vertical" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:4" Margin="0,16,0,0"/>
|
<hc:RunningBlock Orientation="Vertical" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:4" Margin="0,16,0,0"/>
|
||||||
<hc:RunningBlock Margin="0,16,0,0" Duration="0:0:20" IsRunning="{Binding IsMouseOver,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2BooleanReConverter}}">
|
<hc:RunningBlock Margin="0,16,0,0" Duration="0:0:20" IsRunning="{Binding IsMouseOver,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2BooleanReConverter}}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif" Margin="10,0" Width="30" Height="30"/>
|
||||||
|
|||||||
@@ -39,8 +39,11 @@
|
|||||||
<hc:StepBar.ItemTemplate>
|
<hc:StepBar.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="{Binding Header}" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left"/>
|
<TextBlock FontSize="16" FontWeight="Bold" HorizontalAlignment="Left">
|
||||||
<TextBlock Margin="0,4,0,0" Text="{Binding Content}"/>
|
<Run Text="{ex:Lang Key={Binding Header}}"/>
|
||||||
|
<Run Text="{Binding Index,RelativeSource={RelativeSource AncestorType=hc:StepBarItem}}"/>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Margin="0,4,0,0" Text="{ex:Lang Key={Binding Content}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</hc:StepBar.ItemTemplate>
|
</hc:StepBar.ItemTemplate>
|
||||||
@@ -49,8 +52,11 @@
|
|||||||
<hc:StepBar.ItemTemplate>
|
<hc:StepBar.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="{Binding Header}" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left"/>
|
<TextBlock FontSize="16" FontWeight="Bold" HorizontalAlignment="Left">
|
||||||
<TextBlock Margin="0,4,0,0" Text="{Binding Content}"/>
|
<Run Text="{ex:Lang Key={Binding Header}}"/>
|
||||||
|
<Run Text="{Binding Index,RelativeSource={RelativeSource AncestorType=hc:StepBarItem}}"/>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Margin="0,4,0,0" Text="{ex:Lang Key={Binding Content}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</hc:StepBar.ItemTemplate>
|
</hc:StepBar.ItemTemplate>
|
||||||
|
|||||||
@@ -7,16 +7,16 @@
|
|||||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<hc:TagPanel AddTagButtonClick="TagPanel_OnAddTagButtonClick" Margin="32" Orientation="Horizontal" MaxWidth="400" VerticalAlignment="Center" ShowAddButton="True">
|
<hc:TagPanel AddTagButtonClick="TagPanel_OnAddTagButtonClick" Margin="32" Orientation="Horizontal" MaxWidth="400" VerticalAlignment="Center" ShowAddButton="True">
|
||||||
<hc:Tag ShowCloseButton="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
||||||
<hc:Tag Selectable="True" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
<hc:Tag Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
||||||
<hc:Tag ShowCloseButton="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
||||||
<hc:Tag Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||||
<hc:Tag IsSelected="True" Selectable="True" ShowCloseButton="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
<hc:Tag IsSelected="True" Selectable="True" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
||||||
<hc:Tag Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
||||||
<hc:Tag ShowCloseButton="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
|
||||||
<hc:Tag IsSelected="True" Selectable="True" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
<hc:Tag IsSelected="True" Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
|
||||||
<hc:Tag ShowCloseButton="False" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
|
||||||
<hc:Tag Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||||
</hc:TagPanel>
|
</hc:TagPanel>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
|
using HandyControlDemo.Properties.Langs;
|
||||||
|
|
||||||
namespace HandyControlDemo.UserControl
|
namespace HandyControlDemo.UserControl
|
||||||
{
|
{
|
||||||
@@ -14,10 +15,9 @@ namespace HandyControlDemo.UserControl
|
|||||||
{
|
{
|
||||||
if (sender is TagPanel panel)
|
if (sender is TagPanel panel)
|
||||||
{
|
{
|
||||||
panel.Children.Add(new Tag
|
var tag = new Tag();
|
||||||
{
|
LangDecorator.SetLang(tag, ContentProperty, LangKeys.SubTitle);
|
||||||
Content = Properties.Langs.Lang.SubTitle
|
panel.Children.Add(tag);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<TabControl SelectionChanged="TabControl_OnSelectionChanged" ItemContainerStyle="{StaticResource TabItemTransparent}" ItemsSource="{Binding DemoInfoList}" Style="{StaticResource TabControlInLine}" Background="Transparent" SelectedIndex="0">
|
<TabControl SelectionChanged="TabControl_OnSelectionChanged" ItemContainerStyle="{StaticResource TabItemTransparent}" ItemsSource="{Binding DemoInfoList}" Style="{StaticResource TabControlInLine}" Background="Transparent" SelectedIndex="0">
|
||||||
<TabControl.ItemTemplate>
|
<TabControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Title}"/>
|
<TextBlock Text="{ex:Lang Key={Binding Title}}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</TabControl.ItemTemplate>
|
</TabControl.ItemTemplate>
|
||||||
<TabControl.ContentTemplate>
|
<TabControl.ContentTemplate>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Image Width="16" Height="16" Source="{Binding ImageName}"/>
|
<Image Width="16" Height="16" Source="{Binding ImageName}"/>
|
||||||
<TextBlock Margin="6,0,0,0" Text="{Binding Name}"/>
|
<TextBlock Margin="6,0,0,0" Text="{ex:Lang Key={Binding Name}}"/>
|
||||||
<Path Visibility="{Binding IsNew,Converter={StaticResource Boolean2VisibilityConverter}}" VerticalAlignment="Center" Data="{StaticResource NewGeometry}" Stretch="Uniform" Margin="10,0,0,0" Width="30" Height="14" Fill="{DynamicResource DangerBrush}"/>
|
<Path Visibility="{Binding IsNew,Converter={StaticResource Boolean2VisibilityConverter}}" VerticalAlignment="Center" Data="{StaticResource NewGeometry}" Stretch="Uniform" Margin="10,0,0,0" Width="30" Height="14" Fill="{DynamicResource DangerBrush}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Globalization;
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using HandyControl.Controls;
|
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
|
using HandyControl.Tools;
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
using HandyControlDemo.Properties.Langs;
|
using HandyControlDemo.Properties.Langs;
|
||||||
using HandyControlDemo.Window;
|
using HandyControlDemo.Window;
|
||||||
@@ -23,19 +22,11 @@ namespace HandyControlDemo.UserControl
|
|||||||
{
|
{
|
||||||
PopupConfig.IsOpen = false;
|
PopupConfig.IsOpen = false;
|
||||||
if (tag.Equals(GlobalData.Config.Lang)) return;
|
if (tag.Equals(GlobalData.Config.Lang)) return;
|
||||||
Growl.Ask(Properties.Langs.Lang.ChangeLangAsk, b =>
|
ConfigHelper.Instance.SetLang(tag);
|
||||||
{
|
LangDecorator.Culture = new CultureInfo(tag);
|
||||||
if (!b) return true;
|
|
||||||
GlobalData.Config.Lang = tag;
|
|
||||||
GlobalData.Save();
|
|
||||||
|
|
||||||
LangDecorator.Culture = new CultureInfo(tag);
|
GlobalData.Config.Lang = tag;
|
||||||
//var processModule = Process.GetCurrentProcess().MainModule;
|
GlobalData.Save();
|
||||||
//if (processModule != null)
|
|
||||||
// Process.Start(processModule.FileName);
|
|
||||||
//Application.Current.Shutdown();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
Background="{DynamicResource RegionBrush}">
|
Background="{DynamicResource RegionBrush}">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<StackPanel Margin="32">
|
<StackPanel Margin="32">
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}"/>
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelDanger}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelDanger}"/>
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelInfo}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelInfo}"/>
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelPrimary}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelPrimary}"/>
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelSuccess}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelSuccess}"/>
|
||||||
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelWarning}"/>
|
<Label HorizontalAlignment="Left" Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelWarning}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
<RichTextBox Margin="32" Width="400" Height="300" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
<RichTextBox Margin="32" Width="400" Height="300" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||||
<FlowDocument>
|
<FlowDocument>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
<Run FontSize="20" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20,Mode=OneWay}"/>
|
<Run FontSize="20" Text="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=20,Mode=OneWay}"/>
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
<Run Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=1000,Mode=OneWay}"/>
|
<Run Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=1000,Mode=OneWay}"/>
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
<Hyperlink>https://github.com/NaBian/HandyControl</Hyperlink>
|
<Hyperlink>https://github.com/NaBian/HandyControl</Hyperlink>
|
||||||
|
|||||||
@@ -27,23 +27,23 @@
|
|||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultSuccess" Style="{StaticResource TextBlockDefaultSuccess}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultSuccess" Style="{StaticResource TextBlockDefaultSuccess}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Margin="10,0,0,0">
|
<StackPanel Margin="10,0,0,0">
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockLargeBold}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockLargeBold}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockLarge}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockLarge}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=12}" Style="{StaticResource TextBlockTitleBold}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=12}" Style="{StaticResource TextBlockTitleBold}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Title}},Converter={StaticResource StringRepeatConverter},ConverterParameter=12}" Style="{StaticResource TextBlockTitle}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=12}" Style="{StaticResource TextBlockTitle}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.SubTitle}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockSubTitleBold}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.SubTitle},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockSubTitleBold}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.SubTitle}},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockSubTitle}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.SubTitle},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource TextBlockSubTitle}"/>
|
||||||
|
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultBold}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultBold}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefault}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefault}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultAccent}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultAccent}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultSecLight}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultSecLight}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultThiLight}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultThiLight}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultPrimary}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultPrimary}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultDanger}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultDanger}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultWarning}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultWarning}"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultInfo}"/>
|
<TextBlock HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultInfo}"/>
|
||||||
<TextBlock hc:TextBlockAttach.AutoTooltip="True" Width="300" HorizontalAlignment="Left" Margin="5" Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultSuccess}"/>
|
<TextBlock hc:TextBlockAttach.AutoTooltip="True" Width="300" HorizontalAlignment="Left" Margin="5" Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=20}" Style="{StaticResource TextBlockDefaultSuccess}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ToolBar Band="1" Padding="6">
|
<ToolBar Band="1" Padding="6">
|
||||||
<ComboBox ItemsSource="{Binding DataList}" SelectedIndex="0" Width="230"/>
|
<ComboBox ItemsSource="{Binding DataList}" SelectedIndex="0" Width="230"/>
|
||||||
<TextBox Text="{Binding Source={ex:Lang Key={x:Static langs:LangKeys.Text}},Converter={StaticResource StringRepeatConverter},ConverterParameter=4,Mode=OneWay}" Margin="10,0,0,0" Width="230"/>
|
<TextBox Text="{ex:Lang Key={x:Static langs:LangKeys.Text},Converter={StaticResource StringRepeatConverter},ConverterParameter=4,Mode=OneWay}" Margin="10,0,0,0" Width="230"/>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ToolBar Band="0" Padding="6">
|
<ToolBar Band="0" Padding="6">
|
||||||
<Menu Background="Transparent" VerticalAlignment="Center">
|
<Menu Background="Transparent" VerticalAlignment="Center">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Interactivity;
|
using HandyControl.Interactivity;
|
||||||
|
using HandyControl.Properties.Langs;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
using HandyControl.Tools.Extension;
|
using HandyControl.Tools.Extension;
|
||||||
|
|
||||||
@@ -297,10 +298,9 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
if (panel == null) return;
|
if (panel == null) return;
|
||||||
|
|
||||||
var menuItem = new MenuItem
|
var menuItem = new MenuItem();
|
||||||
{
|
LangDecorator.SetLang(menuItem, HeaderedItemsControl.HeaderProperty, LangKeys.Clear);
|
||||||
Header = Properties.Langs.Lang.Clear
|
|
||||||
};
|
|
||||||
menuItem.Click += (s, e) =>
|
menuItem.Click += (s, e) =>
|
||||||
{
|
{
|
||||||
foreach (var item in panel.Children.OfType<Growl>())
|
foreach (var item in panel.Children.OfType<Growl>())
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
|
||||||
namespace HandyControl.Properties.Langs
|
namespace HandyControl.Properties.Langs
|
||||||
@@ -10,7 +12,7 @@ namespace HandyControl.Properties.Langs
|
|||||||
|
|
||||||
private static string CultureInfoStr;
|
private static string CultureInfoStr;
|
||||||
|
|
||||||
public static CultureInfo Culture
|
internal static CultureInfo Culture
|
||||||
{
|
{
|
||||||
get => Lang.Culture;
|
get => Lang.Culture;
|
||||||
set
|
set
|
||||||
@@ -24,6 +26,13 @@ namespace HandyControl.Properties.Langs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
|
||||||
|
BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
|
||||||
|
{
|
||||||
|
Source = Instance,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
|
||||||
private void UpdateLangs()
|
private void UpdateLangs()
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(Am));
|
OnPropertyChanged(nameof(Am));
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#>
|
#>
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
|
||||||
namespace HandyControl.Properties.Langs
|
namespace HandyControl.Properties.Langs
|
||||||
@@ -29,7 +31,7 @@ namespace HandyControl.Properties.Langs
|
|||||||
|
|
||||||
private static string CultureInfoStr;
|
private static string CultureInfoStr;
|
||||||
|
|
||||||
public static CultureInfo Culture
|
internal static CultureInfo Culture
|
||||||
{
|
{
|
||||||
get => Lang.Culture;
|
get => Lang.Culture;
|
||||||
set
|
set
|
||||||
@@ -43,6 +45,13 @@ namespace HandyControl.Properties.Langs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
|
||||||
|
BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
|
||||||
|
{
|
||||||
|
Source = Instance,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
|
||||||
private void UpdateLangs()
|
private void UpdateLangs()
|
||||||
{
|
{
|
||||||
<#foreach(var item in propertyNameList){#>
|
<#foreach(var item in propertyNameList){#>
|
||||||
|
|||||||
@@ -1,42 +1,163 @@
|
|||||||
using HandyControl.Properties.Langs;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
using HandyControl.Properties.Langs;
|
||||||
|
|
||||||
namespace HandyControl.Tools.Extension
|
namespace HandyControl.Tools.Extension
|
||||||
{
|
{
|
||||||
public class LangExtension : MarkupExtension
|
public class LangExtension : MarkupExtension
|
||||||
{
|
{
|
||||||
|
private readonly DependencyObject _proxy;
|
||||||
|
|
||||||
|
private bool _isInternalAction;
|
||||||
|
|
||||||
public LangExtension()
|
public LangExtension()
|
||||||
{
|
{
|
||||||
|
_proxy = new DependencyObject();
|
||||||
|
Source = LangDecorator.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LangExtension(string key) => Key = key;
|
public LangExtension(string key) : this()
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty KeyProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"Key", typeof(object), typeof(LangExtension), new PropertyMetadata(default));
|
||||||
|
|
||||||
|
public object Key
|
||||||
|
{
|
||||||
|
get => _proxy.GetValue(KeyProperty);
|
||||||
|
set => _proxy.SetValue(KeyProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly DependencyProperty TargetPropertyProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"TargetProperty", typeof(DependencyProperty), typeof(LangExtension), new PropertyMetadata(default(DependencyProperty)));
|
||||||
|
|
||||||
|
private static void SetTargetProperty(DependencyObject element, DependencyProperty value)
|
||||||
|
=> element.SetValue(TargetPropertyProperty, value);
|
||||||
|
|
||||||
|
private static DependencyProperty GetTargetProperty(DependencyObject element)
|
||||||
|
=> (DependencyProperty) element.GetValue(TargetPropertyProperty);
|
||||||
|
|
||||||
|
public BindingMode Mode { get; set; }
|
||||||
|
|
||||||
|
public IValueConverter Converter { get; set; }
|
||||||
|
|
||||||
|
public object ConverterParameter { get; set; }
|
||||||
|
|
||||||
|
public object Source { get; set; }
|
||||||
|
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget pvt))
|
if (_isInternalAction) return this;
|
||||||
return null;
|
if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget)) return this;
|
||||||
|
if (provideValueTarget.TargetObject.GetType().FullName == "System.Windows.SharedDp") return this;
|
||||||
|
if (!(provideValueTarget.TargetObject is DependencyObject targetObject)) return this;
|
||||||
|
if (!(provideValueTarget.TargetProperty is DependencyProperty targetProperty)) return this;
|
||||||
|
|
||||||
if (!(pvt.TargetObject is DependencyObject targetObject))
|
switch (Key)
|
||||||
return null;
|
|
||||||
|
|
||||||
if (!(pvt.TargetProperty is DependencyProperty targetProperty))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var binding = new Binding(Key)
|
|
||||||
{
|
{
|
||||||
Source = LangSource,
|
case string key:
|
||||||
Mode = BindingMode.OneWay
|
{
|
||||||
};
|
var binding = new Binding(key)
|
||||||
BindingOperations.SetBinding(targetObject, targetProperty, binding);
|
{
|
||||||
return binding.ProvideValue(serviceProvider);
|
Converter = Converter,
|
||||||
|
ConverterParameter = ConverterParameter,
|
||||||
|
UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
|
||||||
|
Source = Source,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
};
|
||||||
|
BindingOperations.SetBinding(targetObject, targetProperty, binding);
|
||||||
|
return binding.ProvideValue(serviceProvider);
|
||||||
|
}
|
||||||
|
case Binding keyBinding when targetObject is FrameworkElement element:
|
||||||
|
{
|
||||||
|
if (element.DataContext != null)
|
||||||
|
{
|
||||||
|
_isInternalAction = true;
|
||||||
|
SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
|
||||||
|
_isInternalAction = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetTargetProperty(element, targetProperty);
|
||||||
|
element.DataContextChanged += LangExtension_DataContextChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Binding keyBinding when targetObject is FrameworkContentElement element:
|
||||||
|
{
|
||||||
|
if (element.DataContext != null)
|
||||||
|
{
|
||||||
|
_isInternalAction = true;
|
||||||
|
SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
|
||||||
|
_isInternalAction = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetTargetProperty(element, targetProperty);
|
||||||
|
element.DataContextChanged += LangExtension_DataContextChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Key { get; set; }
|
private void LangExtension_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
switch (sender)
|
||||||
|
{
|
||||||
|
case FrameworkElement element:
|
||||||
|
{
|
||||||
|
element.DataContextChanged -= LangExtension_DataContextChanged;
|
||||||
|
if (!(Key is Binding keyBinding)) return;
|
||||||
|
|
||||||
public virtual object LangSource => LangDecorator.Instance;
|
var targetProperty = GetTargetProperty(element);
|
||||||
|
SetTargetProperty(element, null);
|
||||||
|
SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FrameworkContentElement element:
|
||||||
|
{
|
||||||
|
element.DataContextChanged -= LangExtension_DataContextChanged;
|
||||||
|
if (!(Key is Binding keyBinding)) return;
|
||||||
|
|
||||||
|
var targetProperty = GetTargetProperty(element);
|
||||||
|
SetTargetProperty(element, null);
|
||||||
|
SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetLangBinding(DependencyObject targetObject, DependencyProperty targetProperty, PropertyPath path, object dataContext)
|
||||||
|
{
|
||||||
|
if (targetProperty == null) return;
|
||||||
|
|
||||||
|
BindingOperations.SetBinding(targetObject, targetProperty, new Binding
|
||||||
|
{
|
||||||
|
Path = path,
|
||||||
|
Source = dataContext,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
|
||||||
|
var key = targetObject.GetValue(targetProperty) as string;
|
||||||
|
if (string.IsNullOrEmpty(key)) return;
|
||||||
|
|
||||||
|
BindingOperations.SetBinding(targetObject, targetProperty, new Binding(key)
|
||||||
|
{
|
||||||
|
Converter = Converter,
|
||||||
|
ConverterParameter = ConverterParameter,
|
||||||
|
UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
|
||||||
|
Source = Source,
|
||||||
|
Mode = BindingMode.OneWay
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ using System.Windows.Media.Animation;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
|
using HandyControl.Properties.Langs;
|
||||||
|
|
||||||
namespace HandyControl.Tools
|
namespace HandyControl.Tools
|
||||||
{
|
{
|
||||||
@@ -37,13 +38,11 @@ namespace HandyControl.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSystemVersionInfo(SystemVersionInfo info)
|
public void SetSystemVersionInfo(SystemVersionInfo info) => BlurWindow.SystemVersionInfo = info;
|
||||||
{
|
|
||||||
BlurWindow.SystemVersionInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLang(string lang)
|
public void SetLang(string lang)
|
||||||
{
|
{
|
||||||
|
LangDecorator.Culture = new CultureInfo(lang);
|
||||||
Application.Current.Dispatcher.Thread.CurrentUICulture = new CultureInfo(lang);
|
Application.Current.Dispatcher.Thread.CurrentUICulture = new CultureInfo(lang);
|
||||||
Lang = XmlLanguage.GetLanguage(lang);
|
Lang = XmlLanguage.GetLanguage(lang);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user