%
% Setup RHIT AVC Libraries
%
h=msgbox(sprintf('Installing AVC Toolbox.\nThis may take a moment.\n(This dialog box will close automatically.)'),'HSAVC Toolbox Setup', 'warn');
a=matlab.addons.toolbox.installToolbox('High_School_Autonomous_Vehicle_Competition.mltbx');
if ishandle(h)
    close(h);
end
h=msgbox(sprintf('Installation of AVC Toolbox complete.\n\nSetting up paths, shortcuts, and working directory.\n(This dialog box will close automatically.)'),...
    'HSAVC Shortcut Setup', 'warn');
%%
% Copy Preferences to the user's preference directory.
%

fn='''Pref_Directory\*'' ';
target_dir=prefdir;
command=['copyfile ', fn, '''', target_dir,''''];
eval(command);
%%
% Create a working directory in the users matlab directory. 
%
userDir = winqueryreg('HKEY_CURRENT_USER',...
    ['Software\Microsoft\Windows\CurrentVersion\' ...
    'Explorer\Shell Folders'],'Personal');
AVC_Dir=[userDir,'\MATLAB\AVC_Work_Directory'];
if ~exist(AVC_Dir)
    command=['mkdir ', '''', AVC_Dir,''''];
    eval(command);
end

%Copy lesson 12 files to the working directory.
Lesson_12_Dir=[AVC_Dir, '\Lesson_12_Files'];
if ~exist(Lesson_12_Dir)
    fn='''Lesson_12_Files\*'' ';
    command=['copyfile ', fn, '''', Lesson_12_Dir,''''];
    eval(command);
end




%%
% We are done!
pause(5);
if ishandle(h)
    close(h);
end

h=msgbox(sprintf('Setup Complete! MATLAB will now exit after you click the OK button.\nPlease restart MATLAB.'),...
    'HSAVC Setup Complete', 'help'); 
waitfor(h);
exit