fpce_mainform.pas 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. labelSize: TLabel;
  13. labelVersion: TLabel;
  14. labelFilename: TLabel;
  15. shellInput: TShellTreeView;
  16. procedure buttonQuitClick(Sender: TObject);
  17. procedure shellInputSelectionChanged(Sender: TObject);
  18. private
  19. { private declarations }
  20. function CheckInput(): Boolean;
  21. public
  22. { public declarations }
  23. end;
  24. var
  25. formCorelExplorer: TformCorelExplorer;
  26. implementation
  27. uses
  28. fpvectorial, cdrvectorialreader, svgvectorialwriter, pdfvectorialreader,
  29. fpvtocanvas;
  30. {$R *.lfm}
  31. { TformCorelExplorer }
  32. procedure TformCorelExplorer.buttonQuitClick(Sender: TObject);
  33. begin
  34. Close;
  35. end;
  36. procedure TformCorelExplorer.shellInputSelectionChanged(Sender: TObject);
  37. var
  38. Vec: TvVectorialDocument;
  39. Reader: TvCDRVectorialReader;
  40. lFormat: TvVectorialFormat;
  41. lChunk, lCurChunk: TCDRChunk;
  42. Str: string;
  43. begin
  44. // First check the in input
  45. if not CheckInput() then Exit;
  46. // Now read the data from the input file
  47. Reader := TvCDRVectorialReader.Create;
  48. try
  49. Reader.ExploreFromFile(shellInput.GetSelectedNodePath(), lChunk);
  50. labelFilename.Caption := 'Filename: ' + shellInput.GetSelectedNodePath();
  51. if (lChunk.ChildChunks <> nil) and (lChunk.ChildChunks.First <> nil) then
  52. begin
  53. // Version Chunk
  54. lCurChunk := TCDRChunk(lChunk.ChildChunks.First);
  55. Str := TCDRChunkVRSN(lCurChunk).VersionStr;
  56. labelVersion.Caption := 'Version: ' + Str;
  57. // Main data
  58. lCurChunk := TCDRChunk(lChunk.ChildChunks.Items[1]);
  59. labelSize.Caption := 'Size: ' + ;
  60. end;
  61. finally
  62. Reader.Free;
  63. end;
  64. end;
  65. function TformCorelExplorer.CheckInput(): Boolean;
  66. var
  67. lPath: String;
  68. begin
  69. lPath := shellInput.GetSelectedNodePath();
  70. Result := (ExtractFileExt(lPath) = STR_CORELDRAW_EXTENSION);
  71. end;
  72. end.