Ignore:
Timestamp:
Aug 1, 2016, 12:43:49 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Set zero imported acronyms count before start of processing import sources.
  • Modified: Open dialogs positioned at center of screen.
  • Added: Open example acronyms by default if no other files were openned yet.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r64 r69  
    124124    ProjectClosed: Boolean;
    125125    ImportTotalItemCount: Integer;
     126    procedure ProjectOpen(FileName: string);
    126127    procedure Initialize;
    127128    procedure ProcessImportsJob(Job: TJob);
     
    244245    OpenDialog1.FileName := AcronymDb.FileName;
    245246  if OpenDialog1.Execute then begin
    246     AFileClose.Execute;
    247     if ProjectClosed then begin
    248       AFileNew.Execute;
    249       AcronymDb.LoadFromFile(OpenDialog1.FileName);
    250       LastOpenedList1.AddItem(OpenDialog1.FileName);
    251       UpdateAcronymsList;
    252       UpdateInterface;
    253     end;
     247    ProjectOpen(OpenDialog1.FileName);
    254248  end;
    255249end;
     
    441435end;
    442436
     437procedure TFormMain.ProjectOpen(FileName: string);
     438begin
     439  AFileClose.Execute;
     440  if ProjectClosed then begin
     441    try
     442      AFileNew.Execute;
     443      AcronymDb.LoadFromFile(FileName);
     444      LastOpenedList1.AddItem(FileName);
     445    finally
     446      UpdateAcronymsList;
     447      UpdateInterface;
     448    end;
     449  end;
     450end;
     451
    443452procedure TFormMain.Initialize;
    444453begin
     
    448457
    449458    if ParamCount > 0 then begin
     459      // Open file specified as command line parameter
    450460      AcronymDB.LoadFromFile(ParamStr(1));
    451461      LastOpenedList1.AddItem(OpenDialog1.FileName);
    452462    end else
    453     if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then
    454       AcronymDB.LoadFromFile(LastOpenedList1.Items[0]);
     463    if (LastOpenedList1.Items.Count > 0) and FileExists(LastOpenedList1.Items[0]) then begin
     464      // Open last opened file
     465      AcronymDB.LoadFromFile(LastOpenedList1.Items[0])
     466    end else begin
     467      // Open default database with examples if no item is in recent openned history
     468      ProjectOpen(ExtractFileDir(Application.ExeName) + DirectorySeparator + 'Example Acronyms.adp');
     469    end;
    455470    UpdateAcronymsList;
    456471    ListViewFilter1.UpdateFromListView(ListViewAcronyms);
     
    564579  RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
    565580  PersistentForm1.RegistryContext := RegistryContext;
     581  RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey + '\RecentFiles');
    566582  LastOpenedList1.LoadFromRegistry(RegistryContext);
    567583
     
    583599procedure TFormMain.SaveConfig;
    584600begin
     601  RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey + '\RecentFiles');
    585602  LastOpenedList1.SaveToRegistry(RegistryContext);
    586603
Note: See TracChangeset for help on using the changeset viewer.