private void btnOK_Click(object sender, EventArgs e) { string address = txtAddress.Text; string port = txtPort.Text; string id = txtId.Text; string alterId = txtAlterId.Text; string security = cmbSecurity.Text; string network = cmbNetwork.Text; string remarks = txtRemarks.Text; string headerType = cmbHeaderType.Text; string requestHost = txtRequestHost.Text; string path = txtPath.Text; string streamSecurity = cmbStreamSecurity.Text; if (Utils.IsNullOrEmpty(address)) { UI.Show("请填写地址"); return; } if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port)) { UI.Show("请填写正确格式端口"); return; } if (Utils.IsNullOrEmpty(id)) { UI.Show("请填写用户ID"); return; } if (Utils.IsNullOrEmpty(alterId) || !Utils.IsNumberic(alterId)) { UI.Show("请填写正确格式额外ID"); return; } VmessItem vmessItem = new VmessItem(); vmessItem.address = address; vmessItem.port = Utils.ToInt(port); vmessItem.id = id; vmessItem.alterId = Utils.ToInt(alterId); vmessItem.security = security; vmessItem.network = network; vmessItem.remarks = remarks; vmessItem.headerType = headerType; vmessItem.requestHost = requestHost.Replace(" ", ""); vmessItem.path = path.Replace(" ", ""); vmessItem.streamSecurity = streamSecurity; if (ConfigHandler.AddServer(ref config, vmessItem, EditIndex) == 0) { this.DialogResult = DialogResult.OK; } else { UI.Show("操作失败,请检查重试"); } }
private void btnOK_Click(object sender, EventArgs e) { string address = txtAddress.Text; string port = txtPort.Text; string id = txtId.Text; string alterId = txtAlterId.Text; string security = cmbSecurity.Text; string network = cmbNetwork.Text; string remarks = txtRemarks.Text; string headerType = cmbHeaderType.Text; string requestHost = txtRequestHost.Text; string path = txtPath.Text; string streamSecurity = cmbStreamSecurity.Text; string allowInsecure = cmbAllowInsecure.Text; if (Utils.IsNullOrEmpty(address)) { UI.Show(UIRes.I18N("FillServerAddress")); return; } if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port)) { UI.Show(UIRes.I18N("FillCorrectServerPort")); return; } if (Utils.IsNullOrEmpty(id)) { UI.Show(UIRes.I18N("FillUUID")); return; } if (Utils.IsNullOrEmpty(alterId) || !Utils.IsNumberic(alterId)) { UI.Show(UIRes.I18N("FillCorrectAlterId")); return; } vmessItem.address = address; vmessItem.port = Utils.ToInt(port); vmessItem.id = id; vmessItem.alterId = Utils.ToInt(alterId); vmessItem.security = security; vmessItem.network = network; vmessItem.remarks = remarks; vmessItem.headerType = headerType; vmessItem.requestHost = requestHost.Replace(" ", ""); vmessItem.path = path.Replace(" ", ""); vmessItem.streamSecurity = streamSecurity; vmessItem.allowInsecure = allowInsecure; if (ConfigHandler.AddServer(ref config, vmessItem, EditIndex) == 0) { this.DialogResult = DialogResult.OK; } else { UI.Show(UIRes.I18N("OperationFailed")); } }
private void btnOK_Click(object sender, EventArgs e) { string address = txtAddress.Text; string port = txtPort.Text; string id = txtId.Text; string alterId = txtAlterId.Text; string security = cmbSecurity.Text; string remarks = txtRemarks.Text; if (Utils.IsNullOrEmpty(address)) { UI.Show(UIRes.I18N("FillServerAddress")); return; } if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port)) { UI.Show(UIRes.I18N("FillCorrectServerPort")); return; } if (Utils.IsNullOrEmpty(id)) { UI.Show(UIRes.I18N("FillUUID")); return; } if (Utils.IsNullOrEmpty(alterId) || !Utils.IsNumberic(alterId)) { UI.Show(UIRes.I18N("FillCorrectAlterId")); return; } transportControl.EndBindingServer(); vmessItem.address = address; vmessItem.port = Utils.ToInt(port); vmessItem.id = id; vmessItem.alterId = Utils.ToInt(alterId); vmessItem.security = security; vmessItem.remarks = remarks; if (ConfigHandler.AddServer(ref config, vmessItem, EditIndex) == 0) { this.DialogResult = DialogResult.OK; } else { UI.ShowWarning(UIRes.I18N("OperationFailed")); } }
private void menuClipboardImportVmess_Click(object sender, EventArgs e) { VmessItem vmessItem = V2rayConfigHandler.ImportFromClipboardConfig(out string msg); if (vmessItem != null && ConfigHandler.AddServer(ref config, vmessItem, -1) == 0) { //刷新 RefreshServers(); LoadV2ray(); ShowForm(); } else { UI.Show("操作失败,请检查重试"); } }
private void menuAddServers_Click(object sender, EventArgs e) { string clipboardData = Utils.GetClipboardData(); if (Utils.IsNullOrEmpty(clipboardData)) { return; } if (clipboardData.IndexOf("vmess") == clipboardData.LastIndexOf("vmess")) { clipboardData = clipboardData.Replace("\r\n", "").Replace("\n", ""); } int countServers = 0; string[] arrData = clipboardData.Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (string str in arrData) { string msg; VmessItem vmessItem = V2rayConfigHandler.ImportFromClipboardConfig(str, out msg); if (vmessItem == null) { continue; } if (vmessItem.configType == (int)EConfigType.Vmess) { if (ConfigHandler.AddServer(ref config, vmessItem, -1) == 0) { countServers++; } } else if (vmessItem.configType == (int)EConfigType.Shadowsocks) { if (ConfigHandler.AddShadowsocksServer(ref config, vmessItem, -1) == 0) { countServers++; } } } if (countServers > 0) { RefreshServers(); UI.Show(string.Format("从剪贴板导入批量URL成功")); } }
private void menuClipboardImportVmess_Click(object sender, EventArgs e) { List <VmessItem> vmessItems = V2rayConfigHandler.ImportFromClipboardConfig(out string msg); if (vmessItems != null && vmessItems.Count > 0) { foreach (VmessItem vmessItem in vmessItems) { if (ConfigHandler.AddServer(ref config, vmessItem, -1) != 0) { break; } } //刷新 RefreshServers(); LoadV2ray(); ShowForm(); } else { UI.Show("操作失败,请检查重试"); } }
private void btnOK_Click(object sender, EventArgs e) { string remarks = txtRemarks.Text; string address = txtAddress.Text; string port = txtPort.Text; string id = string.Empty; string alterId = string.Empty; string security = string.Empty; string flow = string.Empty; switch (eConfigType) { case EConfigType.VMess: id = txtId.Text; alterId = txtAlterId.Text; security = cmbSecurity.Text; break; case EConfigType.Shadowsocks: id = txtId3.Text; security = cmbSecurity3.Text; break; case EConfigType.Socks: id = txtId4.Text; security = txtSecurity4.Text; break; case EConfigType.VLESS: id = txtId5.Text; flow = cmbFlow5.Text; security = cmbSecurity5.Text; break; case EConfigType.Trojan: id = txtId6.Text; flow = cmbFlow6.Text; break; } if (Utils.IsNullOrEmpty(address)) { UI.Show(ResUI.FillServerAddress); return; } if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port)) { UI.Show(ResUI.FillCorrectServerPort); return; } if (eConfigType == EConfigType.Shadowsocks) { if (Utils.IsNullOrEmpty(id)) { UI.Show(ResUI.FillPassword); return; } if (Utils.IsNullOrEmpty(security)) { UI.Show(ResUI.PleaseSelectEncryption); return; } } if (eConfigType != EConfigType.Socks) { if (Utils.IsNullOrEmpty(id)) { UI.Show(ResUI.FillUUID); return; } } transportControl.EndBindingServer(); vmessItem.remarks = remarks; vmessItem.address = address; vmessItem.port = Utils.ToInt(port); vmessItem.id = id; vmessItem.alterId = Utils.ToInt(alterId); vmessItem.security = security; if (Utils.IsNullOrEmpty(cmbCoreType.Text)) { vmessItem.coreType = null; } else { vmessItem.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), cmbCoreType.Text); } int ret = -1; switch (eConfigType) { case EConfigType.VMess: ret = ConfigHandler.AddServer(ref config, vmessItem); break; case EConfigType.Shadowsocks: ret = ConfigHandler.AddShadowsocksServer(ref config, vmessItem); break; case EConfigType.Socks: ret = ConfigHandler.AddSocksServer(ref config, vmessItem); break; case EConfigType.VLESS: vmessItem.flow = flow; ret = ConfigHandler.AddVlessServer(ref config, vmessItem); break; case EConfigType.Trojan: vmessItem.flow = flow; ret = ConfigHandler.AddTrojanServer(ref config, vmessItem); break; } if (ret == 0) { DialogResult = DialogResult.OK; } else { UI.ShowWarning(ResUI.OperationFailed); } }
private void menuScreenQRCodeScan_Click(object sender, EventArgs e) { Thread.Sleep(100); foreach (Screen screen in Screen.AllScreens) { Point screen_size = Utils.GetScreenPhysicalSize(); using (Bitmap fullImage = new Bitmap(screen_size.X, screen_size.Y)) { using (Graphics g = Graphics.FromImage(fullImage)) { g.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy); } for (int i = 0; i < 100; i++) { double stretch; Rectangle cropRect = Scan.GetScanRect(fullImage.Width, fullImage.Height, i, out stretch); if (cropRect.Width == 0) { break; } string url; Rectangle rect; if (stretch == 1 ? Scan.ScanQRCode(screen, fullImage, cropRect, out url, out rect) : Scan.ScanQRCodeStretch(screen, fullImage, cropRect, stretch, out url, out rect)) { QRCodeSplashForm splash = new QRCodeSplashForm(); splash.FormClosed += splash_FormClosed; splash.Location = new Point(screen.Bounds.X, screen.Bounds.Y); double dpi = Screen.PrimaryScreen.Bounds.Width / (double)screen_size.X; splash.TargetRect = new Rectangle( (int)(rect.Left * dpi + screen.Bounds.X), (int)(rect.Top * dpi + screen.Bounds.Y), (int)(rect.Width * dpi), (int)(rect.Height * dpi)); splash.Size = new Size(fullImage.Width, fullImage.Height); List <VmessItem> vmessItems = V2rayConfigHandler.ImportFromStrConfig(out string msg, url); if (vmessItems != null && vmessItems.Count > 0) { foreach (VmessItem vmessItem in vmessItems) { if (ConfigHandler.AddServer(ref config, vmessItem, -1) != 0) { break; } } splash.Show(); //刷新 RefreshServers(); LoadV2ray(); } else { splash.Show(); UI.Show(msg); } //扫到一个二维码即退出 break; } } } } }