1 unit BottleChainListFrame;
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, BottleChainEvent, BottleChainRule, StdCtrls, CheckLst,
11 TfrmBottleChainList = class(TFrame)
12 lstRules: TCheckListBox;
16 procedure lstRulesMeasureItem(Control: TWinControl; Index: Integer;
18 procedure lstRulesDrawItem(Control: TWinControl; Index: Integer;
19 Rect: TRect; State: TOwnerDrawState);
20 procedure Button1Click(Sender: TObject);
21 procedure lstRulesClickCheck(Sender: TObject);
22 procedure EditRule(Sender: TObject);
23 procedure btnAddClick(Sender: TObject);
24 procedure btnDeleteClick(Sender: TObject);
29 procedure UpdateDisplay;
36 procedure TfrmBottleChainList.lstRulesMeasureItem(Control: TWinControl; Index: Integer;
41 ARect := lstRules.ItemRect(Index);
42 ARect.Left := ARect.Left + 2;
43 ARect.Right := ARect.Right - 2;
45 Str := BottleChainRuleList[Index].StringExpression;
47 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
48 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
49 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
50 Height := ARect.Bottom - ARect.Top;
53 ARect.Left := ARect.Left + 5;
54 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
55 Str := BottleChainRuleList[Index].Title;
56 DrawText(lstRules.Canvas.Handle, PChar(Str), -1,
57 ARect, DT_NOPREFIX or DT_EDITCONTROL or DT_CALCRECT or DT_WORDBREAK);
58 Height := Height + ARect.Bottom - ARect.Top;
62 procedure TfrmBottleChainList.lstRulesDrawItem(Control: TWinControl; Index: Integer;
63 Rect: TRect; State: TOwnerDrawState);
67 lstRules.Canvas.FillRect(Rect);
69 //
\83e
\83L
\83X
\83g
\95`
\89æ
\97Ì
\88æ
\82Ì
\83}
\81[
\83W
\83\93\82ð
\8eæ
\82é
70 Rect.Left := Rect.Left + 2;
71 Rect.Top := Rect.Top + 2;
72 Rect.Right := Rect.Right - 2;
73 Rect.Bottom := Rect.Bottom - 2;
75 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style + [fsBold];
76 Str := BottleChainRuleList[Index].Title;
77 y := DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
78 lstRules.Canvas.Font.Style := lstRules.Canvas.Font.Style - [fsBold];
79 Str := BottleChainRuleList[Index].StringExpression;
80 Rect.Top := Rect.Top + y;
81 Rect.Left := Rect.Left + 5;
82 DrawText(lstRules.Canvas.Handle, PChar(Str), -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
85 procedure TfrmBottleChainList.Button1Click(Sender: TObject);
86 var instance: TBottleChainRuleList;
87 rule: TBottleChainRule;
88 condition: TBottleChainCondition;
91 instance := TBottleChainRuleList.Create(nil);
93 rule := TBottleChainRule.Create(instance);
94 rule.RuleList := instance;
95 condition := TBottleChainChannelCondition.Create(rule);
96 (condition as TBottleChainChannelCondition).Channels.Add('
\8fd
\97v');
97 (condition as TBottleChainChannelCondition).Channels.Add('Important');
98 Condition.Rule := rule;
99 str := ComponentToString(instance);
104 instance := StringToComponent(str) as TBottleChainRuleList;
105 ShowMessage(ComponentToString(instance));
108 procedure TfrmBottleChainList.UpdateDisplay;
111 lstRules.Items.Clear;
112 for i := 0 to BottleChainRuleList.Count-1 do begin
113 lstRules.Items.Add(BottleChainRuleList.Rules[i].StringExpression);
114 lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
118 procedure TfrmBottleChainList.lstRulesClickCheck(Sender: TObject);
121 for i := 0 to BottleChainRuleList.Count-1 do begin
122 BottleChainRuleList[i].Enabled := lstRules.Checked[i];
126 procedure TfrmBottleChainList.EditRule(Sender: TObject);
128 if lstRules.ItemIndex <> -1 then begin
129 frmBottleChainRuleEditor.Execute(BottleChainRuleList[lstRules.ItemIndex]);
134 procedure TfrmBottleChainList.btnAddClick(Sender: TObject);
135 var New: TBottleChainRule;
137 New := TBottleChainRule.Create(BottleChainRuleList);
138 New.RuleList := BottleChainRuleList; //
\8e©
\95ª
\82ð
\83\8a\83X
\83g
\82É
\92Ç
\89Á
\82·
\82é
139 frmBottleChainRuleEditor.Execute(New);
143 procedure TfrmBottleChainList.btnDeleteClick(Sender: TObject);
144 var Del: TBottleChainRule;
146 if lstRules.ItemIndex < 0 then Exit;
147 Del := BottleChainRuleList[lstRules.ItemIndex];