fpce_mainform.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. unit fpce_mainform;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  6. EditBtn, ExtCtrls, ComCtrls, ShellCtrls;
  7. type
  8. { TformCorelExplorer }
  9. TformCorelExplorer = class(TForm)
  10. Label1: TLabel;
  11. Label2: TLabel;
  12. labelVersion: TLabel;
  13. labelFilename: TLabel;
  14. shellInput: TShellTreeView;
  15. procedure buttonQuitClick(Sender: TObject);
  16. procedure shellInputSelectionChanged(Sender: TObject);
  17. private
  18. { private declarations }
  19. function CheckInput(): Boolean;
  20. public
  21. { public declarations }
  22. end;
  23. var
  24. formCorelExplorer: TformCorelExplorer;
  25. implementation
  26. uses
  27. fpvectorial, cdrvectorialreader, svgvectorialwriter, pdfvectorialreader,
  28. fpvtocanvas;
  29. {$R *.lfm}
  30. { TformCorelExplorer }
  31. procedure TformCorelExplorer.buttonQuitClick(Sender: TObject);
  32. begin
  33. Close;
  34. end;
  35. procedure TformCorelExplorer.shellInputSelectionChanged(Sender: TObject);
  36. var
  37. Vec: TvVectorialDocument;
  38. Reader: TvCDRVectorialReader;
  39. lFormat: TvVectorialFormat;
  40. lChunk, lCurChunk: TCDRChunk;
  41. Str: string;
  42. begin
  43. // First check the in input
  44. if not CheckInput() then Exit;
  45. // Now read the data from the input file
  46. Reader := TvCDRVectorialReader.Create;
  47. try
  48. Reader.ExploreFromFile(shellInput.GetSelectedNodePath(), lChunk);
  49. labelFilename.Caption := 'Filename: ' + shellInput.GetSelectedNodePath();
  50. if (lChunk.ChildChunks <> nil) and (lChunk.ChildChunks.First <> nil) then
  51. begin
  52. lCurChunk := TCDRChunk(lChunk.ChildChunks.First);
  53. Str := TCDRChunkVRSN(lCurChunk).VersionStr;
  54. labelVersion.Caption := 'Version: ' + Str;
  55. end;
  56. finally
  57. Reader.Free;
  58. end;
  59. end;
  60. function TformCorelExplorer.CheckInput(): Boolean;
  61. var
  62. lPath: String;
  63. begin
  64. lPath := shellInput.GetSelectedNodePath();
  65. Result := (ExtractFileExt(lPath) = STR_CORELDRAW_EXTENSION);
  66. end;
  67. end.