由於公司業務須要,作了一個客戶端,時間比較緊迫,我儘可能使用簡單技術來實現,畢竟暫時沒有了解其餘的技術,不敢隨便亂用,萬一出現一個難以解決的問題,又得推倒重來。因此爲了儘快實現,也爲了提升性能,我只用到了很基礎的一些控件 架構
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//不顯示默認的標題欄
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
} 性能
public void App_Close(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("肯定要退出系統嗎?", "退出系統", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
Environment.Exit(0);
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
} this
private void App_Min(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
spa
private void MaxWindow() {
if (!maxable)
{ 設計
//最大化以後,不遮蓋任務欄
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
maxable = true;
}
else
{
this.WindowState = FormWindowState.Normal;
maxable = false;
}
} component
private void App_MouseDown(object sender, MouseEventArgs e)
{
this._point.X = e.X;
this._point.Y = e.Y;
}
private void App_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point p = MousePosition;
p.Offset(-this._point.X, -this._point.Y);
this.Location = p;
}
} orm
this.toolbar_panel.MouseDown += new System.Windows.Forms.MouseEventHandler(App_MouseDown);
this.toolbar_panel.MouseMove += new System.Windows.Forms.MouseEventHandler(App_MouseMove);
it
public void ResetLocation()
{
Rectangle ScreenBox = System.Windows.Forms.Screen.GetWorkingArea(this);
screenWidth = ScreenBox.Width;
screenHeight = ScreenBox.Height;
int winWidth = ScreenBox.Width / 2;
int winHeight = ScreenBox.Height / 2;
if (this.form_width > 0)
{
winWidth = this.form_width;
}
if (this.form_height > 0)
{
winHeight = this.form_height;
}
this.Size = new System.Drawing.Size(winWidth, winHeight);
// this.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation;
this.Location = new Point((ScreenBox.Width - winWidth) / 2, (ScreenBox.Height - winHeight) / 2);
}
io
try { 系統架構
Ping p = new Ping();
PingReply pr = null;
//ping百度
pr = p.Send("119.75.218.45");
if (pr.Status != IPStatus.Success)
{
//未聯網
state = -1;
}
else
{
//已聯網
state = 1;
}
}
catch (Exception ex) { }
finally { }
基本上上面這些就已經夠了。代碼只是爲了實現功能,真正體現能力的,是如何組織代碼,就像打dota須要大局觀,可以設計一個很合理,可以複用,達到更高效率的漂亮的系統,那才叫實力。 也能夠理解爲系統架構師,固然我目前還沒達到這種層次,不過人總得有點夢想,有點追求。
但願上面這些可以對你們有所幫助,記錄下這點點滴滴,之後再看也許會有更多的感悟,但願你們可以喜歡,若是有什麼錯誤,或者有更好的改進意見,請留下您的寶貴意見,但願大牛多指點。感謝你們的支持!