function varargout = Steffs_Todo(varargin)
% STEFFS_TODO MATLAB code for Steffs_Todo.fig
%      STEFFS_TODO, by itself, creates a new STEFFS_TODO or raises the existing
%      singleton*.
%
%      H = STEFFS_TODO returns the handle to a new STEFFS_TODO or the handle to
%      the existing singleton*.
%
%      STEFFS_TODO('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STEFFS_TODO.M with the given input arguments.
%
%      STEFFS_TODO('Property','Value',...) creates a new STEFFS_TODO or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Steffs_Todo_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Steffs_Todo_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Steffs_Todo

% Last Modified by GUIDE v2.5 01-Apr-2019 16:24:22

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Steffs_Todo_OpeningFcn, ...
                   'gui_OutputFcn',  @Steffs_Todo_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 Steffs_Todo is made visible.
function Steffs_Todo_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Steffs_Todo (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Steffs_Todo wait for user response (see UIRESUME)
% uiwait(handles.figure1);

%Nachfragen ob Steffs_Todo_Checkbox.mat existiert, wenn ja soll es damit starten
if(exist ("Steffs_Todo_Checkbox_save.mat"))
    fields4read = {'checkbox1','checkbox2','checkbox3','checkbox4','checkbox5','checkbox6','checkbox7','checkbox8','checkbox9','checkbox10','checkbox11','checkbox12','checkbox13','checkbox14','checkbox15','checkbox16','checkbox17','checkbox18','checkbox19','checkbox20','checkbox21','checkboxlang1','checkboxlang2','checkboxlang3','checkboxlang4','checkboxlang5','checkboxlang6','checkboxlang7','checkboxlang8','checkboxlang9','checkboxlang10','checkboxlang11','checkboxlang12','checkboxlang13','checkboxlang14','checkboxlang15','checkboxlang16','checkboxlang17','checkboxlang18','checkboxlang19','checkboxlang20','checkboxlang21'};
    X = load('Steffs_Todo_Checkbox_save');
    if isfield(X, 'savevalue_Checkbox')
        savevalue_Checkbox = X.savevalue_Checkbox;
        for k=1:length(fields4read)
            if isfield(handles, fields4read{k})
                set(handles.(fields4read{k}), 'string', savevalue_Checkbox.(fields4read{k}))
            end
        end
    end
end

%Nachfragen ob Steffs_Todo_Notizen.mat existiert, wenn ja soll es damit starten
if(exist ("Steffs_Todo_Notizen_save.mat"))
    X = load('Steffs_Todo_Notizen_save.mat');
    if isfield(X, 'savevalue_Notizen')
        savevalue_Notizen = X.savevalue_Notizen;
        set(handles.edit_Notizen, 'string', savevalue_Notizen.edit_Notizen)
    end
end

kpf = get(handles.figure1, 'KeyPressFcn');
flds = fieldnames(handles);
for k = 1:numel(flds)
    try
    set(handles.(flds{k}), 'KeyPressFcn', kpf)
    catch
    end
end

% --- Outputs from this function are returned to the command line.
function varargout = Steffs_Todo_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 edit_Todo_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Todo (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 edit_Todo as text
%        str2double(get(hObject,'String')) returns contents of edit_Todo as a double


% --- Executes during object creation, after setting all properties.
function edit_Todo_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Todo (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


function edit_Infos_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Infos (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 edit_Infos as text
%        str2double(get(hObject,'String')) returns contents of edit_Infos as a double



% --- Executes during object creation, after setting all properties.
function edit_Infos_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Infos (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


function edit_Todolangfristig_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Todolangfristig (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 edit_Todolangfristig as text
%        str2double(get(hObject,'String')) returns contents of edit_Todolangfristig as a double


% --- Executes during object creation, after setting all properties.
function edit_Todolangfristig_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Todolangfristig (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 button press in pushbutton_view_Todo.
function pushbutton_view_Todo_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_view_Todo (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Variable Pfad den aktuellen Dateipfat der .m Datei zuweisen
Pfad = pwd;

%Öffnen des Ordners mit den abgelegten Todo Textdateien
winopen([Pfad,'\Textdateien\Todo']);

% --- Executes on button press in pushbutton_view_Info.
function pushbutton_view_Info_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_view_Info (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Öffnen des Ordners mit den abgelegten Infos Textdateien
winopen('c:\__DATEN\04_Infos_Skripte\Infos');

% --- Executes on button press in pushbutton_view_Todo_langfristig.
function pushbutton_view_Todo_langfristig_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_view_Todo_langfristig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Variable Pfad den aktuellen Dateipfat der .m Datei zuweisen
Pfad = pwd;

%Öffnen des Ordners mit den abgelegten Todo langfristig Textdateien
winopen([Pfad,'\Textdateien\Todo langfristig']);


% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox1


% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox2


% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox3


% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox4


% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox5


% --- Executes on button press in checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox6


% --- Executes on button press in checkbox8.
function checkbox8_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox8


% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox7


% --- Executes on button press in checkbox9.
function checkbox9_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox9


% --- Executes on button press in checkbox10.
function checkbox10_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox10


% --- Executes on button press in checkbox11.
function checkbox11_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox11


% --- Executes on button press in checkbox12.
function checkbox12_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox12


% --- Executes on button press in checkbox13.
function checkbox13_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox13


% --- Executes on button press in checkbox14.
function checkbox14_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox14


% --- Executes on button press in checkbox15.
function checkbox15_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox15


% --- Executes on button press in checkbox16.
function checkbox16_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox16


% --- Executes on button press in checkbox17.
function checkbox17_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox17


% --- Executes on button press in checkbox18.
function checkbox18_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox18


% --- Executes on button press in checkbox19.
function checkbox19_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox19


% --- Executes on button press in checkbox20.
function checkbox20_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox20


% --- Executes on button press in checkbox21.
function checkbox21_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox21


% --- Executes on button press in checkboxlang1.
function checkboxlang1_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang1


% --- Executes on button press in checkboxlang2.
function checkboxlang2_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang2


% --- Executes on button press in checkboxlang3.
function checkboxlang3_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang3


% --- Executes on button press in checkboxlang4.
function checkboxlang4_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang4


% --- Executes on button press in checkboxlang5.
function checkboxlang5_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang5


% --- Executes on button press in checkboxlang6.
function checkboxlang6_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang6


% --- Executes on button press in checkboxlang8.
function checkboxlang8_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang8


% --- Executes on button press in checkboxlang7.
function checkboxlang7_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang7


% --- Executes on button press in checkboxlang9.
function checkboxlang9_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang9


% --- Executes on button press in checkboxlang10.
function checkboxlang10_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang10


% --- Executes on button press in checkboxlang11.
function checkboxlang11_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang11


% --- Executes on button press in checkboxlang12.
function checkboxlang12_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang12


% --- Executes on button press in checkboxlang13.
function checkboxlang13_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang13


% --- Executes on button press in checkboxlang14.
function checkboxlang14_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang14


% --- Executes on button press in checkboxlang15.
function checkboxlang15_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang15


% --- Executes on button press in checkboxlang16.
function checkboxlang16_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang16


% --- Executes on button press in checkboxlang17.
function checkboxlang17_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang17


% --- Executes on button press in checkboxlang18.
function checkboxlang18_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang18


% --- Executes on button press in checkboxlang19.
function checkboxlang19_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang19


% --- Executes on button press in checkboxlang20.
function checkboxlang20_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang20


% --- Executes on button press in checkboxlang21.
function checkboxlang21_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxlang21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkboxlang21


% --- Executes on button press in pushbutton_Links.
function pushbutton_Links_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Links (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%öffnen des von Stefan gewollten Dateipfads
winopen('c:\__DATEN\19_Steffs_Admin3000s\links');


% --- Executes on button press in pushbutton_Getrieberechner.
function pushbutton_Getrieberechner_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_Getrieberechner (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%öffnen des von Stefan gewollten Dateipfads
winopen('c:\__DATEN\04_Infos_Skripte\Getrieberechner.xlsm');


% --- Executes on button press in pushbutton_FUD.
function pushbutton_FUD_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_FUD (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%öffnen des von Stefan gewollten Dateipfads
winopen('c:\__DATEN\19_Steffs_Admin3000s\FUD');


% --- Executes on button press in pushbutton_loeschen.
function pushbutton_loeschen_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_loeschen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


%löschen der angekreuzten Checkboxen
for x=1:21
    if(get(handles.(['checkbox', num2str(x)]),'Value') == 1)
        set(handles.(['checkbox', num2str(x)]),'String', '');
        set(handles.(['checkbox', num2str(x)]), 'Value', 0);
    end  
end

%nachrücken der nachfolgenden Texte in Todo
for x=1:21
    if(get(handles.(['checkbox', num2str(x)]), 'String') == "")
        for y=x+1:21
            if(get(handles.(['checkbox', num2str(y)]), 'String') ~= "")
                move = get(handles.(['checkbox', num2str(y)]), 'String');
                set(handles.(['checkbox', num2str(x)]), 'String', move)
                set(handles.(['checkbox', num2str(y)]), 'String', '');
                break
            end
        end
    end
end
 
%löschen der angekreuzten Checkboxen langfristig
for x=1:21
    if(get(handles.(['checkboxlang', num2str(x)]),'Value') == 1)
        set(handles.(['checkboxlang', num2str(x)]),'String', '');
        set(handles.(['checkboxlang', num2str(x)]), 'Value', 0);
    end
end

%nachrücken der nachfolgenden Texte in Todo langfristig
for x=1:21
    if(get(handles.(['checkboxlang', num2str(x)]), 'String') == "")
        for y=x+1:21
            if(get(handles.(['checkboxlang', num2str(y)]), 'String') ~= "")
                move_langfristig = get(handles.(['checkboxlang', num2str(y)]), 'String');
                set(handles.(['checkboxlang', num2str(x)]), 'String', move_langfristig)
                set(handles.(['checkboxlang', num2str(y)]), 'String', '');
                break
            end
        end
    end
end


% --- Executes on button press in pushbutton_bearbeiten.
function pushbutton_bearbeiten_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_bearbeiten (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Variable Pfad den aktuellen Dateipfat der .m Datei zuweisen
Pfad = pwd;

%oberste angekreuzte Checkbox wird gelöscht und in edit_Todo geschrieben
for x = 1:21
    if(get(handles.(['checkbox', num2str(x)]), 'value') == 1)
        bearbeiten = get(handles.(['checkbox', num2str(x)]), 'String');
        set(handles.edit_Todo, 'String', bearbeiten)
        set(handles.(['checkbox', num2str(x)]), 'string', '')
        set(handles.(['checkbox', num2str(x)]), 'value', 0);
        break
    end
end


% --- Executes on button press in pushbutton_checkall.
function pushbutton_checkall_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_checkall (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%ankreuzen aller Todo Checkboxen
for x = 1:21
    set(handles.(['checkbox', num2str(x)]),'value', 1);
end


% --- Executes on button press in pushbutton_move.
function pushbutton_move_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_move (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.checkbox1 , 'value', 0); 

%angekreuzte Checkboxen werden 1 nach oben geschoben 
for x = 2:21
    if(get(handles.(['checkbox', num2str(x)]),'value') == 1 && get(handles.(['checkbox', num2str(x)]), 'string') ~= "")
        move_kreuz = get(handles.(['checkbox', num2str(x)]), 'string');
        move_runter = get(handles.(['checkbox', num2str(x-1)]), 'string');
        set(handles.(['checkbox', num2str(x-1)]), 'string', move_kreuz);
        set(handles.(['checkbox', num2str(x)]), 'string', move_runter);
        set(handles.(['checkbox', num2str(x)]), 'value', 0)
    else
        set(handles.(['checkbox', num2str(x)]), 'value', 0)
    end
    
end

%angekreuzte Checkboxen werden 1 nach oben geschoben 
for x = 2:21
    if(get(handles.(['checkboxlang', num2str(x)]),'value') == 1)
        move_kreuz_langfristig = get(handles.(['checkboxlang', num2str(x)]), 'string');
        move_runter_langfristig = get(handles.(['checkboxlang', num2str(x-1)]), 'string');
        set(handles.(['checkboxlang', num2str(x-1)]), 'string', move_kreuz_langfristig);
        set(handles.(['checkboxlang', num2str(x)]), 'string', move_runter_langfristig);
        set(handles.(['checkboxlang', num2str(x)]), 'value', 0)
    else
        set(handles.(['checkboxlang', num2str(x)]), 'value', 0)
    end
end


% --- Executes on button press in pushbutton_bearbeiten_langfristig.
function pushbutton_bearbeiten_langfristig_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_bearbeiten_langfristig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Variable Pfad den aktuellen Dateipfat der .m Datei zuweisen
Pfad = pwd;

%1. angekreuzte Checkbox wird gelöscht und in edit_Todolangfristig geschrieben
for x = 1:21
    if(get(handles.(['checkboxlang', num2str(x)]), 'value') == 1)
        bearbeiten_langfristig = get(handles.(['checkboxlang', num2str(x)]), 'String');
        set(handles.edit_Todolangfristig, 'String', bearbeiten_langfristig)
        set(handles.(['checkboxlang', num2str(x)]), 'string', '')
        set(handles.(['checkboxlang', num2str(x)]), 'value', 0)
        break
    end
end


% --- Executes on button press in pushbutton_checkall_langfristig.
function pushbutton_checkall_langfristig_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_checkall_langfristig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%ankreuzen aller Todo langfristig Checkboxen
for x = 1:21
    set(handles.(['checkboxlang', num2str(x)]),'value', 1);
end


function edit_Notizen_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Notizen (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 edit_Notizen as text
%        str2double(get(hObject,'String')) returns contents of edit_Notizen as a double


% --- Executes during object creation, after setting all properties.
function edit_Notizen_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Notizen (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 during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Speichern der Checkbox Einträge in Steffs_Todo_Checkbox_save.mat bei Betätigung von Schließen (X Knopf)
fields4save = {'checkbox1','checkbox2','checkbox3','checkbox4','checkbox5','checkbox6','checkbox7','checkbox8','checkbox9','checkbox10','checkbox11','checkbox12','checkbox13','checkbox14','checkbox15','checkbox16','checkbox17','checkbox18','checkbox19','checkbox20','checkbox21','checkboxlang1','checkboxlang2','checkboxlang3','checkboxlang4','checkboxlang5','checkboxlang6','checkboxlang7','checkboxlang8','checkboxlang9','checkboxlang10','checkboxlang11','checkboxlang12','checkboxlang13','checkboxlang14','checkboxlang15','checkboxlang16','checkboxlang17','checkboxlang18','checkboxlang19','checkboxlang20','checkboxlang21'};

for k=1:length(fields4save)
    savevalue_Checkbox.(fields4save{k}) = get(handles.(fields4save{k}), 'string');  
end

save('Steffs_Todo_Checkbox_save', 'savevalue_Checkbox');

%Speichern der Notiz Einträge in Steffs_Todo_Notizen_save.mat
savevalue_Notizen.edit_Notizen = get(handles.edit_Notizen, 'string');
save('Steffs_Todo_Notizen_save', 'savevalue_Notizen')


% --- Executes on key press with focus on pushbutton_move and none of its controls.
function pushbutton_move_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton_move (see GCBO)
% eventdata  structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift)
%	pressed
% handles    structure with handles and user data (see GUIDATA)


if strcmp(eventdata.Key, 'm')
    Data = get(hObject, 'String')
    pushbutton_move_Callback(hObject, eventdata, handles);
end
        
 


% --- Executes on key press with focus on figure1 and none of its controls.
function figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  structure with the following fields (see MATLAB.UI.FIGURE)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

switch eventdata.Key
    case 'm'
        pushbutton_move_Callback(hObject, eventdata, handles)
    case 'return'
        %Variable Pfad den aktuellen Dateipfat der .m Datei zuweisen
        Pfad = pwd;
        
        %{
        if((exist ([Pfad,'\Todo Log'])) ~= 1)
            fid = fopen(([Pfad,'\Todo Log', '.txt']), 'a+');
            fclose(fid);
        end
       %}
 
        %Einlesen des Textes
        text_Todo = get(handles.edit_Todo, 'String');
        text_Todolang = get(handles.edit_Todolangfristig, 'String');
        
        %Ablage des geschriebenen Textes in eine unbeschriebene Todo Checkbox
        for x = 1:22
            if(x <= 21)
                if(get(handles.(['checkbox', num2str(x)]),'String')=="" && get(handles.edit_Todo, 'String')~= "")  
                    set(handles.(['checkbox', num2str(x)]),'String', text_Todo);
                    set(handles.edit_Todo, 'String', '');
                    
                    
                    fid = fopen(([Pfad, '\Todo Log', '.txt.']), 'a+');
                    fprintf(fid, [datestr(now), ': eingetragen | ', text_Todo, '\n']);
                    fclose(fid);
                    
                end    
            elseif (x > 21 && get(handles.edit_Todo, 'String')~= "")
                msgbox('Alle Todo checkboxen sind beschrieben');
            end
        end
        
        %Ablage des geschriebenen Textes in eine unbeschriebene Todo langfristig Checkbox
        for x = 1:22
            if(x <= 21)
                if(get(handles.(['checkboxlang', num2str(x)]),'String') == "" && get(handles.edit_Todolangfristig, 'String')~= "")  
                    set(handles.(['checkboxlang', num2str(x)]),'String', text_Todolang);
                    set(handles.edit_Todolangfristig, 'String', '');                        
                end    
            elseif (x > 21 && get(handles.edit_Todolangfristig, 'String')~= "")
                msgbox('Alle Todo langfristig checkboxen sind beschrieben');
            end
        end
    case 'backspace'
        pushbutton_loeschen_Callback(hObject, eventdata, handles)
    case 'b'
        pushbutton_bearbeiten_langfristig_Callback(hObject, eventdata, handles)
        pushbutton_bearbeiten_Callback(hObject, eventdata, handles)
        
end