function varargout = main(varargin)


% MAIN MATLAB code for main.fig
% Edit the above text to modify the response to help main

% Last Modified by GUIDE v2.5 15-Dec-2015 09:24:53

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_OpeningFcn, ...
                   'gui_OutputFcn',  @main_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 main is made visible.
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.

%Parsen nicht vergessen


% Bildschirmauflösung, unter die GUI entstand: 
develop_screen_size = [1680 1050]; 
% Aktuelle Auflösung abfragen: 
current_screen_size  = get(0,'ScreenSize'); 
%git Test
% Faktoren für die Änderung zw. Auflösungen berechnen 
fctr_w = current_screen_size(3)/develop_screen_size(1); 
fctr_h = current_screen_size(4)/develop_screen_size(2); 
% 

% Die aktuelle Größe des Fensters abfragen: 
figsize = get(handles.figure1, 'Position'); 


% setze die Fenstergröße zurück, 
% falls units auf normalized gesetzt sind 
if all(figsize <= 1) 
   figsize (:,[1,3]) = figsize (:,[1,3])/fctr_w; 
   figsize (:,[2,4]) = figsize (:,[2,4])/fctr_h; 
end 

% danach minimalen Faktor auswählen und 
% nach dem beide Seiten skalieren 
fctr = min(fctr_w,fctr_h); 
figsize (:,[1,3]) = figsize (:,[1,3])*(fctr); 
figsize (:,[2,4]) = figsize (:,[2,4])*(fctr); 

% falls unit nicht normalized sind, runden 
if any(figsize > 1) 
  figsize =round(figsize); 
end 

%verändere die Fenstergröße 
set(handles.figure1,'Position',figsize)

% set(handlesmain, 'Position', [10, 10, 600, 600]);

% GUI zentrieren
movegui('center');


% Choose default command line output for main
handles.output = hObject;
handles.ButtonNode = uicontrol('Style','pushbutton','Units','normalized','Parent',handles.figure1,'String','Node','Position',[.05 .8 .1 .1],'Visible','on','Callback', @(hObject,eventdata)main('ButtonNode_Callback',hObject,eventdata,guidata(hObject)));
% handles.panel_node = uipanel('Title','Nodes','Units','normalized','Parent',handles.figure1,'Position',[.3 .2 .6 .8],'Visible','off');
handles.panel_node1 = uipanel('Units','normalized','Parent',handles.figure1,'Position',[.3 .2 .6 0.8],'Visible','off');
handles.panel_node2 = uipanel('Title','Nodes','Units','normalized','Parent',handles.panel_node1,'Position',[0 -1 1 2],'Visible','off');
handles.slider = uicontrol('Style','slider','Units','normalized','Parent',handles.panel_node2,'Position',[0.8 .4 .1 .6],'Visible','off','Callback', @(hObject,eventdata)main('slider_Callback',hObject,eventdata,guidata(hObject)));
% Laptop Positionen überprüfen!!! Slider alt 'Position',[.8 .05 .1 .5] [left bottom width height]

% Update handles structure
guidata(hObject, handles);


function ButtonNode_Callback(hObject, eventdata, handles)
% hObject    handle to Editier_Text (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.panel_node1,'Visible','on');
set(handles.panel_node2,'Visible','on');
set(handles.slider,'Visible','on');
Textfeldbreite = .1;
Start_Y_Pos = 0.9; %default laptop = 0.9

for i = 1:8
    zaehler = num2str(i);
    text = 'textbox_node_'; 
    wert = strcat(text, zaehler);
    Y_Pos = Start_Y_Pos-i*0.12;
    
    handles.werte = uicontrol('Style','text','Units','normalized','Parent',handles.panel_node2,'Position',[.2 Y_Pos .1 Textfeldbreite],'Visible','on','BackgroundColor','white');
    handles.wert = uicontrol('Style','text','Units','normalized','Parent',handles.panel_node2,'Position',[.35 Y_Pos .1 Textfeldbreite],'Visible','on','BackgroundColor','white');
end
%%

function slider_Callback(hObject,eventdata, handles) 
    set(handles.panel_node2,'Position',[0 get(handles.slider,'Value') 1 1]);
    


%%
% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --------------------------------------------------------------------
function Menu_File_Callback(hObject, eventdata, handles)
% hObject    handle to Menu_File (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FIle_New_Callback(hObject, eventdata, handles)
% hObject    handle to FIle_New (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FIle_Open_Callback(hObject, eventdata, handles)
% hObject    handle to FIle_Open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FIle_Save_Callback(hObject, eventdata, handles)
% hObject    handle to FIle_Save (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FIle_Close_Callback(hObject, eventdata, handles)
% hObject    handle to FIle_Close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider



