private void menuImportRulesFromFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog { Multiselect = false, Filter = "Rules|*.json|All|*.*" }; if (fileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = fileDialog.FileName; if (Utils.IsNullOrEmpty(fileName)) { return; } string result = Utils.LoadResource(fileName); if (Utils.IsNullOrEmpty(result)) { return; } if (ConfigHandler.AddBatchRoutingRules(ref config, result) == 0) { RefreshRoutingsView(); UI.Show(UIRes.I18N("OperationSuccess")); } }
private int AddBatchRoutingRules(ref RoutingItem routingItem, string clipboardData) { bool blReplace = false; if (UI.ShowYesNo(ResUI.AddBatchRoutingRulesYesNo) == DialogResult.No) { blReplace = true; } return(ConfigHandler.AddBatchRoutingRules(ref routingItem, clipboardData, blReplace)); }
private void menuImportRulesFromClipboard_Click(object sender, EventArgs e) { string clipboardData = Utils.GetClipboardData(); if (ConfigHandler.AddBatchRoutingRules(ref config, clipboardData) == 0) { RefreshRoutingsView(); UI.Show(UIRes.I18N("OperationSuccess")); } }
private void menuImportRulesFromPreset_Click(object sender, EventArgs e) { var rules = Utils.GetEmbedText(Global.CustomRoutingFileName + "rules"); if (ConfigHandler.AddBatchRoutingRules(ref config, rules) == 0) { RefreshRoutingsView(); UI.Show(UIRes.I18N("OperationSuccess")); } }
private void menuImportRulesFromUrl_Click(object sender, EventArgs e) { var url = txtUrl.Text.Trim(); if (Utils.IsNullOrEmpty(url)) { UI.Show(UIRes.I18N("MsgNeedUrl")); return; } DownloadHandle downloadHandle = new DownloadHandle(); string clipboardData = downloadHandle.WebDownloadStringSync(url); if (ConfigHandler.AddBatchRoutingRules(ref routingItem, clipboardData) == 0) { RefreshRoutingsView(); UI.Show(UIRes.I18N("OperationSuccess")); } }
private void menuImportRulesFromUrl_Click(object sender, EventArgs e) { var fm = new RoutingSubSettingForm(); if (fm.ShowDialog() != DialogResult.OK) { return; } var url = fm.Url; DownloadHandle downloadHandle = new DownloadHandle(); string clipboardData = downloadHandle.WebDownloadStringSync(url); if (ConfigHandler.AddBatchRoutingRules(ref config, clipboardData) == 0) { RefreshRoutingsView(); UI.Show(UIRes.I18N("OperationSuccess")); } }