Signed-off-by: lilium-saber <WR364999428@hotmail.com>
GDN
lilium-saber 1 year ago
parent 071d725814
commit 5c7f6f2c60

@ -18,7 +18,6 @@ namespace WpfApp2
TranslationApiInt trint = new translationPublic(); TranslationApiInt trint = new translationPublic();
TranslationScnToJson scnjson = new TranslationScnToJson(); TranslationScnToJson scnjson = new TranslationScnToJson();
Messiah jsonnet = new jsonNet(); Messiah jsonnet = new jsonNet();
TempResource temp = new TempResource(); TempResource temp = new TempResource();
public void InputPrivateBaidu(string name, string id, string key) public void InputPrivateBaidu(string name, string id, string key)
@ -31,6 +30,16 @@ namespace WpfApp2
trin.InPutPrivate(name, list); trin.InPutPrivate(name, list);
} }
public bool OutExistsD()
{
return trstr.GetExistsD();
}
public bool OutExistsF(string name)
{
return trstr.GetExistsF(name);
}
public List<string> OutputNameList() public List<string> OutputNameList()
{ {
List<string> list = trstr.OutputTranslationNameList(); List<string> list = trstr.OutputTranslationNameList();
@ -114,6 +123,11 @@ namespace WpfApp2
temp.TempDstSet(dst); temp.TempDstSet(dst);
} }
public void SetChoic(string choic)
{
temp.TempChoicSet(choic);
}
public string GetId() public string GetId()
{ {
return temp.TempIdGet(); return temp.TempIdGet();
@ -139,97 +153,15 @@ namespace WpfApp2
return temp.TempDstGet(); return temp.TempDstGet();
} }
public string GetChoic()
//再转为语音,在多几个接口
}
}
/*
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace OCRConsoleApp
{
class Program
{
static void Main(string[] args)
{
using IHost host = CreateHostBuilder(args).Build();
var ocrService = host.Services.GetRequiredService<IOcrService>();
// 截图并保存到本地文件
var bitmap = ocrService.CaptureScreen();
bitmap.Save("screenshot.png", ImageFormat.Png);
// 识别图片中的文字
var text = ocrService.RecognizeText(bitmap);
Console.WriteLine(text);
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{ {
logging.ClearProviders(); return temp.TempChoicGet();
logging.AddConsole();
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
services.AddSingleton<IOcrService>(new OcrService());
});
} }
public interface IOcrService
{
Bitmap CaptureScreen();
string RecognizeText(Bitmap bitmap);
}
public class OcrService : IOcrService
{
public Bitmap CaptureScreen()
{
var screenBounds = ScreenHelper.GetScreenBounds();
var bitmap = new Bitmap(screenBounds.Width, screenBounds.Height);
using (var graphics = Graphics.FromImage(bitmap))
graphics.CopyFromScreen(screenBounds.X, screenBounds.Y, 0, 0, screenBounds.Size);
return bitmap;
}
public string RecognizeText(Bitmap bitmap)
{
var ocrEngine = new IronOcr.AutoOcr();
var result = ocrEngine.Read(bitmap);
return result.Text;
} }
} }
public static class ScreenHelper
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool GetCursorPos(out Point lpPoint);
public static Rectangle GetScreenBounds()
{
GetCursorPos(out Point point);
var screenBounds = Screen.FromPoint(point).Bounds;
return screenBounds;
}
}
}
*/

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WpfApp1.transToNet namespace WpfApp2.transToNet
{ {
/* /*
internal class GrapeToJsonTrans : GrapeToJson internal class GrapeToJsonTrans : GrapeToJson

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WpfApp1.transToNet namespace WpfApp2.transToNet
{ {
interface Messiah interface Messiah
{ {
@ -14,10 +14,10 @@ namespace WpfApp1.transToNet
public abstract string RequestJsonBaiDu(string input); public abstract string RequestJsonBaiDu(string input);
//以下接口暂时废弃
public abstract string RequestJsonXunFei(string input); public abstract string RequestJsonXunFei(string input);
public abstract string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xsecret, string xkey); public abstract string RequestJsonPrivateXunFei(string input, string srcl, string dstl, string xid, string xsecret, string xkey);
public abstract string RequestJsonLanguageChangeXunFei(string input, string srcl, string dstl); public abstract string RequestJsonLanguageChangeXunFei(string input, string srcl, string dstl);
} }

@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Stripe.Terminal;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
@ -14,7 +14,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
namespace WpfApp1.transToNet namespace WpfApp2.transToNet
{ {
internal class jsonNet : Messiah internal class jsonNet : Messiah
{ {

@ -1,6 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO;
namespace WpfApp1.ScnToJson namespace WpfApp2.ScnToJson
{ {
internal class TranslationScnToJson internal class TranslationScnToJson
{ {
@ -33,7 +34,7 @@ namespace WpfApp1.ScnToJson
public void DirExsis(string id) public void DirExsis(string id)
{ {
if(Directory.Exists(Directory.GetCurrentDirectory() + "\\" + id)) if(!Directory.Exists(Directory.GetCurrentDirectory() + "\\" + id))
{ {
Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\" + id); Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\" + id);
} }

@ -0,0 +1,14 @@
<Window x:Class="WpfApp2.WindowsSEL.ErrorIn"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2.WindowsSEL"
mc:Ignorable="d"
Title="警告" Height="120" Width="150">
<Grid>
<Button Content="确定" HorizontalAlignment="Center" Margin="0,56,0,0" VerticalAlignment="Top" Click="Button_Click"/>
<TextBlock HorizontalAlignment="Center" Margin="0,14,0,0" TextWrapping="Wrap" Text="未输入Id" VerticalAlignment="Top" Height="28" Width="58"/>
</Grid>
</Window>

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApp2.WindowsSEL
{
/// <summary>
/// ErrorIn.xaml 的交互逻辑
/// </summary>
public partial class ErrorIn : Window
{
public ErrorIn()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

@ -0,0 +1,14 @@
<Window x:Class="WpfApp2.WindowsSEL.SelectPriTrueWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2.WindowsSEL"
mc:Ignorable="d"
Title="选择成功" Height="200" Width="200">
<Grid>
<Button Content="返回" HorizontalAlignment="Center" Margin="0,138,0,0" VerticalAlignment="Top" Click="Button_Click"/>
<TextBlock HorizontalAlignment="Center" Margin="0,45,0,0" TextWrapping="Wrap" Text="选择成功" VerticalAlignment="Top" Height="47" Width="88"/>
</Grid>
</Window>

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApp2.WindowsSEL
{
/// <summary>
/// SelectPriTrueWindow.xaml 的交互逻辑
/// </summary>
public partial class SelectPriTrueWindow : Window
{
string value
{ set; get; }
public SelectPriTrueWindow(string id )
{
InitializeComponent();
value = id;
DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

@ -5,8 +5,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2.view" xmlns:local="clr-namespace:WpfApp2.view"
mc:Ignorable="d" mc:Ignorable="d"
Title="TransSourceInWindow" Height="300" Width="400"> Title="私有翻译接口写入" Height="300" Width="400">
<Grid> <Grid>
<Button Content="取消" HorizontalAlignment="Left" Margin="301,226,0,0" VerticalAlignment="Top" Click="Button_Close"/>
<Button Content="保存" HorizontalAlignment="Left" Margin="58,226,0,0" VerticalAlignment="Top" Click="Button_Save"/>
<TextBox x:Name="InId" HorizontalAlignment="Left" Margin="115,47,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="214"/>
<TextBox x:Name="InKey" HorizontalAlignment="Left" Margin="115,86,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="214"/>
<TextBox x:Name="InSecret" HorizontalAlignment="Left" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="214" Margin="115,125,0,0"/>
<TextBlock HorizontalAlignment="Left" Margin="54,47,0,0" TextWrapping="Wrap" Text="ID" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="45,86,0,0" TextWrapping="Wrap" Text="KEY" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="31,125,0,0" TextWrapping="Wrap" Text="Sercet" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="72,178,0,0" TextWrapping="Wrap" Text="提示保存时ID不能留空Sercet可以留空" VerticalAlignment="Top" Width="243"/>
</Grid> </Grid>
</Window> </Window>

@ -11,6 +11,7 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using WpfApp2.WindowsSEL;
namespace WpfApp2.view namespace WpfApp2.view
{ {
@ -19,11 +20,44 @@ namespace WpfApp2.view
/// </summary> /// </summary>
public partial class TransSourceInWindow : Window public partial class TransSourceInWindow : Window
{ {
AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction a = new AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction();
public TransSourceInWindow() public TransSourceInWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Button_Close(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Button_Save(object sender, RoutedEventArgs e)
{
string id = InId.Text;
string key = InKey.Text;
string secret = InSecret.Text;
if (id == "")
{
var windows = new ErrorIn();
windows.ShowDialog();
}
else
{
List<string> li = new List<string> { };
li.Add(id);
li.Add(key);
if(secret != "")
{
li.Add(secret);
}
a.InPutPrivateA(id, li);
this.Close();
}
}
} }
} }

@ -0,0 +1,17 @@
<Window x:Class="WpfApp2.WindowsSEL.TransSourceSelectPri"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2.WindowsSEL"
mc:Ignorable="d"
Title="私有翻译接口选择" Height="500" Width="350">
<Grid>
<ComboBox x:Name="myComBox" HorizontalAlignment="Left" Margin="131,65,0,0" VerticalAlignment="Top" Width="164" SelectionChanged="myComBox_SelectionChanged" ItemsSource="{Binding mylist}"/>
<TextBlock HorizontalAlignment="Center" Margin="0,38,0,0" TextWrapping="Wrap" Text="选择以写入的私有翻译源" VerticalAlignment="Top" Height="38" Width="150"/>
<Button Content="确定更改" HorizontalAlignment="Left" Margin="59,392,0,0" VerticalAlignment="Top" Height="30" Width="62" Click="Button_True"/>
<Button Content="取消" HorizontalAlignment="Left" Margin="213,392,0,0" VerticalAlignment="Top" Height="30" Width="53" Click="Button_Close"/>
</Grid>
</Window>

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApp2.WindowsSEL
{
/// <summary>
/// TransSourceSelectPri.xaml 的交互逻辑
/// </summary>
public partial class TransSourceSelectPri : Window
{
AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction a = new AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction();
string selectvalue = null;
public List<string> mylist { get; set; }
public TransSourceSelectPri()
{
InitializeComponent();
List<string> mylist = a.OutputNameList();
myComBox.ItemsSource = mylist;
}
private void myComBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selectvalue = myComBox.SelectedItem.ToString();
}
private void Button_True(object sender, RoutedEventArgs e)
{
if(selectvalue == "")
{
this.Close();
}
else
{
List<string> li = a.OutputStr(selectvalue);
int i = 0;
string id = "";
foreach (string s in li)
{
if (i == 0)
{
id = s;
a.SetId(s);
a.SetChoic(s);
}
if(i == 1)
{
a.SetKey(s);
}
if (i == 2)
{
a.SetSecret(s);
}
i++;
}
var win = new SelectPriTrueWindow(id);
win.Show();
}
this.Close();
}
private void Button_Close(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

@ -5,8 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2.view" xmlns:local="clr-namespace:WpfApp2.view"
mc:Ignorable="d" mc:Ignorable="d"
Title="TranslationSourceSelect" Height="300" Width="400"> Title="公共翻译接口选择" Height="300" Width="200">
<Grid Margin="0,0,400,91"> <Grid Margin="0,0,200,-5">
<Button Content="选择百度翻译1" Margin="53,61,-142,0" VerticalAlignment="Top" Click="Button1_Click"/>
<Button Content="选择百度翻译2" Margin="53,97,-144,0" VerticalAlignment="Top" Click="Button2_Click"/>
<Button Content="选择讯飞翻译" Margin="53,22,-142,0" VerticalAlignment="Top" Click="ButtonXunfei_Click"/>
<Button Content="取消选择" Margin="53,165,-142,0" VerticalAlignment="Top" Click="ButtonOff_Click"/>
</Grid> </Grid>
</Window> </Window>

@ -20,11 +20,79 @@ namespace WpfApp2.view
/// </summary> /// </summary>
public partial class TranslationSourceSelect : Window public partial class TranslationSourceSelect : Window
{ {
AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction a = new AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction();
public TranslationSourceSelect() public TranslationSourceSelect()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Button1_Click(object sender, RoutedEventArgs e)
{
a.SetChoic("baidu");
int i = 0;
List<string> list = a.OutputChoicPublic(1);
foreach(string s in list)
{
if(i == 0)
{
a.SetId(s);
}else if(i == 1)
{
a.SetKey(s);
}
i++;
}
this.Close();
}
private void Button2_Click(object sender, RoutedEventArgs e)
{
a.SetChoic("baidu");
int i = 0;
List<string> list = a.OutputChoicPublic(2);
foreach (string s in list)
{
if (i == 0)
{
a.SetId(s);
}
else if (i == 1)
{
a.SetKey(s);
}
i++;
}
this.Close();
}
private void ButtonXunfei_Click(object sender, RoutedEventArgs e)
{
a.SetChoic("xunfei");
int i = 0;
List<string> list = a.OutputChoicPublic(0);
foreach (string s in list)
{
if (i == 0)
{
a.SetId(s);
}
else if (i == 1)
{
a.SetKey(s);
}else if (i == 2)
{
a.SetSecret(s);
}
i++;
}
this.Close();
}
private void ButtonOff_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
} }
} }

@ -1,6 +1,9 @@
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http.Json;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,60 +11,118 @@ namespace WpfApp2
{ {
class TempResource class TempResource
{ {
private string id = "20230923001827495";//all string jsonpath = Directory.GetCurrentDirectory() + "\\TempS.json";
private string key = "yjvMNY33Qc1TYSBjTQYQ";//百度、讯飞
private string secret = "M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk";//讯飞 class MyData
private string srcLan = "jp"; {
private string dstLan = "zh"; public string ID { get; set; }
public string KEY { get; set; }
public string SECRET { get; set; }
public string SRCLAN { get; set; }
public string DSTLAN { get; set; }
public string NOW { get; set; }
}
public TempResource() //用于创建
{
if(Directory.Exists(jsonpath))
{
List<MyData> js = JsonConvert.DeserializeObject<List<MyData>>(jsonpath);
js.Add(new MyData() { ID = "20230923001827495", KEY = "yjvMNY33Qc1TYSBjTQYQ", SECRET = "M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk", SRCLAN = "jp", DSTLAN = "zh", NOW = "baidu", } );
string jjson = JsonConvert.SerializeObject(js);
File.WriteAllText(jsonpath, jjson);
}
}
private MyData GetJsonStream()
{
string jsonF = File.ReadAllText(jsonpath);
MyData da = JsonConvert.DeserializeObject<MyData>(jsonF);
return da;
}
private void SetJsonStream(MyData da)
{
string js = JsonConvert.SerializeObject(da);
File.WriteAllText(jsonpath, js);
}
public void TempIdSet(string id) public void TempIdSet(string id)
{ {
this.id = id; MyData da = GetJsonStream();
da.ID = id;
SetJsonStream(da);
} }
public void TempKeySet(string key) public void TempKeySet(string key)
{ {
this.key = key; MyData myData = GetJsonStream();
myData.KEY = key;
SetJsonStream(myData);
} }
public void TempSecretSet(string secret) public void TempSecretSet(string secret)
{ {
this.secret = secret; MyData myData1 = GetJsonStream();
myData1.SECRET = secret;
SetJsonStream(myData1);
} }
public void TempSrcSet(string src) public void TempSrcSet(string src)
{ {
this.srcLan = src; MyData myData = GetJsonStream();
myData.SRCLAN = src;
SetJsonStream(myData);
} }
public void TempDstSet(string dst) public void TempDstSet(string dst)
{ {
this.dstLan = dst; MyData mydata = GetJsonStream();
mydata.DSTLAN = dst;
SetJsonStream(mydata);
}
public void TempChoicSet(string choic)
{
MyData my = GetJsonStream();
my.NOW = choic;
SetJsonStream(my);
} }
public string TempIdGet() public string TempIdGet()
{ {
return id; MyData my = GetJsonStream();
return my.ID;
} }
public string TempKeyGet() public string TempKeyGet()
{ {
return key; MyData my1 = GetJsonStream();
return my1.KEY;
} }
public string TempSecretGet() public string TempSecretGet()
{ {
return secret; MyData my = GetJsonStream();
return my.SECRET;
} }
public string TempSrcGet() public string TempSrcGet()
{ {
return srcLan; MyData my = GetJsonStream();
return my.SECRET;
} }
public string TempDstGet() public string TempDstGet()
{ {
return dstLan; MyData tmp = GetJsonStream();
return tmp.DSTLAN;
}
public string TempChoicGet()
{
MyData my2 = GetJsonStream();
return my2.NOW;
} }
} }
} }

@ -11,8 +11,12 @@ namespace WpfApp2.translationKey
{ {
public abstract List<string> OutputTranslationS(string id); public abstract List<string> OutputTranslationS(string id);
public abstract List<string> OutputTranslationNameList(); public abstract List<string> OutputTranslationNameList();
public abstract bool GetExistsD();
public abstract bool GetExistsF(string name);
} }
interface TranslationApiInt interface TranslationApiInt

@ -24,16 +24,14 @@ namespace WpfApp2.translationKey
string temppathTemp = pathTemp + "\\" + name + ".txt"; string temppathTemp = pathTemp + "\\" + name + ".txt";
StreamWriter sw = new StreamWriter(temppathTemp); StreamWriter sw = new StreamWriter(temppathTemp);
StreamWriter sw2 = new StreamWriter(txtPath);
foreach (string s in list) foreach (string s in list)
{ {
sw.WriteLine(s); sw.WriteLine(s);
} }
name = "\n" + name;
System.IO.File.AppendAllText(txtPath, name);
sw2.WriteLine(name);
sw.Close(); sw.Close();
sw2.Close();
} }
public void InputBaiduPrivate(string name, string id, string key)//该函数仅百度支持 public void InputBaiduPrivate(string name, string id, string key)//该函数仅百度支持

@ -12,6 +12,16 @@ namespace WpfApp2.translationKey
private static string path = Directory.GetCurrentDirectory() + "\\translationResource"; private static string path = Directory.GetCurrentDirectory() + "\\translationResource";
private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt"; private static string txtPath = Directory.GetCurrentDirectory() + "\\translationResource\\ListPrivate.txt";
public bool GetExistsD()
{
return Directory.Exists(path);
}
public bool GetExistsF(string name)
{
return Directory.Exists(txtPath + "\\" + name + ".txt");
}
private String getTranslationPrivateApi(StreamReader sr) private String getTranslationPrivateApi(StreamReader sr)
{ {
String temp = sr.ReadLine(); String temp = sr.ReadLine();
@ -66,10 +76,12 @@ namespace WpfApp2.translationKey
StreamReader sr = new StreamReader(temppath); StreamReader sr = new StreamReader(temppath);
string temp2 = sr.ReadLine();
while(temp2 != null && temp2 != "")
temp.Add(this.getTranslationPrivateApi(sr)); {
temp.Add(this.getTranslationPrivateKey(sr)); temp.Add(temp2);
temp2 = sr.ReadLine();
}
sr.Close(); sr.Close();
return temp; return temp;
@ -82,20 +94,19 @@ namespace WpfApp2.translationKey
if(Directory.Exists(temptxtpath)) if(Directory.Exists(temptxtpath))
{ {
temp.Add("ERROR"); temp.Add("ERROR1");
return temp; return temp;
} }
StreamReader sr = new StreamReader(temptxtpath); StreamReader sr = new StreamReader(temptxtpath);
string temp2 = sr.ReadLine(); string temp2 = sr.ReadLine();
if (temp2 == null) if (temp2 == null)
{ {
temp.Add("ERROR"); temp.Add("ERROR2");
} }
else else
{ {
while (temp2 != null) while (temp2 != null && temp2 != "")
{ {
temp.Add(temp2); temp.Add(temp2);
temp2 = sr.ReadLine(); temp2 = sr.ReadLine();

@ -17,8 +17,8 @@ namespace WpfApp2.translationKey
case 0://讯飞 case 0://讯飞
{ {
temp.Add("1299c840");//id temp.Add("1299c840");//id
temp.Add("M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk");//APISecret
temp.Add("828cb2dc915d28464a904bda5d7b01b3");//APIKey temp.Add("828cb2dc915d28464a904bda5d7b01b3");//APIKey
temp.Add("M2Q4YzkzZTIwZjNkMGE2ZjkwZWMxNzZk");//APISecret
break; break;
} }
case 1://百度 case 1://百度

@ -0,0 +1,36 @@
主窗口:
<MenuItem
Header=" 设置"
Height="20"
Width="50"
Name="设置"
BorderBrush="Gray">
<MenuItem Header="选择公共翻译接口" Click="TransSourceSelectWnd_loaded"/>
<MenuItem Header="选择私有翻译接口" Click="TransSourceSelectPri"/>
<MenuItem Header="写入私有翻译接口" Click="TransSourceInWindow"/>
</MenuItem>
private void TransSourceSelectWnd_loaded(object sender, RoutedEventArgs e)
{
var window = new TranslationSourceSelect();
window.ShowDialog();
}
private void PrograssSelectWnd_loaded(object sender, RoutedEventArgs e)
{
var window = new ProgressSelect();
window.ShowDialog();
}
private void TransSourceInWindow(object sender, RoutedEventArgs e)
{
var window = new TransSourceInWindow();
window.ShowDialog();
}
private void TransSourceSelectPri(object sender, RoutedEventArgs e)
{
var windows = new TransSourceSelectPri();
windows.ShowDialog();
}
Loading…
Cancel
Save