├── .gitattributes ├── .gitignore ├── README.md ├── class-1-10 ├── Class2 │ ├── Class2.sln │ └── Class2 │ │ ├── App.config │ │ ├── Class2.csproj │ │ ├── Program.cs │ │ └── Properties │ │ └── AssemblyInfo.cs ├── Class3 │ ├── Class3.sln │ └── Class3 │ │ ├── App.config │ │ ├── Class3.csproj │ │ ├── Program.cs │ │ └── Properties │ │ └── AssemblyInfo.cs ├── Class4 │ ├── Class4.sln │ └── Class4 │ │ ├── App.config │ │ ├── Class4.csproj │ │ ├── Form1.Designer.cs │ │ ├── Form1.cs │ │ ├── Form1.resx │ │ ├── Program.cs │ │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings └── Class9 │ ├── Class9.sln │ └── Class9 │ ├── App.config │ ├── Class9.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── class-31-40 └── Class40 │ └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Gomoku.csproj │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ └── Resources │ ├── black.png │ ├── board.png │ └── white.png └── class-41-50 ├── Class41 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class42 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class43 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Board.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class44 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Board.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── PieceType.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class45 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Board.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Game.cs │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── PieceType.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class46 └── Gomoku │ ├── Gomoku.sln │ └── Gomoku │ ├── App.config │ ├── BlackPiece.cs │ ├── Board.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Game.cs │ ├── Gomoku.csproj │ ├── Piece.cs │ ├── PieceType.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── black.png │ ├── board.png │ └── white.png │ └── WhitePiece.cs ├── Class47 ├── Class47.sln └── Class47 │ ├── App.config │ ├── Class47.csproj │ ├── Creature.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Monster.cs │ ├── Player.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ └── Villager.cs ├── Class48 ├── Class48.sln └── Class48 │ ├── App.config │ ├── Class48.csproj │ ├── Creature.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── IAttackable.cs │ ├── ITalkable.cs │ ├── Monster.cs │ ├── Player.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ └── Villager.cs ├── Class49 └── Demo │ ├── Demo.sln │ └── Demo │ ├── App.config │ ├── Demo.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── Class50 └── Demo ├── Demo.sln └── Demo ├── App.config ├── Building.cs ├── Demo.csproj ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Resident.cs └── Worker.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C# projects 2 | bin 3 | obj 4 | 5 | # VS 6 | .vs 7 | packages 8 | 9 | # Unit Test 10 | TestResults 11 | 12 | # Configurations 13 | debug.config 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 範例程式碼 2 | 3 | 本程式庫存放了所有使用於「[小山的 C# 教學][1]」的程式碼。每一課的程式碼皆分開擺放,以方便學生直接開啟專案進行修改。 4 | 5 | 注意在課程之中,程式碼的專案名稱通常是「Test」、「Demo」等。這裡為了方便大家識別,每一課的程式碼皆以「ClassN」的形式命名,其中 N 為課程編號。 6 | 7 | 另外並非所有課程都會有範例程式碼,例如大多數介紹簡單語法的課程就不會再另外附上範例程式碼。通常是會有比較複雜的架構或著邏輯存在時才會附上程式碼供大家參考。 8 | 9 | 注意:目前尚未將所有程式碼放上來,未來會慢慢補足。 10 | 11 | ## 如何下載程式碼? 12 | 13 | 在這裡有兩種方式可以下載程式碼。 第一種是直接下載壓縮檔,另一種是使用 `git` 下載。 14 | 15 | ### 下載壓縮檔法 16 | 17 | 點選網頁右上角綠色的「Clone or download」,然後點選「Download ZIP」就可以下載壓縮檔了。 打開之後就能夠依照課程分類打開對應的程式碼。 18 | 19 | ### Git 複製 20 | 21 | 如果會使用 `git` 的話,請直接在你的命令提示字元或者 `git bash` 下執行以下指令: 22 | 23 | ``` 24 | $ git clone https://github.com/slmt-tutorial-channel/c-sharp-course-sample-code.git 25 | ``` 26 | 27 | 這樣就好囉! 28 | 29 | ## 目錄 30 | 31 | - [第 2 課 - IDE 跟 Hello World](class-1-10/Class2) 32 | - [第 3 課 - 程式結構與進入點](class-1-10/Class3) 33 | - [第 4 課 - 視窗與按鈕](class-1-10/Class4) 34 | - [第 9 課 - Label 與 點擊次數記錄程式](class-1-10/Class9) 35 | - [第 40 課 - 五子棋小遊戲 (一) - 棋盤與棋子](class-31-40/Class40) 36 | - [第 41 課 - 五子棋小遊戲 (二) - 動態建立棋子](class-41-50/Class41) 37 | - [第 42 課 - 五子棋小遊戲 (三) - 用滑鼠建立棋子](class-41-50/Class42) 38 | - [第 43 課 - 五子棋小遊戲 (四) - 判斷交差點的位置](class-41-50/Class43) 39 | - [第 44 課 - 五子棋小遊戲 (五) - 正確放置棋子](class-41-50/Class44) 40 | - [第 45 課 - 五子棋小遊戲 (六) - 重構與最後準備](class-41-50/Class45) 41 | - [第 46 課 - 五子棋小遊戲 (七) - 簡單勝利判斷](class-41-50/Class46) 42 | - [第 47 課 - 多型性 (Polymorphism)](class-41-50/Class47) 43 | - [第 48 課 - 介面 (Interface)](class-41-50/Class48) 44 | - [第 49 課 - 串列 (List)](class-41-50/Class49) 45 | - [第 50 課 - 泛型 (Generics) 的初步介紹](class-41-50/Class50) 46 | 47 | ## 錯誤回報 48 | 49 | 如果有發現任何錯誤,請在 [issue][2] 內回報,抑或是來信到 sam123456777+tutorial@gmail.com 信箱也可以。不過若有 Github 帳號建議留 issue 會比較方便追蹤,同時其他人若看到的話也能參與討論。 50 | 51 | [1]: https://www.youtube.com/playlist?list=PLbXghSoQcLZtWqTA8q1NsByVpINoROHHe 52 | [2]: https://github.com/slmt-tutorial-channel/c-sharp-course-sample-code/issues 53 | -------------------------------------------------------------------------------- /class-1-10/Class2/Class2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class2", "Class2\Class2.csproj", "{44F4D4D8-9FD1-475E-8825-E96BB3B0E050}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {44F4D4D8-9FD1-475E-8825-E96BB3B0E050}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {44F4D4D8-9FD1-475E-8825-E96BB3B0E050}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {44F4D4D8-9FD1-475E-8825-E96BB3B0E050}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {44F4D4D8-9FD1-475E-8825-E96BB3B0E050}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {92A97127-F4A7-4E2D-9D69-0E69F8AB606A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-1-10/Class2/Class2/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-1-10/Class2/Class2/Class2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {44F4D4D8-9FD1-475E-8825-E96BB3B0E050} 8 | Exe 9 | Class2 10 | Class2 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /class-1-10/Class2/Class2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class2 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | Console.WriteLine("Hello World! 歡迎學習 C#"); 14 | Console.ReadKey(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /class-1-10/Class2/Class2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class2")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("44f4d4d8-9fd1-475e-8825-e96bb3b0e050")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,或將組建編號或修訂編號設為預設值 33 | // 指定為預設值: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-1-10/Class3/Class3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class3", "Class3\Class3.csproj", "{B0E250E9-1DF7-450D-A1E7-24EF11FA244E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B0E250E9-1DF7-450D-A1E7-24EF11FA244E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B0E250E9-1DF7-450D-A1E7-24EF11FA244E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B0E250E9-1DF7-450D-A1E7-24EF11FA244E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B0E250E9-1DF7-450D-A1E7-24EF11FA244E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {D7D72C34-4981-415B-AE09-633AB5456B4A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-1-10/Class3/Class3/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-1-10/Class3/Class3/Class3.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B0E250E9-1DF7-450D-A1E7-24EF11FA244E} 8 | Exe 9 | Class3 10 | Class3 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /class-1-10/Class3/Class3/Program.cs: -------------------------------------------------------------------------------- 1 | // 程式庫 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Class3 // 自己命名的程式庫,像是一間公司 9 | { 10 | class Program // 負責程式庫中一個工作的元件,像是公司的部門 11 | { 12 | static void Main(string[] args) // 一個工作之中更細部的工作,像是公司部門內的小工作 13 | { 14 | // 在你的視窗上顯示右列文字 15 | Console.WriteLine("Hello World! 歡迎學習 C#"); 16 | Console.ReadKey(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /class-1-10/Class3/Class3/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class3")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class3")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("b0e250e9-1df7-450d-a1e7-24ef11fa244e")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,或將組建編號或修訂編號設為預設值 33 | // 指定為預設值: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class4", "Class4\Class4.csproj", "{F1D53C3C-47E5-4838-AD53-C7EA603C7594}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F1D53C3C-47E5-4838-AD53-C7EA603C7594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F1D53C3C-47E5-4838-AD53-C7EA603C7594}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F1D53C3C-47E5-4838-AD53-C7EA603C7594}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F1D53C3C-47E5-4838-AD53-C7EA603C7594}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3EE03536-1D64-4C1B-BE0B-49EBD60734C4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Class4.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F1D53C3C-47E5-4838-AD53-C7EA603C7594} 8 | WinExe 9 | Class4 10 | Class4 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Form 51 | 52 | 53 | Form1.cs 54 | 55 | 56 | 57 | 58 | Form1.cs 59 | 60 | 61 | ResXFileCodeGenerator 62 | Resources.Designer.cs 63 | Designer 64 | 65 | 66 | True 67 | Resources.resx 68 | 69 | 70 | SettingsSingleFileGenerator 71 | Settings.Designer.cs 72 | 73 | 74 | True 75 | Settings.settings 76 | True 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Class4 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.SuspendLayout(); 33 | // 34 | // button1 35 | // 36 | this.button1.Location = new System.Drawing.Point(91, 90); 37 | this.button1.Name = "button1"; 38 | this.button1.Size = new System.Drawing.Size(135, 58); 39 | this.button1.TabIndex = 0; 40 | this.button1.Text = "請按我~!!"; 41 | this.button1.UseVisualStyleBackColor = true; 42 | this.button1.Click += new System.EventHandler(this.button1_Click); 43 | // 44 | // Form1 45 | // 46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 48 | this.BackColor = System.Drawing.SystemColors.ActiveCaption; 49 | this.ClientSize = new System.Drawing.Size(332, 262); 50 | this.Controls.Add(this.button1); 51 | this.Name = "Form1"; 52 | this.Text = "這是我的視窗"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Button button1; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Class4 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | MessageBox.Show("哇~你發現我了!"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Class4 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class4")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class4")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("f1d53c3c-47e5-4838-ad53-c7ea603c7594")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,或將組建編號或修訂編號設為預設值 33 | // 指定為預設值: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class4.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Class4.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 56 | /// 使用這個強類型資源類別的資源查閱。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class4.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-1-10/Class4/Class4/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32228.343 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class9", "Class9\Class9.csproj", "{3A375F31-7A9D-4156-9BF5-AD712B9BDB73}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3A375F31-7A9D-4156-9BF5-AD712B9BDB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3A375F31-7A9D-4156-9BF5-AD712B9BDB73}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3A375F31-7A9D-4156-9BF5-AD712B9BDB73}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3A375F31-7A9D-4156-9BF5-AD712B9BDB73}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C3A378CC-12BE-4F3E-BC67-7D0CF32C315F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Class9.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3A375F31-7A9D-4156-9BF5-AD712B9BDB73} 8 | WinExe 9 | Class9 10 | Class9 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Form 51 | 52 | 53 | Form1.cs 54 | 55 | 56 | 57 | 58 | Form1.cs 59 | 60 | 61 | ResXFileCodeGenerator 62 | Resources.Designer.cs 63 | Designer 64 | 65 | 66 | True 67 | Resources.resx 68 | 69 | 70 | SettingsSingleFileGenerator 71 | Settings.Designer.cs 72 | 73 | 74 | True 75 | Settings.settings 76 | True 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Class9 3 | { 4 | partial class Form1 5 | { 6 | /// 7 | /// 設計工具所需的變數。 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// 清除任何使用中的資源。 13 | /// 14 | /// 如果應該處置受控資源則為 true,否則為 false。 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form 設計工具產生的程式碼 25 | 26 | /// 27 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 28 | /// 這個方法的內容。 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.button1 = new System.Windows.Forms.Button(); 33 | this.button2 = new System.Windows.Forms.Button(); 34 | this.timesLabel = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // button1 38 | // 39 | this.button1.Font = new System.Drawing.Font("新細明體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 40 | this.button1.Location = new System.Drawing.Point(59, 98); 41 | this.button1.Name = "button1"; 42 | this.button1.Size = new System.Drawing.Size(157, 52); 43 | this.button1.TabIndex = 0; 44 | this.button1.Text = "按我!"; 45 | this.button1.UseVisualStyleBackColor = true; 46 | this.button1.Click += new System.EventHandler(this.button1_Click); 47 | // 48 | // button2 49 | // 50 | this.button2.Font = new System.Drawing.Font("新細明體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 51 | this.button2.Location = new System.Drawing.Point(59, 177); 52 | this.button2.Name = "button2"; 53 | this.button2.Size = new System.Drawing.Size(157, 53); 54 | this.button2.TabIndex = 1; 55 | this.button2.Text = "重設"; 56 | this.button2.UseVisualStyleBackColor = true; 57 | this.button2.Click += new System.EventHandler(this.button2_Click); 58 | // 59 | // timesLabel 60 | // 61 | this.timesLabel.AutoSize = true; 62 | this.timesLabel.Font = new System.Drawing.Font("新細明體", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 63 | this.timesLabel.Location = new System.Drawing.Point(30, 37); 64 | this.timesLabel.Name = "timesLabel"; 65 | this.timesLabel.Size = new System.Drawing.Size(226, 27); 66 | this.timesLabel.TabIndex = 2; 67 | this.timesLabel.Text = "你已經按了 ... 0 下"; 68 | // 69 | // Form1 70 | // 71 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 72 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 73 | this.ClientSize = new System.Drawing.Size(284, 261); 74 | this.Controls.Add(this.timesLabel); 75 | this.Controls.Add(this.button2); 76 | this.Controls.Add(this.button1); 77 | this.Name = "Form1"; 78 | this.Text = "按鈕點擊次數記錄程式"; 79 | this.ResumeLayout(false); 80 | this.PerformLayout(); 81 | 82 | } 83 | 84 | #endregion 85 | 86 | private System.Windows.Forms.Button button1; 87 | private System.Windows.Forms.Button button2; 88 | private System.Windows.Forms.Label timesLabel; 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Class9 12 | { 13 | public partial class Form1 : Form 14 | { 15 | int times = 0; 16 | 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void button1_Click(object sender, EventArgs e) 23 | { 24 | times++; 25 | timesLabel.Text = "你已經按了 ... " + times + " 下"; 26 | } 27 | 28 | private void button2_Click(object sender, EventArgs e) 29 | { 30 | times = 0; 31 | timesLabel.Text = "你已經按了 ... " + times + " 下"; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Class9 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class9")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class9")] 13 | [assembly: AssemblyCopyright("Copyright © 2023")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("3a375f31-7a9d-4156-9bf5-ad712b9bdb73")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace Class9.Properties 13 | { 14 | /// 15 | /// 用於查詢當地語系化字串等的強類型資源類別 16 | /// 17 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 18 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 19 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 20 | // (利用 /str 選項),或重建您的 VS 專案。 21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | internal class Resources 25 | { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() 33 | { 34 | } 35 | 36 | /// 37 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 38 | /// 39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 40 | internal static global::System.Resources.ResourceManager ResourceManager 41 | { 42 | get 43 | { 44 | if ((resourceMan == null)) 45 | { 46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Class9.Properties.Resources", typeof(Resources).Assembly); 47 | resourceMan = temp; 48 | } 49 | return resourceMan; 50 | } 51 | } 52 | 53 | /// 54 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 55 | /// 使用這個強類型資源類別的資源查閱。 56 | /// 57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 58 | internal static global::System.Globalization.CultureInfo Culture 59 | { 60 | get 61 | { 62 | return resourceCulture; 63 | } 64 | set 65 | { 66 | resourceCulture = value; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace Class9.Properties 13 | { 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 17 | { 18 | 19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 20 | 21 | public static Settings Default 22 | { 23 | get 24 | { 25 | return defaultInstance; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /class-1-10/Class9/Class9/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 32 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 33 | this.SuspendLayout(); 34 | // 35 | // pictureBox1 36 | // 37 | this.pictureBox1.BackColor = System.Drawing.Color.Transparent; 38 | this.pictureBox1.Image = global::Gomoku.Properties.Resources.black; 39 | this.pictureBox1.Location = new System.Drawing.Point(351, 198); 40 | this.pictureBox1.Name = "pictureBox1"; 41 | this.pictureBox1.Size = new System.Drawing.Size(50, 50); 42 | this.pictureBox1.TabIndex = 0; 43 | this.pictureBox1.TabStop = false; 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 50 | this.ClientSize = new System.Drawing.Size(750, 735); 51 | this.Controls.Add(this.pictureBox1); 52 | this.Name = "Form1"; 53 | this.Text = "Form1"; 54 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 55 | this.ResumeLayout(false); 56 | 57 | } 58 | 59 | #endregion 60 | 61 | private System.Windows.Forms.PictureBox pictureBox1; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-31-40/Class40/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-31-40/Class40/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-31-40/Class40/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-31-40/Class40/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.ResumeLayout(false); 42 | 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | 19 | this.Controls.Add(new BlackPiece(10, 20)); 20 | this.Controls.Add(new WhitePiece(100, 200)); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | public Piece(int x, int y) 14 | { 15 | this.BackColor = Color.Transparent; 16 | this.Location = new Point(x, y); 17 | this.Size = new Size(50, 50); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class41/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class41/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class41/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class41/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 42 | this.ResumeLayout(false); 43 | 44 | } 45 | 46 | #endregion 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | private bool isBlack = true; 16 | 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void Form1_MouseDown(object sender, MouseEventArgs e) 23 | { 24 | if (isBlack) 25 | { 26 | this.Controls.Add(new BlackPiece(e.X, e.Y)); 27 | isBlack = false; 28 | } else 29 | { 30 | this.Controls.Add(new WhitePiece(e.X, e.Y)); 31 | isBlack = true; 32 | } 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | private static readonly int IMAGE_WIDTH = 50; 14 | 15 | public Piece(int x, int y) 16 | { 17 | this.BackColor = Color.Transparent; 18 | this.Location = new Point(x - IMAGE_WIDTH / 2, y - IMAGE_WIDTH / 2); 19 | this.Size = new Size(IMAGE_WIDTH, IMAGE_WIDTH); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class42/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class42/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class42/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class42/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Board.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | 8 | namespace Gomoku 9 | { 10 | class Board 11 | { 12 | private static readonly Point NO_MATCH_NODE = new Point(-1, -1); 13 | 14 | private static readonly int OFFSET = 75; 15 | private static readonly int NODE_RADIUS = 10; 16 | private static readonly int NODE_DISTANCE = 75; 17 | 18 | public bool CanBePlaced(int x, int y) 19 | { 20 | // 找出最近的節點 (Node) 21 | Point nodeId = FindTheClosetNode(x, y); 22 | 23 | // 如果沒有的話,回傳 false 24 | if (nodeId == NO_MATCH_NODE) 25 | return false; 26 | 27 | // TODO: 如果有的話,檢查是否已經棋子存在 28 | 29 | return true; 30 | } 31 | 32 | private Point FindTheClosetNode(int x, int y) 33 | { 34 | int nodeIdX = FindTheClosetNode(x); 35 | if (nodeIdX == -1) 36 | return NO_MATCH_NODE; 37 | 38 | int nodeIdY = FindTheClosetNode(y); 39 | if (nodeIdY == -1) 40 | return NO_MATCH_NODE; 41 | 42 | return new Point(nodeIdX, nodeIdY); 43 | } 44 | 45 | private int FindTheClosetNode(int pos) 46 | { 47 | if (pos < OFFSET - NODE_RADIUS) 48 | return -1; 49 | 50 | pos -= OFFSET; 51 | 52 | int quotient = pos / NODE_DISTANCE; 53 | int remainder = pos % NODE_DISTANCE; 54 | 55 | if (remainder <= NODE_RADIUS) 56 | return quotient; 57 | else if (remainder >= NODE_DISTANCE - NODE_RADIUS) 58 | return quotient + 1; 59 | else 60 | return -1; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 42 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); 43 | this.ResumeLayout(false); 44 | 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | private Board board = new Board(); 16 | 17 | private bool isBlack = true; 18 | 19 | public Form1() 20 | { 21 | InitializeComponent(); 22 | } 23 | 24 | private void Form1_MouseDown(object sender, MouseEventArgs e) 25 | { 26 | if (isBlack) 27 | { 28 | this.Controls.Add(new BlackPiece(e.X, e.Y)); 29 | isBlack = false; 30 | } else 31 | { 32 | this.Controls.Add(new WhitePiece(e.X, e.Y)); 33 | isBlack = true; 34 | } 35 | 36 | } 37 | 38 | private void Form1_MouseMove(object sender, MouseEventArgs e) 39 | { 40 | if (board.CanBePlaced(e.X, e.Y)) 41 | { 42 | this.Cursor = Cursors.Hand; 43 | } else 44 | { 45 | this.Cursor = Cursors.Default; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | private static readonly int IMAGE_WIDTH = 50; 14 | 15 | public Piece(int x, int y) 16 | { 17 | this.BackColor = Color.Transparent; 18 | this.Location = new Point(x - IMAGE_WIDTH / 2, y - IMAGE_WIDTH / 2); 19 | this.Size = new Size(IMAGE_WIDTH, IMAGE_WIDTH); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class43/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class43/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class43/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class43/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Board.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | 8 | namespace Gomoku 9 | { 10 | class Board 11 | { 12 | private static readonly Point NO_MATCH_NODE = new Point(-1, -1); 13 | 14 | private static readonly int OFFSET = 75; 15 | private static readonly int NODE_RADIUS = 10; 16 | private static readonly int NODE_DISTANCE = 75; 17 | 18 | private Piece[,] pieces = new Piece[9, 9]; 19 | 20 | public bool CanBePlaced(int x, int y) 21 | { 22 | // 找出最近的節點 (Node) 23 | Point nodeId = findTheClosetNode(x, y); 24 | 25 | // 如果沒有的話,回傳 false 26 | if (nodeId == NO_MATCH_NODE) 27 | return false; 28 | 29 | // 如果有的話,檢查是否已經棋子存在 30 | if (pieces[nodeId.X, nodeId.Y] != null) 31 | return false; 32 | 33 | return true; 34 | } 35 | 36 | public Piece PlaceAPiece(int x, int y, PieceType type) 37 | { 38 | // 找出最近的節點 (Node) 39 | Point nodeId = findTheClosetNode(x, y); 40 | 41 | // 如果沒有的話,回傳 false 42 | if (nodeId == NO_MATCH_NODE) 43 | return null; 44 | 45 | // 如果有的話,檢查是否已經棋子存在 46 | if (pieces[nodeId.X, nodeId.Y] != null) 47 | return null; 48 | 49 | // 根據 type 產生對應的棋子 50 | Point formPos = convertToFormPosition(nodeId); 51 | if (type == PieceType.BLACK) 52 | pieces[nodeId.X, nodeId.Y] = new BlackPiece(formPos.X, formPos.Y); 53 | else if (type == PieceType.WHITE) 54 | pieces[nodeId.X, nodeId.Y] = new WhitePiece(formPos.X, formPos.Y); 55 | 56 | return pieces[nodeId.X, nodeId.Y]; 57 | } 58 | 59 | private Point convertToFormPosition(Point nodeId) 60 | { 61 | Point formPosition = new Point(); 62 | formPosition.X = nodeId.X * NODE_DISTANCE + OFFSET; 63 | formPosition.Y = nodeId.Y * NODE_DISTANCE + OFFSET; 64 | return formPosition; 65 | } 66 | 67 | private Point findTheClosetNode(int x, int y) 68 | { 69 | int nodeIdX = findTheClosetNode(x); 70 | if (nodeIdX == -1) 71 | return NO_MATCH_NODE; 72 | 73 | int nodeIdY = findTheClosetNode(y); 74 | if (nodeIdY == -1) 75 | return NO_MATCH_NODE; 76 | 77 | return new Point(nodeIdX, nodeIdY); 78 | } 79 | 80 | private int findTheClosetNode(int pos) 81 | { 82 | if (pos < OFFSET - NODE_RADIUS) 83 | return -1; 84 | 85 | pos -= OFFSET; 86 | 87 | int quotient = pos / NODE_DISTANCE; 88 | int remainder = pos % NODE_DISTANCE; 89 | 90 | if (remainder <= NODE_RADIUS) 91 | return quotient; 92 | else if (remainder >= NODE_DISTANCE - NODE_RADIUS) 93 | return quotient + 1; 94 | else 95 | return -1; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 42 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); 43 | this.ResumeLayout(false); 44 | 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | private Board board = new Board(); 16 | 17 | private PieceType nextPieceType = PieceType.BLACK; 18 | 19 | public Form1() 20 | { 21 | InitializeComponent(); 22 | } 23 | 24 | private void Form1_MouseDown(object sender, MouseEventArgs e) 25 | { 26 | Piece piece = board.PlaceAPiece(e.X, e.Y, nextPieceType); 27 | if (piece != null) 28 | { 29 | this.Controls.Add(piece); 30 | 31 | if (nextPieceType == PieceType.BLACK) 32 | nextPieceType = PieceType.WHITE; 33 | else if (nextPieceType == PieceType.WHITE) 34 | nextPieceType = PieceType.BLACK; 35 | } 36 | } 37 | 38 | private void Form1_MouseMove(object sender, MouseEventArgs e) 39 | { 40 | if (board.CanBePlaced(e.X, e.Y)) 41 | { 42 | this.Cursor = Cursors.Hand; 43 | } else 44 | { 45 | this.Cursor = Cursors.Default; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | private static readonly int IMAGE_WIDTH = 50; 14 | 15 | public Piece(int x, int y) 16 | { 17 | this.BackColor = Color.Transparent; 18 | this.Location = new Point(x - IMAGE_WIDTH / 2, y - IMAGE_WIDTH / 2); 19 | this.Size = new Size(IMAGE_WIDTH, IMAGE_WIDTH); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/PieceType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | enum PieceType 10 | { 11 | BLACK, WHITE 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class44/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class44/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class44/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class44/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | 16 | public override PieceType GetPieceType() 17 | { 18 | return PieceType.BLACK; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Board.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | 8 | namespace Gomoku 9 | { 10 | class Board 11 | { 12 | private static readonly int NODE_COUNT = 9; 13 | 14 | private static readonly Point NO_MATCH_NODE = new Point(-1, -1); 15 | 16 | private static readonly int OFFSET = 75; 17 | private static readonly int NODE_RADIUS = 10; 18 | private static readonly int NODE_DISTANCE = 75; 19 | 20 | private Piece[,] pieces = new Piece[NODE_COUNT, NODE_COUNT]; 21 | 22 | public PieceType GetPieceType(int nodeIdX, int nodeIdY) 23 | { 24 | if (pieces[nodeIdX, nodeIdY] == null) 25 | return PieceType.NONE; 26 | else 27 | return pieces[nodeIdX, nodeIdY].GetPieceType(); 28 | } 29 | 30 | public bool CanBePlaced(int x, int y) 31 | { 32 | // 找出最近的節點 (Node) 33 | Point nodeId = findTheClosetNode(x, y); 34 | 35 | // 如果沒有的話,回傳 false 36 | if (nodeId == NO_MATCH_NODE) 37 | return false; 38 | 39 | // 如果有的話,檢查是否已經棋子存在 40 | if (pieces[nodeId.X, nodeId.Y] != null) 41 | return false; 42 | 43 | return true; 44 | } 45 | 46 | public Piece PlaceAPiece(int x, int y, PieceType type) 47 | { 48 | // 找出最近的節點 (Node) 49 | Point nodeId = findTheClosetNode(x, y); 50 | 51 | // 如果沒有的話,回傳 false 52 | if (nodeId == NO_MATCH_NODE) 53 | return null; 54 | 55 | // 如果有的話,檢查是否已經棋子存在 56 | if (pieces[nodeId.X, nodeId.Y] != null) 57 | return null; 58 | 59 | // 根據 type 產生對應的棋子 60 | Point formPos = convertToFormPosition(nodeId); 61 | if (type == PieceType.BLACK) 62 | pieces[nodeId.X, nodeId.Y] = new BlackPiece(formPos.X, formPos.Y); 63 | else if (type == PieceType.WHITE) 64 | pieces[nodeId.X, nodeId.Y] = new WhitePiece(formPos.X, formPos.Y); 65 | 66 | return pieces[nodeId.X, nodeId.Y]; 67 | } 68 | 69 | private Point convertToFormPosition(Point nodeId) 70 | { 71 | Point formPosition = new Point(); 72 | formPosition.X = nodeId.X * NODE_DISTANCE + OFFSET; 73 | formPosition.Y = nodeId.Y * NODE_DISTANCE + OFFSET; 74 | return formPosition; 75 | } 76 | 77 | private Point findTheClosetNode(int x, int y) 78 | { 79 | int nodeIdX = findTheClosetNode(x); 80 | if (nodeIdX == -1 || nodeIdX >= NODE_COUNT) 81 | return NO_MATCH_NODE; 82 | 83 | int nodeIdY = findTheClosetNode(y); 84 | if (nodeIdY == -1 || nodeIdY >= NODE_COUNT) 85 | return NO_MATCH_NODE; 86 | 87 | return new Point(nodeIdX, nodeIdY); 88 | } 89 | 90 | private int findTheClosetNode(int pos) 91 | { 92 | if (pos < OFFSET - NODE_RADIUS) 93 | return -1; 94 | 95 | pos -= OFFSET; 96 | 97 | int quotient = pos / NODE_DISTANCE; 98 | int remainder = pos % NODE_DISTANCE; 99 | 100 | if (remainder <= NODE_RADIUS) 101 | return quotient; 102 | else if (remainder >= NODE_DISTANCE - NODE_RADIUS) 103 | return quotient + 1; 104 | else 105 | return -1; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 42 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); 43 | this.ResumeLayout(false); 44 | 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | private Game game = new Game(); 16 | 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void Form1_MouseDown(object sender, MouseEventArgs e) 23 | { 24 | Piece piece = game.PlaceAPiece(e.X, e.Y); 25 | if (piece != null) 26 | { 27 | this.Controls.Add(piece); 28 | } 29 | } 30 | 31 | private void Form1_MouseMove(object sender, MouseEventArgs e) 32 | { 33 | if (game.CanBePlaced(e.X, e.Y)) 34 | { 35 | this.Cursor = Cursors.Hand; 36 | } else 37 | { 38 | this.Cursor = Cursors.Default; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Game.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class Game 10 | { 11 | private Board board = new Board(); 12 | 13 | private PieceType currentPlayer = PieceType.BLACK; 14 | 15 | public bool CanBePlaced(int x, int y) 16 | { 17 | return board.CanBePlaced(x, y); 18 | } 19 | 20 | public Piece PlaceAPiece(int x, int y) 21 | { 22 | Piece piece = board.PlaceAPiece(x, y, currentPlayer); 23 | if (piece != null) 24 | { 25 | if (currentPlayer == PieceType.BLACK) 26 | currentPlayer = PieceType.WHITE; 27 | else if (currentPlayer == PieceType.WHITE) 28 | currentPlayer = PieceType.BLACK; 29 | 30 | return piece; 31 | } 32 | 33 | return null; 34 | } 35 | 36 | private void CheckWinner() 37 | { 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | private static readonly int IMAGE_WIDTH = 50; 14 | 15 | public Piece(int x, int y) 16 | { 17 | this.BackColor = Color.Transparent; 18 | this.Location = new Point(x - IMAGE_WIDTH / 2, y - IMAGE_WIDTH / 2); 19 | this.Size = new Size(IMAGE_WIDTH, IMAGE_WIDTH); 20 | } 21 | 22 | public abstract PieceType GetPieceType(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/PieceType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | enum PieceType 10 | { 11 | BLACK, WHITE, NONE 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class45/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class45/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class45/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class45/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | 16 | public override PieceType GetPieceType() 17 | { 18 | return PieceType.WHITE; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gomoku", "Gomoku\Gomoku.csproj", "{2D665281-EC19-4931-BD87-FBC4F6EC8B42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2D665281-EC19-4931-BD87-FBC4F6EC8B42}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A49457B0-93BA-488C-90CB-D94BFD47F7DB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/BlackPiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class BlackPiece : Piece 10 | { 11 | public BlackPiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.black; 14 | } 15 | 16 | public override PieceType GetPieceType() 17 | { 18 | return PieceType.BLACK; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gomoku 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.BackgroundImage = global::Gomoku.Properties.Resources.board; 38 | this.ClientSize = new System.Drawing.Size(750, 735); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 42 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); 43 | this.ResumeLayout(false); 44 | 45 | } 46 | 47 | #endregion 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Gomoku 12 | { 13 | public partial class Form1 : Form 14 | { 15 | private Game game = new Game(); 16 | 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void Form1_MouseDown(object sender, MouseEventArgs e) 23 | { 24 | Piece piece = game.PlaceAPiece(e.X, e.Y); 25 | if (piece != null) 26 | { 27 | this.Controls.Add(piece); 28 | 29 | // 檢查是否有人獲勝 30 | if (game.Winner == PieceType.BLACK) 31 | { 32 | MessageBox.Show("黑色獲勝"); 33 | } else if (game.Winner == PieceType.WHITE) 34 | { 35 | MessageBox.Show("白色獲勝"); 36 | } 37 | } 38 | } 39 | 40 | private void Form1_MouseMove(object sender, MouseEventArgs e) 41 | { 42 | if (game.CanBePlaced(e.X, e.Y)) 43 | { 44 | this.Cursor = Cursors.Hand; 45 | } else 46 | { 47 | this.Cursor = Cursors.Default; 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Game.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class Game 10 | { 11 | private Board board = new Board(); 12 | 13 | private PieceType currentPlayer = PieceType.BLACK; 14 | 15 | private PieceType winner = PieceType.NONE; 16 | public PieceType Winner { get { return winner; } } 17 | 18 | public bool CanBePlaced(int x, int y) 19 | { 20 | return board.CanBePlaced(x, y); 21 | } 22 | 23 | public Piece PlaceAPiece(int x, int y) 24 | { 25 | Piece piece = board.PlaceAPiece(x, y, currentPlayer); 26 | if (piece != null) 27 | { 28 | // 檢查是否現在下棋的人獲勝 29 | CheckWinner(); 30 | 31 | // 交換選手 32 | if (currentPlayer == PieceType.BLACK) 33 | currentPlayer = PieceType.WHITE; 34 | else if (currentPlayer == PieceType.WHITE) 35 | currentPlayer = PieceType.BLACK; 36 | 37 | return piece; 38 | } 39 | 40 | return null; 41 | } 42 | 43 | private void CheckWinner() 44 | { 45 | int centerX = board.LastPlacedNode.X; 46 | int centerY = board.LastPlacedNode.Y; 47 | 48 | // 檢查八個不同方向 49 | for (int xDir = -1; xDir <= 1; xDir++) { 50 | for (int yDir = -1; yDir <= 1; yDir++) { 51 | // 排除中間的情況 52 | if (xDir == 0 && yDir == 0) 53 | continue; 54 | 55 | // 紀錄現在看到幾顆相同的棋子 56 | int count = 1; 57 | while (count < 5) 58 | { 59 | int targetX = centerX + count * xDir; 60 | int targetY = centerY + count * yDir; 61 | 62 | // 檢查顏色是否相同 63 | if (targetX < 0 || targetX >= Board.NODE_COUNT || 64 | targetY < 0 || targetY >= Board.NODE_COUNT || 65 | board.GetPieceType(targetX, targetY) != currentPlayer) 66 | break; 67 | 68 | count++; 69 | } 70 | 71 | // 檢查是否看到五顆棋子 72 | if (count == 5) 73 | winner = currentPlayer; 74 | } 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Piece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace Gomoku 10 | { 11 | abstract class Piece : PictureBox 12 | { 13 | private static readonly int IMAGE_WIDTH = 50; 14 | 15 | public Piece(int x, int y) 16 | { 17 | this.BackColor = Color.Transparent; 18 | this.Location = new Point(x - IMAGE_WIDTH / 2, y - IMAGE_WIDTH / 2); 19 | this.Size = new Size(IMAGE_WIDTH, IMAGE_WIDTH); 20 | } 21 | 22 | public abstract PieceType GetPieceType(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/PieceType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | enum PieceType 10 | { 11 | BLACK, WHITE, NONE 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Gomoku 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Gomoku")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gomoku")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("2d665281-ec19-4931-bd87-fbc4f6ec8b42")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, 7 | // 變更將會遺失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別。 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gomoku.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 51 | /// 使用這個強類型資源類別的資源查閱。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 65 | /// 66 | internal static System.Drawing.Bitmap black { 67 | get { 68 | object obj = ResourceManager.GetObject("black", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 75 | /// 76 | internal static System.Drawing.Bitmap board { 77 | get { 78 | object obj = ResourceManager.GetObject("board", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查詢類型 System.Drawing.Bitmap 的當地語系化資源。 85 | /// 86 | internal static System.Drawing.Bitmap white { 87 | get { 88 | object obj = ResourceManager.GetObject("white", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gomoku.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Resources/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class46/Gomoku/Gomoku/Resources/black.png -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Resources/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class46/Gomoku/Gomoku/Resources/board.png -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/Resources/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slmt-tutorial-channel/c-sharp-course-sample-code/e64c46dfbc8ea6489e9d3c9baace9dbb4ace9cbd/class-41-50/Class46/Gomoku/Gomoku/Resources/white.png -------------------------------------------------------------------------------- /class-41-50/Class46/Gomoku/Gomoku/WhitePiece.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gomoku 8 | { 9 | class WhitePiece : Piece 10 | { 11 | public WhitePiece(int x, int y) : base(x, y) 12 | { 13 | this.Image = Properties.Resources.white; 14 | } 15 | 16 | public override PieceType GetPieceType() 17 | { 18 | return PieceType.WHITE; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class47", "Class47\Class47.csproj", "{C50F46D4-33AF-4F1F-B8F6-CA7E78229C4D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C50F46D4-33AF-4F1F-B8F6-CA7E78229C4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C50F46D4-33AF-4F1F-B8F6-CA7E78229C4D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C50F46D4-33AF-4F1F-B8F6-CA7E78229C4D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C50F46D4-33AF-4F1F-B8F6-CA7E78229C4D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {FD37D27C-F36C-44B6-B41B-9F4751915191} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Creature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class47 8 | { 9 | class Creature 10 | { 11 | protected int hp; 12 | protected string name; 13 | 14 | public Creature(string name) 15 | { 16 | this.name = name; 17 | this.hp = 100; 18 | } 19 | 20 | public void injured(int damage) 21 | { 22 | if (damage > hp) 23 | { 24 | this.hp = 0; 25 | } else 26 | { 27 | this.hp -= damage; 28 | } 29 | } 30 | 31 | public virtual string say() 32 | { 33 | return "我是 " + name + ",我有 " + hp + " 滴血"; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Class47 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.SuspendLayout(); 33 | // 34 | // button1 35 | // 36 | this.button1.Font = new System.Drawing.Font("微軟正黑體", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 37 | this.button1.Location = new System.Drawing.Point(79, 97); 38 | this.button1.Name = "button1"; 39 | this.button1.Size = new System.Drawing.Size(179, 86); 40 | this.button1.TabIndex = 0; 41 | this.button1.Text = "按我測試"; 42 | this.button1.UseVisualStyleBackColor = true; 43 | this.button1.Click += new System.EventHandler(this.button1_Click); 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(346, 301); 50 | this.Controls.Add(this.button1); 51 | this.Name = "Form1"; 52 | this.Text = "Form1"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Button button1; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Class47 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | Player p = new Player("小山貓"); 23 | Villager v = new Villager(); 24 | 25 | Monster m = new Monster(); 26 | m.attack(p); 27 | m.attack(v); 28 | 29 | MessageBox.Show(p.say()); 30 | MessageBox.Show(v.say()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Monster.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class47 8 | { 9 | class Monster 10 | { 11 | public void attack(Creature c) 12 | { 13 | c.injured(10); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class47 8 | { 9 | class Player : Creature 10 | { 11 | public Player(string name) : base(name) 12 | { 13 | 14 | } 15 | 16 | public override string say() 17 | { 18 | return "哈哈!我是玩家 " + name + ",我有 " + hp + " 滴血"; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Class47 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class47")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class47")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("c50f46d4-33af-4f1f-b8f6-ca7e78229c4d")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class47.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Class47.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 56 | /// 使用這個強類型資源類別的資源查閱。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class47.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class47/Class47/Villager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class47 8 | { 9 | class Villager : Creature 10 | { 11 | public Villager() : base("村民") 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Class48", "Class48\Class48.csproj", "{18CA57D3-40EB-4564-AA48-2D4F0E6814ED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {18CA57D3-40EB-4564-AA48-2D4F0E6814ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {18CA57D3-40EB-4564-AA48-2D4F0E6814ED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {18CA57D3-40EB-4564-AA48-2D4F0E6814ED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {18CA57D3-40EB-4564-AA48-2D4F0E6814ED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {79A8ACFD-951D-4EA6-B824-74124ECF0805} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Creature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | abstract class Creature 10 | { 11 | protected int hp = 100; 12 | 13 | public virtual string say() 14 | { 15 | return "Hi~ 我是 " + getName() + ",我有 " + hp + " 滴血"; 16 | } 17 | 18 | public void injured(int damage) 19 | { 20 | hp -= damage; 21 | } 22 | 23 | public abstract string getName(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Class48 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.SuspendLayout(); 33 | // 34 | // button1 35 | // 36 | this.button1.Font = new System.Drawing.Font("微軟正黑體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 37 | this.button1.Location = new System.Drawing.Point(80, 76); 38 | this.button1.Name = "button1"; 39 | this.button1.Size = new System.Drawing.Size(157, 61); 40 | this.button1.TabIndex = 0; 41 | this.button1.Text = "按我測試"; 42 | this.button1.UseVisualStyleBackColor = true; 43 | this.button1.Click += new System.EventHandler(this.button1_Click); 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(331, 219); 50 | this.Controls.Add(this.button1); 51 | this.Name = "Form1"; 52 | this.Text = "Form1"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Button button1; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Class48 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | Creature creature = new Villager(); 23 | 24 | ITalkable someone = new Player(); 25 | MessageBox.Show(someone.talkTo(creature)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/IAttackable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | interface IAttackable 10 | { 11 | void attack(Creature target); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/ITalkable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | interface ITalkable 10 | { 11 | string talkTo(Creature target); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Monster.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | class Monster : Creature, IAttackable 10 | { 11 | public override string say() 12 | { 13 | return "吼吼吼~ (有 " + hp + " 滴血)"; 14 | } 15 | 16 | public override string getName() 17 | { 18 | return "怪物"; 19 | } 20 | 21 | public void attack(Creature target) 22 | { 23 | target.injured(5); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | class Player : Creature, IAttackable, ITalkable 10 | { 11 | public override string getName() 12 | { 13 | return "玩家"; 14 | } 15 | public void attack(Creature target) 16 | { 17 | target.injured(30); 18 | } 19 | 20 | public string talkTo(Creature target) 21 | { 22 | return "Hi~" + target.getName() + "!我是玩家!"; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Class48 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Class48")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Class48")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("18ca57d3-40eb-4564-aa48-2d4f0e6814ed")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class48.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Class48.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 56 | /// 使用這個強類型資源類別的資源查閱。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Class48.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class48/Class48/Villager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Class48 8 | { 9 | class Villager : Creature, ITalkable 10 | { 11 | public override string getName() 12 | { 13 | return "村民"; 14 | } 15 | 16 | public string talkTo(Creature target) 17 | { 18 | return "Hi~" + target.getName() + "!我是村民!"; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{8755CE51-A2BA-4096-B309-FB2DA2782C78}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9E4190A2-AED0-4FCE-B304-428BE48849F1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Demo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8755CE51-A2BA-4096-B309-FB2DA2782C78} 8 | WinExe 9 | Demo 10 | Demo 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Form 51 | 52 | 53 | Form1.cs 54 | 55 | 56 | 57 | 58 | Form1.cs 59 | 60 | 61 | ResXFileCodeGenerator 62 | Resources.Designer.cs 63 | Designer 64 | 65 | 66 | True 67 | Resources.resx 68 | 69 | 70 | SettingsSingleFileGenerator 71 | Settings.Designer.cs 72 | 73 | 74 | True 75 | Settings.settings 76 | True 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Demo 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.SuspendLayout(); 33 | // 34 | // button1 35 | // 36 | this.button1.Font = new System.Drawing.Font("微軟正黑體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 37 | this.button1.Location = new System.Drawing.Point(60, 51); 38 | this.button1.Name = "button1"; 39 | this.button1.Size = new System.Drawing.Size(174, 70); 40 | this.button1.TabIndex = 0; 41 | this.button1.Text = "按我按我~"; 42 | this.button1.UseVisualStyleBackColor = true; 43 | this.button1.Click += new System.EventHandler(this.button1_Click); 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(307, 188); 50 | this.Controls.Add(this.button1); 51 | this.Name = "Form1"; 52 | this.Text = "Form1"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Button button1; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Demo 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | List list = new List(); 23 | 24 | list.Add(5124); 25 | list.Add(232); 26 | list.Add(161636); 27 | list.Add(34); 28 | 29 | list.Sort(); 30 | 31 | for (int i = 0; i < list.Count; i++) 32 | { 33 | MessageBox.Show("List 的第 " + i + " 個資料是: " + list[i]); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Demo 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Demo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Demo")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("8755ce51-a2ba-4096-b309-fb2da2782c78")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Demo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 56 | /// 使用這個強類型資源類別的資源查閱。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Demo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class49/Demo/Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{8755CE51-A2BA-4096-B309-FB2DA2782C78}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8755CE51-A2BA-4096-B309-FB2DA2782C78}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9E4190A2-AED0-4FCE-B304-428BE48849F1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Building.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Demo 8 | { 9 | class Building

10 | { 11 | List

people = new List

(); 12 | 13 | public void Add(P person) 14 | { 15 | people.Add(person); 16 | } 17 | 18 | public override String ToString() 19 | { 20 | String output = "這棟大樓裡有:\r\n"; 21 | 22 | for (int i = 0; i < people.Count; i++) 23 | { 24 | output += people[i].ToString() + "\r\n"; 25 | } 26 | 27 | return output; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Demo 2 | { 3 | partial class Form1 4 | { 5 | ///

6 | /// 設計工具所需的變數。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清除任何使用中的資源。 12 | /// 13 | /// 如果應該處置受控資源則為 true,否則為 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form 設計工具產生的程式碼 24 | 25 | /// 26 | /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 27 | /// 這個方法的內容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.SuspendLayout(); 33 | // 34 | // button1 35 | // 36 | this.button1.Font = new System.Drawing.Font("微軟正黑體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136))); 37 | this.button1.Location = new System.Drawing.Point(60, 51); 38 | this.button1.Name = "button1"; 39 | this.button1.Size = new System.Drawing.Size(174, 70); 40 | this.button1.TabIndex = 0; 41 | this.button1.Text = "按我按我~"; 42 | this.button1.UseVisualStyleBackColor = true; 43 | this.button1.Click += new System.EventHandler(this.button1_Click); 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(307, 188); 50 | this.Controls.Add(this.button1); 51 | this.Name = "Form1"; 52 | this.Text = "Form1"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Button button1; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace Demo 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | Building b = new Building(); 23 | 24 | b.Add(new Worker("小山貓")); 25 | b.Add(new Worker("大山貓")); 26 | 27 | b.Add(new Resident("哈哈")); 28 | 29 | MessageBox.Show(b.ToString()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Demo 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 應用程式的主要進入點。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 組件的一般資訊是由下列的屬性集控制。 6 | // 變更這些屬性的值即可修改組件的相關 7 | // 資訊。 8 | [assembly: AssemblyTitle("Demo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Demo")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 將 ComVisible 設為 false 可對 COM 元件隱藏 18 | // 組件中的類型。若必須從 COM 存取此組件中的類型, 19 | // 的類型,請在該類型上將 ComVisible 屬性設定為 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID 23 | [assembly: Guid("8755ce51-a2ba-4096-b309-fb2da2782c78")] 24 | 25 | // 組件的版本資訊由下列四個值所組成: 26 | // 27 | // 主要版本 28 | // 次要版本 29 | // 組建編號 30 | // 修訂編號 31 | // 32 | // 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 33 | // 設為預設,如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 這段程式碼是由工具產生的。 4 | // 執行階段版本:4.0.30319.42000 5 | // 6 | // 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 7 | // 程式碼,則會遺失變更。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Demo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 用於查詢當地語系化字串等的強類型資源類別 17 | /// 18 | // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder 19 | // 類別透過 ResGen 或 Visual Studio 這類工具產生。 20 | // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen 21 | // (利用 /str 選項),或重建您的 VS 專案。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 56 | /// 使用這個強類型資源類別的資源查閱。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Demo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Resident.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Demo 8 | { 9 | class Resident 10 | { 11 | private String name; 12 | 13 | public Resident(String name) 14 | { 15 | this.name = name; 16 | } 17 | 18 | public override String ToString() 19 | { 20 | return "住戶 " + name; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /class-41-50/Class50/Demo/Demo/Worker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Demo 8 | { 9 | class Worker 10 | { 11 | private String name; 12 | 13 | public Worker(String name) 14 | { 15 | this.name = name; 16 | } 17 | 18 | public override String ToString() 19 | { 20 | return "辦公人士 " + name; 21 | } 22 | } 23 | } 24 | --------------------------------------------------------------------------------