下面圖片中的Circle或是Pie的圖形邊緣都有鋸齒出現不怎麼美觀.
找到IdentifyPictureControl.cs中這個DrawANewPicture() Function
加入下面粗體字那行,修正後就可以美觀一點了...
//Private Function
private void DrawANewPicture()
{
myPictureSize = this.Size;
GraphicsPath myGP = new GraphicsPath();
myBitmap = new Bitmap(this.Width, this.Height);
Graphics myG = Graphics.FromImage(myBitmap);
//GDI+ 修飾用屬性
myG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
myG.Clear(Color.White);
....
修正後,看起來舒服多了...
歡迎跟我連絡
免安裝程式...哈哈 歡迎聊天
2009年7月31日 星期五
認證登錄系統圖片產生 .Net 控制項 (續)
母親給出的答案
有個孩子對一個問題一直想不通:為什麼他的同桌的同學想考第一名就考上第一,而自己想考第一卻才考了全班第二十一名?
回家後他問道:"媽媽我是不是比別人笨?我覺得我和他一樣聽老師的話,一樣認真地做作業,可是,為什麼我總是比落後他?"媽媽聽了兒子的話,感覺到兒子開始有自 尊心了,而這種自尊心正在被學校的排名傷害著。她望著兒子,沒有回答,因為她不知道該怎樣回答。
又一次考試後,孩子考了第十七名,而他的同學還是第一名。回家後,兒子又問了同樣的問題。她真想說,人的智力確實有三六九等,考第一的人,腦子就是比一般的人靈活。然而這樣的回答,難道是孩子真想知道的答案嗎?她慶幸自己沒說出口。
應該怎樣回答兒子的問題呢?有幾次,她真想重覆那幾句被上萬個父母重覆了上萬次的話--你太貪玩了,你在學習上還不夠勤奮,和別人比起來還不夠努力……以此來搪塞兒子。然而,像她兒子這樣腦袋不夠聰明,在班上成績不甚突出的孩子,平時活得還不夠辛苦嗎?所以她沒有那麼做,她想為兒子的問題找到一個完美的答案。
兒子小學畢業了,雖然他比過去更加努力,但依然沒有趕上他的同學,不過與過去相比,他的成績一直在進步。為了對兒子的進步表示讚賞,她帶他去看了一次大海。就是在這次旅行中,這位母親回答了兒子的問題。
現在這位兒子再也不擔心自己的名次了,也再沒有人追問他小學時成績排第幾名,因為他已經以全校第一名的成績考上了大學。放寒假回來時,母校請他給同學及家長們做一段演說。其中他講小時候的一段經歷:「我和母親坐在沙灘上,她指著前面對我說,你看那些在海邊爭食的鳥兒,當海浪打來的時候,小麻雀總能迅速地起飛,牠們拍打兩三下翅膀就升入天空;而海鷗總顯得非常笨拙,牠們從沙灘飛入天空總要很長時間,然而,真正能飛越大海橫過大洋的還是海鷗。」這場演說使很多母親流下了眼淚,其中包括他自己的母親。
這位母親從不說一些令孩子洩氣的話,在找不到適當的答案前寧可沉默,以自身之受去支持孩子的一步步成長,孩子在這樣寬容的環境下,最後交出優秀的成績。
教育,是對生命個體的尊重和喚醒,是對人的內在潛能的開發和拓展,讓孩子健康地生長,需要一種平和的心境,一種智慧的胸襟,一種獨特的魅力,這一切必須以寬容為基礎!
雨季說:
一段刻苦銘心的話,可以改變聽的懂的人的一生...
但是絕大部分,都是對牛彈琴 聽者無心
2009年7月30日 星期四
認證登錄系統圖片產生 .Net 控制項
繼續上一篇文章,將Class改寫為.Net控制項
新增一個Event,如果USER點選到圓圈(Circle),會產生Identify_OK Event.
新增一個屬性SharpNumber,可以設定圖形的複雜度.
新增一個Method GetNext(),可以重新繪製新的認證圖片.
程式碼:
1.IdentifyPictureControl.cspublic partial class IdentifyPictureControl : UserControl
{
//Private Variable
private Random myRandom = new Random();
private int mySharpNo;
private Size myPictureSize;
private Bitmap myBitmap;
private Region myRegion;
private Point myMouseLocation;
public int SharpNumber
{
set { mySharpNo = value; }
get { return mySharpNo; }
}
public IdentifyPictureControl()
{
InitializeComponent();
mySharpNo = 20;
myRegion = new Region();
myMouseLocation = new Point(-1, -1);
}
//Event
public event EventHandler Identify_OK;
protected virtual void OnIdentify_OK(EventArgs e)
{
if (Identify_OK != null)
{
Identify_OK(this, e);
}
}
//Private Component Event
private void IdentifyPictureControl_Load(object sender, EventArgs e)
{
DrawANewPicture();
this.BackgroundImage = myBitmap;
}
private void IdentifyPictureControl_Click(object sender, EventArgs e)
{
if (myRegion.IsVisible(myMouseLocation))
{
OnIdentify_OK(EventArgs.Empty);
}
}
private void IdentifyPictureControl_MouseMove(object sender, MouseEventArgs e)
{
myMouseLocation = e.Location;
}
private void IdentifyPictureControl_MouseLeave(object sender, EventArgs e)
{
myMouseLocation = new Point(-1, -1);
}
//Private Function
private void DrawANewPicture()
{
myPictureSize = this.Size;
GraphicsPath myGP = new GraphicsPath();
myBitmap = new Bitmap(this.Width, this.Height);
Graphics myG = Graphics.FromImage(myBitmap);
myG.Clear(Color.White);
//DrawEllipse
int mySize = GetSize(myPictureSize.Height);
Point myPoint = GetLocation(myPictureSize, mySize);
Pen myPen = new Pen(GetColor(), 3);
myG.DrawEllipse(myPen, new Rectangle(myPoint, new Size(mySize, mySize)));
myGP.AddEllipse(new Rectangle(myPoint, new Size(mySize, mySize)));
myRegion = new Region(myGP);
//DrawRectangle
for (int i = 0; i < mySharpNo/2; i++)
{
mySize = GetSize(myPictureSize.Height);
myPoint = GetLocation(myPictureSize, mySize);
myPen = new Pen(GetColor(), 3);
myG.DrawRectangle(myPen, new Rectangle(myPoint, new Size(mySize, mySize)));
}
for (int i = 0; i < mySharpNo/2; i++)
{
mySize = GetSize(myPictureSize.Height);
myPoint = GetLocation(myPictureSize, mySize);
myPen = new Pen(GetColor(), 3);
myG.DrawPie(myPen, new Rectangle(myPoint, new Size(mySize, mySize)), GetAngle(), GetAngle());
}
}
private Point GetLocation(Size PictureSize, int SharpWidth)
{
int X = myRandom.Next(0, PictureSize.Width - SharpWidth - 3); //3 Pen Width
int Y = myRandom.Next(0, PictureSize.Height - SharpWidth - 3); //3 Pen Width
return new Point(X, Y);
}
private int GetSize(int PictureWidth)
{
return (int)(PictureWidth / myRandom.Next(2, 6));
}
private Color GetColor()
{
switch (myRandom.Next(0, 10))
{
case 0:
return Color.Yellow;
case 1:
return Color.Violet;
case 2:
return Color.Green;
case 3:
return Color.DeepPink;
case 4:
return Color.DarkSlateBlue;
case 5:
return Color.DarkRed;
case 6:
return Color.CornflowerBlue;
case 7:
return Color.DarkSalmon;
case 8:
return Color.Gainsboro;
case 9:
return Color.Gold;
case 10:
return Color.Indigo;
default:
return Color.Black;
}
}
private float GetAngle()
{
return (float)(myRandom.Next(10, 350));
}
//Public method
public void GetNext()
{
DrawANewPicture();
this.BackgroundImage = myBitmap;
}
}
2.IdentifyPictureControl.Designer.cs
partial class IdentifyPictureControl
{
///
/// 設計工具所需的變數。
///
private System.ComponentModel.IContainer components = null;
///
/// 清除任何使用中的資源。
///
/// 如果應該公開 Managed 資源則為 true,否則為 false。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
///
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改這個方法的內容。
///
///
private void InitializeComponent()
{
this.SuspendLayout();
//
// IdentifyPictureControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Name = "IdentifyPictureControl";
this.Size = new System.Drawing.Size(148, 148);
this.Load += new System.EventHandler(this.IdentifyPictureControl_Load);
this.MouseLeave += new System.EventHandler(this.IdentifyPictureControl_MouseLeave);
this.Click += new System.EventHandler(this.IdentifyPictureControl_Click);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.IdentifyPictureControl_MouseMove);
this.ResumeLayout(false);
}
#endregion
}
範例引用程式碼:
private void button1_Click(object sender, EventArgs e)
{
identifyPictureControl1.SharpNumber = 30;
identifyPictureControl1.GetNext();
}
private void identifyPictureControl1_Identify_OK(object sender, EventArgs e)
{
MessageBox.Show("OK");
}
認證登錄系統圖片產生物件
目前網路上有很多防止程式自動登錄註冊...攻擊網頁的方式...
常見的方式有底下兩種...

今天利用C#寫了一個認證圖片產生物件IdentifyPicture,效果如下圖
只要USER點選到圖中唯一圓形的區塊就算認證成功(箭頭所指)...
程式碼:
public class IdentifyPicture
{
private Random myRandon;
private int mySharpNo;
private Size myPictureSize;
private Bitmap myBitmap;
public Bitmap IdPicture //產生的圖片
{
get { return myBitmap; }
}
private Region myRegion;
public Region IdRegion //驗證圓形於圖上範圍
{
get { return myRegion; }
}
public IdentifyPicture(Size PictureSize , int SharpNumber)
{
myRandon = new Random();
mySharpNo = SharpNumber;
myPictureSize = PictureSize;
myBitmap = new Bitmap(PictureSize.Width, PictureSize.Height);
myRegion = new Region();
DrawANewPicture();
}
private void DrawANewPicture()
{
GraphicsPath myGP = new GraphicsPath();
Graphics myG = Graphics.FromImage(myBitmap);
myG.Clear(Color.White);
//DrawEllipse
int mySize = GetSize(myPictureSize.Height);
Point myPoint = GetLocation(myPictureSize, mySize);
Pen myPen = new Pen(GetColor(), 3);
myG.DrawEllipse(myPen, new Rectangle(myPoint, new Size(mySize, mySize)));
myGP.AddEllipse(new Rectangle(myPoint, new Size(mySize, mySize)));
myRegion = new Region(myGP);
//DrawRectangle
for (int i = 0; i < mySharpNo; i++)
{
mySize = GetSize(myPictureSize.Height);
myPoint = GetLocation(myPictureSize, mySize);
myPen = new Pen(GetColor(), 3);
myG.DrawRectangle(myPen, new Rectangle(myPoint, new Size(mySize, mySize)));
}
for (int i = 0; i < mySharpNo; i++)
{
mySize = GetSize(myPictureSize.Height);
myPoint = GetLocation(myPictureSize, mySize);
myPen = new Pen(GetColor(), 3);
myG.DrawPie(myPen, new Rectangle(myPoint, new Size(mySize, mySize)), GetAngle(), GetAngle());
}
}
private Point GetLocation(Size PictureSize, int SharpWidth)
{
int X = myRandon.Next(0, PictureSize.Width - SharpWidth - 3); //3 Pen Width
int Y = myRandon.Next(0, PictureSize.Height - SharpWidth - 3);//3 Pen Width
return new Point(X, Y);
}
private int GetSize(int PictureWidth)
{
return (int)(PictureWidth / myRandon.Next(2, 6));
}
private Color GetColor()
{
switch (myRandon.Next(0, 10))
{
case 0:
return Color.Yellow;
case 1:
return Color.Violet;
case 2:
return Color.Green;
case 3:
return Color.DeepPink;
case 4:
return Color.DarkSlateBlue;
case 5:
return Color.DarkRed;
case 6:
return Color.CornflowerBlue;
case 7:
return Color.DarkSalmon;
case 8:
return Color.Gainsboro;
case 9:
return Color.Gold;
case 10:
return Color.Indigo;
default:
return Color.Black;
}
}
private float GetAngle()
{
return (float)(myRandon.Next(10, 350));
}
}
應用範例如下:
程式碼:
public partial class Form1 : Form
{
Region CheckRegion;
Point MouseLocation;
IdentifyPicture myIDPicture;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CheckRegion = new Region();
MouseLocation = new Point(0, 0);
myIDPicture = new IdentifyPicture(pictureBox_CP.Size, 10);
pictureBox_CP.Image = myIDPicture.IdPicture;
CheckRegion = myIDPicture.IdRegion; }
private void button_NewPicture_Click(object sender, EventArgs e)
{
myIDPicture = new IdentifyPicture(pictureBox_CP.Size, 10);
pictureBox_CP.Image = myIDPicture.IdPicture;
CheckRegion = myIDPicture.IdRegion; label_Result.Text = "?";
}
private void pictureBox_CP_Click(object sender, EventArgs e)
{
if (CheckRegion.IsVisible(MouseLocation))
label_Result.Text = "OK";
else
label_Result.Text = "?"; }
private void pictureBox_CP_MouseMove(object sender, MouseEventArgs e)
{
MouseLocation = e.Location;
}
private void pictureBox_CP_MouseLeave(object sender, EventArgs e)
{
MouseLocation = new Point(0, 0);
}
}
提供大家參考(重點用粗體字表示)...
若有錯請不吝指教...
有機會在改成.Net 控制項(Control)...
2009年7月22日 星期三
Google 的日全蝕

今天早上8點20分,全亞洲都在屏息以待一個天文奇觀,本世紀最長的日蝕現象將從上演,時間長達六分多鐘,是去年新疆日全蝕的近三倍,不過台灣只能看到日偏蝕...
其餘亞洲地區包括印度、尼泊爾、不丹、孟加拉、日本南部等地都可以看到日全蝕的景象,根據美國太空總署(NASA)運用Google Map的介面,在地圖上畫出了日全蝕所經過的地帶,其中中國大陸佔據了最大的區塊,日蝕最長的地區則是日本鹿兒島縣十島村的惡石島,時間長達6分20秒。日本的直播網站為:http://www.live-eclipse.org/
今年台灣只能看到日偏蝕的現象,不過到2012年3月21日台灣的基隆、台北、桃園、新竹、苗栗一代將可見到日環蝕;至於日全蝕的現象,則要等到2070年4月11日,地點在墾丁及蘭嶼一帶。
2009年7月20日 星期一
2009年7月10日 星期五
Parallel運算 in .NetFramework 4.0出現
架構圖
使用前必須先Using
System.Threading
System.Threading.Tasks
這兩個NameSpace
簡單範例:
....
Parallel.Invoke(
() => MethodA(),
() => MethodB(),
() => MethodC() );
....
private void MethodA()
{
MessageBox.Show("This is Method A");
}
private void MethodB()
{
MessageBox.Show("This is Method B");
}
private void MethodC()
{
MessageBox.Show("This is Method C");
}
相關文章:
http://msdn.microsoft.com/zh-tw/dd996613.aspx
http://msdn.microsoft.com/en-us/concurrency/default.aspx
http://msdn.microsoft.com/en-us/library/dd460693(VS.100).aspx
2009年7月6日 星期一
VS2005 屬性視窗 (Property Window) 不見了
今天早上開啟VS2005時發現,屬性視窗 (Property Window) 不見了,怎麼都叫不出來,這還得了...
趕緊上網用Google及Bing查詢結果,好像只有重新安裝一途,因為也嘗試過修復,依然是叫不出屬性視窗...
正打算重新安裝時,突然想到"工具"->"匯出及匯入設定",試看看說不一定可以死馬當活馬醫...
打開候選取"匯入選取的環境設定"
然後"瀏覽",選取檔案
然後選擇"CurrentSettings.vssettings",按OK.
檔案位於->..\Documents and Settings\(user name)\My Documents\Visual Studio 2005\Settings
匯入成功後,重新啟動VS2005,終於可以叫出"屬性視窗",哈哈....成功了,不用重新安裝....
2009年6月25日 星期四
iNo CP09,老人家專用手機

承認吧,今日的手機一點也不適合老人使用,它們充滿了太多先進的功能,觸控式螢幕、複雜的使用者介面、字體太小等等,就是不適合反科技者。所以你可以想像我的驚訝,當我才剛稱讚完日本人很有遠見懂得為老人設計手機,就已經有一家新加坡公司做出這樣的手機了。
看看Foresight Technologies推出的iNo CP09 ,一眼就能看出是為老人設計的:特大號的按鍵、大型字體、鈴聲大到可以叫醒死人。雖然它的螢幕只能顯示一排字且好像已經過時了,卻有助於延長電池的時間,且大型字體真的很容易看懂。
為了力求簡單並省去麻煩,你可以不在乎相機、全球衛星定位系統(GPS)、音樂播放器、藍芽等等的時尚功能,CP09有的是一些你爸爸會喜歡的有用功能。我們發現手機的左側有一個開關可啟動FM收音機,右側還有一個可啟動超級亮的LED照明燈。FM天線就設置在手機裡,所以爸爸們想聽收音機時不需時時記得得插上耳機。
CP09最獨特的功能是背部的大型橘色SOS(求救)按鍵,當這個按鍵在緊急時被按壓下,就會發送一個簡訊到指定的聯絡人手機裡,接著還會撥電話給這些人,且按下它也會啟動很大的警報聲。如果連這都還不能引起其他人的注意,那真的沒有別的東西可以了。這對於那些不放心把年老父母單獨留在家裡的人而言,的確是一個能讓他們少點擔憂的重要功能。
iNo CP09不是手機裡最好看的一個,但至少外型還能看,也蠻簡潔小巧的,此外還供應黑色、白色或金色款。上一次看到這支手機的零售價是在最近的新加坡電腦展 (Singapore PC Show),每支售價78星幣(約新台幣1765元),標準配件包含一個AC 充電器跟一個耳機。
2009年6月19日 星期五
HTML 2 PDF
難免有時候遇到網站關閉,以前可以輕易找到的參考資料,現在卻不見了...
爲此苦惱嗎?
以我來說,看到好的極具日後參考價值的網頁,我都會作保存的動作,不外乎是利用瀏覽器另存新檔的功能,就是SnagIt整個網頁照相存檔,但是今天找到一個不錯的網頁儲存工具 HTML->PDF
可以利用這個網頁,將HTML轉成PDF提供檢視及存檔
只需將想要轉換的網址輸入即可,視網頁的複雜程度,可能需要等一下子就OK了....










