📄 umfloadproject.pas
字号:
{ JADD - Just Another DelphiDoc: Documentation from Delphi Source Code
Copyright (C) 2002-2008 Gerold Veith
This file is part of JADD - Just Another DelphiDoc.
DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit UMFLoadProject;
{Contains a simple page with buttons to load and save the set options to parse
source code files. }
interface
uses Classes, Forms, Controls, StdCtrls, ExtCtrls,
UMainFormFrame,
UJADDState;
type
{A simple page with buttons to load and save the set options to parse source
code files. }
TMFLoadProject = class(TMainFormFrame)
ButtonLoad: TButton;
ButtonSave: TButton;
procedure ButtonLoadClick(Sender: TObject);
procedure ButtonSaveClick(Sender: TObject);
private
//Loads a DelphiDoc project ini file.
procedure LoadDelphiDocProject(FileName: String);
//Saves a DelphiDoc project ini file.
procedure SaveDelphiDocProject(FileName: String);
protected
public
//Creates the components and allows dropping of files.
constructor Create(Parent: TWinControl; State: TJADDState); override;
//Called when some files are dropped on the form.
procedure FilesDropped(Files: TStrings); override;
end;
implementation
{$R *.dfm}
uses SysUtils,
Dialogs, IniFiles,
UFilePaths,
UCommandParameters;
{Creates the components and allows dropping of files.
~param Parent the component to show the frame in, preferably a TPanel or a
similar component
~param State the state of the program }
constructor TMFLoadProject.Create(Parent: TWinControl; State: TJADDState);
begin
inherited Create(Parent, State); //create form
Include(FProperties, mffpAcceptsFileDrop); //accepts dropped files
end;
{Called when some files are dropped on the form.
~param Files the list of the dropped files }
procedure TMFLoadProject.FilesDropped(Files: TStrings);
begin
LoadDelphiDocProject(Files[0]); //load the (first) file
end;
{Loads a DelphiDoc project ini file.
~param FileName the name of the DelphiDoc project ini file to load }
procedure TMFLoadProject.LoadDelphiDocProject(FileName: String);
var Ini :TIniFile; //the DelphiDoc project file
begin
//ini files need to be marked to be local (in current directory)
if (Pos(PathDelimiter, FileName) = 0) and (Pos(':', FileName) = 0) then
FileName := '.' + PathDelimiter + FileName;
Ini := TIniFile.Create(FileName); //open the file
try
State.LoadProject(Ini); //load the project
finally
Ini.Free; //close the file
end;
end;
{Saves a DelphiDoc project ini file.
~param FileName the name of the DelphiDoc project ini file to save }
procedure TMFLoadProject.SaveDelphiDocProject(FileName: String);
var Ini :TIniFile; //the DelphiDoc project file
begin
//ini files need to be marked to be local (in current directory)
if (Pos(PathDelimiter, FileName) = 0) and (Pos(':', FileName) = 0) then
FileName := '.' + PathDelimiter + FileName;
Ini := TIniFile.Create(FileName); //open the file
try
State.SaveProject(Ini); //save the project
finally
Ini.Free; //close the file
end;
end;
{Called when the button to load a DelphiDoc project file is clicked.
~param Sender the sender of the event, ~[link ButtonLoad] }
procedure TMFLoadProject.ButtonLoadClick(Sender: TObject);
begin
with TOpenDialog.Create(nil) do //create a file open - dialog
try
DefaultExt := DDPDefaultExtension;
Filter := Format('DelphiDoc-Project (*.%s)|*.%s|initialization files (*.ini)|*.ini|all files (*)|*',
[DDPDefaultExtension, DDPDefaultExtension]);
InitialDir := GetCurrentDir;
Options := [ofHideReadOnly, ofFileMustExist, ofPathMustExist,
ofEnableSizing, ofShowHelp];
HelpContext := ButtonLoad.HelpContext;
Title := 'Load DelphiDoc-Project';
if Execute then //show the dialog; file chosen?
LoadDelphiDocProject(FileName); //load the DelphiDoc project file
finally
Free; //free the dialog
end;
end;
{Called when the button to save the DelphiDoc project file is clicked.
~param Sender the sender of the event, ~[link ButtonSave] }
procedure TMFLoadProject.ButtonSaveClick(Sender: TObject);
begin
with TSaveDialog.Create(nil) do //create a file save - dialog
try
DefaultExt := DDPDefaultExtension;
Filter := Format('DelphiDoc-Project (*.%s)|*.%s|initialization files (*.ini)|*.ini|all files (*)|*',
[DDPDefaultExtension, DDPDefaultExtension]);
InitialDir := GetCurrentDir;
Options := [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist,
ofEnableSizing, ofShowHelp];
HelpContext := ButtonSave.HelpContext;
Title := 'Save DelphiDoc-Project';
if Execute then //show the dialog; file chosen?
SaveDelphiDocProject(FileName); //save the DelphiDoc project
finally
Free; //free the dialog
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -