2using System.Collections.Generic;
8using System.Threading.Tasks;
27 string m_strName =
"";
30 List<Exception> m_loadErrors;
31 bool m_bEnableRecording =
false;
32 int m_nRecordingIndex = 0;
33 string m_strRecordingFolder;
40 InitializeComponent();
41 m_loadErrors = m_colGym.
Load();
42 m_strRecordingFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
"\\MyCaffe\\gym\\recordings";
53 get {
return m_bEnableRecording; }
54 set { m_bEnableRecording = value; }
62 get {
return m_loadErrors; }
70 get {
return m_strName; }
73 private void MyCaffeGymControl_Resize(
object sender, EventArgs e)
77 private void MyCaffeGymControl_Load(
object sender, EventArgs e)
81 private void record(Bitmap bmp)
83 if (!m_bEnableRecording)
86 if (!
System.IO.Directory.Exists(m_strRecordingFolder))
87 System.IO.Directory.CreateDirectory(m_strRecordingFolder);
89 string strFile = m_strRecordingFolder +
"\\" + m_nRecordingIndex.ToString(
"000000") +
".png";
90 bmp.Save(strFile,
System.Drawing.Imaging.ImageFormat.Png);
102 if (Directory.Exists(m_strRecordingFolder))
104 string[] rgstrFiles = Directory.GetFiles(m_strRecordingFolder,
"*.png");
105 return (rgstrFiles.Length > 0);
117 if (Directory.Exists(m_strRecordingFolder))
119 string[] rgstrFiles = Directory.GetFiles(m_strRecordingFolder,
"*.png");
121 foreach (
string strFile
in rgstrFiles)
123 File.Delete(strFile);
126 m_nRecordingIndex = 0;
135 public void Render(
string strName, Image bmp)
138 m_bmp =
new Bitmap(bmp);
140 if (IsHandleCreated && Visible)
153 public void Render(
bool bShowUi,
string strName,
double[] rgData, Image bmp)
161 m_bmp =
new Bitmap(bmp);
165 Tuple<Bitmap, SimpleDatum> data = igym.
Render(bShowUi, Width, Height, rgData,
false);
170 if (IsHandleCreated && Visible)
176 private void MyCaffeGymControl_Paint(
object sender, PaintEventArgs e)
179 e.Graphics.DrawImage(m_bmp,
new Point(0, 0));
The GymCollection contains the available Gyms.
List< Exception > Load()
Loads the default and dynamic gyms.
IXMyCaffeGym Find(string strName)
Search for a given Gym by its name.
The MyCaffeGymControl displays the actual Gym visualizations.
bool HasRecordingData
Returns whether or not the Gym has any recording data.
string GymName
Returns the GymName.
void Render(bool bShowUi, string strName, double[] rgData, Image bmp)
Renders the Gym visualizations.
List< Exception > LoadErrors
Returns any load errors that may have occured while loading the gyms.
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.
MyCaffeGymControl()
The constructor.
The IXMyCaffeGym interface is used to interact with each Gym.
Tuple< Bitmap, SimpleDatum > Render(bool bShowUi, int nWidth, int nHeight, bool bGetAction)
Render the gym on a bitmap.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
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-...