Resource

Resource Basics

Resource Name Export Import GEO Favorites
Resource Version 1.0
Category Catalog
Downloads 647
Release Date 8/30/2021 11:54:35 AM
 

Resource Details

Description This script allows you to export/import GEO Favorites from database to/from file.
Installation Instructions Download the script to your local hard drive
Usage Instructions 1. Start Photo Supreme
2. Open Tools -> Scripter
3. Load the downloaded script file
4. Click the run button to start the script

NOTE; Use with caution. Importing a file will overwrite your existing GEO Favorites.
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Available Attachments

Attachment #1 Export_Import_GEO_Favorites.png
 

Script

  procedure ExportToFile(AFileName: WideString);
  var
    AData: TxomResource;
  begin
    AData := TxomResource.Create(nil);
    if PublicCatalog.EnumGUIDData(AdminGUID, 'GEOFAVORITES', AData) then
    begin
      AData.ResourceStream.SaveToFile(AFileName);
      Say('Saved as: ' + AFileName);
    end
    else
      Say('No GEO Favorites Found');
    AData.Free;
  end;

  procedure ImportFromFile(AFileName: WideString);
  var
    AData: TxomResource;
  begin
    AData := TxomResource.Create(nil);
    if WideFileExists(AFileName) then
    begin
      AData.ResourceStream.LoadFromFile(AFileName);
      PublicCatalog.StoreGUIDData(AdminGUID, 'GEOFAVORITES', AData);
      AData.ResourceStream.Position := 0;
      PublicOptions.LoadFromStream(AData.ResourceStream);
      Say('GEO Favorites are read from file.');
    end
    else
      Say('File ' + AFilename + ' Not Found');
    AData.Free;
  end;

  procedure StartImport;
  var
    AFileName: WideString;
  begin
    OpenDialog.DefaultExt := '.preferences';
    OpenDialog.InitialDir := WindowsDesktopDir;
    OpenDialog.FileName := 'PhotoSupreme.geofav'
    OpenDialog.Filter := 'GEO Favorites files|*.geofav|All Files|*.*';
    OpenDialog.Title := 'Import GEO Favorites From';
    if OpenDialog.Execute then
    begin
      if AskYN('Are you sure your want to overwrite your existing GEO Favorites with that from the selected file?') then
      begin
        AFileName := OpenDialog.FileName;
        ImportFromFile(AFileName);
      end;
    end;
  end;

  procedure StartExport;
  var
    AFileName: WideString;
  begin
    SaveDialog.DefaultExt := '.geofav';
    SaveDialog.InitialDir := WindowsDesktopDir;
    SaveDialog.FileName := 'PhotoSupreme.geofav'
    SaveDialog.Filter := 'GEO Favorites files|*.geofav|All Files|*.*';
    SaveDialog.Title := 'Export GEO Favorites To';
    if SaveDialog.Execute then
    begin
      AFileName := SaveDialog.FileName;
      ExportToFile(AFileName);
    end;
  end;

var
  ACustoms: TTntStringList;
  AIdx: Integer;
  ACheck: Boolean;
begin
  ACustoms := TTntStringList.Create;
  try
    ACustoms.Add ('Export GEO Favorites to File');
    ACustoms.Add ('Import GEO Favorites from File');
    ACustoms.Add ('Cancel');

    ACheck := False;
    AIdx := AskCustom(
                       'What operation would you like to perform?',
                       'CAUTION: Importing GEO Favorites will overwrite existing GEO Favorites',
                       '',
                       '',
                       ACheck,
                       ACustoms
                     );

    if AIdx = 0 then
      StartExport
    else if AIdx = 1 then
      StartImport;
  finally
    ACustoms.Free;
  end;
end;