| 1 | unit fAlertForward;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses Windows, Messages, SysUtils, Classes, Graphics, Forms, Controls,
|
---|
| 6 | Dialogs, StdCtrls, Buttons, ORCtrls, ORfn, ExtCtrls, fAutoSz, ComCtrls, fBase508Form,
|
---|
| 7 | VA508AccessibilityManager;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmAlertForward = class(TfrmBase508Form)
|
---|
| 11 | cmdOK: TButton;
|
---|
| 12 | cmdCancel: TButton;
|
---|
| 13 | cboSrcList: TORComboBox;
|
---|
| 14 | DstList: TORListBox;
|
---|
| 15 | SrcLabel: TLabel;
|
---|
| 16 | DstLabel: TLabel;
|
---|
| 17 | pnlBase: TORAutoPanel;
|
---|
| 18 | memAlert: TMemo;
|
---|
| 19 | Label1: TLabel;
|
---|
| 20 | memComment: TMemo;
|
---|
| 21 | btnAddAlert: TButton;
|
---|
| 22 | btnRemoveAlertFwrd: TButton;
|
---|
| 23 | btnRemoveAllAlertFwrd: TButton;
|
---|
| 24 | procedure btnRemoveAlertFwrdClick(Sender: TObject);
|
---|
| 25 | procedure btnAddAlertClick(Sender: TObject);
|
---|
| 26 | procedure cboSrcListNeedData(Sender: TObject; const StartFrom: String;
|
---|
| 27 | Direction, InsertAt: Integer);
|
---|
| 28 | procedure cmdOKClick(Sender: TObject);
|
---|
| 29 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 30 | procedure cboSrcListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
---|
| 31 | procedure cboSrcListMouseClick(Sender: TObject);
|
---|
| 32 | procedure FormCreate(Sender: TObject);
|
---|
| 33 | procedure cboSrcListChange(Sender: TObject);
|
---|
| 34 | procedure DstListChange(Sender: TObject);
|
---|
| 35 | procedure btnRemoveAllAlertFwrdClick(Sender: TObject);
|
---|
| 36 | private
|
---|
| 37 | RemovingAll: boolean;
|
---|
| 38 | end;
|
---|
| 39 |
|
---|
| 40 | function ForwardAlertTo(Alert: String): Boolean;
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | implementation
|
---|
| 44 |
|
---|
| 45 | {$R *.DFM}
|
---|
| 46 |
|
---|
| 47 | uses rCore, uCore, VA508AccessibilityRouter;
|
---|
| 48 |
|
---|
| 49 | const
|
---|
| 50 | TX_DUP_RECIP = 'You have already selected that recipient.';
|
---|
| 51 | TX_RECIP_CAP = 'Error adding recipient';
|
---|
| 52 |
|
---|
| 53 | var XQAID: string;
|
---|
| 54 |
|
---|
| 55 | function ForwardAlertTo(Alert: String): Boolean;
|
---|
| 56 | var
|
---|
| 57 | frmAlertForward: TfrmAlertForward;
|
---|
| 58 | begin
|
---|
| 59 | frmAlertForward := TfrmAlertForward.Create(Application);
|
---|
| 60 | try
|
---|
| 61 | ResizeAnchoredFormToFont(frmAlertForward);
|
---|
| 62 | with frmAlertForward do
|
---|
| 63 | begin
|
---|
| 64 | memAlert.SetTextBuf(PChar(Piece(Alert, U, 2)));
|
---|
| 65 | XQAID := Piece(Alert, U, 1);
|
---|
| 66 | ShowModal;
|
---|
| 67 | end;
|
---|
| 68 | finally
|
---|
| 69 | frmAlertForward.Release;
|
---|
| 70 | Result := True;
|
---|
| 71 | end;
|
---|
| 72 | end;
|
---|
| 73 |
|
---|
| 74 | procedure TfrmAlertForward.FormCreate(Sender: TObject);
|
---|
| 75 | begin
|
---|
| 76 | inherited;
|
---|
| 77 | if ScreenReaderSystemActive then
|
---|
| 78 | memAlert.TabStop := TRUE;
|
---|
| 79 | cboSrcList.InitLongList('');
|
---|
| 80 | end;
|
---|
| 81 |
|
---|
| 82 | procedure TfrmAlertForward.cboSrcListNeedData(Sender: TObject;
|
---|
| 83 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 84 | begin
|
---|
| 85 | (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
|
---|
| 86 | end;
|
---|
| 87 |
|
---|
| 88 | procedure TfrmAlertForward.cmdCancelClick(Sender: TObject);
|
---|
| 89 | begin
|
---|
| 90 | Close;
|
---|
| 91 | end;
|
---|
| 92 |
|
---|
| 93 | procedure TfrmAlertForward.cmdOKClick(Sender: TObject);
|
---|
| 94 | var
|
---|
| 95 | i: integer ;
|
---|
| 96 | Recip: string;
|
---|
| 97 | begin
|
---|
| 98 |
|
---|
| 99 | for i := 0 to DstList.Items.Count-1 do
|
---|
| 100 | begin
|
---|
| 101 | Recip := Piece(DstList.Items[i], U, 1);
|
---|
| 102 | memComment.Text := StringReplace(memComment.Text, CRLF, ' ', [rfReplaceAll]);
|
---|
| 103 | ForwardAlert(XQAID, Recip, 'A', memComment.Text);
|
---|
| 104 | end;
|
---|
| 105 | Close;
|
---|
| 106 | end;
|
---|
| 107 |
|
---|
| 108 | procedure TfrmAlertForward.DstListChange(Sender: TObject);
|
---|
| 109 | var
|
---|
| 110 | HasFocus: boolean;
|
---|
| 111 | begin
|
---|
| 112 | inherited;
|
---|
| 113 | if DstList.SelCount = 1 then
|
---|
| 114 | if Piece(DstList.Items[0], '^', 1) = '' then
|
---|
| 115 | begin
|
---|
| 116 | btnRemoveAlertFwrd.Enabled := false;
|
---|
| 117 | btnRemoveAllAlertFwrd.Enabled := false;
|
---|
| 118 | exit;
|
---|
| 119 | end;
|
---|
| 120 | HasFocus := btnRemoveAlertFwrd.Focused;
|
---|
| 121 | if Not HasFocus then
|
---|
| 122 | HasFocus := btnRemoveAllAlertFwrd.Focused;
|
---|
| 123 | btnRemoveAlertFwrd.Enabled := DstList.SelCount > 0;
|
---|
| 124 | btnRemoveAllAlertFwrd.Enabled := DstList.Items.Count > 0;
|
---|
| 125 | if HasFocus and (DstList.SelCount = 0) then
|
---|
| 126 | btnAddAlert.SetFocus;
|
---|
| 127 | end;
|
---|
| 128 |
|
---|
| 129 | procedure TfrmAlertForward.btnAddAlertClick(Sender: TObject);
|
---|
| 130 | begin
|
---|
| 131 | inherited;
|
---|
| 132 | cboSrcListMouseClick(btnAddAlert);
|
---|
| 133 | end;
|
---|
| 134 |
|
---|
| 135 | procedure TfrmAlertForward.btnRemoveAlertFwrdClick(Sender: TObject);
|
---|
| 136 | var
|
---|
| 137 | i: integer;
|
---|
| 138 | begin
|
---|
| 139 | with DstList do
|
---|
| 140 | begin
|
---|
| 141 | if ItemIndex = -1 then exit ;
|
---|
| 142 | for i := Items.Count-1 downto 0 do
|
---|
| 143 | if Selected[i] then
|
---|
| 144 | begin
|
---|
| 145 | if ScreenReaderSystemActive and (not RemovingAll) then
|
---|
| 146 | GetScreenReader.Speak(Piece(DstList.Items[i],U,2) +
|
---|
| 147 | ' Removed from ' + DstLabel.Caption);
|
---|
| 148 | Items.Delete(i) ;
|
---|
| 149 | end;
|
---|
| 150 | end;
|
---|
| 151 | end;
|
---|
| 152 |
|
---|
| 153 | procedure TfrmAlertForward.btnRemoveAllAlertFwrdClick(Sender: TObject);
|
---|
| 154 | begin
|
---|
| 155 | inherited;
|
---|
| 156 | DstList.SelectAll;
|
---|
| 157 | RemovingAll := TRUE;
|
---|
| 158 | try
|
---|
| 159 | btnRemoveAlertFwrdClick(self);
|
---|
| 160 | if ScreenReaderSystemActive then
|
---|
| 161 | GetScreenReader.Speak(DstLabel.Caption + ' Cleared');
|
---|
| 162 | finally
|
---|
| 163 | RemovingAll := FALSE;
|
---|
| 164 | end;
|
---|
| 165 | end;
|
---|
| 166 |
|
---|
| 167 | procedure TfrmAlertForward.cboSrcListChange(Sender: TObject);
|
---|
| 168 | begin
|
---|
| 169 | inherited;
|
---|
| 170 | btnAddAlert.Enabled := CboSrcList.ItemIndex > -1;
|
---|
| 171 | end;
|
---|
| 172 |
|
---|
| 173 | procedure TfrmAlertForward.cboSrcListKeyDown(Sender: TObject; var Key: Word;
|
---|
| 174 | Shift: TShiftState);
|
---|
| 175 | begin
|
---|
| 176 | if Key = VK_RETURN then
|
---|
| 177 | begin
|
---|
| 178 | cboSrcListMouseClick(Self);
|
---|
| 179 | end;
|
---|
| 180 | end;
|
---|
| 181 |
|
---|
| 182 | procedure TfrmAlertForward.cboSrcListMouseClick(Sender: TObject);
|
---|
| 183 | begin
|
---|
| 184 | if cboSrcList.ItemIndex = -1 then exit;
|
---|
| 185 | if (DstList.SelectByID(cboSrcList.ItemID) <> -1) then
|
---|
| 186 | begin
|
---|
| 187 | InfoBox(TX_DUP_RECIP, TX_RECIP_CAP, MB_OK or MB_ICONWARNING);
|
---|
| 188 | Exit;
|
---|
| 189 | end;
|
---|
| 190 | DstList.Items.Add(cboSrcList.Items[cboSrcList.Itemindex]);
|
---|
| 191 | if ScreenReaderSystemActive then
|
---|
| 192 | GetScreenReader.Speak(Piece(cboSrcList.Items[cboSrcList.Itemindex],U,2) +
|
---|
| 193 | ' Added to ' + DstLabel.Caption);
|
---|
| 194 | btnRemoveAlertFwrd.Enabled := DstList.SelCount > 0;
|
---|
| 195 | btnRemoveAllAlertFwrd.Enabled := DstList.Items.Count > 0;
|
---|
| 196 | end;
|
---|
| 197 |
|
---|
| 198 | end.
|
---|