mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
修复日期读取错误
替换确定与取消的位置 多语言编辑器可以独立运行, 并随模组的编辑而改变
This commit is contained in:
parent
7ffc9fcd7d
commit
e6700407bd
@ -11,4 +11,5 @@
|
||||
<c:FalseToHiddenConverter x:Key="FalseToHiddenConverter" />
|
||||
<c:EqualsConverter x:Key="EqualsConverter" />
|
||||
<c:NotEqualsConverter x:Key="NotEqualsConverter" />
|
||||
<c:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||
</ResourceDictionary>
|
18
VPet.ModMaker/Converters/NullToFalseConverter.cs
Normal file
18
VPet.ModMaker/Converters/NullToFalseConverter.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace VPet.ModMaker.Converters;
|
||||
|
||||
public class NullToFalseConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is not null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -46,7 +46,9 @@ public class I18nModel<T>
|
||||
/// <param name="newValue"></param>
|
||||
private void CultureChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (I18nDatas.TryGetValue(newValue, out var result))
|
||||
if (newValue is null)
|
||||
CurrentI18nData.Value = null;
|
||||
else if (I18nDatas.TryGetValue(newValue, out var result))
|
||||
CurrentI18nData.Value = result;
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
new Line("intro", DescriptionId.Value),
|
||||
new Line("authorid", AuthorID.ToString()),
|
||||
new Line("itemid", ItemID.ToString()),
|
||||
new Line("cachedate", DateTime.Now.Date.ToString())
|
||||
new Line("cachedate", DateTime.Now.Date.ToString("s"))
|
||||
};
|
||||
foreach (var cultureName in I18nHelper.Current.CultureNames)
|
||||
{
|
||||
|
@ -98,6 +98,7 @@
|
||||
<Compile Include="Converters\FalseToHiddenConverter.cs" />
|
||||
<Compile Include="Converters\MediaColorToBrushConverter.cs" />
|
||||
<Compile Include="Converters\NotEqualsConverter.cs" />
|
||||
<Compile Include="Converters\NullToFalseConverter.cs" />
|
||||
<Compile Include="Converters\StringFormatConverter.cs" />
|
||||
<Compile Include="Converters\RatioMarginConverter.cs" />
|
||||
<Compile Include="Converters\MaxConverter.cs" />
|
||||
|
@ -96,14 +96,7 @@ public class ModEditWindowVM
|
||||
return;
|
||||
}
|
||||
var window = new I18nEditWindow(ModInfo.Value);
|
||||
//foreach (var culture in I18nHelper.Current.CultureNames)
|
||||
// window.AddCulture(culture);
|
||||
//if (window.IsCancel)
|
||||
// return;
|
||||
//I18nHelper.Current.CultureNames.Add(window.ViewModel.Culture.Value);
|
||||
//if (I18nHelper.Current.CultureNames.Count == 1)
|
||||
// I18nHelper.Current.CultureName.Value = window.ViewModel.Culture.Value;
|
||||
window.ShowDialog();
|
||||
window.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,6 +105,7 @@ public class ModEditWindowVM
|
||||
public void Close()
|
||||
{
|
||||
ModInfo.Value.Image.Value?.StreamSource?.Close();
|
||||
I18nEditWindow.Instance?.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -227,20 +221,20 @@ public class ModEditWindowVM
|
||||
private void SaveTo(string path)
|
||||
{
|
||||
var pending = PendingBox.Show("保存中".Translate());
|
||||
//try
|
||||
//{
|
||||
ModInfo.Value.SaveTo(path);
|
||||
if (string.IsNullOrWhiteSpace(ModInfo.Value.SourcePath.Value))
|
||||
ModInfo.Value.SourcePath.Value = path;
|
||||
pending.Close();
|
||||
MessageBox.Show(ModEditWindow, "保存成功".Translate());
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// pending.Close();
|
||||
// MessageBox.Show("保存失败 错误信息:\n{0}".Translate(ex));
|
||||
// return;
|
||||
//}
|
||||
try
|
||||
{
|
||||
ModInfo.Value.SaveTo(path);
|
||||
if (string.IsNullOrWhiteSpace(ModInfo.Value.SourcePath.Value))
|
||||
ModInfo.Value.SourcePath.Value = path;
|
||||
pending.Close();
|
||||
MessageBox.Show(ModEditWindow, "保存成功".Translate());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
pending.Close();
|
||||
MessageBox.Show("保存失败 错误信息:\n{0}".Translate(ex));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -59,21 +59,21 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
IsCancel="True"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
IsDefault="True"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
IsCancel="True"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
|
@ -289,20 +289,20 @@
|
||||
Command="{Binding AddAnimeCommand}"
|
||||
Content="{ll:Str 添加动画}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="2"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="2"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -629,20 +629,20 @@
|
||||
Command="{Binding AddAnimeCommand}"
|
||||
Content="{ll:Str 添加动画}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="2"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="2"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -57,19 +57,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -169,19 +169,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
@ -186,19 +186,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
@ -27,13 +27,14 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox
|
||||
pu:TextBoxHelper.Watermark="{ll:Str 搜索}"
|
||||
IsEnabled="{Binding SearchTarget.Value, Converter={StaticResource NullToFalseConverter}}"
|
||||
Style="{DynamicResource StandardTextBoxStyle}"
|
||||
Text="{Binding Search.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<ComboBox
|
||||
Grid.Column="1"
|
||||
ItemsSource="{Binding SearchTargets}"
|
||||
SelectedIndex="0"
|
||||
SelectedItem="{Binding SearchTarget.Value}" />
|
||||
SelectedItem="{Binding SearchTarget.Value}"
|
||||
Style="{DynamicResource StandardComboBoxStyle}" />
|
||||
</Grid>
|
||||
<DataGrid
|
||||
x:Name="DataGrid_Datas"
|
||||
|
@ -65,6 +65,12 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
//if (IsCancel)
|
||||
//ViewModel.Close();
|
||||
I18nHelper.Current.CultureNames.CollectionChanged -= CultureNames_CollectionChanged;
|
||||
foreach (var i18nData in AllI18nDatas)
|
||||
{
|
||||
foreach (var data in i18nData.Value.Datas)
|
||||
data.Group?.Clear();
|
||||
}
|
||||
try
|
||||
{
|
||||
DataContext = null;
|
||||
@ -74,6 +80,7 @@ public partial class I18nEditWindow : WindowX
|
||||
};
|
||||
InitializeI18nData(model);
|
||||
ShowI18nDatas.Value = I18nDatas;
|
||||
SearchTarget.Value = nameof(ModInfoModel.Id);
|
||||
}
|
||||
|
||||
public void InitializeI18nData(ModInfoModel model)
|
||||
@ -83,6 +90,8 @@ public partial class I18nEditWindow : WindowX
|
||||
AddCulture(culture);
|
||||
SearchTargets.Add(culture);
|
||||
}
|
||||
I18nHelper.Current.CultureNames.CollectionChanged -= CultureNames_CollectionChanged;
|
||||
I18nHelper.Current.CultureNames.CollectionChanged += CultureNames_CollectionChanged;
|
||||
LoadFood(model);
|
||||
LoadClickText(model);
|
||||
LoadLowText(model);
|
||||
@ -90,6 +99,39 @@ public partial class I18nEditWindow : WindowX
|
||||
LoadPets(model);
|
||||
}
|
||||
|
||||
private void CultureNames_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newCulture = (string)e.NewItems[0];
|
||||
AddCulture(newCulture);
|
||||
SearchTargets.Add(newCulture);
|
||||
foreach (var data in AllI18nDatas)
|
||||
data.Value.Datas.Add(new());
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldCulture = (string)e.OldItems[0];
|
||||
RemoveCulture(oldCulture);
|
||||
SearchTargets.Remove(oldCulture);
|
||||
foreach (var data in AllI18nDatas)
|
||||
{
|
||||
var value = data.Value.Datas[e.OldStartingIndex];
|
||||
value.Group?.Remove(value);
|
||||
data.Value.Datas.RemoveAt(e.OldStartingIndex);
|
||||
}
|
||||
if (SearchTarget.Value is null)
|
||||
SearchTarget.Value = nameof(ModInfoModel.Id);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var oldCulture = (string)e.OldItems[0];
|
||||
var newCulture = (string)e.NewItems[0];
|
||||
ReplaceCulture(oldCulture, newCulture);
|
||||
SearchTargets[SearchTargets.IndexOf(oldCulture)] = newCulture;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddData<T>(
|
||||
ObservableValue<string> id,
|
||||
I18nModel<T> i18nModel,
|
||||
@ -97,7 +139,7 @@ public partial class I18nEditWindow : WindowX
|
||||
)
|
||||
where T : class, new()
|
||||
{
|
||||
if (AllData.TryGetValue(id.Value, out var outData))
|
||||
if (AllI18nDatas.TryGetValue(id.Value, out var outData))
|
||||
{
|
||||
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate())
|
||||
{
|
||||
@ -117,16 +159,16 @@ public partial class I18nEditWindow : WindowX
|
||||
foreach (var culture in I18nHelper.Current.CultureNames)
|
||||
data.Datas.Add(i18nValue(i18nModel.I18nDatas[culture]));
|
||||
I18nDatas.Add(data);
|
||||
AllData.Add(id.Value, data);
|
||||
AllI18nDatas.Add(id.Value, data);
|
||||
//id.ValueChanged += IdChange;
|
||||
}
|
||||
}
|
||||
|
||||
private void IdChange(string oldValue, string newValue)
|
||||
{
|
||||
var sourceData = AllData[oldValue];
|
||||
var sourceData = AllI18nDatas[oldValue];
|
||||
sourceData.Id.Group?.Remove(sourceData.Id);
|
||||
if (AllData.TryGetValue(oldValue, out var outData))
|
||||
if (AllI18nDatas.TryGetValue(oldValue, out var outData))
|
||||
{
|
||||
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate())
|
||||
{
|
||||
@ -140,8 +182,8 @@ public partial class I18nEditWindow : WindowX
|
||||
else
|
||||
{
|
||||
sourceData.Id.Value = newValue;
|
||||
AllData.Remove(oldValue);
|
||||
AllData.Add(newValue, sourceData);
|
||||
AllI18nDatas.Remove(oldValue);
|
||||
AllI18nDatas.Add(newValue, sourceData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +194,7 @@ public partial class I18nEditWindow : WindowX
|
||||
)
|
||||
where T : class, new()
|
||||
{
|
||||
var data = AllData[id.Value];
|
||||
var data = AllI18nDatas[id.Value];
|
||||
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate())
|
||||
{
|
||||
if (data.Datas[culture.Index].Group is ObservableValueGroup<string> group)
|
||||
@ -167,7 +209,7 @@ public partial class I18nEditWindow : WindowX
|
||||
else
|
||||
{
|
||||
I18nDatas.Remove(data);
|
||||
AllData.Remove(id.Value);
|
||||
AllI18nDatas.Remove(id.Value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -180,7 +222,7 @@ public partial class I18nEditWindow : WindowX
|
||||
)
|
||||
where T : class, new()
|
||||
{
|
||||
var data = AllData[id.Value];
|
||||
var data = AllI18nDatas[id.Value];
|
||||
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate())
|
||||
{
|
||||
var oldValue = data.Datas[culture.Index];
|
||||
@ -205,22 +247,22 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newFood = (FoodModel)e.NewItems[0];
|
||||
AddData(newFood.Id, newFood, (m) => m.Name);
|
||||
AddData(newFood.DescriptionId, newFood, (m) => m.Description);
|
||||
var newModel = (FoodModel)e.NewItems[0];
|
||||
AddData(newModel.Id, newModel, (m) => m.Name);
|
||||
AddData(newModel.DescriptionId, newModel, (m) => m.Description);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldFood = (FoodModel)e.OldItems[0];
|
||||
RemoveData(oldFood.Id, oldFood, (m) => m.Name);
|
||||
RemoveData(oldFood.DescriptionId, oldFood, (m) => m.Description);
|
||||
var oldModel = (FoodModel)e.OldItems[0];
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Name);
|
||||
RemoveData(oldModel.DescriptionId, oldModel, (m) => m.Description);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var newFood = (FoodModel)e.NewItems[0];
|
||||
var oldFood = (FoodModel)e.OldItems[0];
|
||||
ReplaceData(newFood.Id, newFood, (m) => m.Name);
|
||||
ReplaceData(newFood.DescriptionId, newFood, (m) => m.Description);
|
||||
var newModel = (FoodModel)e.NewItems[0];
|
||||
var oldModel = (FoodModel)e.OldItems[0];
|
||||
ReplaceData(newModel.Id, newModel, (m) => m.Name);
|
||||
ReplaceData(newModel.DescriptionId, newModel, (m) => m.Description);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -231,6 +273,25 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
AddData(text.Id, text, (m) => m.Text);
|
||||
}
|
||||
model.ClickTexts.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newModel = (ClickTextModel)e.NewItems[0];
|
||||
AddData(newModel.Id, newModel, (m) => m.Text);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldModel = (ClickTextModel)e.OldItems[0];
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Text);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var newModel = (ClickTextModel)e.NewItems[0];
|
||||
var oldModel = (ClickTextModel)e.OldItems[0];
|
||||
ReplaceData(newModel.Id, newModel, (m) => m.Text);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void LoadLowText(ModInfoModel model)
|
||||
@ -239,6 +300,25 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
AddData(text.Id, text, (m) => m.Text);
|
||||
}
|
||||
model.LowTexts.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newModel = (LowTextModel)e.NewItems[0];
|
||||
AddData(newModel.Id, newModel, (m) => m.Text);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldModel = (LowTextModel)e.OldItems[0];
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Text);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var newModel = (LowTextModel)e.NewItems[0];
|
||||
var oldModel = (LowTextModel)e.OldItems[0];
|
||||
ReplaceData(newModel.Id, newModel, (m) => m.Text);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void LoadSelectText(ModInfoModel model)
|
||||
@ -248,6 +328,28 @@ public partial class I18nEditWindow : WindowX
|
||||
AddData(text.Id, text, (m) => m.Text);
|
||||
AddData(text.ChooseId, text, (m) => m.Choose);
|
||||
}
|
||||
model.SelectTexts.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newModel = (SelectTextModel)e.NewItems[0];
|
||||
AddData(newModel.Id, newModel, (m) => m.Text);
|
||||
AddData(newModel.ChooseId, newModel, (m) => m.Choose);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldModel = (SelectTextModel)e.OldItems[0];
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Text);
|
||||
RemoveData(oldModel.ChooseId, oldModel, (m) => m.Choose);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var newModel = (SelectTextModel)e.NewItems[0];
|
||||
var oldModel = (SelectTextModel)e.OldItems[0];
|
||||
ReplaceData(newModel.Id, newModel, (m) => m.Text);
|
||||
ReplaceData(newModel.ChooseId, newModel, (m) => m.Choose);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void LoadPets(ModInfoModel model)
|
||||
@ -259,11 +361,45 @@ public partial class I18nEditWindow : WindowX
|
||||
AddData(pet.Id, pet, (m) => m.Name);
|
||||
AddData(pet.PetNameId, pet, (m) => m.PetName);
|
||||
AddData(pet.DescriptionId, pet, (m) => m.Description);
|
||||
foreach (var work in pet.Works)
|
||||
AddData(work.Id, work, (m) => m.Name);
|
||||
}
|
||||
model.Pets.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var newModel = (PetModel)e.NewItems[0];
|
||||
AddData(newModel.Id, newModel, (m) => m.Name);
|
||||
AddData(newModel.DescriptionId, newModel, (m) => m.Description);
|
||||
foreach (var work in newModel.Works)
|
||||
AddData(work.Id, work, (m) => m.Name);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldModel = (PetModel)e.OldItems[0];
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Name);
|
||||
RemoveData(oldModel.DescriptionId, oldModel, (m) => m.Description);
|
||||
foreach (var work in oldModel.Works)
|
||||
RemoveData(work.Id, work, (m) => m.Name);
|
||||
}
|
||||
else if (e.Action is NotifyCollectionChangedAction.Replace)
|
||||
{
|
||||
var newModel = (PetModel)e.NewItems[0];
|
||||
var oldModel = (PetModel)e.OldItems[0];
|
||||
ReplaceData(newModel.Id, newModel, (m) => m.Name);
|
||||
ReplaceData(newModel.DescriptionId, newModel, (m) => m.Description);
|
||||
foreach (var work in newModel.Works)
|
||||
ReplaceData(work.Id, work, (m) => m.Name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, DataGridTextColumn> _dataGridI18nColumns = new();
|
||||
public Dictionary<string, I18nData> AllData { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// (Id, I18nData)
|
||||
/// </summary>
|
||||
public Dictionary<string, I18nData> AllI18nDatas { get; } = new();
|
||||
public ObservableCollection<I18nData> I18nDatas { get; } = new();
|
||||
public ObservableValue<ObservableCollection<I18nData>> ShowI18nDatas { get; } = new();
|
||||
|
||||
@ -312,6 +448,13 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
DataGrid_Datas.Columns.Remove(_dataGridI18nColumns[culture]);
|
||||
_dataGridI18nColumns.Remove(culture);
|
||||
for (var i = 1; i < DataGrid_Datas.Columns.Count; i++)
|
||||
{
|
||||
var column = (DataGridTextColumn)DataGrid_Datas.Columns[i];
|
||||
var dataPath = string.Format(ValueBindingFormat, i - 1);
|
||||
column.Binding = new Binding(dataPath) { Mode = BindingMode.TwoWay };
|
||||
column.SortMemberPath = dataPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -323,16 +466,11 @@ public partial class I18nEditWindow : WindowX
|
||||
{
|
||||
//if (_dataGridI18nColumns.ContainsKey(newCultureName))
|
||||
// throw new();
|
||||
var dataPath = string.Format(
|
||||
ValueBindingFormat,
|
||||
I18nHelper.Current.CultureNames.IndexOf(newCulture)
|
||||
);
|
||||
var column = _dataGridI18nColumns[oldCulture];
|
||||
column.Header = newCulture;
|
||||
column.Binding = new Binding(dataPath) { Mode = BindingMode.TwoWay };
|
||||
column.SortMemberPath = dataPath;
|
||||
_dataGridI18nColumns.Remove(oldCulture);
|
||||
_dataGridI18nColumns.Add(newCulture, column);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -88,19 +88,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -50,6 +51,7 @@ public partial class ModEditWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new ModEditWindowVM(this);
|
||||
Closing += ModEditWindow_Closing;
|
||||
Closed += ModEditWindow_Closed;
|
||||
Loaded += ModEditWindow_Loaded;
|
||||
}
|
||||
@ -66,6 +68,14 @@ public partial class ModEditWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private void ModEditWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (
|
||||
MessageBox.Show("确认退出吗?".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No
|
||||
)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private void ModEditWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
ViewModel.Close();
|
||||
|
@ -278,19 +278,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -809,19 +809,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
@ -158,19 +158,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
@ -103,7 +103,7 @@
|
||||
Command="{Binding AddImageCommand}"
|
||||
Content="{ll:Str 添加测试图片}">
|
||||
<Button.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Style BasedOn="{StaticResource ThemedButtonStyle}" TargetType="Button">
|
||||
<Setter Property="Visibility" Value="Hidden" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Image.Value}" Value="{x:Null}">
|
||||
@ -290,19 +290,19 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}"
|
||||
Style="{DynamicResource ThemedButtonStyle}" />
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}"
|
||||
Style="{DynamicResource Button_Cancel}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
|
||||
|
Loading…
Reference in New Issue
Block a user