我可以用mouseClick绘制一个矩形吗?到目前为止,我的代码无效.你能帮助我吗?
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen pen = new Pen(Color.Black, 2);
g.DrawRectangle(pen, 100,100, 100, 200);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在OCaml中实现尾递归列表排序功能,我想出了以下代码:
let tailrec_merge_sort l =
let split l =
let rec _split source left right =
match source with
| [] -> (left, right)
| head :: tail -> _split tail right (head :: left)
in _split l [] []
in
let merge l1 l2 =
let rec _merge l1 l2 result =
match l1, l2 with
| [], [] -> result
| [], h :: t | h :: t, [] -> _merge [] t (h :: result)
| …Run Code Online (Sandbox Code Playgroud) setSelection不会在reloadGrid之后选择id为2的行.
$("#training").setGridParam({url: 'index.php?func=trainingmgr&aAction=refreshData'});
$("#training").trigger("reloadGrid");
$("#training").jqGrid('setSelection', "2?);
Run Code Online (Sandbox Code Playgroud)
但是,当您使用此行时,setSelection可以选择id为2的行:$("#training").trigger("reloadGrid");
有人遇到过同样的问题吗?
谢谢
我正在使用此代码用于页面卷曲效果....它在模拟器和设备中工作正常......但它不是(setType:@"pageCurl")苹果记录的api,这导致它被iPhone开发人员计划拒绝App Store审核流程:
animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0.5;
animation.endProgress = 1;
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"pageCurl"];
[animation setSubtype:@"fromRight"];
[animation setRemovedOnCompletion:NO];
[animation setFillMode: @"extended"];
[animation setRemovedOnCompletion: NO];
[[imageView layer] addAnimation:animation
forKey:@"pageFlipAnimation"];
Run Code Online (Sandbox Code Playgroud)
所以我改变并使用这样的方式
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationWillStartSelector:@selector(transitionWillStart:finished:context:)];
[UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)];
// other animation properties
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:imageView cache:YES];
// set view properties
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我想在中途停止页面卷曲效果..但我不能在中途停止它像ipod中的地图应用程序...这是否有任何修复?或是否有任何苹果记录的方法用于ipod touch中的页面卷曲效果?
我正在寻找很多.但没有得到任何答案?谁能帮我?在此先感谢..plz
我正在尝试编写一个在被调用后"刷新"的装饰器,但是在最后一个函数退出后只刷新一次.这是一个例子:
@auto_refresh
def a():
print "In a"
@auto_refresh
def b():
print "In b"
a()
Run Code Online (Sandbox Code Playgroud)
如果a()被调用,我希望退出后运行刷新功能a().如果b()被调用,我希望刷新函数在退出b()后运行,而不是在a()调用之后运行b().以下是执行此操作的类的示例:
class auto_refresh(object):
def __init__(self, f):
print "Initializing decorator"
self.f = f
def __call__(self, *args, **kwargs):
print "Before function"
if 'refresh' in kwargs:
refresh = kwargs.pop('refresh')
else:
refresh = False
self.f(*args, **kwargs)
print "After function"
if refresh:
print "Refreshing"
Run Code Online (Sandbox Code Playgroud)
有了这个装饰,如果我跑
b()
print '---'
b(refresh=True)
print '---'
b(refresh=False)
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
Initializing decorator
Initializing decorator
Before function …Run Code Online (Sandbox Code Playgroud) 我需要这个,因为超类中的构造函数正在调用在子类中重写的方法.该方法返回一个传递给子类构造函数的值.但必须在子类构造函数之前调用超类构造函数,因此我没有机会保存传入的值.
最近,我一直在尝试从这个网站学习C++ .不幸的是,每当我尝试运行其中一个代码示例时,我会看到该程序打开大约半秒然后立即关闭.有没有办法阻止程序立即关闭,以便我可以看到我努力的成果?
我是Google App Engine的新用户,我有这个用户类 -
user_id - 整数
user_name - 字符串
密码 - 字符串
我想为user_id做自动增量,我该怎么做?
我得到以下代码:
char buffer[2047];
int charsRead;
do {
if(fscanf(file, "%2047[^\n]%n%*c", buffer, &charsRead) == 1) {
// Do something
}
} while (charsRead == 2047);
Run Code Online (Sandbox Code Playgroud)
我想将此代码转换为使用动态分配的变量,以便在调用此代码时,我不会遇到大量内存泄漏.因此,我试过这个:
char *buffer = malloc(sizeof(char) * 2047);
int *charsRead = malloc(sizeof(int));
do {
if(fscanf(file, "%2047[^\n]%n%*c", *buffer, charsRead) == 1) {
// Do something
}
} while (*charsRead == 2047);
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用.我总是得到"EXC_BAD_ACCESS"错误,就在使用fscanf调用的if语句之前.我究竟做错了什么?
谢谢你的帮助!
- Ry
我有一个名字存储在一个表中,而姓氏存储在另一个表中.我知道这很愚蠢,但我正在尝试不同的东西,因为我刚开始使用MySQL.无论如何,是否可以在一个查询中从一个表中选择名字,从另一个表中选择另一个名字?并将结果放在PHP变量中?