├── 2048
├── 2048.vcxproj
├── 2048.vcxproj.filters
├── 2048.vcxproj.user
├── controller.cpp
├── controller.h
├── main.cpp
├── map.cpp
└── map.h
├── .gitignore
├── EasyxProject.sln
├── Easyx_Maye
├── Easyx_Maye.vcxproj
├── Easyx_Maye.vcxproj.filters
├── Easyx_Maye.vcxproj.user
├── images
│ ├── human (9).jpg
│ ├── img1.png
│ ├── planeNormal_1.jpg
│ └── planeNormal_2.jpg
├── include
│ ├── BasicWidget.h
│ ├── Configure.h
│ ├── Image.h
│ ├── LineEdit.h
│ ├── Table.h
│ ├── Timer.h
│ ├── Window.h
│ ├── commonutils
│ │ ├── Color.h
│ │ ├── Font.h
│ │ ├── Painter.h
│ │ └── TypeDefine.h
│ ├── pushButton.h
│ └── randomGenerator.h
├── lib
│ ├── x64
│ │ ├── Easyx_Maye.idb
│ │ └── Easyx_Maye.lib
│ └── x86
│ │ ├── Easyx_Maye.idb
│ │ └── Easyx_Maye.lib
├── main.cpp
└── source
│ ├── BasicWidget.cpp
│ ├── Image.cpp
│ ├── LineEdit.cpp
│ ├── Table.cpp
│ ├── Timer.cpp
│ ├── Window.cpp
│ ├── commonutils
│ ├── Color.cpp
│ ├── Font.cpp
│ └── Painter.cpp
│ ├── pushButton.cpp
│ └── randomGenerator.cpp
├── README.md
├── StudentManagementSystem_CPP
├── ManageMent(控制台版).cpp
├── ManageMent(控制台版).h
├── ManageMent_gui.cpp
├── ManageMent_gui.h
├── Student.cpp
├── Student.h
├── StudentManagementSystem_CPP.vcxproj
├── StudentManagementSystem_CPP.vcxproj.user
├── images
│ ├── bk.png
│ └── student.txt
├── main.cpp
└── resource
│ ├── student - 备份.txt
│ └── student.txt
├── StudentManagementSystem_all.7z
├── StudentManagementSystem_all
├── ManageMent(控制台版).cpp
├── ManageMent(控制台版).h
├── ManageMent_gui.cpp
├── ManageMent_gui.h
├── Student.cpp
├── Student.h
├── StudentManagementSystem_all.sln
├── StudentManagementSystem_all.vcxproj
├── StudentManagementSystem_all.vcxproj.filters
├── StudentManagementSystem_all.vcxproj.user
├── images
│ ├── bk.png
│ └── student.txt
├── main.cpp
├── resource
│ ├── student - 备份.txt
│ └── student.txt
└── widgets
│ ├── BasicWidget.cpp
│ ├── BasicWidget.h
│ ├── Configure.h
│ ├── Image.cpp
│ ├── Image.h
│ ├── LineEdit.cpp
│ ├── LineEdit.h
│ ├── Table.cpp
│ ├── Table.h
│ ├── Timer.cpp
│ ├── Timer.h
│ ├── Window.cpp
│ ├── Window.h
│ ├── commonutils
│ ├── Color.cpp
│ ├── Color.h
│ ├── Font.cpp
│ ├── Font.h
│ └── TypeDefine.h
│ ├── pushButton.cpp
│ ├── pushButton.h
│ ├── randomGenerator.cpp
│ └── randomGenerator.h
├── gobang
├── checkerBoard.cpp
├── checkerBoard.h
├── chessPieces.cpp
├── chessPieces.h
├── controller.cpp
├── controller.h
├── gobang.vcxproj
├── gobang.vcxproj.filters
├── gobang.vcxproj.user
├── main.cpp
└── resource
│ ├── images
│ └── bk.jpg
│ └── music
│ └── G弦之歌.mp3
├── mineSweeper
├── controller.cpp
├── controller.h
├── main.cpp
├── map.cpp
├── map.h
├── mineSweeper.vcxproj
├── mineSweeper.vcxproj.filters
├── mineSweeper.vcxproj.user
└── resource
│ ├── images
│ ├── 0.jpg
│ ├── 1.jpg
│ ├── 10.jpg
│ ├── 11.jpg
│ ├── 2.jpg
│ ├── 3.jpg
│ ├── 4.jpg
│ ├── 5.jpg
│ ├── 6.jpg
│ ├── 7.jpg
│ ├── 8.jpg
│ ├── 9.jpg
│ └── 9_copy.jpg
│ └── music
│ ├── click.wav
│ ├── rightClick.wav
│ ├── search.wav
│ └── start.mp3
└── pushBox
├── README.md
├── controller.cpp
├── controller.h
├── gamer.cpp
├── gamer.h
├── main.cpp
├── map.h
├── pushBox.vcxproj
├── pushBox.vcxproj.filters
├── pushBox.vcxproj.user
├── resource
├── images
│ ├── 0.bmp
│ ├── 1.bmp
│ ├── 2.bmp
│ ├── 3.bmp
│ ├── 4.bmp
│ ├── 5.bmp
│ └── 6.bmp
└── map.txt
├── rollback.cpp
└── rollback.h
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | #*.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | #x64/
25 | #x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
--------------------------------------------------------------------------------
/2048/2048.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {96043313-d9dd-4a6d-9998-26fe1a432a90}
25 | My2048
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | ..\Easyx_Maye\include;$(IncludePath)
76 | ..\Easyx_Maye\lib\x86\;$(LibraryPath)
77 |
78 |
79 | false
80 |
81 |
82 | true
83 |
84 |
85 | false
86 |
87 |
88 |
89 | Level3
90 | true
91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
92 | true
93 |
94 |
95 | Console
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | true
103 | true
104 | true
105 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
106 | true
107 |
108 |
109 | Console
110 | true
111 | true
112 | true
113 |
114 |
115 |
116 |
117 | Level3
118 | true
119 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
120 | true
121 |
122 |
123 | Console
124 | true
125 |
126 |
127 |
128 |
129 | Level3
130 | true
131 | true
132 | true
133 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
134 | true
135 |
136 |
137 | Console
138 | true
139 | true
140 | true
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/2048/2048.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 | 源文件
23 |
24 |
25 | 源文件
26 |
27 |
28 |
29 |
30 | 头文件
31 |
32 |
33 | 头文件
34 |
35 |
36 |
--------------------------------------------------------------------------------
/2048/2048.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/2048/controller.cpp:
--------------------------------------------------------------------------------
1 | #include "controller.h"
2 | #include
3 |
4 |
5 | Controller::Controller()
6 | :flag(false)
7 | {
8 |
9 | }
10 | void Controller::run()
11 | {
12 | while (true)
13 | {
14 | map.show();
15 | GameControl();
16 | GameWin();
17 | }
18 | }
19 |
20 | //向上移动
21 | void Controller::moveup()
22 | {
23 | /*
24 | 向上移动:遍历每列
25 | */
26 | for (int i = 0; i < map.cols(); i++)
27 | {
28 | int temp = 0;
29 | for (int begin = 1; begin < map.rows(); begin++)
30 | {
31 | if (map[begin][i] != 0)
32 | {
33 | if (map[temp][i] == 0)
34 | {
35 | map[temp][i] = map[begin][i];
36 | map[begin][i] = 0;
37 | }
38 | else if (map[temp][i] == map[begin][i])
39 | {
40 | map[temp][i] += map[begin][i];
41 | map[begin][i] = 0;
42 | temp++;
43 | }
44 | else
45 | {
46 | map[temp + 1][i] = map[begin][i];
47 | if (temp + 1 != begin)//如果temp+1和begn不在同一个位置,就让begin所在的位置的数字置空
48 | {
49 | map[begin][i] = 0;
50 | }
51 | temp++;
52 | }
53 | flag = 1;
54 | }
55 | }
56 | }
57 | }
58 | //向下移动
59 | void Controller::movedown()
60 | {
61 | for (int i = 0; i < map.cols(); i++)
62 | {
63 | int temp = map.rows() - 1;
64 | for (int begin = map.rows() - 2; begin >= 0; begin--)
65 | {
66 | if (map[begin][i] != 0)
67 | {
68 | if (map[temp][i] == 0)
69 | {
70 | map[temp][i] = map[begin][i];
71 | map[begin][i] = 0;
72 | }
73 | else if (map[temp][i] == map[begin][i])
74 | {
75 | map[temp][i] += map[begin][i];
76 | map[begin][i] = 0;
77 | temp--;
78 | }
79 | else
80 | {
81 | map[temp - 1][i] = map[begin][i];
82 | if ((temp - 1) != begin)
83 | {
84 | map[begin][i] = 0;
85 | }
86 | temp--;
87 | }
88 | flag = 1;
89 | }
90 | }
91 | }
92 | }
93 | //向左移动
94 | void Controller::moveleft()
95 | {
96 | for (int i = 0; i < map.rows(); i++)
97 | {
98 | int temp = 0;
99 | for (int begin = 1; begin < map.cols(); begin++)
100 | {
101 | if (map[i][begin] != 0)
102 | {
103 | if (map[i][temp] == 0)
104 | {
105 | map[i][temp] = map[i][begin];
106 | map[i][begin] = 0;;
107 | }
108 | else if (map[i][temp] == map[i][begin])
109 | {
110 | map[i][temp] += map[i][begin];
111 | map[i][begin] = 0;
112 | temp++;
113 | }
114 | else
115 | {
116 | map[i][temp + 1] = map[i][begin];
117 | if (temp + 1 != begin)
118 | {
119 | map[i][begin] = 0;
120 | }
121 | temp++;
122 | }
123 | flag = 1;
124 | }
125 | }
126 | }
127 | }
128 | //向右移动
129 | void Controller::moveright()
130 | {
131 | for (int i = 0; i < map.rows(); i++)
132 | {
133 | int temp = map.cols() - 1;
134 | for (int begin = map.cols() - 2; begin >= 0; begin--)
135 | {
136 | if (map[i][begin] != 0)
137 | {
138 | if (map[i][temp] == 0)
139 | {
140 | map[i][temp] = map[i][begin];
141 | map[i][begin] = 0;
142 | }
143 | else if (map[i][temp] == map[i][begin])
144 | {
145 | map[i][temp] += map[i][begin];
146 | map[i][begin] = 0;
147 | temp--;
148 | }
149 | else
150 | {
151 | map[i][temp - 1] = map[i][begin];
152 | if (temp - 1 != begin)
153 | {
154 | map[i][begin] = 0;
155 | }
156 | temp--;
157 | }
158 | flag = 1;
159 | }
160 | }
161 | }
162 | }
163 | void Controller::GameControl()
164 | {
165 | switch (_getch())
166 | {
167 | case 72:
168 | case 'w':
169 | case 'W':
170 | moveup();
171 | break;
172 | case 80:
173 | case 's':
174 | case 'S':
175 | movedown();
176 | break;
177 | case 75:
178 | case 'a':
179 | case 'A':
180 | moveleft();
181 | break;
182 | case 77:
183 | case 'd':
184 | case 'D':
185 | moveright();
186 | break;
187 | default:
188 | break;
189 | }
190 | if (flag == 1)
191 | {
192 | map.generateNumber();
193 | flag = 0;
194 | }
195 | //userkey = 0;
196 | }
197 | void Controller::GameWin()
198 | {
199 | for (int i = 0; i < map.rows(); i++)
200 | {
201 | for (int k = 0; k < map.cols(); k++)
202 | {
203 | if (map[i][k] == 2048)
204 | {
205 | HWND hnd = GetHWnd();
206 | int isok = MessageBox(hnd, "你赢了", "提示", MB_OKCANCEL);
207 | if (isok == IDOK)
208 | {
209 | //GameInit();
210 | }
211 | else
212 | {
213 | exit(666);
214 | }
215 | }
216 | }
217 | }
218 | }
--------------------------------------------------------------------------------
/2048/controller.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"map.h"
3 | class Controller
4 | {
5 | public:
6 | Controller();
7 | void run();
8 | void moveup();
9 | void movedown();
10 | void moveleft();
11 | void moveright();
12 | void GameControl();
13 | void GameWin();
14 | private:
15 | Map map;
16 | bool flag;
17 | };
18 |
19 |
--------------------------------------------------------------------------------
/2048/main.cpp:
--------------------------------------------------------------------------------
1 | #include"controller.h"
2 | #include
3 | #pragma comment(lib,"Easyx_Maye.lib")
4 | int main()
5 | {
6 | Window w(475, 475, EW_SHOWCONSOLE);
7 | w.setWindowTitle("2048游戏");
8 |
9 | Controller c;
10 | c.run();
11 |
12 | return w.exec();
13 | }
--------------------------------------------------------------------------------
/2048/map.cpp:
--------------------------------------------------------------------------------
1 | #include "map.h"
2 | #include
3 |
4 | Map::Map():m_rows(4),m_cols(4), m_GRIDW(100),m_SPACE(15)
5 | ,m_map(m_rows)
6 | {
7 | for (int i = 0; i < m_rows; i++)
8 | {
9 | for (int k = 0; k < m_cols; k++)
10 | {
11 | m_map[i].push_back(0);
12 | }
13 | }
14 | //开始随机生成两个数
15 | generateNumber();
16 | generateNumber();
17 |
18 | //设置背景颜色
19 | setbkcolor(Color::back);
20 | cleardevice();
21 | }
22 |
23 |
24 | void Map::show()
25 | {
26 | //初始化格子颜色
27 | for (int i = 0; i < m_rows; i++)
28 | {
29 | for (int k = 0; k < m_cols; k++)
30 | {
31 | printf("%d ", m_map[i][k]);
32 | //求出每个格子左上角的坐标
33 | int x = k * m_GRIDW + (k + 1) * m_SPACE;
34 | int y = i * m_GRIDW + (i + 1) * m_SPACE;
35 | int index = (int)log2(m_map[i][k]);//求以2为底的x的对数(求出每个数对应的,颜色的下标)
36 | DWORD tempcolor = colors[index];
37 | setfillcolor(tempcolor);
38 | setlinecolor(tempcolor);
39 | //fillrectangle(x, y, x + GRID_WIDTH, y + GRID_WIDTH);
40 | fillroundrect(x, y, x + m_GRIDW, y + m_GRIDW, 10, 10);
41 | if (m_map[i][k] != 0)//把当前数字,显示到窗口上
42 | {
43 | setbkmode(TRANSPARENT);
44 | settextstyle(50, 0, "黑体");
45 | settextcolor(RGB(119, 110, 101));
46 | char number[5] = " ";
47 | sprintf_s(number, "%d", m_map[i][k]);
48 | int temp = textwidth(number);//获取字符
49 | temp = m_GRIDW / 2 - temp / 2;//计算第一个字开始的位置
50 | outtextxy(x + temp, y + 25, number);
51 | }
52 | }
53 | printf("\n");
54 | }
55 | }
56 |
57 | int Map::rows()
58 | {
59 | return m_rows;
60 | }
61 |
62 | int Map::cols()
63 | {
64 | return m_cols;
65 | }
66 |
67 | std::vector& Map::operator[](int index)
68 | {
69 | return m_map[index];
70 | }
71 |
72 | void Map::generateNumber()
73 | {
74 | while (true)
75 | {
76 | int r = RandomGenerator::global()->bounded(m_rows);
77 | int c = RandomGenerator::global()->bounded(m_cols);
78 | if (m_map[r][c] == 0)
79 | {
80 | m_map[r][c] = generate2or4(5); //五分之一的概率生成4
81 | break;
82 | }
83 | }
84 | }
85 |
86 | int Map::generate2or4(int probability)
87 | {
88 | if (RandomGenerator::global()->bounded(probability) == 0)
89 | {
90 | return 4;
91 | }
92 | return 2;
93 | }
94 |
--------------------------------------------------------------------------------
/2048/map.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | class Map
5 | {
6 | enum Color //枚举格子颜色
7 | {
8 | zero = RGB(205, 193, 180), //0的颜色
9 | twoTo1 = RGB(238, 228, 218), //2的颜色
10 | twoTo2 = RGB(237, 224, 200), //4的颜色
11 | twoTo3 = RGB(242, 177, 121), //8的颜色
12 | twoTo4 = RGB(245, 149, 99), //16的颜色
13 | twoTo5 = RGB(246, 124, 95), //32的颜色
14 | twoTo6 = RGB(246, 94, 59), //64的颜色
15 | twoTo7 = RGB(242, 177, 121), //128的颜色
16 | twoTo8 = RGB(237, 204, 97), //256的颜色
17 | twoTo9 = RGB(255, 0, 128), //512的颜色
18 | twoTo10 = RGB(145, 0, 72), //1024的颜色
19 | twoTo11 = RGB(242, 17, 158), //2048的颜色
20 | back = RGB(187, 173, 160) //背景颜色
21 | };
22 | Color colors[12] = { zero,twoTo1,twoTo2,twoTo3,twoTo4,twoTo5,twoTo6,twoTo7,twoTo8,twoTo9,twoTo10,twoTo11 };
23 | public:
24 | Map();
25 | void show();
26 | int rows();
27 | int cols();
28 | void generateNumber();
29 | std::vector& operator[](int index);
30 | private:
31 | //随机生成2 或 4 probability生成4的概率
32 | int generate2or4(int probability);
33 | private:
34 | const int m_rows;
35 | const int m_cols;
36 | const int m_GRIDW;
37 | const int m_SPACE;
38 | std::vector> m_map;
39 | };
40 |
41 |
--------------------------------------------------------------------------------
/EasyxProject.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31515.178
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pushBox", "pushBox\pushBox.vcxproj", "{E394C016-8C3C-4D35-A4BC-8FEC4567A239}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easyx_Maye", "Easyx_Maye\Easyx_Maye.vcxproj", "{D688C05B-DB21-4D73-A766-FDC8085B8A1F}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gobang", "gobang\gobang.vcxproj", "{8B7C6AE0-F434-4C35-84CA-F0351E3F375B}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mineSweeper", "mineSweeper\mineSweeper.vcxproj", "{61E2A3E8-C88D-4A30-8C81-30411FB7440E}"
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2048", "2048\2048.vcxproj", "{96043313-D9DD-4A6D-9998-26FE1A432A90}"
15 | EndProject
16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StudentManagementSystem", "StudentManagementSystem_CPP\StudentManagementSystem_CPP.vcxproj", "{C2171D33-E8BB-429B-B040-673F15CD181A}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Debug|x64.ActiveCfg = Debug|x64
27 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Debug|x64.Build.0 = Debug|x64
28 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Debug|x86.ActiveCfg = Debug|Win32
29 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Debug|x86.Build.0 = Debug|Win32
30 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Release|x64.ActiveCfg = Release|x64
31 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Release|x64.Build.0 = Release|x64
32 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Release|x86.ActiveCfg = Release|Win32
33 | {E394C016-8C3C-4D35-A4BC-8FEC4567A239}.Release|x86.Build.0 = Release|Win32
34 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Debug|x64.ActiveCfg = Debug|x64
35 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Debug|x64.Build.0 = Debug|x64
36 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Debug|x86.ActiveCfg = Debug|Win32
37 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Debug|x86.Build.0 = Debug|Win32
38 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Release|x64.ActiveCfg = Release|x64
39 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Release|x64.Build.0 = Release|x64
40 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Release|x86.ActiveCfg = Release|Win32
41 | {D688C05B-DB21-4D73-A766-FDC8085B8A1F}.Release|x86.Build.0 = Release|Win32
42 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Debug|x64.ActiveCfg = Debug|x64
43 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Debug|x64.Build.0 = Debug|x64
44 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Debug|x86.ActiveCfg = Debug|Win32
45 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Debug|x86.Build.0 = Debug|Win32
46 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Release|x64.ActiveCfg = Release|x64
47 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Release|x64.Build.0 = Release|x64
48 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Release|x86.ActiveCfg = Release|Win32
49 | {8B7C6AE0-F434-4C35-84CA-F0351E3F375B}.Release|x86.Build.0 = Release|Win32
50 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Debug|x64.ActiveCfg = Debug|x64
51 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Debug|x64.Build.0 = Debug|x64
52 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Debug|x86.ActiveCfg = Debug|Win32
53 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Debug|x86.Build.0 = Debug|Win32
54 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Release|x64.ActiveCfg = Release|x64
55 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Release|x64.Build.0 = Release|x64
56 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Release|x86.ActiveCfg = Release|Win32
57 | {61E2A3E8-C88D-4A30-8C81-30411FB7440E}.Release|x86.Build.0 = Release|Win32
58 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Debug|x64.ActiveCfg = Debug|x64
59 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Debug|x64.Build.0 = Debug|x64
60 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Debug|x86.ActiveCfg = Debug|Win32
61 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Debug|x86.Build.0 = Debug|Win32
62 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Release|x64.ActiveCfg = Release|x64
63 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Release|x64.Build.0 = Release|x64
64 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Release|x86.ActiveCfg = Release|Win32
65 | {96043313-D9DD-4A6D-9998-26FE1A432A90}.Release|x86.Build.0 = Release|Win32
66 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Debug|x64.ActiveCfg = Debug|x64
67 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Debug|x64.Build.0 = Debug|x64
68 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Debug|x86.ActiveCfg = Debug|Win32
69 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Debug|x86.Build.0 = Debug|Win32
70 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Release|x64.ActiveCfg = Release|x64
71 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Release|x64.Build.0 = Release|x64
72 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Release|x86.ActiveCfg = Release|Win32
73 | {C2171D33-E8BB-429B-B040-673F15CD181A}.Release|x86.Build.0 = Release|Win32
74 | EndGlobalSection
75 | GlobalSection(SolutionProperties) = preSolution
76 | HideSolutionNode = FALSE
77 | EndGlobalSection
78 | GlobalSection(ExtensibilityGlobals) = postSolution
79 | SolutionGuid = {18079622-B81E-4E2B-8DEC-15D7C219C378}
80 | EndGlobalSection
81 | EndGlobal
82 |
--------------------------------------------------------------------------------
/Easyx_Maye/Easyx_Maye.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 16.0
51 | Win32Proj
52 | {d688c05b-db21-4d73-a766-fdc8085b8a1f}
53 | EasyxMaye
54 | 10.0
55 |
56 |
57 |
58 | StaticLibrary
59 | true
60 | v142
61 | Unicode
62 |
63 |
64 | StaticLibrary
65 | false
66 | v142
67 | true
68 | MultiByte
69 |
70 |
71 | StaticLibrary
72 | true
73 | v142
74 | Unicode
75 |
76 |
77 | StaticLibrary
78 | false
79 | v143
80 | true
81 | MultiByte
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | true
103 | $(SolutionDir)Easyx_Maye\lib\x86\
104 |
105 |
106 | false
107 | $(SolutionDir)Easyx_Maye\lib\x86\
108 |
109 |
110 | true
111 | $(SolutionDir)\Easyx_Maye\lib\x64\
112 |
113 |
114 | false
115 | $(SolutionDir)lib\x64
116 |
117 |
118 |
119 | Level3
120 | true
121 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
122 | true
123 |
124 |
125 | Console
126 | true
127 |
128 |
129 |
130 |
131 | Level3
132 | true
133 | true
134 | false
135 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
136 | true
137 | stdcpplatest
138 |
139 |
140 | Console
141 | true
142 | true
143 | true
144 |
145 |
146 |
147 |
148 | Level3
149 | false
150 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
151 | true
152 | stdcpplatest
153 |
154 |
155 | Console
156 | true
157 |
158 |
159 |
160 |
161 | Level3
162 | true
163 | true
164 | false
165 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
166 | true
167 | stdcpp20
168 |
169 |
170 | Console
171 | true
172 | true
173 | true
174 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/Easyx_Maye/Easyx_Maye.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {6cd784be-ba6e-45fb-aac1-f404c32d8792}
18 |
19 |
20 | {896b99f4-1a82-4097-be7b-7b6294378428}
21 |
22 |
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件\commonutils
50 |
51 |
52 | 头文件\commonutils
53 |
54 |
55 | 头文件\commonutils
56 |
57 |
58 | 头文件\commonutils
59 |
60 |
61 | 头文件
62 |
63 |
64 |
65 |
66 | 源文件
67 |
68 |
69 | 源文件
70 |
71 |
72 | 源文件
73 |
74 |
75 | 源文件
76 |
77 |
78 | 源文件
79 |
80 |
81 | 源文件
82 |
83 |
84 | 源文件
85 |
86 |
87 | 源文件\commonutils
88 |
89 |
90 | 源文件\commonutils
91 |
92 |
93 | 源文件\commonutils
94 |
95 |
96 | 源文件
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Easyx_Maye/Easyx_Maye.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Easyx_Maye/images/human (9).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/images/human (9).jpg
--------------------------------------------------------------------------------
/Easyx_Maye/images/img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/images/img1.png
--------------------------------------------------------------------------------
/Easyx_Maye/images/planeNormal_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/images/planeNormal_1.jpg
--------------------------------------------------------------------------------
/Easyx_Maye/images/planeNormal_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/images/planeNormal_2.jpg
--------------------------------------------------------------------------------
/Easyx_Maye/include/BasicWidget.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Configure.h"
3 | #include"commonutils/Color.h"
4 | class BasicWidget
5 | {
6 | public:
7 | BasicWidget(int x, int y, int w, int h);
8 | int width() const;
9 | int height()const;
10 | void setFixedSize(int w, int h);
11 |
12 | int x()const;
13 | int y()const;
14 | void move(int x, int y);
15 |
16 | //未实现
17 | void setBackgroundColor(const Color& color);
18 | Color BackgroundColor();
19 |
20 | void setFont(const Font& font);
21 | const Font& font();
22 | virtual void show();
23 | protected:
24 | int m_x;
25 | int m_y;
26 | int m_w;
27 | int m_h;
28 |
29 | Color m_bkColor; //背景颜色
30 | Font m_font; //字体
31 | };
32 |
33 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/Configure.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef UNICODE
4 | #undef UNICODE
5 | #endif // UNICODE
6 |
7 | #ifdef _DEBUG
8 | #include
9 | #define plog printf
10 | #else
11 | #define plog
12 | #endif // DEBUG
13 |
14 | #include
15 | #include
16 | #include"Timer.h"
17 | #include"commonutils/Font.h"
18 |
19 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/Image.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Configure.h"
3 | class Image :public IMAGE
4 | {
5 | public:
6 | Image();
7 | Image(const std::string& imgPath,int w = 0,int h =0);
8 | //example: Image("./res/images/jumpMask.jpg","./res/images/jumpSrc.jpg")
9 | Image(const std::string& maskImgPath, const std::string& srcImgPath,int w = 0,int h =0);
10 | //example: Image("./res/images/","jumpMask.jpg","jumpSrc.jpg")
11 | Image(const std::string& prefixPath,const std::string& maskImgPath, const std::string& srcImgPath,int w = 0,int h = 0);
12 | void draw();
13 | void draw(DWORD maskdwRop, DWORD srcdwRop);
14 | void move(int x, int y);
15 |
16 | void save(const std::string& savePath);
17 | static void save(const std::string& savePath, Image* img);
18 | Image* getimage(int x, int y, int w, int h);
19 |
20 | DWORD* ImageBuffer(); // 获取绘图设备的显存指针
21 |
22 | private:
23 | void SetDefault() override; // 设置为默认状态
24 | static void putimage_alapha(int x, int y, IMAGE* src);
25 |
26 | int x;
27 | int y;
28 | private://使用掩码图透明贴图
29 | Image *pMaskImg;
30 | };
31 |
32 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/LineEdit.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"BasicWidget.h"
3 | #include
4 | #pragma comment(lib,"Imm32.lib")
5 | class LineEdit:public BasicWidget
6 | {
7 | public:
8 | LineEdit(int x = 0, int y = 0, int w = 100, int h = 30);
9 | void show();
10 |
11 | void eventLoop(const ExMessage& msg);
12 |
13 | //弹出数据输入框
14 | void popInputBox();
15 | void setInputBoxTitle(const std::string& title);
16 | std::string text();
17 | void clear();
18 | //文本是否改变了
19 | bool textChanged();
20 | private:
21 | std::string m_pretext; //上一次的文字
22 | std::string m_text; //行编辑器中的文字
23 | int textw;
24 |
25 | std::string m_title; //行编辑器弹出窗标题
26 |
27 | bool m_isPopUp; //是否弹出
28 | };
29 |
30 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/Table.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"BasicWidget.h"
3 | #include"pushButton.h"
4 | #include
5 | class Table :public BasicWidget
6 | {
7 | public:
8 | Table(int row = 1, int col = 0);
9 | void setRowCount(int row);
10 | void setColCount(int col);
11 |
12 | //插入以\t分隔的字符串数据
13 | void setHeader(const std::string& data);
14 | void insert(const std::string& data);
15 | void clear();
16 |
17 | void eventLoop(const ExMessage& msg);
18 |
19 |
20 | void show();
21 | std::vector split(std::string str, char separator = '\t');
22 | private:
23 | void drawTableGrid();
24 | void drawTableText();
25 | void drawHeader();
26 | void updateData(); //更新数据
27 |
28 | //初始化换页按钮位置
29 | void initPageBtnPos();
30 |
31 | private:
32 | size_t m_rows;
33 | size_t m_cols;
34 |
35 | int m_gridw;
36 | int m_gridh;
37 |
38 | std::string m_header;
39 | std::vector m_datas;
40 | private: //换页处理
41 | int m_curPage; //当前页
42 | int m_maxPage; //总页数
43 | int m_extraData; //如果不是整数页,那么保存一下最后一页有多少条数据
44 |
45 | PushButton m_prevPageBtn; //上一页
46 | PushButton m_nextPageBtn; //下一页
47 | PushButton m_beginPageBtn; //第一页
48 | PushButton m_endPageBtn; //末尾页
49 | };
50 |
51 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/Timer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | using namespace std::chrono;
4 | /*定时器*/
5 | class Timer
6 | {
7 | public:
8 | Timer(int64_t ms = 0);
9 | void startTimer();
10 | bool timeout();
11 | void setTime(int64_t ms);
12 | void killTimer();
13 | public:
14 | //静态定时器
15 | static bool startTimer(int64_t ms, int id);
16 | //定时器的最大ID
17 | inline static size_t maxTimerID() { return 20; };
18 | private:
19 | int64_t m_ms; //延迟毫秒数
20 | time_point m_startime;
21 | time_point m_endtime;
22 |
23 | bool m_threadIsRun; //控制线程运行
24 | };
25 |
26 | /*时间间隔(计算运行时间)*/
27 | class ElapsedTimer
28 | {
29 | public:
30 | ElapsedTimer();
31 | void reset();
32 | //默认输出毫秒
33 | int64_t elapsed() const;
34 | //微秒
35 | int64_t elapsed_micro() const;
36 | //纳秒
37 | int64_t elapsed_nano() const;
38 | //秒
39 | int64_t elapsed_seconds() const;
40 | //分
41 | int64_t elapsed_minutes() const;
42 | //时
43 | int64_t elapsed_hours() const;
44 | private:
45 | time_point m_begin;
46 | };
47 |
48 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/Window.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Configure.h"
3 | #include
4 |
5 | /*@setCursor光标样式名字
6 | IDC_ARROW, //正常
7 | IDC_IBEAM, //工
8 | IDC_WAIT, //○
9 | IDC_CROSS, //十
10 | IDC_UPARROW, //↑
11 | IDC_SIZE, //????
12 | IDC_ICON, //????
13 | IDC_SIZENWSE,//左上角缩放
14 | IDC_SIZENESW,//右上角缩放
15 | IDC_SIZEWE, //左右
16 | IDC_SIZENS, //上下
17 | IDC_SIZEALL, //带箭头的十
18 | IDC_NO //(X)
19 | */
20 |
21 | class Window
22 | {
23 | public:
24 | Window(int w, int h,int flag = 0);
25 | ~Window();
26 | void setWindowTitle(const std::string& title);
27 | void setWindowColor(COLORREF c);
28 | void setCursor(LPSTR curSorStyle);
29 | inline int exec() { system("pause"); return 0; };
30 | public://static
31 | static int width();
32 | static int height();
33 | static void clear();
34 | static void beginDraw();
35 | static void flushDraw();
36 | static void endDraw();
37 |
38 | inline static bool hasMsg() { return peekmessage(&s_message, EM_MOUSE | EM_KEY); }
39 | inline static const ExMessage& getMsg() { return s_message; }
40 |
41 | private:
42 | HWND handle; //当前窗口句柄
43 | static ExMessage s_message;
44 | };
45 |
46 |
--------------------------------------------------------------------------------
/Easyx_Maye/include/commonutils/Color.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"TypeDefine.h"
3 | class Color
4 | {
5 | public:
6 | Color(int rgb = 0x000);
7 | Color(uint8 r, uint8 g, uint8 b);
8 | uint32 toRgb() const ;
9 |
10 | inline operator uint32() const
11 | {
12 | return m_color;
13 | }
14 |
15 | static uint32 rgb(uint8 r, uint8 g, uint8 b);
16 | private:
17 | uint32 m_color;
18 | public:
19 | enum ColorDef
20 | {
21 | Black = 0,
22 | Blue = 0xAA0000,
23 | Green = 0x00AA00,
24 | Cyan = 0xAAAA00,
25 | Red = 0x0000AA,
26 | Magenta = 0xAA00AA,
27 | Brown = 0x0055AA,
28 | LightGray = 0xAAAAAA,
29 | DarkGray = 0x555555,
30 | LightBlue = 0xFF5555,
31 | LightGreen = 0x55FF55,
32 | LightCyan = 0xFFFF55,
33 | LightRed = 0x5555FF,
34 | LightMagenta = 0xFF55FF,
35 | Yellow = 0x55FFFF,
36 | White = 0xFFFFFF,
37 | };
38 | };
--------------------------------------------------------------------------------
/Easyx_Maye/include/commonutils/Font.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"TypeDefine.h"
3 | #include
4 | #include"../../include/commonutils/Color.h"
5 | class Font
6 | {
7 | public:
8 | Font();
9 | Font(const std::string& family, int Weight = 0, bool italic = false);
10 |
11 | void setHeight(int height);
12 | void setWidth(int width);
13 | void setBold(bool enable);
14 | void setItalic(bool enable);
15 | void setWeight(int weight);
16 | void setQuality(int Quality);
17 | void setFamily(const std::string& family);
18 | void setColor(const Color& color);
19 |
20 | const Color& color();
21 |
22 | int Height();
23 | int Width();
24 | bool Bold();
25 | bool Italic();
26 | int Weight();
27 | int Quality();
28 | std::string Family();
29 |
30 | private:
31 | int32 lfHeight = 0; //字符的平均高度
32 | int32 lfWidth = 0; //字符的平均宽度(0 表示自适应)
33 | int32 lfEscapement = 0; //字符串的书写角度(单位 0.1 度);
34 | int32 lfOrientation = 0; //每个字符的书写角度(单位 0.1 度);
35 | int32 lfWeight = 0; //字符的笔画粗细(0 表示默认粗细);
36 | Byte lfItalic = 0; //是否斜体;
37 | Byte lfUnderline = 0; //是否下划线;
38 | Byte lfStrikeOut = 0; //是否删除线
39 | Byte lfCharSet = 0; //指定字符集;
40 | Byte lfOutPrecision = 0; //指定文字的输出精度;
41 | Byte lfClipPrecision = 0; //指定文字的剪辑精度;
42 | Byte lfQuality = 0; //指定文字的输出质量;
43 | Byte lfPitchAndFamily = 0; //指定以常规方式描述字体的字体系列。
44 | char lfFaceName[32] = { 0 }; //字体名称
45 | Color lfcolor;
46 | };
--------------------------------------------------------------------------------
/Easyx_Maye/include/commonutils/Painter.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/include/commonutils/Painter.h
--------------------------------------------------------------------------------
/Easyx_Maye/include/commonutils/TypeDefine.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | using uint8 = unsigned char;
4 | using uint16 = unsigned short;
5 | using uint32 = unsigned int;
6 | using uint64 = unsigned long long;
7 |
8 | using int8 = char;
9 | using int16 = short;
10 | using int32 = int;
11 | using int64 = long long;
12 |
13 | using Byte = uint8;
14 | using Word = uint16;
15 | using Dword = uint32;
--------------------------------------------------------------------------------
/Easyx_Maye/include/pushButton.h:
--------------------------------------------------------------------------------
1 | /*pushButton 按钮类*/
2 | #ifndef __PUSHBUTTON_H_
3 | #define __PUSHBUTTON_H_
4 | #include"Configure.h"
5 | #include"image.h"
6 | #include"BasicWidget.h"
7 |
8 | class PushButton:public BasicWidget
9 | {
10 | public:
11 | PushButton(std::string text ="PushButton",int x=0,int y=0,int w =100,int h = 30);
12 | void show();
13 |
14 | void setText(std::string text);
15 | void setBackgroundImage(std::string imgPath);
16 | void setBackgroundColor(Color color);
17 |
18 | void setHover(COLORREF c);
19 | void setHover(std::string imgPath);
20 | //事件循环
21 | void eventLoop(const ExMessage&);
22 |
23 | //鼠标是否在按钮上面
24 | bool isin();
25 | //鼠标是否点击了按钮
26 | bool isClicked();
27 |
28 |
29 | ~PushButton();
30 |
31 | public:
32 | std::string text;
33 | bool isshow = false; //显示状态
34 | ExMessage _msg; //鼠标消息
35 | public: //current
36 | Image* cur_img = nullptr;
37 | COLORREF cur_color = RGB(232, 232, 236);
38 |
39 | public: //normal
40 | Image* nor_img = nullptr;
41 | COLORREF nor_color = RGB(232, 232, 236);
42 |
43 | public: //hover
44 | Image* h_img = nullptr;
45 | COLORREF h_color = RGB(194, 195, 201);
46 | };
47 | #endif
--------------------------------------------------------------------------------
/Easyx_Maye/include/randomGenerator.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/include/randomGenerator.h
--------------------------------------------------------------------------------
/Easyx_Maye/lib/x64/Easyx_Maye.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/lib/x64/Easyx_Maye.idb
--------------------------------------------------------------------------------
/Easyx_Maye/lib/x64/Easyx_Maye.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/lib/x64/Easyx_Maye.lib
--------------------------------------------------------------------------------
/Easyx_Maye/lib/x86/Easyx_Maye.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/lib/x86/Easyx_Maye.idb
--------------------------------------------------------------------------------
/Easyx_Maye/lib/x86/Easyx_Maye.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/lib/x86/Easyx_Maye.lib
--------------------------------------------------------------------------------
/Easyx_Maye/main.cpp:
--------------------------------------------------------------------------------
1 | #include"Window.h"
2 | #include"Image.h"
3 | #include"pushButton.h"
4 | #include"LineEdit.h"
5 |
6 | int main()
7 | {
8 | Window w(640, 480,EW_SHOWCONSOLE);
9 | w.setCursor(IDC_CROSS);
10 | w.setWindowTitle("Maye Easyx");
11 | w.setWindowColor(RGB(194, 195, 201));
12 |
13 |
14 | setbkmode(TRANSPARENT);
15 |
16 | LineEdit edit(100,100,200,30);
17 |
18 | Window::beginDraw();
19 | while (true)
20 | {
21 | Window::clear();
22 | edit.updateText();
23 | edit.show();
24 |
25 | std::cout << edit.text() << std::endl;
26 | Window::flushDraw();
27 | }
28 |
29 |
30 | return w.exec();
31 | }
--------------------------------------------------------------------------------
/Easyx_Maye/source/BasicWidget.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/BasicWidget.h"
2 |
3 | BasicWidget::BasicWidget(int x, int y, int w, int h)
4 | :m_x(x),m_y(y),m_w(w),m_h(h),m_bkColor(),m_font("黑体")
5 | {
6 | m_font.setHeight(20);
7 | m_font.setQuality(PROOF_QUALITY);
8 | settextstyle((LOGFONT*)&m_font);
9 | settextcolor(m_font.color().toRgb());
10 |
11 | }
12 |
13 | int BasicWidget::width() const
14 | {
15 | return m_w;
16 | }
17 |
18 | int BasicWidget::height() const
19 | {
20 | return m_h;
21 | }
22 |
23 | void BasicWidget::setFixedSize(int w, int h)
24 | {
25 | this->m_w = w;
26 | this->m_h = h;
27 | }
28 |
29 | int BasicWidget::x() const
30 | {
31 | return m_x;
32 | }
33 |
34 | int BasicWidget::y() const
35 | {
36 | return m_y;
37 | }
38 |
39 | void BasicWidget::move(int x, int y)
40 | {
41 | this->m_x = x;
42 | this->m_y = y;
43 | }
44 |
45 |
46 | void BasicWidget::setBackgroundColor(const Color& color)
47 | {
48 | m_bkColor = color;
49 | }
50 |
51 | Color BasicWidget::BackgroundColor()
52 | {
53 | return m_bkColor;
54 | }
55 |
56 | void BasicWidget::setFont(const Font& font)
57 | {
58 | m_font = font;
59 | }
60 |
61 | const Font& BasicWidget::font()
62 | {
63 | return m_font;
64 | }
65 |
66 | void BasicWidget::show()
67 | {
68 | settextstyle((LOGFONT*)&m_font);
69 | settextcolor(m_font.color());
70 | }
71 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/Image.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/Image.h"
2 | #include"../include/Window.h"
3 |
4 | Image::Image():x(0),y(0),pMaskImg(nullptr)
5 | {
6 |
7 | }
8 |
9 | Image::Image(const std::string& imgPath, int w, int h): Image()
10 | {
11 | ::loadimage(this, imgPath.c_str(), w, h);
12 | if (this->getwidth() == 0 && this->getheight() == 0)
13 | {
14 | plog("[error] %s load failed\n", imgPath.c_str());
15 | }
16 | }
17 |
18 | Image::Image(const std::string& maskImgPath, const std::string& srcImgPath, int w, int h)
19 | :pMaskImg(new Image(maskImgPath,w,h))
20 | {
21 | ::loadimage(this, srcImgPath.c_str(), w, h);
22 | if (this->getwidth() == 0 && this->getheight() == 0)
23 | {
24 | plog("[error] %s load failed\n", srcImgPath.c_str());
25 | }
26 | }
27 |
28 | Image::Image(const std::string& prefixPath, const std::string& maskImgPath, const std::string& srcImgPath, int w, int h)
29 | :Image(prefixPath+maskImgPath, prefixPath+srcImgPath,w,h)
30 | {
31 | }
32 |
33 | void Image::draw()
34 | {
35 | putimage_alapha(this->x, this->y, this);
36 | }
37 |
38 | void Image::draw(DWORD maskdwRop,DWORD srcdwRop)
39 | {
40 | ::putimage(this->x, this->y, pMaskImg, maskdwRop);
41 | ::putimage(this->x, this->y, this, srcdwRop);
42 | }
43 |
44 | void Image::move(int x, int y)
45 | {
46 | this->x = x;
47 | this->y = y;
48 | }
49 |
50 | void Image::save(const std::string& savePath)
51 | {
52 | ::saveimage(savePath.c_str(), this);
53 | }
54 |
55 | void Image::save(const std::string& savePath, Image* img)
56 | {
57 | ::saveimage(savePath.c_str(), img);
58 | }
59 |
60 | Image* Image::getimage(int x, int y, int w, int h)
61 | {
62 | Image* img = new Image;
63 | ::getimage(img, x, y, w, h);
64 | return img;
65 | }
66 |
67 | DWORD* Image::ImageBuffer()
68 | {
69 | return ::GetImageBuffer(this);
70 | }
71 |
72 | void Image::SetDefault()
73 | {
74 | }
75 |
76 |
77 |
78 | /*@私有成员*/
79 | //png图片透明贴图
80 | void Image::putimage_alapha(int x, int y, IMAGE* src)
81 | {
82 | // 变量初始化
83 | DWORD* pwin = GetImageBuffer(); //窗口缓冲区指针
84 | DWORD* psrc = GetImageBuffer(src); //图片缓冲区指针
85 | int win_w = Window::width(); //窗口宽高
86 | int win_h = Window::height();
87 | int src_w = src->getwidth(); //图片宽高
88 | int src_h = src->getheight();
89 |
90 | // 计算贴图的实际长宽
91 | int real_w = (x + src_w > win_w) ? win_w - x : src_w; // 处理超出右边界
92 | int real_h = (y + src_h > win_h) ? win_h - y : src_h; // 处理超出下边界
93 | if (x < 0) { psrc += -x; real_w -= -x; x = 0; } // 处理超出左边界
94 | if (y < 0) { psrc += (src_w * -y); real_h -= -y; y = 0; } // 处理超出上边界
95 |
96 |
97 | // 修正贴图起始位置
98 | pwin += (win_w * y + x);
99 |
100 | // 实现透明贴图
101 | for (int iy = 0; iy < real_h; iy++)
102 | {
103 | for (int ix = 0; ix < real_w; ix++)
104 | {
105 | byte a = (byte)(psrc[ix] >> 24);//计算透明通道的值[0,256) 0为完全透明 255为完全不透明
106 | if (a > 100)
107 | {
108 | pwin[ix] = psrc[ix];
109 | }
110 | }
111 | //换到下一行
112 | pwin += win_w;
113 | psrc += src_w;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/LineEdit.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/LineEdit.h"
2 | #include"../include/Window.h"
3 | #include
4 |
5 | LineEdit::LineEdit(int x, int y, int w, int h)
6 | :BasicWidget(x, y, w, h), textw(2), m_isPopUp(false)
7 | , m_title("请输入")
8 | {
9 |
10 | }
11 |
12 | void LineEdit::show()
13 | {
14 | BasicWidget::show();
15 | setfillcolor(RGB(232, 232, 236));
16 | fillrectangle(m_x, m_y, m_x+m_w, m_y+m_h);
17 |
18 | //闪烁的小竖线
19 | setlinecolor(RED);
20 | line(m_x + textw + 2, m_y + 2, m_x + textw + 2, m_y + m_h - 2);
21 |
22 | //把文字输出到edit上
23 | outtextxy(m_x, m_y+(m_h - textheight(m_text.c_str())) / 2,m_text.c_str());
24 |
25 |
26 | if (m_isPopUp)
27 | {
28 | m_pretext = m_text;
29 | popInputBox();
30 | m_isPopUp = false;
31 | }
32 | }
33 | void LineEdit::eventLoop(const ExMessage& msg)
34 | {
35 | //判断是否需要弹出输入框
36 | if (msg.x > m_x && msg.x < m_x + m_w && msg.y > m_y && msg.y < m_y + m_h
37 | && msg.message == WM_LBUTTONDOWN)
38 | {
39 | m_isPopUp = true;
40 | }
41 | }
42 | void LineEdit::popInputBox()
43 | {
44 | char str[128] = { 0 };
45 | InputBox(str, 128, nullptr,m_title.c_str(),m_text.c_str());
46 | m_text = str;
47 | textw = ::textwidth(m_text.c_str());
48 | }
49 | void LineEdit::setInputBoxTitle(const std::string& title)
50 | {
51 | m_title = title;
52 | }
53 |
54 | std::string LineEdit::text()
55 | {
56 | return m_text;
57 | }
58 |
59 | void LineEdit::clear()
60 | {
61 | m_text.clear();
62 | textw = 0;
63 | }
64 |
65 | bool LineEdit::textChanged()
66 | {
67 | if (m_pretext == m_text)
68 | {
69 | return false;
70 | }
71 | m_pretext = m_text; //更新,通知一次文本改变即可
72 | return true;
73 | }
74 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/Table.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/Table.h"
2 | #include
3 | using namespace std;
4 | Table::Table(int row, int col)
5 | :m_rows(row), m_cols(col), m_curPage(0), m_maxPage(0)
6 | ,BasicWidget(0,0,0,0)
7 | {
8 | m_prevPageBtn.setText("上一页");
9 | m_nextPageBtn.setText("下一页");
10 | m_beginPageBtn.setText("第一页");
11 | m_endPageBtn.setText("结尾页");
12 |
13 | }
14 |
15 | void Table::setRowCount(int row)
16 | {
17 | m_rows = row;
18 | }
19 |
20 | void Table::setColCount(int col)
21 | {
22 | m_cols = col;
23 | }
24 |
25 |
26 | void Table::setHeader(const std::string& data)
27 | {
28 | m_header = data;
29 | m_cols = std::count(m_header.begin(), m_header.end(), '\t') - 1;
30 |
31 |
32 | int textw = ::textwidth("计算机1401");
33 | int texth = ::textheight(m_header.c_str());
34 |
35 | m_gridw = textw + 15;
36 | m_gridh = texth + 10;
37 |
38 | //设置从父类继承过来的宽度和高度
39 | m_h = m_rows * m_gridh;
40 | m_w = m_cols* m_gridw;
41 | }
42 |
43 | void Table::insert(const std::string& data)
44 | {
45 | m_datas.push_back(data);
46 | updateData();
47 | }
48 |
49 | void Table::clear()
50 | {
51 | m_datas.clear();
52 | updateData();
53 | }
54 |
55 | void Table::eventLoop(const ExMessage& msg)
56 | {
57 | m_prevPageBtn.eventLoop(msg);
58 | m_nextPageBtn.eventLoop(msg);
59 | m_beginPageBtn.eventLoop(msg);
60 | m_endPageBtn.eventLoop(msg);
61 |
62 | if (m_prevPageBtn.isClicked())
63 | {
64 | //cout << "m_prevPageBtn" << endl;
65 | if (m_curPage != 0)
66 | {
67 | m_curPage--;
68 | }
69 | //cout << "m_extraData:" << m_extraData << endl;
70 | }
71 | if (m_nextPageBtn.isClicked())
72 | {
73 | //cout << "m_nextPageBtn" << endl;
74 | if (m_curPage != m_maxPage)
75 | {
76 | m_curPage++;
77 | }
78 | }
79 | if (m_beginPageBtn.isClicked())
80 | {
81 | m_curPage = 0;
82 | //cout << "m_beginPageBtn" << endl;
83 | }
84 | if (m_endPageBtn.isClicked())
85 | {
86 | m_curPage = m_maxPage;
87 | //cout << "m_endPageBtn" << endl;
88 | }
89 | //cout << "m_curPage:" << m_curPage << "/" << m_maxPage << endl;
90 | }
91 |
92 | void Table::drawTableGrid()
93 | {
94 | if (m_rows == 0)
95 | {
96 | m_rows = m_datas.size();
97 | }
98 | drawHeader();
99 | setlinestyle(PS_SOLID, 1);
100 | //表格横线
101 | for (size_t i = 0; i < m_rows + 1; i++)
102 | {
103 | //m_x + m_cols * textw 表格的总宽度
104 | int resy = m_y + m_gridh * i;
105 | line(m_x, resy, m_x + m_cols * m_gridw, resy);
106 | }
107 | //表格竖线
108 | for (size_t k = 0; k < m_cols+1; k++)
109 | {
110 | line(m_x + k * m_gridw, m_y, m_x + k * m_gridw, m_y + m_gridh * m_rows);
111 | }
112 |
113 | if (m_maxPage > 0)
114 | {
115 | initPageBtnPos();
116 | }
117 | }
118 |
119 | void Table::drawTableText()
120 | {
121 | //防止越界
122 | if (m_rows > m_datas.size() &&m_datas.size()!=0)
123 | {
124 | m_rows = m_datas.size();
125 | }
126 |
127 | int begPos = m_curPage * m_rows; //当前页数*每页行数,获取当前页在m_datas中的数据下标
128 | int endPos = m_rows + m_curPage * m_rows; //上面的数据加上 每行的行数,获取一页的数据
129 | //如果是最后一页,只遍历余下的数据
130 | if (m_curPage == m_maxPage)
131 | {
132 | endPos = begPos + m_extraData;
133 | }
134 | //如果没有数据,不输出
135 | if (m_datas.size() == 0)
136 | {
137 | endPos = 0;
138 | }
139 |
140 | for (int beg = begPos,i =0; beg < endPos; beg++,i++)
141 | {
142 | std::vector line_data = split(m_datas[beg]);
143 |
144 | for (size_t k = 0; k < line_data.size(); k++)
145 | {
146 | int tx = m_x + k * m_gridw;
147 | int ty = m_y + i * m_gridh;
148 | BasicWidget::show();
149 | outtextxy(tx,ty+5, line_data[k].c_str());
150 | }
151 | }
152 | }
153 |
154 | void Table::drawHeader()
155 | {
156 | //绘制表头表格
157 | setlinestyle(PS_SOLID, 2);
158 | rectangle(m_x, m_y - 30, m_x + m_gridw * m_cols, m_y);
159 | for (size_t i = 0; i < m_cols + 1; i++)
160 | {
161 | line(m_x + i * m_gridw, m_y - 30, m_x + i * m_gridw, m_y);
162 | }
163 | //绘制表头数据
164 | std::vector header = split(m_header);
165 | for (auto it = header.begin(); it != header.end();)
166 | {
167 | if (it->empty())
168 | {
169 | it = header.erase(it);
170 | }
171 | else
172 | {
173 | it++;
174 | }
175 | }
176 | int space = 0;
177 | for (size_t i = 0; i < header.size(); i++)
178 | {
179 | space = (m_gridw - textwidth(header[i].c_str())) / 2; //居中显示表头,计算两边的间隔
180 | outtextxy(m_x + i * m_gridw + space, m_y - m_gridh+5, header[i].c_str());
181 | }
182 | }
183 |
184 | void Table::updateData()
185 | {
186 | //计算最大页数
187 | if (m_rows >= m_datas.size())
188 | {
189 | m_maxPage = 0;
190 | m_extraData = m_datas.size();
191 | }
192 | else
193 | {
194 | m_extraData = m_datas.size() % m_rows; //计算余下多少条数据
195 | m_maxPage = m_datas.size() / m_rows;
196 | }
197 | }
198 |
199 | void Table::initPageBtnPos()
200 | {
201 | m_prevPageBtn.move(m_x, m_y + m_gridh * m_rows + 20);
202 | m_nextPageBtn.move(m_x + 100, m_y + m_gridh * m_rows + 20);
203 | m_beginPageBtn.move(m_x + 200, m_y + m_gridh * m_rows + 20);
204 | m_endPageBtn.move(m_x + 300, m_y + m_gridh * m_rows + 20);
205 |
206 | m_prevPageBtn.show();
207 | m_nextPageBtn.show();
208 | m_beginPageBtn.show();
209 | m_endPageBtn.show();
210 |
211 | std::string pageInfo("共" + std::to_string(m_maxPage + 1) + "页,第" + std::to_string(m_curPage + 1) + "页");
212 | outtextxy(m_x + 450, m_y + m_gridh * m_rows + 20, pageInfo.c_str());
213 | }
214 |
215 | std::vector Table::split(std::string str,char separator)
216 | {
217 | std::vector res;
218 | for (size_t pos = 0; pos != std::string::npos ; )
219 | {
220 | if (pos != 0)
221 | pos++;
222 | //以指定的字符分隔
223 | pos = str.find(separator);
224 | //保存分隔出来的字符串
225 | res.push_back(str.substr(0, pos));
226 | //剩下未分隔的字符串
227 | str = std::string(str.data() + pos+1);
228 | }
229 | return res;
230 | }
231 |
232 | void Table::show()
233 | {
234 | BasicWidget::show();
235 | drawTableGrid();
236 | drawTableText();
237 | }
238 |
239 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/Timer.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/Timer.h"
2 | #include
3 | #include
4 | Timer::Timer(int64_t ms)
5 | :m_ms(ms), m_threadIsRun(false)
6 | {
7 | }
8 |
9 | void Timer::startTimer()
10 | {
11 | m_startime = high_resolution_clock::now();
12 |
13 | m_threadIsRun = true;
14 | static std::thread thr;
15 | thr = std::thread([this]()
16 | {
17 | while (m_threadIsRun)
18 | {
19 | m_endtime = high_resolution_clock::now();
20 | std::this_thread::sleep_for(std::chrono::milliseconds(2));
21 | }
22 | });
23 | }
24 |
25 | bool Timer::timeout()
26 | {
27 | if (m_endtime - m_startime >= milliseconds(m_ms))
28 | {
29 | m_startime = m_endtime;
30 | return true;
31 | }
32 | return false;
33 | }
34 |
35 | void Timer::setTime(int64_t ms)
36 | {
37 | m_ms = ms;
38 | }
39 |
40 | void Timer::killTimer()
41 | {
42 | m_threadIsRun = false;
43 | }
44 |
45 | bool Timer::startTimer(int64_t ms, int id)
46 | {
47 | static int64_t start[21] = { 0 };
48 | int64_t end = clock();
49 | if (end - start[id] >= ms)
50 | {
51 | start[id] = end;
52 | return true;
53 | }
54 | return false;
55 | }
56 |
57 |
58 | /*@时间间隔*/
59 | ElapsedTimer::ElapsedTimer() : m_begin(high_resolution_clock::now()) {}
60 | void ElapsedTimer::reset() { m_begin = high_resolution_clock::now(); }
61 | //默认输出毫秒
62 | int64_t ElapsedTimer::elapsed() const
63 | {
64 | return duration_cast(high_resolution_clock::now() - m_begin).count();
65 | }
66 | //微秒
67 | int64_t ElapsedTimer::elapsed_micro() const
68 | {
69 | return duration_cast(high_resolution_clock::now() - m_begin).count();
70 | }
71 | //纳秒
72 | int64_t ElapsedTimer::elapsed_nano() const
73 | {
74 | return duration_cast(high_resolution_clock::now() - m_begin).count();
75 | }
76 | //秒
77 | int64_t ElapsedTimer::elapsed_seconds() const
78 | {
79 | return duration_cast(high_resolution_clock::now() - m_begin).count();
80 | }
81 | //分
82 | int64_t ElapsedTimer::elapsed_minutes() const
83 | {
84 | return duration_cast(high_resolution_clock::now() - m_begin).count();
85 | }
86 | //时
87 | int64_t ElapsedTimer::elapsed_hours() const
88 | {
89 | return duration_cast(high_resolution_clock::now() - m_begin).count();
90 | }
--------------------------------------------------------------------------------
/Easyx_Maye/source/Window.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/Window.h"
2 | #include
3 | ExMessage Window::s_message;
4 | Window::Window(int w, int h, int flag)
5 | {
6 | handle = initgraph(w, h, flag);
7 | setbkmode(TRANSPARENT);
8 | }
9 |
10 | Window::~Window()
11 | {
12 | closegraph();
13 | }
14 |
15 | void Window::setWindowTitle(const std::string& title)
16 | {
17 | SetWindowText(handle, title.c_str());
18 | }
19 |
20 | void Window::setWindowColor(COLORREF c)
21 | {
22 | ::setbkcolor(c);
23 | clear();
24 | }
25 |
26 | void Window::setCursor(LPSTR curSorStyle)
27 | {
28 | IDC_ARROW;
29 | HCURSOR hcur = LoadCursor(NULL, curSorStyle);
30 | SetClassLong(GetHWnd(), GCLP_HCURSOR, (long)hcur);
31 | }
32 |
33 | int Window::width()
34 | {
35 | return ::getwidth();
36 | }
37 |
38 | int Window::height()
39 | {
40 | return ::getheight();
41 | }
42 |
43 | void Window::clear()
44 | {
45 | ::cleardevice();
46 | }
47 |
48 | void Window::beginDraw()
49 | {
50 | ::BeginBatchDraw();
51 | }
52 |
53 | void Window::flushDraw()
54 | {
55 | ::FlushBatchDraw();
56 | }
57 |
58 | void Window::endDraw()
59 | {
60 | ::EndBatchDraw();
61 | }
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/commonutils/Color.cpp:
--------------------------------------------------------------------------------
1 | #include "..\..\include\commonutils\Color.h"
2 |
3 | Color::Color(int rgb)
4 | {
5 | m_color = rgb;
6 | }
7 |
8 | Color::Color(uint8 r, uint8 g, uint8 b)
9 | {
10 | //m_color = ( (((color) & 0xFF) << 16) | ((color) & 0xFF00FF00) | (((color) & 0xFF0000) >> 16) )
11 | m_color = ((Dword)(((Byte)(r) | ((Word)((Byte)(g)) << 8)) | (((Dword)(Byte)(b)) << 16)));
12 | }
13 |
14 | uint32 Color::toRgb() const
15 | {
16 | return m_color;
17 | }
18 |
19 | uint32 Color::rgb(uint8 r, uint8 g, uint8 b)
20 | {
21 | return ((Dword)(((Byte)(r) | ((Word)((Byte)(g)) << 8)) | (((Dword)(Byte)(b)) << 16)));
22 | }
23 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/commonutils/Font.cpp:
--------------------------------------------------------------------------------
1 | #include"../../include/commonutils/Font.h"
2 |
3 | Font::Font()
4 | {
5 | }
6 |
7 | Font::Font(const std::string& family, int Weight, bool italic)
8 | {
9 | strcpy_s(lfFaceName, family.c_str());
10 | lfWeight = Weight;
11 | lfItalic = italic;
12 | lfcolor = Color::Black; //黑色
13 | }
14 |
15 |
16 |
17 | void Font::setHeight(int height)
18 | {
19 | lfHeight = height;
20 | }
21 |
22 | void Font::setWidth(int width)
23 | {
24 | lfWidth = width;
25 | }
26 |
27 | void Font::setBold(bool enable)
28 | {
29 |
30 | }
31 |
32 | void Font::setItalic(bool enable)
33 | {
34 | lfItalic = enable;
35 | }
36 |
37 | void Font::setWeight(int weight)
38 | {
39 | lfWeight = weight;
40 | }
41 |
42 | void Font::setQuality(int Quality)
43 | {
44 | lfQuality = lfQuality;
45 | }
46 |
47 | void Font::setFamily(const std::string& family)
48 | {
49 | strcpy_s(lfFaceName, family.c_str());
50 | }
51 |
52 | void Font::setColor(const Color& color)
53 | {
54 | lfcolor = color;
55 | }
56 |
57 | const Color& Font::color()
58 | {
59 | return lfcolor;
60 | }
61 |
62 | int Font::Height()
63 | {
64 | return lfHeight;
65 | }
66 |
67 | int Font::Width()
68 | {
69 | return lfWidth;
70 | }
71 |
72 | bool Font::Bold()
73 | {
74 | return false;
75 | }
76 |
77 | bool Font::Italic()
78 | {
79 | return lfItalic;
80 | }
81 |
82 | int Font::Weight()
83 | {
84 | return lfWeight;
85 | }
86 |
87 | int Font::Quality()
88 | {
89 | return lfQuality;
90 | }
91 |
92 | std::string Font::Family()
93 | {
94 | return lfFaceName;
95 | }
96 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/commonutils/Painter.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zcmaye/easyx-Project-C_CPP/c87130da2b470a85601a373784d42c5c033f2220/Easyx_Maye/source/commonutils/Painter.cpp
--------------------------------------------------------------------------------
/Easyx_Maye/source/pushButton.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/pushButton.h"
2 |
3 |
4 | PushButton::PushButton(std::string text, int x, int y, int w, int h)
5 | :text(text),BasicWidget(x,y,w,h)
6 | {
7 | memset(&_msg, 0, sizeof(ExMessage));
8 |
9 | }
10 |
11 | void PushButton::show()
12 | {
13 | BasicWidget::show();
14 | if (cur_img)
15 | {
16 | cur_img->draw();
17 | }
18 | else
19 | {
20 | setlinecolor(BLACK);
21 | setfillcolor(cur_color);
22 | ::fillroundrect(m_x, m_y, m_x + m_w, m_y + m_h,10,10);
23 | }
24 |
25 | //居中显示文本
26 | int tx = m_x + (m_w - textwidth(text.data())) / 2;
27 | int ty = m_y + (m_h - textheight(text.data())) / 2;
28 | outtextxy(tx, ty, text.data());
29 | }
30 |
31 | void PushButton::setText(std::string text)
32 | {
33 | this->text = text;
34 | }
35 |
36 | void PushButton::setBackgroundImage(std::string imgPath)
37 | {
38 | if(!nor_img)
39 | nor_img = new Image(imgPath.data(), this->m_w, this->m_h);
40 | this->cur_img = nor_img;
41 | this->show();
42 | }
43 |
44 | void PushButton::setBackgroundColor(Color color)
45 | {
46 | this->nor_color = color;
47 | }
48 |
49 | void PushButton::setHover(COLORREF c)
50 | {
51 | h_color = c;
52 | }
53 |
54 | void PushButton::setHover(std::string imgPath)
55 | {
56 | if(!h_img)
57 | h_img = new Image(imgPath.c_str(),m_w,m_h);
58 | }
59 |
60 | void PushButton::eventLoop(const ExMessage& msg)
61 | {
62 | this->_msg = msg;
63 | if (isin())
64 | {
65 | if (cur_img)
66 | {
67 | cur_img = h_img;
68 | }
69 | else
70 | {
71 | cur_color = h_color;
72 | }
73 | }
74 | else
75 | {
76 | if (cur_img)
77 | {
78 | cur_img = nor_img;
79 | }
80 | else
81 | {
82 | cur_color = nor_color;
83 | }
84 |
85 | }
86 |
87 | //this->show();
88 | }
89 |
90 | bool PushButton::isin()
91 | {
92 | if (_msg.x >= m_x && _msg.x <= m_x + m_w && _msg.y >= m_y && _msg.y <= m_y+m_h)
93 | {
94 | return true;
95 | }
96 | return false;
97 | }
98 |
99 | bool PushButton::isClicked()
100 | {
101 | if (isin())
102 | {
103 | switch (_msg.message)
104 | {
105 | case WM_LBUTTONDOWN:
106 | return true;
107 | }
108 | }
109 | return false;
110 | }
111 |
112 | PushButton::~PushButton()
113 | {
114 | }
115 |
--------------------------------------------------------------------------------
/Easyx_Maye/source/randomGenerator.cpp:
--------------------------------------------------------------------------------
1 | #include "../include/randomGenerator.h"
2 | #include
3 |
4 | RandomGenerator::RandomGenerator(uint32_t seedValue)
5 | :m_engine(new std::default_random_engine(seedValue))
6 | {
7 |
8 | }
9 |
10 | int RandomGenerator::bounded(int highest)
11 | {
12 | std::uniform_int_distribution intDis(0, highest-1);
13 | return intDis(*m_engine);
14 | }
15 |
16 | int RandomGenerator::bounded(int lowest, int highest)
17 | {
18 | std::uniform_int_distribution intDis(lowest, highest-1);
19 | return intDis(*m_engine);
20 | }
21 |
22 | RandomGenerator* RandomGenerator::global()
23 | {
24 | static RandomGenerator* instance = nullptr;
25 | if (instance == nullptr)
26 | {
27 | instance = new RandomGenerator((uint32_t)std::chrono::system_clock::now().time_since_epoch().count());
28 | }
29 | return instance;
30 | }
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # easyx-Project-C_CPP
2 | Easyx的一些项目
3 |
--------------------------------------------------------------------------------
/StudentManagementSystem_CPP/ManageMent(控制台版).cpp:
--------------------------------------------------------------------------------
1 | #include "ManageMent.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | using namespace std;
8 |
9 | ManageMent::ManageMent()
10 | {
11 | readData("./student.txt");
12 | //writeData("./test.txt");
13 | }
14 |
15 | void ManageMent::run()
16 | {
17 | menu();
18 | while (true)
19 | {
20 | cout << "请选择>";
21 | int op = -1;
22 | cin >> op;
23 | switch (op)
24 | {
25 | case 0:
26 | system("cls");
27 | menu();
28 | break;
29 | case ManageMent::ShowAll:
30 | displayAll();
31 | break;
32 | case ManageMent::Insert:
33 | insert();
34 | break;
35 | case ManageMent::Erase:
36 | erase();
37 | break;
38 | case ManageMent::Modify:
39 | modify();
40 | break;
41 | case ManageMent::Find:
42 | find();
43 | break;
44 | case ManageMent::Sort:
45 | sort();
46 | break;
47 | case ManageMent::Exit:
48 | writeData("./test.txt");
49 | break;
50 | default:
51 | break;
52 | }
53 | }
54 | }
55 |
56 | void ManageMent::menu()
57 | {
58 | cout << "***** 学生成绩管理系统 *****" << endl;
59 | cout << "***** 1,查看学生 *****" << endl;
60 | cout << "***** 2,添加学生 *****" << endl;
61 | cout << "***** 3,删除学生 *****" << endl;
62 | cout << "***** 4,修改学生 *****" << endl;
63 | cout << "***** 5,查找学生 *****" << endl;
64 | cout << "***** 6,排序 *****" << endl;
65 | cout << "***** 7,退出系统 *****" << endl;
66 | cout << "***** 0,清除屏幕 *****" << endl;
67 | cout << endl;
68 | }
69 |
70 | void ManageMent::displayAll()
71 | {
72 | std::cout << this->tableHeader << endl;
73 | for (auto& val : vec_stu)
74 | {
75 | val.display();
76 | }
77 | std::cout << "共(" << vec_stu.size() << ")条数据" << endl;
78 | }
79 |
80 | void ManageMent::insert()
81 | {
82 | Student stu;
83 | cout << "请依次输入<学号,姓名,班级,数学,语文,英语>" << endl;
84 | cin >> stu.number >> stu.name >> stu.grade >> stu.math >> stu.chinese >> stu.english;
85 | vec_stu.push_back(stu);
86 | }
87 |
88 | void ManageMent::erase()
89 | {
90 | int number = -1;
91 | cout << "请输入要删除的学生的学号>";
92 | cin >> number;
93 | auto delIt = std::find(vec_stu.begin(), vec_stu.end(), Student(number));
94 | if (delIt != vec_stu.end())
95 | {
96 | vec_stu.erase(delIt);
97 | }
98 | }
99 |
100 | void ManageMent::modify()
101 | {
102 | //略
103 | }
104 |
105 | void ManageMent::find()
106 | {
107 | cout << "*** 选择查找属性 ***" << endl;
108 | cout << "*** 1,按学号查找 ***" << endl;
109 | cout << "*** 2,按姓名查找 ***" << endl;
110 | int op = -1;
111 | cout << "select>";
112 | cin >> op;
113 | Student stu;
114 | if (op == 1)
115 | {
116 | cout << "输入学号:";
117 | cin >> stu.number;
118 | auto findIt = std::find(vec_stu.begin(), vec_stu.end(), stu);
119 | if (findIt != vec_stu.end())
120 | {
121 | cout << "找到咯~ ";
122 | findIt->display();
123 | }
124 | }
125 | else
126 | {
127 | cout << "输入姓名:";
128 | cin >> stu.name;
129 | for (Student& s : vec_stu)
130 | {
131 | if (s.name == stu.name)
132 | {
133 | cout << "找到咯~ ";
134 | s.display();
135 | }
136 | }
137 | }
138 | }
139 |
140 | void ManageMent::sort()
141 | {
142 | //默认升序
143 | std::sort(vec_stu.begin(), vec_stu.end());
144 | std::cout << "排序成功QAQ~" << std::endl;
145 | }
146 |
147 | void ManageMent::readData(const std::string& fileName)
148 | {
149 | fstream stream(fileName.c_str(), ios::in);
150 | if (!stream.is_open())
151 | {
152 | cerr << fileName << " file open failed" << endl;
153 | return;
154 | }
155 | Student stu;
156 | char buf[1024] = { 0 };
157 | //读取表头
158 | stream.getline(buf, 1024);
159 | tableHeader = buf;
160 | //读取数据
161 | while (!stream.eof())
162 | {
163 | memset(buf, 0, sizeof(buf));
164 | stream.getline(buf, 1024);
165 |
166 | stringstream ss(buf);
167 | ss >> stu.number >> stu.name >> stu.grade >> stu.math >> stu.chinese >> stu.english;
168 | vec_stu.push_back(stu);
169 | }
170 | stream.close();
171 | }
172 |
173 | void ManageMent::writeData(const std::string& fileName)
174 | {
175 | fstream write(fileName.c_str(), ios::trunc | ios::out);
176 | if (!write.is_open())
177 | {
178 | cerr << fileName << " file open failed [save]";
179 | return;
180 | }
181 | tableHeader += '\n';
182 | write.write(tableHeader.c_str(), tableHeader.size());
183 | for (auto& val : vec_stu)
184 | {
185 | string info = val.formatInfo();
186 | write.write(info.c_str(),info.size());
187 | }
188 | write.close();
189 | }
190 |
--------------------------------------------------------------------------------
/StudentManagementSystem_CPP/ManageMent(控制台版).h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Student.h"
3 | #include
4 | class ManageMent
5 | {
6 | enum Operator
7 | {
8 | ShowAll =1,
9 | Insert,
10 | Erase,
11 | Modify,
12 | Find,
13 | Sort,
14 | Exit,
15 | };
16 | public:
17 | ManageMent();
18 | void run();
19 | void menu();
20 | //显示所有学生信息
21 | void displayAll();
22 | //添加
23 | void insert();
24 | //删除
25 | void erase();
26 | //修改
27 | void modify();
28 | void find();
29 | //排序
30 | void sort();
31 | private:
32 | //从文件读取学生信息
33 | void readData(const std::string& fileName);
34 | //保存学生信息到文件
35 | void writeData(const std::string& fileName);
36 | public:
37 | std::string tableHeader; //表头
38 | std::vector vec_stu;
39 | };
40 |
41 |
--------------------------------------------------------------------------------
/StudentManagementSystem_CPP/ManageMent_gui.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include"Student.h"
3 | #include
4 | #include