Skip to content

Commit 108bd65

Browse files
Added drag-drop support for external files into editor.
Setup with signed certificate.
1 parent 15aa8c5 commit 108bd65

16 files changed

+273
-1752
lines changed

Build.bat

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ msbuild.exe "Source\SVGTextEditor.dproj" /target:Clean;Build /p:Platform=Win64 /
66
:INNO
77
"C:\Program Files (x86)\Inno Setup 6\iscc.exe" "D:\ETHEA\SVGShellExtensions\Setup\SVGShellExtensions.iss"
88
set INNO_STATUS=%ERRORLEVEL%
9-
if %INNO_STATUS%==0 GOTO END
9+
if %INNO_STATUS%==0 GOTO SIGNSETUP
1010
pause
1111
EXIT
1212

13+
:SIGNSETUP
14+
call D:\ETHEA\Certificate\SignFileWithSectico.bat D:\ETHEA\SVGShellExtensions\Setup\Output\SVGShellExtensionsSetup.exe
15+
1316
:END
1417
pause

Images/Setup.png

-14 Bytes
Loading
7.47 KB
Binary file not shown.

Setup/SVGShellExtensions.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Script generated by the Inno Setup Script Wizard.
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33
#define MyAppName 'SVG Shell Extensions and SVG Text Editor'
4-
#define MyAppVersion '1.3.0'
4+
#define MyAppVersion '1.4.0'
55

66
[Setup]
77
AppName={#MyAppName}

Source/EditorMainForm.pas

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface
5252
, Vcl.Styles.Utils.ComCtrls
5353
, Vcl.Styles.Utils.StdCtrls
5454
, Vcl.Styles.Ext
55+
, uDragDropUtils
5556
;
5657

5758
const
@@ -96,7 +97,7 @@ TEditingFile = class
9697
property Extension : string read FExtension;
9798
end;
9899

99-
TfrmMain = class(TForm)
100+
TfrmMain = class(TForm, IDragDrop)
100101
OpenDialog: TOpenDialog;
101102
ActionList: TActionList;
102103
acOpenFile: TAction;
@@ -182,6 +183,7 @@ TfrmMain = class(TForm)
182183
StatusStaticText: TStaticText;
183184
StatusSplitter: TSplitter;
184185
CloseAll1: TMenuItem;
186+
procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
185187
procedure acOpenFileExecute(Sender: TObject);
186188
procedure acSaveExecute(Sender: TObject);
187189
procedure FormDestroy(Sender: TObject);
@@ -255,6 +257,7 @@ TfrmMain = class(TForm)
255257
MousePos: TPoint; var Handled: Boolean);
256258
procedure FormClose(Sender: TObject; var Action: TCloseAction);
257259
private
260+
MinFormWidth, MinFormHeight, MaxFormWidth, MaxFormHeight: Integer;
258261
FProcessingFiles: Boolean;
259262
FEditorSettings: TEditorSettings;
260263
currentDir: string;
@@ -272,6 +275,10 @@ TfrmMain = class(TForm)
272275
gsReplaceTextHistory: string;
273276
FEditorOptions: TSynEditorOptionsContainer;
274277
FFontSize: Integer;
278+
FDropTarget: TDropTarget;
279+
// implement IDragDrop
280+
function DropAllowed(const FileNames: array of string): Boolean;
281+
procedure Drop(const FileNames: array of string);
275282
procedure CloseSplitViewMenu;
276283
procedure UpdateHighlighters;
277284
procedure UpdateFromSettings(AEditor: TSynEdit);
@@ -297,7 +304,12 @@ TfrmMain = class(TForm)
297304
procedure UpdateHighlighter(ASynEditor: TSynEdit);
298305
procedure SetEditorFontSize(const Value: Integer);
299306
procedure LoadOpenedFiles;
307+
function CanAcceptFileName(const AFileName: string): Boolean;
308+
function AcceptedExtensions: string;
300309
property EditorFontSize: Integer read FFontSize write SetEditorFontSize;
310+
protected
311+
procedure CreateWindowHandle(const Params: TCreateParams); override;
312+
procedure DestroyWindowHandle; override;
301313
end;
302314

303315
var
@@ -428,6 +440,17 @@ procedure TfrmMain.acOpenFileExecute(Sender: TObject);
428440
AssignSVGToImage;
429441
end;
430442

443+
function TfrmMain.CanAcceptFileName(const AFileName: string): Boolean;
444+
begin
445+
Result := pos(ExtractFileExt(AFileName), AcceptedExtensions) <> 0;
446+
end;
447+
448+
function TfrmMain.AcceptedExtensions: string;
449+
begin
450+
//Check file extension
451+
Result := '.svg;.xml';
452+
end;
453+
431454
function TfrmMain.OpenFile(const FileName : string;
432455
const ARaiseError: Boolean = True): Boolean;
433456
var
@@ -439,6 +462,10 @@ function TfrmMain.OpenFile(const FileName : string;
439462
FProcessingFiles := True;
440463
if FileExists(FileName) then
441464
begin
465+
if not CanAcceptFileName(FileName) then
466+
raise Exception.CreateFmt('Cannot open file with extensions different from "%s"',
467+
[AcceptedExtensions]);
468+
442469
//looking for the file already opened
443470
EditingFile := nil;
444471
I := -1;
@@ -505,10 +532,10 @@ procedure TfrmMain.acSaveExecute(Sender: TObject);
505532

506533
procedure TfrmMain.FormDestroy(Sender: TObject);
507534
begin
508-
EditFileList.Free;
509-
SynEditPrint.Free;
510-
FEditorSettings.Free;
511-
FEditorOptions.Free;
535+
FreeAndNil(EditFileList);
536+
FreeAndNil(SynEditPrint);
537+
FreeAndNil(FEditorSettings);
538+
FreeAndNil(FEditorOptions);
512539
inherited;
513540
end;
514541

@@ -632,6 +659,12 @@ procedure TfrmMain.SVOpening(Sender: TObject);
632659
catMenuItems.ButtonOptions := catMenuItems.ButtonOptions + [boShowCaptions];
633660
end;
634661

662+
procedure TfrmMain.DestroyWindowHandle;
663+
begin
664+
FreeAndNil(FDropTarget);
665+
inherited;
666+
end;
667+
635668
function TfrmMain.DialogPosRect: TRect;
636669
begin
637670
GetWindowRect(Self.Handle, Result);
@@ -670,6 +703,32 @@ procedure TfrmMain.DoSearchReplaceText(AReplace: boolean;
670703
ConfirmReplaceDialog.Free;
671704
end;
672705

706+
procedure TfrmMain.Drop(const FileNames: array of string);
707+
var
708+
LFileName: string;
709+
i: Integer;
710+
begin
711+
for i := 0 to Length(FileNames)-1 do
712+
begin
713+
if CanAcceptFileName(FileNames[i]) then
714+
OpenFile(FileNames[i], False);
715+
end;
716+
AssignSVGToImage;
717+
end;
718+
719+
function TfrmMain.DropAllowed(const FileNames: array of string): Boolean;
720+
var
721+
i: Integer;
722+
begin
723+
Result := False;
724+
for i := 0 to Length(FileNames)-1 do
725+
begin
726+
Result := CanAcceptFileName(FileNames[i]);
727+
if Result then
728+
Break;
729+
end;
730+
end;
731+
673732
procedure TfrmMain.ExportToPNGActionExecute(Sender: TObject);
674733
var
675734
LFileName: string;
@@ -1005,6 +1064,12 @@ procedure TfrmMain.CloseSplitViewMenu;
10051064
Screen.Cursor := crDefault;
10061065
end;
10071066

1067+
procedure TfrmMain.CreateWindowHandle(const Params: TCreateParams);
1068+
begin
1069+
inherited;
1070+
FDropTarget := TDropTarget.Create(WindowHandle, Self);
1071+
end;
1072+
10081073
function TfrmMain.CurrentEditFile: TEditingFile;
10091074
begin
10101075
if (PageControl.ActivePage <> nil) then
@@ -1388,6 +1453,32 @@ procedure TfrmMain.UpdateStatusBarPanels;
13881453
end;
13891454
end;
13901455

1456+
procedure TfrmMain.WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
1457+
var
1458+
LMinMaxInfo: PMinMaxInfo;
1459+
begin
1460+
if not (csReading in ComponentState) then
1461+
begin
1462+
LMinMaxInfo := Message.MinMaxInfo;
1463+
with LMinMaxInfo^ do
1464+
begin
1465+
with ptMinTrackSize do
1466+
begin
1467+
if MinFormWidth > 0 then X := MinFormWidth;
1468+
if MinFormHeight > 0 then Y := MinFormHeight;
1469+
end;
1470+
with ptMaxTrackSize do
1471+
begin
1472+
if MaxFormWidth > 0 then X := MaxFormWidth;
1473+
if MaxFormHeight > 0 then Y := MaxFormHeight;
1474+
end;
1475+
ConstrainedResize(ptMinTrackSize.X, ptMinTrackSize.Y, ptMaxTrackSize.X,
1476+
ptMaxTrackSize.Y);
1477+
end;
1478+
end;
1479+
inherited;
1480+
end;
1481+
13911482
procedure TfrmMain.ActionListExecute(Action: TBasicAction;
13921483
var Handled: Boolean);
13931484
begin

0 commit comments

Comments
 (0)