-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewDialog.cpp
More file actions
189 lines (146 loc) · 5.22 KB
/
NewDialog.cpp
File metadata and controls
189 lines (146 loc) · 5.22 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "NewDialog.h"
//#include <stdio.h>
#include <wx/dir.h>
#include <wx/msgdlg.h>
#include <wx/textfile.h>
#include "ExportName.h"
#include "NewProfileName.h"
#include "ProfileOverwrite.h"
//#include "WinTypes.h"
//#include"ftd2xx.h"
//(*InternalHeaders(NewDialog)
#include <wx/string.h>
#include <wx/intl.h>
//*)
// portmidi initialization
//#include "portmidi.h"
//#include "porttime.h"
/*#include "stdlib.h"
#include "string.h"
#include "assert.h"
#define INPUT_BUFFER_SIZE 100
#define OUTPUT_BUFFER_SIZE 0
#define DRIVER_INFO NULL
#define TIME_PROC ((int32_t (*)(void *)) Pt_Time)
#define TIME_INFO NULL
#define TIME_START Pt_Start(1, 0, 0)
#define STRING_MAX 80
int32_t latency = 0;
*/
wxArrayString files;
extern bool ischanged;
extern bool isloading;
extern bool isexporting;
extern wxString profiledirectory;
extern bool issavefirst;
extern wxString fullpath;
extern wxString nameofexport;
extern bool isnewblankprofile;
//(*IdInit(NewDialog)
const long NewDialog::ID_LISTBOX1 = wxNewId();
const long NewDialog::ID_BUTTON4 = wxNewId();
const long NewDialog::ID_BUTTON5 = wxNewId();
const long NewDialog::ID_BUTTON1 = wxNewId();
const long NewDialog::ID_STATICTEXT1 = wxNewId();
const long NewDialog::ID_BUTTON2 = wxNewId();
//*)
BEGIN_EVENT_TABLE(NewDialog,wxDialog)
//(*EventTable(NewDialog)
//*)
END_EVENT_TABLE()
NewDialog::NewDialog(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(NewDialog)
Create(parent, wxID_ANY, _("Change Profile Sets"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, _T("wxID_ANY"));
SetClientSize(wxSize(433,355));
ListBox1 = new wxListBox(this, ID_LISTBOX1, wxPoint(48,32), wxSize(336,152), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
Button4 = new wxButton(this, ID_BUTTON4, _("Load Profile Set"), wxPoint(48,232), wxSize(336,23), 0, wxDefaultValidator, _T("ID_BUTTON4"));
Button5 = new wxButton(this, ID_BUTTON5, _("Copy the Current Profile Set"), wxPoint(48,264), wxSize(336,23), 0, wxDefaultValidator, _T("ID_BUTTON5"));
Button1 = new wxButton(this, ID_BUTTON1, _("Cancel"), wxPoint(48,304), wxSize(336,32), 0, wxDefaultValidator, _T("ID_BUTTON1"));
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Lightput Profile Set Files"), wxPoint(48,8), wxDefaultSize, 0, _T("ID_STATICTEXT1"));
Button2 = new wxButton(this, ID_BUTTON2, _("Create a New Empty Profile Set"), wxPoint(48,200), wxSize(336,23), 0, wxDefaultValidator, _T("ID_BUTTON2"));
Connect(ID_LISTBOX1,wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,(wxObjectEventFunction)&NewDialog::OnListBox1Select);
Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&NewDialog::OnButton4Click);
Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&NewDialog::OnButton5Click);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&NewDialog::OnButton1Click1);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&NewDialog::OnButton2Click);
Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&NewDialog::OnInit);
//*)
//this code block gets
//the contents of that directory aand puts it into files wxStringArray type
wxDir dir(wxGetCwd());
//files = 0;
dir.GetAllFiles(profiledirectory, &files, wxT("*.lightput"), wxDIR_DEFAULT);
ListBox1->Clear();
//writes "files" to listbox1
ListBox1->Append(files);
}
NewDialog::~NewDialog()
{
//(*Destroy(NewDialog)
//*)
}
void NewDialog::OnButton1Click(wxCommandEvent& event)
{
//TDmxSender *dmx_sender_thread;
//dmx_sender_thread->Execute();
}
void NewDialog::OnInit(wxInitDialogEvent& event)
{
}
//import button
void NewDialog::OnButton4Click(wxCommandEvent& event)
{
int selection;
selection = ListBox1->GetSelection();
if (selection > -1) {
isloading = true;
fullpath = ListBox1->GetStringSelection();
//profilefilename = fullpath not wxT(".\\profiles\\");
wxString buffer;
wxString charbuffer;
wxString nodirectory;
//these lines take the drectory off the profile name for saving/displaying
int a = ListBox1->GetSelection();
buffer = ListBox1->GetString(a);
charbuffer = buffer;
int npos = 11;//buffer.Find('.\\profiles\\',true);
int nvpos = buffer.Find(wxT('.lightput'),true) + 1;
do {
nodirectory = nodirectory + charbuffer[npos];
npos++;
} while (npos < nvpos);
nameofexport = nodirectory;
//ListBox1->SetStringSelection(wxT(".\\profiles\\"));
//ListBox1->SetStringSelection(wxT(""));
//int a = ListBox1->GetSelection();
//nameofexport = ListBox1->GetLabel();
//need to make options dialog to generate directory structure
Destroy();
}
}
//export button
void NewDialog::OnButton5Click(wxCommandEvent& event)
{
//create dialog to get filename
ExportName Dlg(0);
Dlg.ShowModal();
//write file with filename
if (isexporting == true) Destroy();
}
//cancel button
void NewDialog::OnButton1Click1(wxCommandEvent& event)
{
Destroy();
}
void NewDialog::OnListBox1Select(wxCommandEvent& event)
{
OnButton4Click(event);
}
//new blank profile button
void NewDialog::OnButton2Click(wxCommandEvent& event)
{
NewProfileName Dlg(0);
Dlg.ShowModal();
if (isnewblankprofile == true) Destroy();
}