Changeset 34 for trunk/Components/Common/ULastOpenedList.pas
- Timestamp:
- Nov 25, 2017, 12:27:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 tunneler.dbg 6 tunneler.lps 5 7 heaptrclog.trc 6 tunneler.lps 8 Components/Common/Languages/*.mo 9 Components/CoolTranslator/Demo/lib
-
- Property svn:ignore
-
trunk/Components/Common/ULastOpenedList.pas
r31 r34 6 6 7 7 uses 8 Classes, SysUtils, Registry, URegistry, Menus ;8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf; 9 9 10 10 type … … 18 18 procedure SetMaxCount(AValue: Integer); 19 19 procedure LimitMaxCount; 20 procedure ItemsChange(Sender: TObject); 21 procedure DoChange; 20 22 public 21 23 Items: TStringList; … … 25 27 procedure LoadFromRegistry(Context: TRegistryContext); 26 28 procedure SaveToRegistry(Context: TRegistryContext); 29 procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string); 30 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 27 31 procedure AddItem(FileName: string); 28 32 published … … 38 42 procedure Register; 39 43 begin 40 RegisterComponents(' Samples', [TLastOpenedList]);44 RegisterComponents('Common', [TLastOpenedList]); 41 45 end; 42 46 … … 58 62 end; 59 63 64 procedure TLastOpenedList.ItemsChange(Sender: TObject); 65 begin 66 DoChange; 67 end; 68 69 procedure TLastOpenedList.DoChange; 70 begin 71 if Assigned(FOnChange) then 72 FOnChange(Self); 73 end; 74 60 75 constructor TLastOpenedList.Create(AOwner: TComponent); 61 76 begin 62 77 inherited; 63 78 Items := TStringList.Create; 79 Items.OnChange := ItemsChange; 64 80 MaxCount := 10; 65 81 end; … … 129 145 end; 130 146 147 procedure TLastOpenedList.LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string 148 ); 149 var 150 I: Integer; 151 Value: string; 152 Count: Integer; 153 begin 154 with XMLConfig do begin 155 Count := GetValue(Path + '/Count', 0); 156 if Count > MaxCount then Count := MaxCount; 157 Items.Clear; 158 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), ''); 160 if Trim(Value) <> '' then Items.Add(Value); 161 end; 162 if Assigned(FOnChange) then 163 FOnChange(Self); 164 end; 165 end; 166 167 procedure TLastOpenedList.SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 168 var 169 I: Integer; 170 begin 171 with XMLConfig do begin 172 SetValue(Path + '/Count', Items.Count); 173 for I := 0 to Items.Count - 1 do 174 SetValue(Path + '/File' + IntToStr(I), Items[I]); 175 Flush; 176 end; 177 end; 178 131 179 procedure TLastOpenedList.AddItem(FileName:string); 132 180 begin … … 134 182 Items.Insert(0, FileName); 135 183 LimitMaxCount; 136 if Assigned(FOnChange) then 137 FOnChange(Self); 184 DoChange; 138 185 end; 139 186
Note:
See TracChangeset
for help on using the changeset viewer.