-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathptrDlgCreateTraining.m
114 lines (102 loc) · 4.21 KB
/
ptrDlgCreateTraining.m
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
%
% Ask for a name and method to create a new training
%
function [name, methodName, methodPath] = ptrDlgCreateTraining(pathMethods)
name = -1;
methodName = '';
methodPath = '';
winWidth = 370; % Window width
winHeight = 140; % Window height
% List of available methods
mNames = [];
mPaths = [];
lis = dir(pathMethods);
for i=1:numel(lis)
if lis(i).name(1) ~= '.' && lis(i).isdir
nameFile = [pathMethods filesep lis(i).name ...
filesep 'nfo_name.txt'];
if exist(nameFile,'file')
mName = textread(nameFile,'%s');
mNames{numel(mNames)+1} = ptrStrJoin({mName{:}},' ');
mPaths{numel(mNames)} = lis(i).name;
end
end
end
if isempty (mNames), mNames = ' '; end
f = figure('Name', ptrLgGetString('dlgEntrenar_Title'), ...
'NumberTitle', 'off', ...
'visible','off',...
'WindowStyle','modal', ...
'Position', [1 1 winWidth winHeight], ...
'MenuBar', 'none', ...
'Resize', 'off', ...
'UserData', 0);
ptrCenterWindow(f);
pan = uipanel('Parent',f, 'BorderType', 'none',...
'Units','pixels','Position',[1 1 winWidth winHeight]);
textName = uicontrol('Parent', pan, ...
'String', ptrLgGetString('dlgEntrenar_NameLab'), ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [20 105 90 15], ...
'FontUnits','pixels', ...
'FontName', 'Helvetica', ...
'FontSize',12, ...
'HorizontalAlignment','right');
editName = uicontrol('Parent', pan, ...
'String', '', ...
'Style', 'edit', ...
'Units', 'pixels', ...
'Position', [115 100 225 25], ...
'FontUnits','pixels', ...
'FontName', 'Helvetica', ...
'FontSize',12, ...
'HorizontalAlignment','left');
textMethod = uicontrol('Parent', pan, ...
'String', ptrLgGetString('dlgEntrenar_MetLab'), ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [20 70 90 15], ...
'FontUnits','pixels', ...
'FontName', 'Helvetica', ...
'FontSize',12, ...
'HorizontalAlignment','right');
comboMethod = uicontrol('Parent', pan, ...
'String', mNames, ...
'Style', 'popupmenu', ...
'Units', 'pixels', ...
'Position', [115 65 225 25], ...
'FontUnits','pixels', ...
'FontName', 'Helvetica', ...
'FontSize',12, ...
'HorizontalAlignment','left');
btnOk = uicontrol('Parent',pan, ...
'String', ptrLgGetString('all_OkBtn'),...
'Units','pixels', ...
'Position', [winWidth/2-100 10 90 30], ...
'FontUnits', 'pixels', ...
'FontName', 'Helvetica', ...
'FontSize', 11, ...
'FontWeight', 'bold',...
'Callback', 'set(gcbf,''UserData'',1); uiresume(gcbf)');
btnCancel = uicontrol('Parent',pan, ...
'String', ptrLgGetString('all_CancelBtn'),...
'Units','pixels', ...
'Position', [winWidth/2+10 10 90 30], ...
'FontUnits', 'pixels', ...
'FontName', 'Helvetica', ...
'FontSize', 11, ...
'FontWeight', 'bold',...
'Callback', 'uiresume(gcbf)');
set(f,'Visible','on');
drawnow;
uicontrol(editName);
uiwait(f);
if ~ishandle(f), return; end
if get(f,'UserData') == 1
name = strtrim(get(editName,'String'));
methodName = mNames{get(comboMethod,'Value')};
methodPath = mPaths{get(comboMethod,'Value')};
end
close(f);
end