-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGrid.h
More file actions
82 lines (69 loc) · 2.17 KB
/
Grid.h
File metadata and controls
82 lines (69 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
using namespace Platform;
using namespace AlgorithmVisualization;
using namespace Platform::Collections;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI;
using namespace Windows::UI::Xaml;
namespace AlgorithmVisualization {
/// <summary>
/// 矩形状态
/// </summary>
public enum class RectState
{
Susceptible = 0, //易感者
Infectious = 1, //感染者
Recovered = 2, //康复者
Exposed = 3, //潜伏者
Asymptomatic = 4, //无症状感染者
};
/// <summary>
/// 矩形类
/// </summary>
public ref class Rect sealed
{
public:
Rect(double width, double height, RectState state); //构造函数
void Resize(int width, int height); //修改尺寸
void ChangeState(RectState newState); //修改状态
Color StateToColor(RectState state); //状态转颜色
property Controls::StackPanel^ Container; //容器
property Shapes::Rectangle^ InternalRect; //内部的矩形
property RectState CurrentState; //当前状态
//边缘
static property int Margin
{
int get()
{
return 1;
}
}
private:
Color SusceptibleColor = Colors::Blue; //易感者颜色
Color InfectiousColor = Colors::Red; //感染者颜色
Color RecoveredColor = Colors::Green; //康复者颜色
Color ExposedColor = Colors::Yellow; //潜伏者颜色
Color AsymptomaticColor = Colors::DeepSkyBlue; //无症状感染者颜色
};
/// <summary>
/// 网格图
/// </summary>
public ref class Grid sealed
{
public:
Grid(double _width, double _height, int _rows, int _cols, RectState defaultState); //构造函数
Windows::UI::Xaml::Controls::StackPanel^ GetView(); //获取视图
void OnSizeChanged(double _width, double _height); //尺寸改变时回调
Rect^ Get(int x, int y); //获取矩形
Rect^ GetCenter(); //获取中心矩形
void Set(int x, int y, Rect^ newRect); //设置矩形
void SetState(int x, int y, RectState newState); //设置矩形状态
property int rows; //行数
property int cols; //列数
private:
Windows::UI::Xaml::Controls::StackPanel^ ThisView; //视图
IVector<IVector<Rect^>^>^ Data; //网格的数据
double width{ 800.0 }; //宽度
double height{ 800.0 }; //高度
};
}