mirror of
https://github.com/Rayerd/dfl.git
synced 2025-04-26 13:09:57 +03:00
Add Timer example
This commit is contained in:
parent
a89e010112
commit
e073c378b5
11 changed files with 161 additions and 7 deletions
16
examples/timer/.gitignore
vendored
Normal file
16
examples/timer/.gitignore
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
.dub
|
||||
docs.json
|
||||
__dummy.html
|
||||
docs/
|
||||
/hello_dfl
|
||||
hello_dfl.so
|
||||
hello_dfl.dylib
|
||||
hello_dfl.dll
|
||||
hello_dfl.a
|
||||
hello_dfl.lib
|
||||
hello_dfl-test-*
|
||||
*.exe
|
||||
*.pdb
|
||||
*.o
|
||||
*.obj
|
||||
*.lst
|
13
examples/timer/.vscode/launch.json
vendored
Normal file
13
examples/timer/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C++ Launch (Windows) timer",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "./bin/timer_sample.exe",
|
||||
"console": "internalConsole"
|
||||
}
|
||||
]
|
||||
}
|
20
examples/timer/.vscode/tasks.json
vendored
Normal file
20
examples/timer/.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "dub",
|
||||
"run": false,
|
||||
"cwd": ".",
|
||||
"compiler": "$current",
|
||||
"archType": "$current",
|
||||
"buildType": "$current",
|
||||
"configuration": "$current",
|
||||
"problemMatcher": [
|
||||
"$dmd"
|
||||
],
|
||||
"group": "build",
|
||||
"label": "dub: Build timer_sample",
|
||||
"detail": "dub build --compiler=dmd.EXE -a=x86_64 -b=debug -c=application"
|
||||
}
|
||||
]
|
||||
}
|
2
examples/timer/README.md
Normal file
2
examples/timer/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Screen Shot
|
||||

|
16
examples/timer/dub.json
Normal file
16
examples/timer/dub.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"authors": ["haru-s"],
|
||||
"copyright": "Copyright (C) 2023 haru-s",
|
||||
"description": "DFL sample code.",
|
||||
"name": "timer_sample",
|
||||
"targetType": "executable",
|
||||
"targetPath": "bin",
|
||||
"dependencies": {
|
||||
"dfl": {
|
||||
"path": "../../../dfl"
|
||||
}
|
||||
},
|
||||
"lflags-windows-x86_omf-dmd": ["/exet:nt/su:windows:6.0"],
|
||||
"lflags-windows-x86_mscoff-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"],
|
||||
"lflags-windows-x86_64-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"]
|
||||
}
|
BIN
examples/timer/image/screenshot.png
Normal file
BIN
examples/timer/image/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
3
examples/timer/shell.bat
Normal file
3
examples/timer/shell.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
set dmd_path=c:\d\dmd2\windows
|
||||
set dmc_path=c:\dmc\dm
|
||||
cmd
|
65
examples/timer/source/timer_sample.d
Normal file
65
examples/timer/source/timer_sample.d
Normal file
|
@ -0,0 +1,65 @@
|
|||
import dfl;
|
||||
import std.conv;
|
||||
|
||||
version(Have_dfl) // For DUB.
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
pragma(lib, "dfl.lib");
|
||||
}
|
||||
|
||||
class MainForm : Form
|
||||
{
|
||||
private Label _label;
|
||||
private Timer _timer;
|
||||
private Button _start;
|
||||
private Button _stop;
|
||||
private uint _count;
|
||||
|
||||
public this()
|
||||
{
|
||||
this.text = "Timer example";
|
||||
this.size = Size(300, 200);
|
||||
|
||||
_label = new Label;
|
||||
_label.location = Point(100, 0);
|
||||
_label.font = new Font("Verdana", 50f);
|
||||
_label.autoSize = true;
|
||||
_label.text = to!string(_count);
|
||||
_label.parent = this;
|
||||
|
||||
_timer = new Timer;
|
||||
_timer.interval = 1000;
|
||||
_timer.tick ~= (Timer t, EventArgs e) {
|
||||
_label.text = to!string(_count);
|
||||
_count++;
|
||||
};
|
||||
|
||||
_start = new Button;
|
||||
_start.text = "Start";
|
||||
_start.location = Point(10, 10);
|
||||
_start.click ~= (Control c, EventArgs e) {
|
||||
_timer.start();
|
||||
};
|
||||
_start.parent = this;
|
||||
|
||||
_stop = new Button;
|
||||
_stop.text = "Stop";
|
||||
_stop.location = Point(10, 50);
|
||||
_stop.click ~= (Control c, EventArgs e) {
|
||||
_timer.stop();
|
||||
};
|
||||
_stop.parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
Application.enableVisualStyles();
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
Application.run(new MainForm());
|
||||
}
|
12
examples/timer/timer.code-workspace
Normal file
12
examples/timer/timer.code-workspace
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"d.projectImportPaths": [
|
||||
"..\\..\\..\\dfl\\source"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue