testListBoxlj.m
资源名称:cx9.rar [点击查看]
上传用户:xueli1969
上传日期:2022-07-27
资源大小:19k
文件大小:8k
源码类别:
通讯编程文档
开发平台:
Matlab
- function varargout = testListBoxlj(varargin)
- % TESTLISTBOXLJ M-file for testListBoxlj.fig
- % TESTLISTBOXLJ, by itself, creates a new TESTLISTBOXLJ or raises the existing
- % singleton*.
- %
- % H = TESTLISTBOXLJ returns the handle to a new TESTLISTBOXLJ or the handle to
- % the existing singleton*.
- %
- % TESTLISTBOXLJ('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in TESTLISTBOXLJ.M with the given input arguments.
- %
- % TESTLISTBOXLJ('Property','Value',...) creates a new TESTLISTBOXLJ or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before testListBoxlj_OpeningFunction gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to testListBoxlj_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 testListBoxlj
- % Last Modified by GUIDE v2.5 19-Sep-2005 10:36:50
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @testListBoxlj_OpeningFcn, ...
- 'gui_OutputFcn', @testListBoxlj_OutputFcn, ...
- 'gui_LayoutFcn', [] , ...
- 'gui_Callback', []);
- if nargin & isstr(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 testListBoxlj is made visible.
- function testListBoxlj_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 testListBoxlj (see VARARGIN)
- % Choose default command line output for testListBoxlj
- %%%%%%%%%%%记得解除
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % if nargin == 3,
- % initial_dir = pwd;
- % elseif nargin > 4
- % if strcmpi(varargin{1},'dir')
- % if exist(varargin{2},'dir')
- % initial_dir = varargin{2};
- % else
- % errordlg('Input argument must be a valid directory','Input Argument Error!')
- % return
- % end
- % else
- % errordlg('Unrecognized input argument','Input Argument Error!');
- % return;
- % end
- % end
- initial_dir = pwd;
- ss=load_listbox(initial_dir,handles);
- handles.ss=ss;
- % UIWAIT makes testListBoxlj wait for user response (see UIRESUME)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % % % add by lijing
- % handles.parhandles=varargin{1};
- guidata(handles.figure1, handles);
- % while handles.ss.IsImage==0
- uiwait(handles.figure1); %%%%%%%只有在这里加才不会出错
- % handles.figure1
- % handles.ss.IsImage
- % end
- % --- Outputs from this function are returned to the command line.
- function varargout = testListBoxlj_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;
- varargout{1} = handles;
- % delete(handles.figure1)%%%%%%%%%%
- % --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER.
- if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
- % --- Executes on selection change in listbox1. function listbox1_Callback(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % get(handles.figure1,'SelectionType');
- index_selected = get(handles.listbox1,'Value');
- % file_list = get(handles.listbox1,'String');
- %%%%%%%%%%%%大问题%%%%%%%%%%%%%%%%%%%%%%%
- filename = handles.ss.sorted_names{index_selected};
- handles.ss.filename=[pwd,'',filename];
- handles.ss.names_disp=handles.ss.sorted_names_disp{index_selected};
- handles.ss.imsize=handles.ss.imsize_disp{index_selected}; % (返回)
- % handles.ss.f=handles.figure1
- if index_selected<=handles.ss.cnPiont
- cd(handles.ss.filename)
- ss=load_listbox(pwd,handles);
- handles.ss=ss;
- handles.ss.IsImage=0; % 返回一个‘文件’或‘图片’的记录
- % filename = handles.ss.sorted_names{index_selected};
- % handles.ss.filename=[pwd,'',filename];
- % handles.ss.names_disp=handles.ss.sorted_names_disp{index_selected};
- % handles.ss.imsize=handles.ss.imsize_disp{index_selected}; % (返回)
- else
- handles.ss.IsImage=1; % (返回)
- end
- %%%%%%%%%%%%
- guidata(handles.figure1, handles);
- uiresume(handles.figure1);%%%%%%%只有在这里加才不会出错
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function ss=load_listbox(dir_path,handles)
- cd (dir_path)
- dir_struct = dir(dir_path);
- [sorted_names1,sorted_index1] = sortrows({dir_struct.name}');
- k=max(sorted_index1);
- if k==2
- sorted_names{1}='.';
- sorted_names{2}='..';
- sorted_names_disp{1}='.';
- sorted_names_disp{2}='..';
- imsize_disp{1}='null';
- imsize_disp{2}='null';
- cnPiont=2;
- else
- sorted_names{1}='.';
- sorted_names{2}='..';
- sorted_names_disp{1}='.';
- sorted_names_disp{2}='..';
- imsize_disp{1}='null';
- imsize_disp{2}='null';
- cn=2;
- %%%%%% 找文件夹
- for i=1:k
- [path,name,ext,ver] = fileparts(sorted_names1{i});
- switch ext
- case ''
- cn=cn+1;
- cnarray(cn)=cn;
- %sorted_names(cn)=name;
- sorted_names{cn}=name;
- sorted_names_disp{cn}=name;
- %name
- imsize_disp{cn}='null';
- end
- end
- cnPiont=cn;
- % guidata(handles.figure1,handles)
- %%%%%% 找图片
- for i=1:k
- [path,name,ext,ver] = fileparts(sorted_names1{i});
- switch ext
- case {'.bmp','.jpg','.jpeg','.tif'}
- cn=cn+1;
- cnarray(cn)=cn;
- %sorted_names(cn)=name;
- name=[name,ext];
- sorted_names{cn}=name;
- temp=imread(name);
- [m,n]=size(temp);
- m=num2str(m);
- n=num2str(n);
- imsize=[' ',m,'*',n,' (size)']; %%% 要返回
- name_disp=[name,imsize];
- sorted_names_disp{cn}=name_disp;
- imsize_disp{cn}=imsize;
- %name
- end
- end
- end
- ss.sorted_names=sorted_names; %%% 要返回
- ss.sorted_names_disp=sorted_names_disp; %%% 要返回
- ss.imsize_disp=imsize_disp;
- ss.cnPiont=cnPiont; %%% 要返回
- % % handles.file_names = sorted_names;
- % handles.file_names =sorted_names_disp;
- % handles.is_dir = [dir_struct.isdir];
- % %handles.sorted_index = [sorted_index];
- % handles.sorted_index = [cnarray];
- set(handles.listbox1,'String',sorted_names_disp,...
- 'Value',1)
- set(handles.text1,'String',pwd)