123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Newtonsoft.Json.Linq;
- using PackingPress.Common;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace PackingPress
- {
- /// <summary>
- /// PackageDescriptionWindow.xaml 的交互逻辑
- /// </summary>
- public partial class PackageDescriptionWindow : BaseWindow
- {
- SettingJsonGet _jObjectSystemConfig = new SettingJsonGet(AppDomain.CurrentDomain.BaseDirectory + "\\DescriptionConfig.json");
- public PackageDescriptionWindow()
- {
- InitializeComponent();
- var selectValue = ((TextBlock)DescriptionType.SelectedValue).Text;
- if (!string.IsNullOrWhiteSpace(selectValue))
- {
- var jsonRoot = (JObject)_jObjectSystemConfig.GetJsonRoot();
- Chinese.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.ChineseDescription"));
- English.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.EnglishDescription"));
- Portugal.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.PortugalDescription"));
- Rumania.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.RumaniaDescription"));
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- var jsonRoot = (JObject)_jObjectSystemConfig.GetJsonRoot();
- jsonRoot.AddChild(DescriptionType.Text,JToken.Parse($"{{ \"ChineseDescription\" : \"{ HttpUtility.UrlEncode(Chinese.Text)}\", \"EnglishDescription\" : \"{HttpUtility.UrlEncode(English.Text)}\", \"PortugalDescription\" : \"{HttpUtility.UrlEncode(Portugal.Text)}\", \"RumaniaDescription\" : \"{HttpUtility.UrlEncode(Rumania.Text)}\" }}"));
- _jObjectSystemConfig.SaveJson();
- }
- private void DescriptionType_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (IsInitialized)
- {
- if (!string.IsNullOrWhiteSpace(Chinese.Text) || !string.IsNullOrWhiteSpace(English.Text) || !string.IsNullOrWhiteSpace(Portugal.Text) || !string.IsNullOrWhiteSpace(Rumania.Text))
- {
- var jsonRoot = (JObject)_jObjectSystemConfig.GetJsonRoot();
- jsonRoot.AddChild(DescriptionType.Text, JToken.Parse($"{{ \"ChineseDescription\" : \"{ HttpUtility.UrlEncode(Chinese.Text)}\", \"EnglishDescription\" : \"{HttpUtility.UrlEncode(English.Text)}\", \"PortugalDescription\" : \"{HttpUtility.UrlEncode(Portugal.Text)}\", \"RumaniaDescription\" : \"{HttpUtility.UrlEncode(Rumania.Text)}\" }}"));
- _jObjectSystemConfig.SaveJson();
- }
- var selectValue = ((TextBlock)DescriptionType.SelectedValue).Text;
- if (!string.IsNullOrWhiteSpace(selectValue))
- {
- var jsonRoot = (JObject)_jObjectSystemConfig.GetJsonRoot();
- Chinese.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.ChineseDescription"));
- English.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.EnglishDescription"));
- Portugal.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.PortugalDescription"));
- Rumania.Text = HttpUtility.UrlDecode(jsonRoot.GetJPropertyValueByPath<string>($"$.{selectValue}.RumaniaDescription"));
- }
- }
- }
- }
- }
|