private void All_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { if (Convert.ToInt32(TbxPage.Text) > (int)list.Count / count) { TbxPage.Text = ((int)list.Count / count).ToString(); AppInfoHelper.SetCurrentIndex(CbxWordbook.Text, ((Convert.ToInt32(TbxPage.Text) - 1) * count + 1).ToString()); ShowWord(); } else if (Convert.ToInt32(TbxPage.Text) <= 0) { TbxPage.Text = 1.ToString(); AppInfoHelper.SetCurrentIndex(CbxWordbook.Text, ((Convert.ToInt32(TbxPage.Text) - 1) * count + 1).ToString()); ShowWord(); } else { AppInfoHelper.SetCurrentIndex(CbxWordbook.Text, ((Convert.ToInt32(TbxPage.Text) - 1) * count + 1).ToString()); ShowWord(); } } catch { } } }
private void BtnSearch_Click(object sender, EventArgs e) { Tbx.Clear(); LbxWord.Items.Clear(); OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = AppInfoHelper.GetArticleFolder(); dialog.Multiselect = false; //该值确定是否可以选择多个文件 dialog.Title = "请选择文件夹"; dialog.Filter = "所有文件(*.xml)|*.xml"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { articlePath = dialog.FileName; TbxArticle.Text = dialog.SafeFileName.Replace(".xml", ""); } words = new HashSet <string>(); dict = CbxDictionary.Text; wordList = new List <string>(); transList = new List <string>(); phoneticList = new List <string>(); if (File.Exists(articlePath)) { MPB.Value = 0; MPB.Show(); OpenArticle(); t = new Thread(BackgroundProcess); t.IsBackground = true; t.Start(); } }
private void DisorderDict() { string srcpath = AppInfoHelper.GetDictionaryFolder() + "\\" + CbxDictSelect.Text + ".xml"; string destpath = AppInfoHelper.GetDictionaryFolder() + "\\" + CbxDictSelect.Text + "乱序版.xml"; //XmlHelper.CreateXml(destpath, "wordbook"); List <string> items = XmlHelper.GetInnerXml(srcpath, "wordbook", "item"); Random r = new Random(); List <string> newlist = new List <string>(); foreach (string s in items) { newlist.Insert(r.Next(newlist.Count), "<item>" + s + "</item>"); } newlist.Insert(0, "<wordbook>"); newlist.Add("</wordbook>"); if (File.Exists(destpath)) { File.Delete(destpath); } //FileStream fs = new FileStream(destpath, FileMode.Create); StreamWriter sw = new StreamWriter(destpath, true, Encoding.UTF8); foreach (string s in newlist) { sw.Write(s + "\r\n"); } sw.Close(); }
public GenerateArticle() { InitializeComponent(); TsbTbx.Text = AppInfoHelper.GetArticleFolder(); TsbFileName.Text = title; modelpath = Application.StartupPath + "/Model.xml"; }
private void TbxReciteNumber_TextChanged(object sender, EventArgs e) { Regex reg = new Regex("^[0-9]{1,2}"); if (reg.IsMatch(TbxReciteNumber.Text)) { if (Convert.ToInt32(TbxReciteNumber.Text) > 10) { LblTip.Text = "请输入1-10,超过最大值"; LblTip.Show(); } else if (Convert.ToInt32(TbxReciteNumber.Text) < 1) { LblTip.Text = ("请输入1-10,低于最小值"); LblTip.Show(); } else { LblTip.Hide(); AppInfoHelper.SetReciteNumber(TbxReciteNumber.Text); } } else { LblTip.Text = ("请输入1-10"); LblTip.Show(); } }
private void ClbWordbookSetting_SelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < wordbookList.Count; i++) { AppInfoHelper.AlterWordbookList(wordbookList[i], AppInfoHelper.Dict.iswordbook, Convert.ToString(ClbWordbookSetting.GetItemChecked(i))); } }
private void AddDict(string dictPath) { List <string> l = DictHelper.ReadDictList(); if (File.Exists(dictPath)) { string dictNewPath = AppInfoHelper.GetDictionaryFolder() + "\\" + Path.GetFileName(dictPath); if (l.Contains(Path.GetFileNameWithoutExtension(dictPath))) { DialogResult dr = MessageBox.Show("字典" + Path.GetFileNameWithoutExtension(dictPath) + "已经存在,是否要替换", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { if (dictNewPath != dictPath) { File.Delete(dictNewPath); File.Copy(dictPath, dictNewPath); } } } else { File.Copy(dictPath, dictNewPath); } } }
/// <summary> /// 管道配置 /// </summary> /// <param name="app"></param> /// <param name="env"></param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseOpenApi(); // NSwag app.UseSwaggerUi3(c => { c.DocExpansion = "list"; c.DefaultModelExpandDepth = 3; c.ValidateSpecification = true; }); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); AppInfoHelper.WriteAndLogConfiguration(app.ApplicationServices.GetService <ILogger <Startup> >(), env, Configuration); }
private void AddDict_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "请选择字典"; dialog.Multiselect = true; dialog.Filter = "所有文件(*.xml)|*.xml"; if (dialog.ShowDialog() == DialogResult.OK) { if (!File.Exists(dialog.FileName)) { MessageBox.Show(this, "找不到文件", "提示"); } else if (File.Exists(AppInfoHelper.GetDictionaryFolder() + "/" + Path.GetFileName(dialog.FileName))) { MessageBox.Show(this, "文件已存在", "提示"); } else { File.Copy(dialog.FileName, AppInfoHelper.GetDictionaryFolder() + "/" + Path.GetFileName(dialog.FileName)); List <string> list = new List <string>(); list.Add(dialog.FileName); AppInfoHelper.UpdateDictList(); } } InitialApp(); }
private void AddWordList(int num) { int count = words.Count; int i = 0; foreach (var str in words) { if (count != 0) { num = 1 + i * 100 / count; } else { num = 0; } string trans = AddTrans(str); if (trans.Trim() != "") { if (WordDataHelper.GetProgress(str) < AppInfoHelper.GetReciteNumber()) { wordList.Add(str); transList.Add(trans); } } Thread a = new Thread(AnotherProcess); a.IsBackground = true; a.Start(num); i++; } }
/// <summary> /// Default constructor is protected so callers must use one with a parent. /// </summary> protected AboutBox() { InitializeComponent(); // Add product information description.Text += String.Format("Assembly Version = {0}\n", AppInfoHelper.getAssemblyVersion()); description.Text += String.Format("Deployment Version = {0}\n", AppInfoHelper.getDeploymentVersion()); }
public DictSettings() { InitializeComponent(); AppInfoHelper.UpdateWordbookList(); AppInfoHelper.UpdateDictList(); dictList = AppInfoHelper.SelectDictList(); wordbookList = AppInfoHelper.SelectWordbookList(); InitialApp(); }
public WordbookSettings() { InitializeComponent(); TbxReciteNumber.Text = AppInfoHelper.GetReciteNumber().ToString(); recitenumber = TbxReciteNumber.Text; CTBArticle.Label = "文章路径"; CTBArticle.DispalyOpenButton = true; CTBArticle.Value = AppInfoHelper.GetArticleFolder(); CTBArticle.Button = "浏览"; CTBArticle.OnOpen += new EventHandler(ReviseArticlePath); }
private void DefaultDict(object sender, EventArgs e) { DefaultSet d = new DefaultSet("设置默认词典"); d.Text = "设置默认词典"; d.ShowDialog(); if (d.control == true) { CTBDefaultDict.Value = AppInfoHelper.GetDefaultDict(); } }
public void GenerateAppId() { var appId = AppInfoHelper.GenerateAppId(AppInfoHelper.SystemDefaultTenantId, AppType.System, AppClientType.Server); var appinfo = new AppIdentity() { app_id = appId }; AppInfoHelper.FormatAppIdInfo(appinfo); Assert.IsTrue(appinfo.app_type == AppType.System); }
static void Main(string[] args) { //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de"); //WordDataHelper.UpdateDict(); AppInfoHelper.UpdateDictList(); AppInfoHelper.UpdateWordbookList(); User u = new User(); //Settings u = new Settings(); u.ShowDialog(); }
private void ShowWord() { PnlWord.Controls.Clear(); int y = (int)((Height - 95) / 25); int x = (int)((Width - 100) / 350); count = x * y; Label[] l = new Label[count]; if (list.Count == 0) { for (int i = 0; i < count; i++) { WordStructure w = new WordStructure(); w.str = ""; list.Add(w); } } int current = 0; try { int currentpage = (int)(AppInfoHelper.GetCurrentIndex(CbxWordbook.Text) / count) + 1; current = (currentpage - 1) * count; TbxPage.Text = currentpage.ToString(); } catch { } try { for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { int k = i * y + j; l[k] = new Label(); l[k].Name = "label" + k.ToString(); if (current + k < list.Count) { l[k].Text = list[current + k].str; } else { l[k].Text = ""; } Point p = WordPoint(i, j, x); AddLable(l[k], p, l[k].Text, list[current + k].progress); } } } catch { MessageBox.Show("文件已损坏!"); } }
private void GenerateWordbooklist() { wordbooklist = new List <string>(); WordDataHelper.WordbookListInFolder(AppInfoHelper.GetMyWordBookFolder(), wordbooklist); List <string> dictlist = new List <string>(); dictlist = DictHelper.ReadDictList(); for (int i = 0; i < dictlist.Count; i++) { wordbooklist.Add(dictlist[i]); } }
private void TbxPageInit() { list = new List <WordStructure>(); int page = 0; int currentCount = AppInfoHelper.GetCurrentIndex(CbxWordbook.Text); if (count != 0) { page = (int)(currentCount / count) + 1; } TbxPage.Text = page.ToString(); }
private void LblLastPage_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (Convert.ToInt32(TbxPage.Text) > 1) { TbxPage.Text = (Convert.ToInt32(TbxPage.Text) - 1).ToString(); AppInfoHelper.SetCurrentIndex(CbxWordbook.Text, ((Convert.ToInt32(TbxPage.Text) - 1) * count + 1).ToString()); ShowWord(); } } }
/// <summary> /// Сканированией пропуска и получение данных /// </summary> public override void OnNavigatedTo(Dictionary <string, object> parameters, NavigationMode mode) { CoreWindow.GetForCurrentThread().KeyDown += ScannerViewModel_KeyDown; Settings.IsAuthorized = false; Settings.CurrentSessionBadgeId = null; LogOutService.Stop(); AppVersion = AppInfoHelper.GetAppVersionString(); base.OnNavigatedTo(parameters, mode); }
protected void Page_Load(object sender, EventArgs e) { // Add product information labelAppInfo.Text = "<b>Application Information:</b> <br>"; labelAppInfo.Text += String.Format("Assembly Version = {0}<br>", AppInfoHelper.getAssemblyVersion()); labelAppInfo.Text += String.Format("Deployment Version = {0}<br>", AppInfoHelper.getDeploymentVersion()); // Add assembly information labelAppInfo.Text += "<b>Assembly Information:</b> <br>"; labelAppInfo.Text += String.Format("Full Name = {0}<br>", System.Reflection.Assembly.GetExecutingAssembly().FullName); labelAppInfo.Text += String.Format("Image Runtime Version = {0}<br>", System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion); labelAppInfo.Text += String.Format("Location = {0}<br>", System.Reflection.Assembly.GetExecutingAssembly().Location); }
private void InitialApp() { DictionaryFile = AppInfoHelper.GetDictionaryFolder(); if (DictionaryFile == "") { } else { if (!Directory.Exists(DictionaryFile)) { try { Directory.CreateDirectory(DictionaryFile); } catch { } } else { dict = DictHelper.ReadDictList(); AppInfoHelper.UpdateDictList(); ClbDictSetting.Items.Clear(); ClbWordbookSetting.Items.Clear(); for (int i = 0; i < dictList.Count; i++) { ClbDictSetting.Items.Add(dictList[i]); if (AppInfoHelper.GetDictList().Contains(dictList[i])) { ClbDictSetting.SetItemChecked(i, true); } else { ClbDictSetting.SetItemChecked(i, false); } } for (int i = 0; i < wordbookList.Count; i++) { ClbWordbookSetting.Items.Add(wordbookList[i]); if (AppInfoHelper.GetDisorderList().Contains(wordbookList[i])) { ClbWordbookSetting.SetItemChecked(i, true); } else { ClbWordbookSetting.SetItemChecked(i, false); } } CTBDict.Value = DictionaryFile; } } }
private Color SetColor(string word) { int progress = WordDataHelper.GetProgress(word); Color color = new Color(); if (progress == AppInfoHelper.GetReciteNumber()) { color = Color.FromArgb(34, 177, 76); } if (progress < 0) { color = Color.Red; } return(color); }
public static Resp CheckAppSign(AppIdentity appInfo, HttpContext context) { var authTicketStr = context.Request.Headers[ServerSignModeHeaderName]; appInfo.FromTicket(authTicketStr); if (!AppInfoHelper.FormatAppIdInfo(appInfo)) { return(new Resp(RespTypes.OperateFailed, "未知应用来源!")); } var key = ConfigHelper.GetSection("KnockAppSecrets:" + appInfo.app_id)?.Value; const int expireSecs = 60 * 60 * 2; return(appInfo.CheckSign(key, expireSecs)); }
private void AddWordList(bool model) { List <string> dict = new List <string>(); WordDataHelper.WordbookListInFolder(AppInfoHelper.GetRecord(), dict); if (dict.Contains(CbxWordbook.Text)) { } else { if (model) { l.Clear(); } l = WordDataHelper.GenerateWordbook(String.Format("{0}\\{1}.xml", AppInfoHelper.GetDictionaryFolder(), CbxWordbook.Text)); } }
private void SetList() { switch (text) { case "设置默认单词书": list = AppInfoHelper.GetDisorderList(); selected = AppInfoHelper.GetDefaultWordbook(); break; case "设置默认词典": list = AppInfoHelper.GetDictList(); selected = AppInfoHelper.GetDefaultDict(); break; default: break; } }
// This method gets called by the runtime. Use this method to add services to the container. /// <summary> /// 依赖注入 /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetConnectionString(Configuration.GetSection("db:ConnectionName")?.Value ?? "DefaultConnection"); string assemblyFullName = this.GetType().Assembly.FullName; services.AddDbContext <MyDbContext>(options => options.UseSqlServer(connectionString, b => b.MigrationsAssembly(assemblyFullName))); AppInfoHelper.WriteConnectionString(connectionString, Configuration); services.AddOpenApiDocument(c => { c.Title = "Users"; c.Version = "v1"; c.Description = "Users sample open api."; c.DocumentName = "UsersOpenApi"; }); services.AddControllers(); }
private void BtnOK_Click(object sender, EventArgs e) { switch (text) { case "设置默认单词书": AppInfoHelper.SetDefaultWordbook(Lbx.SelectedItem.ToString()); break; case "设置默认词典": AppInfoHelper.SetDefaultDict(Lbx.SelectedItem.ToString()); break; default: break; } control = true; this.Hide(); }
private static async Task <Resp> CheckAppAuthIdentity(HttpContext context, IAppAuthProvider provider, AppIdentity appInfo) { var secretKeyRes = await provider.IntialAuthAppConfig(context, appInfo); if (!secretKeyRes.IsSuccess()) { return(secretKeyRes); } const int expireSecs = 60 * 60 * 2; if (!appInfo.CheckSign(secretKeyRes.data.AppSecret, expireSecs).IsSuccess() || !AppInfoHelper.FormatAppIdInfo(appInfo)) { return(new Resp(RespTypes.SignError, "签名错误!")); } return(secretKeyRes); }