MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
FormGym.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
5using System.Data;
6using System.Diagnostics;
7using System.Drawing;
8using System.IO;
9using System.Linq;
10using System.Text;
11using System.Threading.Tasks;
12using System.Windows.Forms;
13
14namespace MyCaffe.gym
15{
19 public partial class FormGym : Form
20 {
21 string m_strName;
22 MyCaffeGymControl m_ctrl;
23 FormActionImage m_dlgActionImage;
24 bool m_bStartRecording = false;
25
32 public FormGym(string strName, MyCaffeGymControl ctrl = null, bool bStartRecording = false)
33 {
34 InitializeComponent();
35
36 m_strName = strName;
37 m_bStartRecording = bStartRecording;
38
39 if (ctrl == null)
40 ctrl = new MyCaffeGymControl();
41
42 ctrl.Dock = DockStyle.Fill;
43 toolStripContainer1.ContentPanel.Controls.Add(ctrl);
44 m_ctrl = ctrl;
45 m_dlgActionImage = new FormActionImage();
46 m_dlgActionImage.FormClosing += dlgActionImage_FormClosing;
47 }
48
52 public string GymName
53 {
54 get { return m_strName; }
55 }
56
62 public void Render(Image bmp, Image bmpAction)
63 {
64 m_ctrl.Render(m_strName, bmp);
65
66 if (bmpAction == null)
67 {
68 btnShowActionImage.Enabled = false;
69 }
70 else
71 {
72 btnShowActionImage.Enabled = true;
73 m_dlgActionImage.SetImage(bmpAction);
74 }
75 }
76
83 public void Render(double[] rgData, Image bmp, Image bmpAction)
84 {
85 m_ctrl.Render(true, m_strName, rgData, bmp);
86
87 if (bmpAction == null)
88 {
89 btnShowActionImage.Enabled = false;
90 }
91 else
92 {
93 btnShowActionImage.Enabled = true;
94 m_dlgActionImage.SetImage(bmpAction);
95 }
96 }
97
98 private void dlgActionImage_FormClosing(object sender, FormClosingEventArgs e)
99 {
100 if (e.CloseReason == CloseReason.WindowsShutDown)
101 return;
102
103 m_dlgActionImage.Hide();
104 e.Cancel = true;
105 }
106
107 private void FormGym_Load(object sender, EventArgs e)
108 {
109 Text = "MyCaffe Test Gym - " + m_strName;
110
111 if (m_bStartRecording)
112 {
113 btnRecord.Checked = true;
114 btnRecord_Click(btnRecord, EventArgs.Empty);
115 }
116 }
117
118 private void FormGym_FormClosing(object sender, FormClosingEventArgs e)
119 {
120 if (e.CloseReason == CloseReason.WindowsShutDown || e.CloseReason == CloseReason.ApplicationExitCall)
121 return;
122
123 Hide();
124 e.Cancel = true;
125 }
126
127 private void btnShowActionImage_Click(object sender, EventArgs e)
128 {
129 if (btnShowActionImage.Checked)
130 {
131 if (m_dlgActionImage.Visible)
132 m_dlgActionImage.BringToFront();
133 else
134 m_dlgActionImage.Show(this);
135 }
136 else
137 {
138 if (m_dlgActionImage.Visible)
139 m_dlgActionImage.Hide();
140 }
141 }
142
143 private void btnRecord_Click(object sender, EventArgs e)
144 {
145 if (btnRecord.Checked)
146 {
147 btnRecord.Image = Properties.Resources.record_on;
148 m_ctrl.EnableRecording = true;
149 }
150 else
151 {
152 btnRecord.Image = Properties.Resources.record_off;
153 m_ctrl.EnableRecording = false;
154 }
155 }
156
157 private void btnDeleteRecordingData_Click(object sender, EventArgs e)
158 {
159 m_ctrl.DeleteRecordingData();
160 }
161
162 private void timerUI_Tick(object sender, EventArgs e)
163 {
164 btnDeleteRecordingData.Enabled = m_ctrl.HasRecordingData;
165 }
166 }
167}
The FormActionImage displays the action image (if one exists)
void SetImage(Image bmp)
Set the image to display.
The FormGym displays the gym visualization.
Definition: FormGym.cs:20
FormGym(string strName, MyCaffeGymControl ctrl=null, bool bStartRecording=false)
The constructor.
Definition: FormGym.cs:32
string GymName
Returns the Gym name.
Definition: FormGym.cs:53
void Render(Image bmp, Image bmpAction)
Renders the bitmap and action image (if exists).
Definition: FormGym.cs:62
void Render(double[] rgData, Image bmp, Image bmpAction)
Renders the bitmap and action image (if exists).
Definition: FormGym.cs:83
The MyCaffeGymControl displays the actual Gym visualizations.
bool HasRecordingData
Returns whether or not the Gym has any recording data.
bool EnableRecording
Enable or disable recording. When recording is enabled, each image is saved to the recording folder.
void DeleteRecordingData()
Delete any recording data that exists.
void Render(string strName, Image bmp)
Renders the Gym visualization.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12