Browse Source

Quick.Config samples updated

Unknown 6 years ago
parent
commit
6ec81aac4d

+ 9 - 0
samples/fpc/QuickConfig/ConfigToYAML/lib/i386-win32/umain.lfm

@@ -37,4 +37,13 @@ object Form1: TForm1
     ScrollBars = ssAutoBoth
     TabOrder = 2
   end
+  object Button1: TButton
+    Left = 96
+    Height = 25
+    Top = 424
+    Width = 75
+    Caption = 'Button1'
+    OnClick = Button1Click
+    TabOrder = 3
+  end
 end

+ 40 - 0
samples/fpc/QuickConfig/ConfigToYAML/lib/x86_64-linux/umain.lfm

@@ -0,0 +1,40 @@
+object Form1: TForm1
+  Left = 379
+  Height = 457
+  Top = 208
+  Width = 592
+  Caption = 'Form1'
+  ClientHeight = 457
+  ClientWidth = 592
+  OnClose = FormClose
+  OnCreate = FormCreate
+  LCLVersion = '1.9.0.0'
+  object btnSaveYaml: TButton
+    Left = 448
+    Height = 25
+    Top = 424
+    Width = 120
+    Caption = 'Save to Yaml'
+    OnClick = btnSaveYamlClick
+    TabOrder = 0
+  end
+  object btnLoadYaml: TButton
+    Left = 312
+    Height = 25
+    Top = 424
+    Width = 123
+    Cancel = True
+    Caption = 'Load From Yaml'
+    OnClick = btnLoadYamlClick
+    TabOrder = 1
+  end
+  object meInfo: TMemo
+    Left = 19
+    Height = 407
+    Top = 9
+    Width = 549
+    ReadOnly = True
+    ScrollBars = ssAutoBoth
+    TabOrder = 2
+  end
+end

+ 9 - 0
samples/fpc/QuickConfig/ConfigToYAML/umain.lfm

@@ -37,4 +37,13 @@ object Form1: TForm1
     ScrollBars = ssAutoBoth
     TabOrder = 2
   end
+  object Button1: TButton
+    Left = 96
+    Height = 25
+    Top = 424
+    Width = 75
+    Caption = 'Button1'
+    OnClick = Button1Click
+    TabOrder = 3
+  end
 end

+ 20 - 1
samples/fpc/QuickConfig/ConfigToYAML/umain.pas

@@ -10,6 +10,7 @@ uses
   registry,
   {$ENDIF}
   Quick.Config.Yaml,
+  Quick.Yaml,
   Generics.Collections;
 
 type
@@ -68,7 +69,7 @@ type
     fModifyDate : TDateTime;
     //fWorkList : TObjectList<TWorker>;
   public
-    procedure Init;
+    procedure Init; override;
     destructor Destroy; override;
     procedure DefaultValues; override;
     property Hidden : Boolean read fHidden write fHidden;
@@ -89,9 +90,11 @@ type
   TForm1 = class(TForm)
     btnSaveYaml: TButton;
     btnLoadYaml: TButton;
+    Button1: TButton;
     meInfo: TMemo;
     procedure btnLoadYamlClick(Sender: TObject);
     procedure btnSaveYamlClick(Sender: TObject);
+    procedure Button1Click(Sender: TObject);
     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     procedure FormCreate(Sender: TObject);
     procedure OnConfigFileModified;
@@ -126,6 +129,22 @@ begin
   meInfo.Lines.Add('Saved Config in Yaml at ' + DateTimeToStr(ConfigYaml.LastSaved));
 end;
 
+procedure TForm1.Button1Click(Sender: TObject);
+var
+  yaml : TYamlObject;
+  sl : TStringList;
+begin
+  sl := TStringList.Create;
+  try
+    sl.LoadFromFile('.\Config.yml');
+    yaml := TYamlObject.Create;
+    yaml.ParseYaml(sl.Text);
+    meInfo.Lines.Add(yaml.ToYaml);
+  finally
+    sl.Free;
+  end;
+end;
+
 procedure TForm1.btnLoadYamlClick(Sender: TObject);
 begin
   meInfo.Lines.Add('Load ConfigYaml');