예제 #1
0
        private void ProxyListViewDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var files = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (var file in files.Where(f => f.EndsWith(".txt")))
                {
                    var lines = File.ReadAllLines(file);
                    var dto   = new ProxiesForImportDto {
                        Lines = lines
                    };

                    if (file.Contains("socks4a", StringComparison.OrdinalIgnoreCase))
                    {
                        dto.DefaultType = ProxyType.Socks4a;
                    }
                    else if (file.Contains("socks4", StringComparison.OrdinalIgnoreCase))
                    {
                        dto.DefaultType = ProxyType.Socks4;
                    }
                    else if (file.Contains("socks5", StringComparison.OrdinalIgnoreCase))
                    {
                        dto.DefaultType = ProxyType.Socks5;
                    }
                    else // Default to HTTP
                    {
                        dto.DefaultType = ProxyType.Http;
                    }
                }
            }
        }
예제 #2
0
 public async void AddProxies(ProxiesForImportDto dto)
 {
     try
     {
         await vm.AddProxies(dto);
     }
     catch (Exception ex)
     {
         Alert.Exception(ex);
     }
 }