C#從零開始_自學C#、Visual Studio實境秀 20/ 小山的 C# 教學-第41-42課
57:00 在VBA中怎麼計時 VBA.Timer
1:02:05 小山的 C# 教學-第42課-五子棋小遊戲(三)-用滑鼠建立棋子
https://youtu.be/2VzO76N74ao
1:05:10 1:09:50
事件(events)
2:20:00 測試成功!列出滑鼠點按表單時的座標:
public Form1()
{ //委派事件處理程序
MouseDown += new MouseEventHandler(frm_MouseDown);//http://bit.ly/2urZYWe
//MouseDown += frm_MouseDown;
}
void frm_MouseDown(object sender, MouseEventArgs e)
{
MessageBox.Show(e.X.ToString() + " " + e.Y.ToString());
MessageBox.Show(e.Location.ToString());
}
//上下二種方法寫法比較! MouseEventArgs 子類別直接可以轉型成父類別
//Examples include conversions from smaller to larger integral types, and conversions from derived classes to base classes. // http://bit.ly/2tiH8lT
void frm_MouseDown_EventArgs(object sender,EventArgs e)
{
//if(e==false)
//{ Controls.Add(new Piece(10, 30, false)); }
//MouseEventArgs msea = new MouseEventArgs(MouseButtons.Left, 2, 23, 25, 0);
//Point p = new Point();
//p = msea.Location;
//MessageBox.Show(p.X.ToString() + " " + p.Y.ToString());
// MouseEventArgs meargs = (MouseEventArgs)e;//http://bit.ly/2tiH8lT //http://bit.ly/2tJSkca
MouseEventArgs meargs = e as MouseEventArgs;
MessageBox.Show(meargs.X.ToString() + " " + meargs.Y.ToString());
MessageBox.Show(meargs.Location.ToString());
}
2:35:00 測試成功!按照滑鼠點按表單時的座標位置來交替下黑子、白子:
public Form1()
{ //委派事件處理程序
MouseDown += new MouseEventHandler(frm_MouseDown);//http://bit.ly/2urZYWe
//MouseDown += frm_MouseDown;
}
int clickCount=1;
void frm_MouseDown(object sender,MouseEventArgs e)
{
int x = e.X, y= e.Y;
if (clickCount % 2 == 1)//求餘數:下黑子
{
x -= Properties.Resources.black.Width / 2;
y -= Properties.Resources.black.Height / 2;
Controls.Add(new Piece(x, y, false));
}
else//下白子
{
x -= Properties.Resources.white.Width / 2;
y -= Properties.Resources.white.Height / 2;
Controls.Add(new Piece(x, y, true));
}
clickCount++;
}
3:07:50 目前「部件篩選器」改進的進度。
6:12:00 「部件篩選器」利用Application.OpenForms 在表單間傳值成功
9:24:16 自動按下輸出的功能,也成功了
10:07:00 結果呈現為作用中最大化視窗也成功了
留言