Changeset 65 for trunk/Forms
- Timestamp:
- Dec 5, 2014, 8:34:59 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r64 r65 180 180 SDone = 'Done'; 181 181 SChanged = 'Changed'; 182 SUnsavedChanges = 'Unsaved changes'; 183 SDoYouWantToSaveProject = 'There are unsaved changes in project. Do you want to save them?'; 184 SCloseProjectFirst = 'Project need to be closed before it can be openned'; 182 185 183 186 { TMainForm } … … 259 262 procedure TMainForm.ProjectOpen(FileName: string); 260 263 begin 261 AProjectClose.Execute; 264 if Core.Project.Openned then 265 raise Exception.Create(SCloseProjectFirst); 262 266 FormSourceCode.MemoSource.Lines.LoadFromFile(UTF8Decode(FileName)); 263 267 Core.LastOpenedList.AddItem(FileName); … … 455 459 procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean); 456 460 begin 457 if Core.Project.Modified then AProjectSaveAs.Execute; 461 if Core.Project.Modified then begin 462 AProjectClose.Execute; 463 if Core.Project.Openned then CanClose := False; 464 end; 458 465 end; 459 466 … … 564 571 565 572 procedure TMainForm.AProjectCloseExecute(Sender: TObject); 566 begin 567 if Core.Project.Modified then AProjectSaveAs.Execute; 568 AProgramStop.Execute; 569 Core.Project.Openned := False; 570 FormSourceCode.MemoSource.Clear; 571 UpdateInterface; 573 var 574 DialogResult: TModalResult; 575 begin 576 DialogResult := mrNo; 577 if Core.Project.Modified then begin 578 DialogResult := MessageDlg(SUnsavedChanges, SDoYouWantToSaveProject, mtConfirmation, [mbYes, mbNo, mbCancel], 0); 579 if DialogResult = mrYes then begin 580 AProjectSave.Execute; 581 end; 582 end; 583 if (DialogResult = mrNo) or (DialogResult = mrYes) then begin 584 AProgramStop.Execute; 585 Core.Project.Openned := False; 586 FormSourceCode.MemoSource.Clear; 587 UpdateInterface; 588 end; 572 589 end; 573 590 … … 575 592 begin 576 593 AProjectClose.Execute; 594 if Core.Project.Openned then Exit; 577 595 Core.Project.FileName := 'Examples' + DirectorySeparator + SNewProject + '.b'; 578 596 FormSourceCode.MemoSource.Clear; … … 584 602 procedure TMainForm.AProjectOpenRecentExecute(Sender: TObject); 585 603 begin 604 AProjectClose.Execute; 605 if Core.Project.Openned then Exit; 586 606 ProjectOpen(Core.LastOpenedList.Items[TMenuItem(Sender).MenuIndex]); 587 607 end; … … 589 609 procedure TMainForm.AProjectOpenExecute(Sender: TObject); 590 610 begin 591 AProjectClose.Execute;592 611 if Core.LastOpenedList.Items.Count > 0 then 593 612 OpenDialog1.FileName := Core.LastOpenedList.Items[0] … … 595 614 OpenDialog1.InitialDir := ExtractFileDir(OpenDialog1.FileName); 596 615 if OpenDialog1.Execute then begin 616 AProjectClose.Execute; 617 if Core.Project.Openned then Exit; 597 618 ProjectOpen(OpenDialog1.FileName); 598 619 end;
Note:
See TracChangeset
for help on using the changeset viewer.