我有一个C#应用程序,它由3种形式组成:
Run Code Online (Sandbox Code Playgroud)1: Battleship Game GUI 2: Network GUI (does client/server connections) 3: Chat GUI
首先加载表单1.当用户选择时setup network,显示表单2.
当用户选择发送聊天或收到聊天时,将显示聊天.
我希望表单2处理所有消息并将相关消息传递给相关GUI以进一步解码消息.
我还处于发展的早期阶段.目前我正在尝试使用代表在表单之间进行通信.
这是最好的方法吗?关于应用程序组件相互发送消息的最佳实践是什么?
我一直在做一些休闲度假计算.我的迷你项目是对意大利"tomboli"游戏的模拟.一个关键的构建模块是对以下过程的模拟;
游戏由一个男人控制,一袋90个大理石,编号为1到90.他从包里随机抽出弹珠,每次都给玩家打出大理石号码.
经过一番思考后,我为这个构建块编写了以下代码;
// NBR marbles, numbered 1...NBR are in a bag. Simulate randomly
// pulling them from the bag, one by one, until the bag is empty
void bag( int random_sequence[NBR] )
{
int i;
// Store each marble as it is pulled out
int *store = random_sequence;
// Array of marbles still in the bag
int not_yet_pulled[NBR];
for( i=0; i<NBR; i++ )
not_yet_pulled[i] = i+1; // eg NBR=90; 1,2,3 ... 90
// Loop pulling marbles from the bag, …Run Code Online (Sandbox Code Playgroud) 我试过以下,但似乎没有用.
var helpIcon = dojo.create("span", {"class":"help-icon", innerHTML:"[?]"}, td1);
var tooltip = new dijit.Tooltip({
connectId: [helpIcon],
label: "large paragraph of text here ... "
});
tooltip._setStyleAttr("max-width: 100px");Run Code Online (Sandbox Code Playgroud)
救命!
我遇到了一个容易解决的设计问题,但是在我年轻的时候还没有遇到过.
我有一个课程需要经过一些设置程序才能发生其他事情.
但是,在构造这个类的过程中,我在构造函数的参数中有一个可以传递的委托,以便用户可以将自己的信息添加到类中.
当调用它时,创建类的作用域仍然没有有效的实例,因此会发生null异常错误.
我该如何设计呢?我应该将"this"的实例传递给该代表吗?
在这里做出什么样的好决定?我有一个"StartServices()"方法,我可以很容易地把呼叫转移到代表,但我觉得明智的设计应该是在构造函数中.
感谢您的建议!
好奇,如果Git和Subversion for Java有任何API包装器?
我希望能够从Subversion和Git repos中提取变更集和源代码(以及差异).
这可能吗?任何预先构建的API?
我可以用c ++/g ++做到这一点:
struct vec3 {
union {
struct {
float x, y, z;
};
float xyz[3];
};
};
Run Code Online (Sandbox Code Playgroud)
然后,
vec3 v;
assert(&v.xyz[0] == &v.x);
assert(&v.xyz[1] == &v.y);
assert(&v.xyz[2] == &v.z);
Run Code Online (Sandbox Code Playgroud)
将工作.
如何使用gcc在c中执行此操作?我有
typedef struct {
union {
struct {
float x, y, z;
};
float xyz[3];
};
} Vector3;
Run Code Online (Sandbox Code Playgroud)
但我特别是周围都有错误
line 5: warning: declaration does not declare anything
line 7: warning: declaration does not declare anything
Run Code Online (Sandbox Code Playgroud) 由于某种原因,项目"description"返回NULL以下代码:
<?php
include('db.php');
$result = mysql_query('SELECT * FROM `staff` ORDER BY `id` DESC LIMIT 2') or die(mysql_error());
$rows = array();
while($row = mysql_fetch_assoc($result)){
$rows[] = $row;
}
echo json_encode($rows);
?>
Run Code Online (Sandbox Code Playgroud)
这是我的数据库的架构:
CREATE TABLE `staff` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` longtext COLLATE utf8_unicode_ci,
`description` longtext COLLATE utf8_unicode_ci,
`icon` longtext COLLATE utf8_unicode_ci,
`date` longtext COLLATE utf8_unicode_ci,
`company` longtext COLLATE utf8_unicode_ci,
`companyurl` longtext COLLATE utf8_unicode_ci,
`appurl` longtext COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Run Code Online (Sandbox Code Playgroud)
以下是页面上的回显: …
我正在通过我的ASP.NET MVC应用程序中的表单提交的textarea中显示一些文本.
我希望在显示文本时显示换行符.
为什么
Message.Replace(Environment.NewLine, "<br />")
Run Code Online (Sandbox Code Playgroud)
不行,但是
Message.Replace("\n", "<br />")
Run Code Online (Sandbox Code Playgroud)
呢?
浏览器提交的breakline字符是否与windows Newline"\ r \n"不同?
我有一个字节[](从服务中下载),我的MP3文件,我想发挥它我的设备类似上你可以怎么玩的文件:
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
mp.prepare();
mp.start();
Run Code Online (Sandbox Code Playgroud)
但我似乎无法找到办法.我不介意将文件保存到手机然后播放.我该如何播放文件,或下载然后播放?
在SQL 2005/8中,我希望将select查询中的列转换为NOT NULL列.
coalease()并且isnull(),虽然精功能,是不是我要找的.我希望select抛出一个错误,任何数据都是NULL.
这可能吗?
[更新]显然,最好的方法是修改源表,不幸的是,在这种情况下,它不是一个(成本效益)选项.
c# ×3
c ×2
c++ ×2
null ×2
.net ×1
algorithm ×1
android ×1
anonymous ×1
asp.net-mvc ×1
audio-player ×1
bytearray ×1
constructor ×1
delegates ×1
dojo ×1
git ×1
ipc ×1
java ×1
javascript ×1
json ×1
messaging ×1
mp3 ×1
php ×1
random ×1
simulation ×1
sql-server ×1
struct ×1
svn ×1
unions ×1
winforms ×1