www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/+mbcmodelview/+project/ProjectActions.m

    classdef ProjectActions < handle
    %ProjectActions MBCMODEL project actions
    
    %  Copyright 2016-2016 The MathWorks, Inc. 

    properties (Constant)
        %Examples list of examples to be displayed
        Examples = struct('FileName',{'gasolineOneStage.mat','CI_MultiInject_PointbyPoint.mat','Gasoline_project.mat'},...
            'Description',{'Dual CAM gasoline engine with spark optimized during testing','Multi-injection diesel tested with pilot injection on and off','Dual CAM gasoline engine with spark'},...
            'Type',{'One-stage','Point-by-point','Two-Stage'},...
            'HelpTag',{'GasolineOneStage','DieselPtByPt','GasolineTwoStage'},...
            'Icon',{'gloreg.bmp','modelSwitch.bmp','mle2.bmp'});
    end
    
    properties (SetAccess=private)
        %NewProject new project action
        NewProject
        %OpenProject open project action
        OpenProject
        %Browser MBCMODEL browser handle
        Browser
    end
    
    properties (Dependent,SetAccess=private)
        %RecentFiles list of recent files
        RecentFiles
    end
    
    methods
        function obj = ProjectActions(Browser)
        %ProjectActions constructor
        
        obj.Browser = Browser;
        obj.NewProject = mbcgui.actions.StatefulAction(@obj.onNewProject,'New Project',...
            '',xregrespath('fileNew.bmp'));
        obj.OpenProject = mbcgui.actions.StatefulAction(@obj.onOpenProject,'Open Project',...
            '',xregrespath('fileOpen.bmp'));
        end
        
        function files = get.RecentFiles(obj) %#ok<MANU>
        %list of recent files from preferences for MBCMODEL 
        AP=mbcprefs('mbc');
        LastOpened=getpref(AP,'LastOpened');
        lbls = cell(1,length(LastOpened));
        files = lbls;
        for i=1:length(LastOpened)
            files{i} = fullfile(LastOpened(i).Path,LastOpened(i).File);
        end

        end
        
        function open(obj,file,addFile)
        %open open file 
        %   open(obj,file,addFile)
        %    addFile is a boolean flag to add file to recent file
        if nargin<3
            addFile = true;
        end
  
        OpenProject(obj.Browser,file,addFile); %#ok<CPROPLC>
        end
    end
    
    
    methods 
        function onNewProject(obj,~,~)
        
        NewProject(obj.Browser); %#ok<CPROPLC>
        
        end
  
        function onOpenProject(obj,~,~)
        %onBrowse browse for a new project
        
        OpenProject(obj.Browser); %#ok<CPROPLC>
        end
        
    end
    
end