Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.10 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "BaseMain.h"
  7. #include "LineAction.h"
  8. #include "SettingsActions.h"
  9. #include "HeadersSettings.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma resource "*.dfm"
  13. TForm1 *Form1;
  14. //---------------------------------------------------------------------------
  15.  
  16. //---------------------------------------------------------------------------
  17. __fastcall TForm1::TForm1(TComponent* Owner)
  18.     : TForm(Owner)
  19. {
  20.     DataProgram = new TDataProgram();
  21.     SaveName = "";
  22.  
  23.     TIniFile *ini = new TIniFile("Lib/Baseini.ini");
  24.     Top = ini->ReadInteger("Form_Parameter", "Top", Width);
  25.     Height = ini->ReadInteger("Form_Parameter", "Height", Height);
  26.     Left = ini->ReadInteger("Form_Parameter", "Left", Left);
  27.     Right = ini->ReadInteger("Form_Parameter", "Right", 100);
  28.     Other = ini->ReadInteger("Form_Parameter", "Other", 100);
  29.     Caption = ini->ReadString("Form_Parameter", "Name", "Base v2.0 - > Pro version");
  30.     ini->ReadBool("Form_Parameter", "InitMax", false) ?
  31.     WindowState = wsMaximized:
  32.     WindowState = wsNormal;
  33.     delete ini;
  34.  
  35. }
  36. //---------------------------------------------------------------------------
  37.  
  38. void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
  39. {
  40.  
  41.    TIniFile *ini = new TIniFile("Lib/Baseini.ini");
  42.    ini->WriteInteger("Form_Parameter", "Top", Width);
  43.    ini->WriteInteger("Form_Parameter", "Height", Height);
  44.    ini->WriteInteger("Form_Parameter", "Left", Left);
  45.    ini->WriteInteger("Form_Parameter", "Other", 100);
  46.    ini->WriteString("Form_Parameter", "Name" , Caption);
  47.    ini->WriteInteger("Form_Parameter", "Right", 100);
  48.    ini->WriteBool("Form_Parameter", "InitMax", WindowState == wsMaximized);
  49.    delete ini;
  50.  
  51.    if (Application->MessageBoxW(L"Close Program?", L"Confim", MB_YESNO|MB_ICONINFORMATION)== ID_NO)
  52.    {
  53.       Action = caNone;
  54.    }
  55.  
  56. }
  57.  
  58. //---------------------------------------------------------------------------
  59.  
  60. void __fastcall TForm1::NewFile1Click(TObject *Sender)
  61. {
  62.    DataProgram->RefreshDataProgram();
  63.    Image1->Picture = NULL;
  64.    for (int i = 0; i < StringGrid1->RowCount; i++)
  65.    {
  66.       for (int j = 0; j < StringGrid1->ColCount; j++)
  67.       {
  68.          StringGrid1->Cells[j][i] = "";
  69.       }
  70.    }
  71.    StringGrid1->RowCount = 2;
  72.    StringGrid1->ColCount = 2;
  73.    SaveName = "";
  74. }
  75. //---------------------------------------------------------------------------
  76.  
  77. void __fastcall TForm1::Open1Click(TObject *Sender)
  78. {
  79.    if (OpenDialog1->Execute())
  80.    {
  81.       DataProgram->RefreshDataProgram();
  82.       DataProgram->LoadFromFile(OpenDialog1->FileName, StringGrid1);
  83.       SaveName = OpenDialog1->FileName;
  84.       StringGrid1->Col = (StringGrid1->Col == 0) ? 1:0;
  85.    }
  86. }
  87. //---------------------------------------------------------------------------
  88.  
  89. void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol, int ARow,
  90.           bool &CanSelect)
  91. {
  92.    Memo1->Clear();
  93.    memo temp;
  94.    temp = DataProgram->GetMemo(ARow);
  95.    if(DataProgram->note)
  96.    {
  97.        for (int i = 0; i < DataProgram->MemoCount; i++)
  98.        {
  99.           if (!temp.A[DataProgram->MemoCount-i-1].IsEmpty())
  100.           Memo1->Lines->Add(temp.A[DataProgram->MemoCount-i-1]);
  101.        }
  102.  
  103.    }
  104.   Image1->Picture = NULL;
  105.   try{Image1->Picture->LoadFromFile(DataProgram->GetBitmap(ARow));}catch(...){;}
  106. }
  107. //---------------------------------------------------------------------------
  108.  
  109. void __fastcall TForm1::AddBitMap1Click(TObject *Sender)
  110. {
  111.     if (OpenPictureDialog1->Execute())
  112.     {
  113.        DataProgram->SetBitmap(OpenPictureDialog1->FileName ,StringGrid1->Row);
  114.        Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
  115.     }
  116. }
  117. //---------------------------------------------------------------------------
  118.  
  119. void __fastcall TForm1::LineSection1Click(TObject *Sender)
  120. {
  121.    Form3->ShowModal();
  122. }
  123. //---------------------------------------------------------------------------
  124.  
  125. void __fastcall TForm1::HeadersSection1Click(TObject *Sender)
  126. {
  127.    Form2->ShowModal();
  128. }
  129. //---------------------------------------------------------------------------
  130.  
  131. void __fastcall TForm1::SettingsActions1Click(TObject *Sender)
  132. {
  133.     Form4->ShowModal();
  134. }
  135. //---------------------------------------------------------------------------
  136.  
  137. void __fastcall TForm1::SaveCtrlS1Click(TObject *Sender)
  138. {
  139.    if (SaveName.IsEmpty())
  140.    {
  141.       if (SaveDialog1->Execute())
  142.       DataProgram->SaveToFile(SaveDialog1->FileName, StringGrid1);
  143.    }
  144.    else
  145.    DataProgram->SaveToFile(SaveName, StringGrid1);
  146.    SaveName = SaveDialog1->FileName;
  147. }
  148. //---------------------------------------------------------------------------
  149.  
  150. void __fastcall TForm1::SaveAs1Click(TObject *Sender)
  151. {
  152.  if (SaveDialog1->Execute())
  153.  DataProgram->SaveToFile(SaveDialog1->FileName, StringGrid1);
  154.  SaveName = SaveDialog1->FileName;
  155.  
  156. }
  157. //---------------------------------------------------------------------------
  158.  
  159. void __fastcall TForm1::Close1Click(TObject *Sender)
  160. {
  161.     Application->Terminate();
  162.     delete DataProgram;
  163. }
  164. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement