c#代码,改写成vb.net代码
publicMainWindow(){InitializeComponent();_spider=newSpider();_spider.ContentsSaved+=n...
public MainWindow()
{
InitializeComponent();
_spider = new Spider();
_spider.ContentsSaved += new Spider.ContentsSavedHandler(Spider_ContentsSaved);
_spider.DownloadFinish += new Spider.DownloadFinishHandler(Spider_DownloadFinish);
this.Closed += new EventHandler(MainWindow_Closed);
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
btnStop.IsEnabled = false;
}
void Spider_DownloadFinish(int count)
{
DFHandler h = c =>
{
_spider.Abort();
btnDownload.IsEnabled = true;
btnDownload.Content = "Download";
btnStop.IsEnabled = false;
MessageBox.Show("Finished " + c.ToString());
};
Dispatcher.Invoke(h, count);
} 展开
{
InitializeComponent();
_spider = new Spider();
_spider.ContentsSaved += new Spider.ContentsSavedHandler(Spider_ContentsSaved);
_spider.DownloadFinish += new Spider.DownloadFinishHandler(Spider_DownloadFinish);
this.Closed += new EventHandler(MainWindow_Closed);
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
btnStop.IsEnabled = false;
}
void Spider_DownloadFinish(int count)
{
DFHandler h = c =>
{
_spider.Abort();
btnDownload.IsEnabled = true;
btnDownload.Content = "Download";
btnStop.IsEnabled = false;
MessageBox.Show("Finished " + c.ToString());
};
Dispatcher.Invoke(h, count);
} 展开
1个回答
展开全部
Public Sub New()
InitializeComponent()
_spider = New Spider()
_spider.ContentsSaved += New Spider.ContentsSavedHandler(Spider_ContentsSaved)
_spider.DownloadFinish += New Spider.DownloadFinishHandler(AddressOf Spider_DownloadFinish)
Me.Closed += New EventHandler(MainWindow_Closed)
Me.Loaded += New RoutedEventHandler(MainWindow_Loaded)
btnStop.IsEnabled = False
End Sub
Private Sub Spider_DownloadFinish(count As Integer)
Dim h As DFHandler = Function(c)
_spider.Abort()
btnDownload.IsEnabled = True
btnDownload.Content = "Download"
btnStop.IsEnabled = False
MessageBox.Show("Finished " & c.ToString())
End Function
Dispatcher.Invoke(h, count)
End Sub
InitializeComponent()
_spider = New Spider()
_spider.ContentsSaved += New Spider.ContentsSavedHandler(Spider_ContentsSaved)
_spider.DownloadFinish += New Spider.DownloadFinishHandler(AddressOf Spider_DownloadFinish)
Me.Closed += New EventHandler(MainWindow_Closed)
Me.Loaded += New RoutedEventHandler(MainWindow_Loaded)
btnStop.IsEnabled = False
End Sub
Private Sub Spider_DownloadFinish(count As Integer)
Dim h As DFHandler = Function(c)
_spider.Abort()
btnDownload.IsEnabled = True
btnDownload.Content = "Download"
btnStop.IsEnabled = False
MessageBox.Show("Finished " & c.ToString())
End Function
Dispatcher.Invoke(h, count)
End Sub
追问
void Spider_ContentsSaved(string path, string url)
{ CSHandler h = (p, u) =>
{ListDownload.Items.Add(new { Url = u, File = p }); };
Dispatcher.Invoke(h, path, url); }
追答
Private Sub Spider_ContentsSaved(path As String, url As String)
Dim h As CSHandler = Function(p, u)
ListDownload.Items.Add(New With { _
Key .Url = u, _
Key .File = p _
})
End Function
Dispatcher.Invoke(h, path, url)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询