例外是代码:
private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
ActiveDownloadJob adJob = e.UserState as ActiveDownloadJob;
if (adJob != null && adJob.ProgressBar != null)
{
adJob.ProgressBar.Invoke((Action)(() => adJob.ProgressBar.Value = e.ProgressPercentage));
}
}
Run Code Online (Sandbox Code Playgroud)
在线上:
adJob.ProgressBar.Invoke((Action)(() => adJob.ProgressBar.Value = e.ProgressPercentage));
Run Code Online (Sandbox Code Playgroud)
这是form1中的ActiveDownloadJob类:
class ActiveDownloadJob
{
public DownloadImages.DownloadData DownloadData;
public ProgressBar ProgressBar;
public WebClient WebClient;
public ActiveDownloadJob(DownloadImages.DownloadData downloadData, ProgressBar progressBar, WebClient webClient)
{
try
{
this.DownloadData = downloadData;
this.ProgressBar = progressBar;
this.WebClient = webClient;
}
catch (Exception err)
{
MessageBox.Show(err.ToString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定我是否需要调用此行,因为我现在不使用背景工作者,但我不确定.
这是完整的异常消息:在创建窗口句柄之前,无法在控件上调用Invoke或BeginInvoke
System.InvalidOperationException …
Run Code Online (Sandbox Code Playgroud) 这个类的代码给出了一些错误,其中大多数错误出现在像这样的符号上:&和>和<以及仅&它可能是什么?我该如何修复它们?
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;
namespace CaptureScreenDirect3D
{
public static class Direct3DCapture
{
private static SlimDX.Direct3D9.Direct3D _direct3D9 = new SlimDX.Direct3D9.Direct3D();
private static Dictionary<IntPtr, SlimDX.Direct3D9.Device> _direct3DDeviceCache = new Dictionary<IntPtr, SlimDX.Direct3D9.Device>();
/// <summary>
/// Capture the entire client area of a window
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
public static Bitmap CaptureWindow(IntPtr hWnd)
{
return CaptureRegionDirect3D(hWnd, NativeMethods.GetAbsoluteClientRect(hWnd));
}
/// <summary>
/// Capture a region of the screen using Direct3D
/// </summary>
/// <param name="handle">The handle …
Run Code Online (Sandbox Code Playgroud) private void Extract(string url)
{
HtmlWeb hw = new HtmlWeb();
HtmlDocument doc = hw.Load(url);
foreach (HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href]"))
{
}
}
Run Code Online (Sandbox Code Playgroud)
我想从html文件中提取/解析所有链接.但我得到一个错误:
错误8'HtmlAgilityPack.HtmlDocument'不包含'DocumentElement'的定义,并且没有可以找到接受类型'HtmlAgilityPack.HtmlDocument'的第一个参数的扩展方法'DocumentElement'(您是否缺少using指令或程序集引用?)
编辑**
我这样做了:
private void Extract(string url)
{
StreamWriter w = new StreamWriter(@"d:\localpath\test.txt");
HtmlWeb hw = new HtmlWeb();
HtmlDocument doc = hw.Load(url);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
w.WriteLine(link);
}
w.Close();
}
Run Code Online (Sandbox Code Playgroud)
并使用它:
Extract(@"d:\localpath\Sat24_Cloudsheight_Europe.html");
Run Code Online (Sandbox Code Playgroud)
但是我得到的是同一条线的很多次:
HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode HtmlAgilityPack.HtmlNode
如何写解析链接的文本文件?
代码:
private void Form1_MouseWheel(object sender, MouseEventArgs e)
{
if (leave == true)
{
timer1.Interval = 10;
}
}
Run Code Online (Sandbox Code Playgroud)
我想要这样做,如果我将鼠标滚轮向下转动,它会减慢计时器将增加间隔,如果我向上转动它将减少间隔.
我该怎么做 ?
在构造函数中我做了:
mouseState = Mouse.GetState();
var mousePosition = new Point(mouseState.X, mouseState.Y);
Run Code Online (Sandbox Code Playgroud)
然后在我创建的输入法中添加了:
private void ProcessInput(float amount)
{
Vector3 moveVector = new Vector3(0, 0, 0);
KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Up) || keyState.IsKeyDown(Keys.W))
moveVector += new Vector3(0, 0, -1);
if (keyState.IsKeyDown(Keys.Down) || keyState.IsKeyDown(Keys.S))
moveVector += new Vector3(0, 0, 1);
if (keyState.IsKeyDown(Keys.Right) || keyState.IsKeyDown(Keys.D))
moveVector += new Vector3(1, 0, 0);
if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
moveVector += new Vector3(-1, 0, 0);
if (keyState.IsKeyDown(Keys.Q))
moveVector += new Vector3(0, 1, 0);
if (keyState.IsKeyDown(Keys.Z))
moveVector += new …
Run Code Online (Sandbox Code Playgroud) 我试过了:
string endtag = "\"","\"";
Run Code Online (Sandbox Code Playgroud)
但那不起作用.字符串应该是:","
这"
也是字符串的一部分,
这是我的代码:
void CutAction(object sender, EventArgs e)
{
richTextBox2.Cut();
}
void CopyAction(object sender, EventArgs e)
{
Clipboard.SetData(DataFormats.Rtf, richTextBox2.SelectedRtf);
Clipboard.Clear();
}
void PasteAction(object sender, EventArgs e)
{
if (Clipboard.ContainsText(TextDataFormat.Rtf))
{
richTextBox2.SelectedRtf
= Clipboard.GetData(DataFormats.Rtf).ToString();
}
}
private void richTextBox2_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{ //click event
//MessageBox.Show("you got it!");
ContextMenu contextMenu = new System.Windows.Forms.ContextMenu();
MenuItem menuItem = new MenuItem("Cut");
menuItem.Click += new EventHandler(CutAction);
contextMenu.MenuItems.Add(menuItem);
menuItem = new MenuItem("Copy");
menuItem.Click += new EventHandler(CopyAction);
contextMenu.MenuItems.Add(menuItem);
menuItem = new MenuItem("Paste");
menuItem.Click += …
Run Code Online (Sandbox Code Playgroud) 我怎么解决呢?如果我在我的代码中做:使用System.Web; 它试图帮助我尝试添加System.Web.ApplicationServices的参考没有帮助也尝试引用:System.WebServices也没有帮助.这是在visual studio 2010 .net引用列表中使用Web的唯一两个引用.
这条线是:
var queryString = System.Web.HttpUtility.ParseQueryString(url);
Run Code Online (Sandbox Code Playgroud)
错误发生在:HttpUtility
错误1名称空间'System.Web'中不存在类型或命名空间名称'HttpUtility'(您是否缺少程序集引用?)
该项目在Target Framework上设置为:.net 4客户端配置文件.我有Windows 8 64位.
代码:
private void beginOperstionChecker(DateTime dt)
{
string time = Options_DB.Get_OperationLastTime();
DateTime.Now = time;
}
Run Code Online (Sandbox Code Playgroud)
现在时间例如显示保存的datetime.now可能是分钟前或小时ao.在我的程序完成后进行操作,保存datetime.now.
dt =当前的日期时间现在我在构造函数中使用此方法.
我想要做的是计算上次保存的datetime.now(时间)和当前datetime.now(dt)之间的时间.
如果已经过的时间是20分钟或更长时间,则启用按钮.
我有这个代码:
for (int i = 0; i < Maps.Count; i++)
{
string startTag = FirstTags[i];
string endTag = LastTags[i];
startIndex = Maps[i].IndexOf(startTag);
while (startIndex > 0)
{
endIndex = Maps[i].IndexOf(endTag, startIndex);
if (endIndex == -1)
{
break;
}
string t = Maps[i].Substring(startIndex, endIndex - startIndex + endTag.Length);
if (i == 0)
{
imagesSatelliteUrls.Add(t);
}
position = endIndex + endTag.Length;
startIndex = Maps[i].IndexOf(startTag, position);
}
imagesSatelliteUrls = imagesSatelliteUrls.OrderBy(q => q).ToList();
Run Code Online (Sandbox Code Playgroud)
所以第一次迭代/循环i = 0然后它进入一个while循环.然后我做了:
if (i == 0)
{
imagesSatelliteUrls.Add(t);
}
Run Code Online (Sandbox Code Playgroud)
所以最终imagesSatelliteUrls包含9个文件.我想在imagesSatelliteUrls …
我有这个代码:
if (TextParsingConfiguration.join == true)
{
images = images.Trim(' ');
}
if (TextParsingConfiguration.removecommas == true)
{
images = ReplacingChars(images, new[] { ',', '"' }, " ");
}
Run Code Online (Sandbox Code Playgroud)
join和removecommas是bool变量我也在checkBoxes中的form1中使用它们.和ReplacingChars方法:
public static string ReplacingChars(string source, char[] toReplace, string withThis)
{
return string.Join(withThis, source.Split(toReplace, StringSplitOptions.None));
}
Run Code Online (Sandbox Code Playgroud)
也许我错了逻辑,但我想给用户两个选项.
如果2号是逻辑的问题呢?如果不是我可以删除(清洁)的其他选项?removecommas正在运行.它删除逗号和引号并保留空格.