function varargout = ModelName(varargin)
% ModelName Prompts for a name for the model

%   Project: IMPACT
%   Title of Code: ModelName
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ModelName_OpeningFcn, ...
                   'gui_OutputFcn',  @ModelName_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before ModelName is made visible.
function ModelName_OpeningFcn(hObject, eventdata, handles,varargin)
addIMPACTIcon(hObject);

filename = varargin{2};

% Choose default command line output for ModelName
handles.output = hObject;

if ~isempty(filename)
    filenameIndex = strfind(filename,'.');
    filenameIndex = max(filenameIndex);
    Newfilename = strrep(filename,filename(filenameIndex:end),'');
    set (handles.edit1,'string',Newfilename);
end
    
handles.pushbuttonValue = 0;
% Update handles structure
guidata(hObject, handles);

uiwait(hObject);

% --- Outputs from this function are returned to the command line.
function varargout = ModelName_OutputFcn(hObject, eventdata, handles) 
varargout{1} =  get(handles.edit1,'string');
close(hObject);


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
handles.pushbuttonValue = 1;
guidata (hObject,handles);
uiresume(handles.figure1);


function edit1_Callback(hObject, eventdata, handles)



% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
if ~handles.pushbuttonValue
    choice = questMLS(handles,'Do you want to load with this name?', ...
        'OK','Cancel');
    % Handle response
    if choice==1
        handles.pushbuttonValue = 1;
        guidata (hObject,handles);
        uiresume(handles.figure1);
    else
    end
else
    delete(hObject);
end


