如何挂钩浏览器窗口调整大小事件?
有一种jQuery方式可以监听resize事件,但我不想将它带入我的项目中,只需要这个要求.
我需要在C#/ Windows Forms中敲出一个快速动画来进行万圣节显示.只是一些2D形状在坚实的背景上移动.由于这只是一个快速的一次性项目,我真的不想安装和学习一整套新的工具.(DirectX开发工具包,Silverlight,Flash等.)我还必须在多台计算机上安装它,因此除了基本的.Net框架(2.0)之外的任何东西都会让人痛苦.
对于工具,我有VS2k8,25年的开发经验,独轮车,大屠杀斗篷,大约2天就可以解决这个问题.自从在我的Atari 130XE上使用汇编程序以来,我没有完成动画(对于页面翻转和播放器/导弹图形来说很好!)
建议吗?以下是我想知道的一些事情:
谢谢.
Post Mortem Edit ..."几天后编码"
好吧,项目已经完成.下面的链接派上用场,虽然其中有几个是404.(我希望SO允许不止一个回复被标记为"正确").我必须克服的最大问题是闪烁,当我试图直接在表单上绘制时,这是一个持久的错误.
设置表单上的所有"双缓冲"选项仍然留下一些必须修复的闪烁.(我发现有冲突的文档说"将它们设置在控件上"并"将它们设置在窗体上".好的控件没有.SetStyle()方法.)我没有测试它们,所以它们可能是做某事(this是形式):
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
Run Code Online (Sandbox Code Playgroud)所以代码的主力看起来像(pf是面板控件):
void PaintPlayField()
{
Bitmap bufl = new Bitmap(pf.Width, pf.Height);
using (Graphics g = Graphics.FromImage(bufl))
{
g.FillRectangle(Brushes.Black, new Rectangle(0, 0, pf.Width, pf.Height));
DrawItems(g);
DrawMoreItems(g);
pf.CreateGraphics().DrawImageUnscaled(bufl, 0, 0);
}
}
Run Code Online (Sandbox Code Playgroud)
我刚从Timer循环内部调用了PaintPlayField.根本没有闪烁.
使用反射来获取MethodInfo,我想测试返回的类型是否为typeof System.Void.
测试它是否是System.Int32正常工作
myMethodInfo.ReturnType == typeof(System.Int32)
Run Code Online (Sandbox Code Playgroud)
但
myMethodInfo.ReturnType == typeof(System.Void)
Run Code Online (Sandbox Code Playgroud)
不编译?目前我正在测试名称的字符串表示是否为"System.Void",这看起来非常错误.
目前,我的代码结构XmlDocument用于加载Xml数据,然后SelectNodes迭代重复项列表.
对于每个元素,我XmlNode.SelectSingleNode用来挑选字段元素.
我现在想要使用JSON.NET来实现与作为JSON传递给我的文档相同的结果.答案可能是JSON.net之外的其他东西,只要它是C#可积极的.
可以在编译时创建一个数组;
int[] myValues = new int[] { 1, 2, 3 } ;
Run Code Online (Sandbox Code Playgroud)
但我想做这样的事情;
List<int> myValues = new List<int>() { 1, 2, 3 };
Run Code Online (Sandbox Code Playgroud)
编译器说没有.有没有办法在不使用LINQ(C#3.0)的情况下执行此操作(C#2.0)?
我已经知道如何使用CLLocationManager,所以我可以用代表和所有这些来完成它.
但我希望有一个方便的方法,只需获取当前位置一次,然后阻塞直到获得结果.
我有两个表有一个相同的列名,但数据不同.我想加入表,但访问两列(row ["price"],row ["other_price"]):如何在select语句中重命名/别名?(我不想在DB中重命名它们)
如何获取ConstructorInfo静态构造函数?
public class MyClass
{
public static int SomeValue;
static MyClass()
{
SomeValue = 23;
}
}
Run Code Online (Sandbox Code Playgroud)
我试过以下但失败了....
Type myClass = typeof (MyClass);
// throws exception
myClass.TypeInitializer.Invoke(null);
// returns null (also tried deleting BindingFlags.Public
ConstructorInfo ci = myClass.GetConstructor(BindingFlags.Static|BindingFlags.Public, System.Type.DefaultBinder, System.Type.EmptyTypes, null);
// returns empty array
ConstructorInfo[] clutchingAtStraws = myClass.GetConstructors(BindingFlags.Static| BindingFlags.Public);
Run Code Online (Sandbox Code Playgroud) 我正在寻找一个开源库来解析和执行C#中的公式/函数.
我想创建一组从接口派生的对象(即IFormulaEntity),它具有属性/方法/值,并允许用户为这些对象指定公式.
例如,我可能有
public class Employee : IForumulaEntity
{
public double Salary { get; set; }
public void SendMessage(string message)
}
Run Code Online (Sandbox Code Playgroud)
然后允许应用程序用户写一些类似的东西;
Employee person = <get from datasource>
if (person.Salary > 1000)
person.Salary += 1000;
person.SendMessage("Hello");
Run Code Online (Sandbox Code Playgroud)
这"看起来像C#",但它将是一种简化的编程语言.我知道这很有问题.我希望我的用户能够合理(即可以编写自己的Excel公式).
为什么我添加到网页的Google Analytics脚本需要包含两个脚本块?
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxxxx-xx");
pageTracker._trackPageview();
} catch (err) { }
</script>
Run Code Online (Sandbox Code Playgroud) c# ×6
javascript ×2
reflection ×2
.net ×1
animation ×1
c#-2.0 ×1
generics ×1
iphone ×1
json.net ×1
methodinfo ×1
parsing ×1
sql ×1
winforms ×1