懂C#的和GUI控制程序的进
我想弄个随机发牌的C#,就是不懂得用Random做,还有不懂得把牌和随机联系起来。懂得细聊
追问:那我要怎样让它跟GUI界面联系起来啊 我想让16张不同的牌随机显示在界面上的picturebox上
答案:我临时写了一个,继承了一个PictureBox,用painter画牌出来。如果有问题再提吧,这个可以实现从8种16张牌里,单击相同的两张可以消除。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace text
{
public partial class Form1 : Form
{
private PokerPictureBox poker;
private Button button;
private Random rand;
private Label lable;
private bool selected;
private int selectednum;
private int selectedindex;
public Form1()
{
InitializeComponent();
poker = new PokerPictureBox();
poker.Location = new Point(50, 50);
poker.Size = new Size(500, 100);
poker.MouseClick += new MouseEventHandler(poker_MouseClick);
this.Controls.Add(poker);
lable = new Label();
lable.Name = "Lable1";
lable.AutoSize = true;
lable.Location = new Point(200,20);
lable.Size = new Size(300, 40);
lable.Text = "未选择";
this.Controls.Add(lable);
button = new Button();
button.Text = "发牌";
button.Location = new Point(10, 10);
button.Click += new EventHandler(button_Click);
this.Controls.Add(button);
selected = false;
}
//一次发不完,等会补充
这种代码满街都有啊..
给你一个阿良写的,非常简单.
class Poker
{
/// <summary>
/// 记录54张牌
/// </summary>
private int[] _cards = new int[54] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 };
public Poker()
{ }
public void Reshuffle()
{
Random ram = new Random();
int currentIndex;
int tempValue;
for (int i = 0; i < 54; i++)
{
currentIndex = ram.Next(0, 54 - i);
tempValue = _cards[currentIndex];
_cards[currentIndex] = _cards[53 - i];
_cards[53 - i] = tempValue;
}
通过ssh可以和UNIX通信。通过设置ssh的key(也就是把server的public key放到client的~/.ssh/authorized_key2文件中)可以避免输密码,具体步骤可以网上搜一下。
设置好key,不需密码后,
ssh 192.168.0.1 ls /
就可以直接显示ls /的输出结果
另一种办法就是在client端运行自己写的一个daemon,通过socket和server通信,返回想要的结果。
Top
我有现成的项目
上一个:关于编程语言哪个好(java C++ C#)
下一个:c#,获取控件的句柄?,高手入!