ufrmRule.~pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:17k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit ufrmRule;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils,Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, cxGraphics, Menus,
  6.   cxLookAndFeelPainters, cxButtons, cxCheckBox, cxTextEdit, cxMaskEdit,
  7.   cxDropDownEdit, cxImageComboBox, cxLabel, cxControls, cxContainer,
  8.   cxEdit, cxGroupBox, dxBar, cxClasses, cxCustomData, 
  9.   cxDataStorage, cxGridCustomTableView, cxGridTableView,
  10.   cxGridCustomView, cxGridLevel, cxGrid, cxButtonEdit, dxBarExtItems,uRulerMgr,
  11.   RzShellDialogs, cxListBox, DB, cxDBData, cxGridDBTableView, cxStyles,
  12.   cxFilter, cxData, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel,
  13.   dxSkinCoffee, dxSkinDarkSide, dxSkinGlassOceans, dxSkiniMaginary,
  14.   dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin,
  15.   dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  16.   dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  17.   dxSkinPumpkin, dxSkinSilver, dxSkinStardust, dxSkinSummer2008,
  18.   dxSkinsDefaultPainters, dxSkinValentine, dxSkinXmas2008Blue,
  19.   dxSkinscxPCPainter, dxSkinsdxBarPainter,
  20.   {dxSkinDarkRoom,dxSkinDarkSide,dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,}  {dxSkinFoggy,}
  21.     {dxSkinPumpkin,dxSkinSeven,dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  22.   dxSkinOffice2007Pink, dxSkinOffice2007Silver,}
  23.   {dxSkinSharp,dxSkinSilver,}  {dxSkinSpringTime,dxSkinStardust,
  24.   dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  25.   dxSkinXmas2008Blue, dxSkinscxPCPainter, dxSkinsdxBarPainter} ;
  26. type
  27.   TfrmRule = class(TForm)
  28.     pnl1: TPanel;
  29.     pnl3: TPanel;
  30.     dxbrmngr1: TdxBarManager;
  31.     dxbrmngr1Bar1: TdxBar;
  32.     dxbrbtn1: TdxBarButton;
  33.     dxbrbtn2: TdxBarButton;
  34.     dxbrbtn3: TdxBarButton;
  35.     dxbrbtn4: TdxBarButton;
  36.     pnl2: TPanel;
  37.     btnCancel: TcxButton;
  38.     btnSave: TcxButton;
  39.     btn3: TdxBarLargeButton;
  40.     btn4: TdxBarLargeButton;
  41.     btn5: TdxBarLargeButton;
  42.     btn6: TdxBarLargeButton;
  43.     dlgOpen: TRzOpenDialog;
  44.     lstRules: TcxListBox;
  45.     cxEditStyleController1: TcxEditStyleController;
  46.     dlgSave: TRzSaveDialog;
  47.     pnl4: TPanel;
  48.     cxgrpbx1: TcxGroupBox;
  49.     cxGrid1: TcxGrid;
  50.     tvRules: TcxGridTableView;
  51.     gtvColGrid1TableView1Column1: TcxGridColumn;
  52.     gtvColGrid1TableView1Column2: TcxGridColumn;
  53.     gtvColGrid1TableView1Column3: TcxGridColumn;
  54.     cxgrdbtblvwGrid1DBTableView1: TcxGridDBTableView;
  55.     cxgrdbtblvwGrid1DBTableView1Area: TcxGridDBColumn;
  56.     cxgrdbtblvwGrid1DBTableView1Compare: TcxGridDBColumn;
  57.     cxgrdbtblvwGrid1DBTableView1Text: TcxGridDBColumn;
  58.     cxgrdbtblvwGrid1DBTableView1RecId: TcxGridDBColumn;
  59.     tvRule: TcxGridTableView;
  60.     gtvColGrid1TableView1Column4: TcxGridColumn;
  61.     gtvColGrid1TableView1Column5: TcxGridColumn;
  62.     gtvColGrid1TableView1Column6: TcxGridColumn;
  63.     cxgrdlvlGrid1Level1: TcxGridLevel;
  64.     cxgrpbx2: TcxGroupBox;
  65.     chkDeleteOnServer: TcxCheckBox;
  66.     chkIgnore: TcxCheckBox;
  67.     chkPopTip: TcxCheckBox;
  68.     chkPlaySound: TcxCheckBox;
  69.     chkRunExe: TcxCheckBox;
  70.     edtPlaySound: TcxButtonEdit;
  71.     edtRunExe: TcxButtonEdit;
  72.     pnl5: TPanel;
  73.     lbl1: TcxLabel;
  74.     lbl2: TcxLabel;
  75.     cbAccount: TcxImageComboBox;
  76.     edtRuleName: TcxTextEdit;
  77.     chkEnable: TcxCheckBox;
  78.     chkUseToNew: TcxCheckBox;
  79.     btnAddRow: TcxButton;
  80.     btnDeleteRow: TcxButton;
  81.     btnSaveRecord: TcxButton;
  82.     btn1: TdxBarLargeButton;
  83.     btn2: TdxBarLargeButton;
  84.     procedure btnCancelClick(Sender: TObject);
  85.     procedure FormCreate(Sender: TObject);
  86.     procedure FormDestroy(Sender: TObject);
  87.     procedure lstRulesMouseUp(Sender: TObject; Button: TMouseButton;
  88.       Shift: TShiftState; X, Y: Integer);
  89.     procedure chkPlaySoundClick(Sender: TObject);
  90.     procedure chkRunExeClick(Sender: TObject);
  91.     procedure edtPlaySoundPropertiesButtonClick(Sender: TObject;
  92.       AButtonIndex: Integer);
  93.     procedure edtRunExePropertiesButtonClick(Sender: TObject;
  94.       AButtonIndex: Integer);
  95.     procedure chkEnableClick(Sender: TObject);
  96.     procedure btnAddRowClick(Sender: TObject);
  97.     procedure btnDeleteRowClick(Sender: TObject);
  98.     procedure btn3Click(Sender: TObject);
  99.     procedure btnSaveClick(Sender: TObject);
  100.     procedure btn6Click(Sender: TObject);
  101.     procedure btn4Click(Sender: TObject);
  102.     procedure edtRuleNamePropertiesEditValueChanged(Sender: TObject);
  103.     procedure chkUseToNewClick(Sender: TObject);
  104.     procedure chkDeleteOnServerClick(Sender: TObject);
  105.     procedure chkIgnoreClick(Sender: TObject);
  106.     procedure chkPopTipClick(Sender: TObject);
  107.     procedure cbAccountPropertiesCloseUp(Sender: TObject);
  108.     procedure tvRulesDataControllerRecordChanged(
  109.       ADataController: TcxCustomDataController; ARecordIndex,
  110.       AItemIndex: Integer);
  111.     procedure btnSaveRecordClick(Sender: TObject);
  112.     procedure btn5Click(Sender: TObject);
  113.     procedure btn2Click(Sender: TObject);
  114.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  115.   private
  116.     { Private declarations }
  117.     FRuleItems:TRuleItems;
  118.     FRulesSaveTo:string;
  119.     FIndex:Integer;
  120.     procedure LoadRules;
  121.     procedure ShowRules;
  122.     procedure LoadAccount;
  123.     procedure LoadRuleRows;
  124.     procedure ShowRuleRows;
  125.   public
  126.     { Public declarations }
  127.   end;
  128. var
  129.   frmRule: TfrmRule;
  130. const
  131.   CONST_AREA:array[0..5] of ShortString=('主题','收件人','发件人','抄送','暗送','邮件正文');
  132.   CONST_COMPARE:array[0..3] of ShortString=('包含','相等','空','使用正则表达式');
  133. implementation
  134. uses ufrmMain, uMyXml, NativeXml, uCommon;
  135. {$R *.dfm}
  136. procedure TfrmRule.btnCancelClick(Sender: TObject);
  137. begin
  138.   self.close;
  139.   ModalResult:=mrCancel;
  140. end;
  141. procedure TfrmRule.FormCreate(Sender: TObject);
  142. var
  143.   MyXml:TMyxml;
  144. begin
  145.   tvRule.DataController.Options:=tvRule.DataController.Options+[ dcoImmediatePost,dcoInsertOnNewItemRowFocusing]; //立即自动提交新记录
  146.   FRuleItems:=TRuleItems.Create;
  147.   LoadAccount;
  148.   MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
  149.   try
  150.     if MyXml.Root.FindNode('Rules')<> nil then
  151.     begin
  152.       FRulesSaveTo:=MyXml.Root.FindNode('Rules').AttributeByName['RulesSaveTo'];
  153.       FRulesSaveTo:=GetFullPath(FRulesSaveTo);
  154.       if FileExists(FRulesSaveTo) then  TRuleItems.ReadFromFile(FRulesSaveTo,FRuleItems);
  155.     end;
  156.     LoadRules;
  157.   finally
  158.     MyXml.Free;
  159.   end;  
  160. end;
  161. procedure TfrmRule.FormDestroy(Sender: TObject);
  162. begin
  163.   FRuleItems.Free;
  164. end;
  165. procedure TfrmRule.LoadAccount;
  166. var
  167.   myxml:TMyXml;
  168.   L:TList;
  169.   I:Integer;
  170. begin
  171.   cbAccount.Properties.Items.Clear;
  172.   with cbAccount.Properties.Items.Add do
  173.   begin
  174.     ImageIndex:=0;
  175.     Description:='所有账号';
  176.     Value:='All';
  177.   end;
  178.   MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
  179.   try
  180.     L:=TList.Create;
  181.     myxml.Pop3Nodes(L);
  182.     for I:=0 to L.Count-1 do
  183.       with cbAccount.Properties.Items.Add do
  184.       begin
  185.         ImageIndex:=I;
  186.         Description:=TXmlNode(L[I]).ReadString('displayname');
  187.         Value:=TXmlNode(L[I]).ReadString('emailaddr');
  188.       end;
  189.     L.Free;
  190.   finally
  191.     myxml.Free;
  192.   end;
  193. end;
  194. procedure TfrmRule.LoadRules;
  195. var
  196.   I:Integer;
  197. begin
  198.   lstRules.Items.Clear;
  199.   for I:=0 to FRuleItems.Count-1 do
  200.     lstRules.AddItem(TRuleItem(FRuleItems[I]).Name,TObject(FRuleItems.Items[I]));
  201.   if lstRules.Items.Count=0 then
  202.   begin
  203.     FIndex:=-1;
  204.     edtRuleName.Enabled:=False;
  205.   end
  206.   else
  207.   begin
  208.     lstRules.ItemIndex:=0;
  209.     FIndex:=0;
  210.     ShowRules;
  211.   end;
  212. end;
  213. procedure TfrmRule.lstRulesMouseUp(Sender: TObject; Button: TMouseButton;
  214.   Shift: TShiftState; X, Y: Integer);
  215. var
  216.   P:TPoint;
  217. begin
  218.   p.X:=X; P.Y:=Y;
  219.   FIndex:=TcxListBox(Sender).ItemAtPos(P,True);
  220.   if FIndex<0 then Exit;
  221.   
  222.   ShowRules;
  223.   //while tvRule.DataController.RecordCount>0 do tvRule.DataController.DeleteRecord(0);
  224. end;
  225. procedure TfrmRule.chkPlaySoundClick(Sender: TObject);
  226. begin
  227.  edtPlaySound.Visible:=TcxCheckBox(Sender).Checked;
  228. end;
  229. procedure TfrmRule.chkRunExeClick(Sender: TObject);
  230. begin
  231.   edtRunExe.Visible:=TcxCheckBox(Sender).Checked;
  232. end;
  233. procedure TfrmRule.edtPlaySoundPropertiesButtonClick(Sender: TObject;
  234.   AButtonIndex: Integer);
  235. begin
  236.   dlgOpen.Filter:='WAV|*.WAV|MP3|*.MP3|MP3|*.MP4|RM|*.RM|WMA|*.WMA|RA|*.RA|RMX|*.RMX|aif|*.aif|AU|*.AU|MPEG|*.MPEG|MPG|*.MPG|*.*|*.*';
  237.   if dlgOpen.Execute then
  238.   begin
  239.     edtPlaySound.Text:=dlgOpen.FileName;
  240.     TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound:=edtPlaySound.Text;
  241.   end;
  242. end;
  243. procedure TfrmRule.edtRunExePropertiesButtonClick(Sender: TObject;
  244.   AButtonIndex: Integer);
  245. begin
  246.   dlgOpen.Filter:='EXE|*.exe|BAT|*.bat|*.*|*.*';
  247.   if dlgOpen.Execute then
  248.   begin
  249.     edtRunExe.Text:=dlgOpen.FileName;
  250.     TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe:=edtRunExe.Text;
  251.   end;
  252. end;
  253. procedure TfrmRule.chkEnableClick(Sender: TObject);
  254. begin
  255.   FRuleItems.Items[FIndex].Enabled:=chkEnable.Checked;
  256. end;
  257. procedure TfrmRule.btnAddRowClick(Sender: TObject);
  258. begin
  259.   tvRule.DataController.AppendRecord;
  260. end;
  261. procedure TfrmRule.btnDeleteRowClick(Sender: TObject);
  262. begin
  263.   if not tvRule.DataController.IsEOF then
  264.     tvRule.DataController.DeleteFocused;
  265. end;
  266. procedure TfrmRule.btn3Click(Sender: TObject);
  267. var
  268.   item:TRuleItem;
  269. begin
  270.   item:=FRuleItems.Add;
  271.   item.Name:='新规则';
  272.   lstRules.Items.InsertObject(lstRules.Items.Count,'新规则',TObject(item));
  273.   lstRules.ItemIndex:=lstRules.Count-1;
  274.   FIndex:=lstRules.ItemIndex;
  275.   ShowRules;
  276. end;
  277. procedure TfrmRule.btnSaveClick(Sender: TObject);
  278. begin
  279.   if FIndex<0 then
  280.   begin
  281.     MessageDlg('请选中一个规则,再保存!' + #13#10#13#10#13#10,  
  282.       mtError, [mbOK], 0);
  283.     Exit;
  284.   end;
  285.   //if not FileExists(FRulesSaveTo) then
  286.     FRuleItems.SaveToFile(FRulesSaveTo);
  287.   //else raise Exception.Create('');
  288.   ModalResult:=mrOk;
  289. end;
  290. procedure TfrmRule.ShowRules;
  291. var
  292.   I:Integer;
  293. begin
  294.   if FIndex>=0 then
  295.   begin
  296.     edtRuleName.Enabled:=True;
  297.     edtRuleName.Text:=TRuleItem(FRuleItems[FIndex]).Name;
  298.     chkEnable.Checked:=TRuleItem(FRuleItems[FIndex]).Enabled;
  299.     chkUseToNew.Checked:=TRuleItem(FRuleItems[FIndex]).UseToNewEmail;
  300.     chkDeleteOnServer.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.DeleteOnServer;
  301.     chkIgnore.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.IgnoreNotRecv;
  302.     chkPopTip.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.PopTip;
  303.     chkPlaySound.Checked:=FileExists(TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound);
  304.     if chkPlaySound.Checked then
  305.     begin
  306.       edtPlaySound.Visible:=chkPlaySound.Checked;
  307.       edtPlaySound.Text:=TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound;
  308.     end;
  309.     chkRunExe.Checked:=FileExists(TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe);
  310.     if chkRunExe.Checked then
  311.     begin
  312.       edtRunExe.Visible:=chkRunExe.Checked;
  313.       edtRunExe.Text:=TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe;
  314.     end;
  315.     if TRuleItem(FRuleItems[FIndex]).AllAccount then
  316.       cbAccount.ItemIndex:=0
  317.     else
  318.       for I:=0 to cbAccount.Properties.Items.Count-1 do
  319.       begin
  320.         if CompareText(cbAccount.Properties.Items[I].Value,TRuleItem(FRuleItems[FIndex]).Account)=0 then
  321.         begin
  322.           cbAccount.ItemIndex:=I;
  323.           Break;
  324.         end;
  325.       end;
  326.     ShowRuleRows;
  327.   end;
  328. end;
  329. procedure TfrmRule.btn6Click(Sender: TObject);
  330. begin
  331.   dlgSave.Filter:='xml file|*.xml';
  332.   if dlgSave.Execute then
  333.     FRuleItems.SaveToFile(dlgSave.FileName);
  334. end;
  335. procedure TfrmRule.btn4Click(Sender: TObject);
  336. begin
  337.   FRuleItems.Delete(lstRules.ItemIndex);
  338.   lstRules.Items.Delete(lstRules.ItemIndex);
  339.   FIndex:=lstRules.ItemIndex;
  340.   ShowRules;
  341. end;
  342. procedure TfrmRule.edtRuleNamePropertiesEditValueChanged(Sender: TObject);
  343. begin
  344.   lstRules.Items[FIndex]:=edtRuleName.Text;
  345.   FRuleItems.Items[FIndex].Name:=edtRuleName.Text;
  346. end;
  347. procedure TfrmRule.chkUseToNewClick(Sender: TObject);
  348. begin
  349.   FRuleItems.Items[FIndex].UseToNewEmail:=chkUseToNew.Checked;
  350. end;
  351. procedure TfrmRule.chkDeleteOnServerClick(Sender: TObject);
  352. begin
  353.   FRuleItems.Items[FIndex].RulerAction.DeleteOnServer:=chkDeleteOnServer.Checked;
  354. end;
  355. procedure TfrmRule.chkIgnoreClick(Sender: TObject);
  356. begin
  357.   FRuleItems.Items[FIndex].RulerAction.IgnoreNotRecv:=chkIgnore.Checked;
  358. end;
  359. procedure TfrmRule.chkPopTipClick(Sender: TObject);
  360. begin
  361.   FRuleItems.Items[FIndex].RulerAction.PopTip:=chkPopTip.Checked;
  362. end;
  363. procedure TfrmRule.cbAccountPropertiesCloseUp(Sender: TObject);
  364. begin
  365.   if FIndex>=0 then
  366.   begin
  367.     FRuleItems.Items[FIndex].AllAccount:=cbAccount.ItemIndex=0;
  368.     FRuleItems.Items[FIndex].Account:=cbAccount.Properties.Items[cbAccount.ItemIndex].Value;
  369.   end;
  370. end;
  371. procedure TfrmRule.tvRulesDataControllerRecordChanged(
  372.   ADataController: TcxCustomDataController; ARecordIndex,
  373.   AItemIndex: Integer);
  374. //var
  375. //  I:Integer;
  376. //const
  377. //  tips:array[0..2] of string=('区域选项不允许空值','比较选项不允许空值','文本不允许空值');
  378. begin
  379. //  for I:=0 to 2 do
  380. //    if ((I<>3) and VarIsNull(ADataController.Values[ADataController.FocusedRecordIndex,I])) and
  381. //        ((I=3) and VarIsNull(ADataController.Values[ADataController.FocusedRecordIndex,I]) and
  382. //        (ADataController.Values[ADataController.FocusedRecordIndex,2]<>'空')) then
  383. //    begin
  384. //      ADataController.Cancel;
  385. //      MsgBox('出错啦',tips[I]);
  386. //    end;
  387. end;
  388. procedure TfrmRule.LoadRuleRows;
  389. var
  390.   I:Integer;
  391. begin
  392.   FRuleItems.Items[FIndex].Rows.Clear;
  393.   for I:=0 to tvRule.DataController.RecordCount-1 do
  394.   begin
  395.     with FRuleItems.Items[FIndex].Rows.Add do
  396.     begin
  397.       Text:=VarToStr(tvRule.DataController.Values[I,2]);
  398.       Area:=TRuleArea(tvRule.DataController.Values[I,0]);
  399.       Compare:=TRuleCompare(tvRule.DataController.Values[I,1]);
  400. //      if VarToStr(tvRule.DataController.Values[I,0])='主题' then  {主题,收件人,发件人,抄送,暗送,邮件正文}
  401. //        Area:=raSubject
  402. //      else if VarToStr(tvRule.DataController.Values[I,0])='收件人' then
  403. //        Area:=raTo
  404. //      else if VarToStr(tvRule.DataController.Values[I,0])='发件人' then
  405. //        Area:=raFrom
  406. //      else if VarToStr(tvRule.DataController.Values[I,0])='抄送' then
  407. //        Area:=raCC
  408. //      else if VarToStr(tvRule.DataController.Values[I,0])='暗送' then
  409. //        Area:=raCB
  410. //      else if VarToStr(tvRule.DataController.Values[I,0])='邮件正文' then
  411. //        Area:=raBody
  412. //      else {Error!} ;
  413. //
  414. //      if VarToStr(tvRule.DataController.Values[I,1])='包含' then    {包含,相等,空,使用正则表达式}
  415. //        Compare:=rcContains
  416. //      else if VarToStr(tvRule.DataController.Values[I,1])='相等' then
  417. //        Compare:=rcEquals
  418. //      else if VarToStr(tvRule.DataController.Values[I,1])='空' then
  419. //      begin
  420. //        Compare:=rcEmpty;
  421. //        Text:='';
  422. //      end
  423. //      else if VarToStr(tvRule.DataController.Values[I,1])='使用正则表达式' then
  424. //         Compare:=rcRegExpr
  425. //      else {Error!} ;
  426.     end;
  427.   end;
  428. end;
  429. procedure TfrmRule.ShowRuleRows;
  430. var
  431.   I,idx:Integer;
  432. begin
  433.   while tvRule.DataController.RecordCount>0  do tvRule.DataController.DeleteRecord(0);
  434.   
  435.   tvRule.DataController.BeginUpdate;
  436.   try
  437.     for I:=0 to FRuleItems.Items[FIndex].Rows.Count-1 do
  438.     begin
  439.       if not(VarIsOrdinal(FRuleItems.Items[FIndex].Rows.Items[I].Area) and VarIsOrdinal(FRuleItems.Items[FIndex].Rows.Items[I].Compare)) then
  440.         Continue; //忽略无效的值
  441.       idx:=tvRule.DataController.AppendRecord;
  442.       tvRule.DataController.Values[idx,0]:=Ord(FRuleItems.Items[FIndex].Rows.Items[I].Area);
  443.       tvRule.DataController.Values[idx,1]:=Ord(FRuleItems.Items[FIndex].Rows.Items[I].Compare);
  444.       tvRule.DataController.Values[idx,2]:=FRuleItems.Items[FIndex].Rows.Items[I].Text;
  445.       tvRule.DataController.Post;
  446.       //tvRule.DataController.PostEditingData;
  447.     end;
  448.   finally
  449.     tvRule.DataController.EndUpdate;
  450.   end;
  451. end;
  452. procedure TfrmRule.btnSaveRecordClick(Sender: TObject);
  453. var
  454.   I:Integer;
  455.   item:TRuleRow;
  456. begin
  457.   if FIndex<0 then Exit;
  458.   FRuleItems.Items[FIndex].Rows.Clear;
  459.   with tvRule.DataController do
  460.     for I:=0 to RecordCount -1 do
  461.     begin
  462.       if (not VarIsOrdinal(Values[I,0])) or  (not VarIsOrdinal(Values[I,1])) then
  463.         Continue;  //检查数据合法性
  464.         item:=FRuleItems.Items[FIndex].Rows.Add;
  465.       //begin
  466.         item.Area:=TRuleArea(Values[I,0]);
  467.         item.Compare:=TRuleCompare(Values[I,1]);
  468.         item.Text:=VarToStr(Values[I,2]);
  469.      // end;
  470.     end;
  471. end;
  472. procedure TfrmRule.btn5Click(Sender: TObject);
  473. var
  474.   count,I:Integer;
  475. begin
  476.   dlgOpen.Filter:='xml file|*.xml';
  477.   if dlgOpen.Execute then
  478.   begin
  479.     count:=FRuleItems.Count;
  480.     TRuleItems.AppendFromFile(dlgOpen.FileName,FRuleItems);
  481.     for I:=count to  FRuleItems.Count-1 do
  482.       lstRules.AddItem(FRuleItems.Items[I].Name,TObject(FRuleItems.Items[I]));
  483.   end;
  484. end;
  485. procedure TfrmRule.btn2Click(Sender: TObject);
  486. begin
  487.   close;
  488. end;
  489. procedure TfrmRule.FormClose(Sender: TObject; var Action: TCloseAction);
  490. begin
  491.   Action:=caFree;
  492. end;
  493. end.