unit SendContact;

interface

uses
  Dockable,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, fRosterTree, ExtCtrls, ComCtrls, RichEdit2, ExRichEdit;

type
  TfrmSendContact = class(TfrmDockable)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Panel5: TPanel;
    Panel6: TPanel;
    frameTreeRosterSelect: TframeTreeRoster;
    frameTreeRosterSend: TframeTreeRoster;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    txtMsg: TExRichEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function GetSelectList: TList;
    function GetSendList: TList;
    procedure CheckSelect(List: TList);
    procedure CheckSelectAll;
    procedure CheckSend(List: TList);
  end;

var
  frmSendContact: TfrmSendContact;

implementation

{$R *.dfm}
uses
  GnuGetText, RiserWindow, Jabber1;

procedure TfrmSendContact.FormCreate(Sender: TObject);
begin
  TranslateProperties(Self);
  frameTreeRosterSelect.Initialize();
  frameTreeRosterSelect.DrawRoster(False);
  frameTreeRosterSend.Initialize();
  frameTreeRosterSend.DrawRoster(False);
end;

function TfrmSendContact.GetSelectList: TList;
begin
  Result := frameTreeRosterSelect.GetCheckedList;
end;

function TfrmSendContact.GetSendList: TList;
begin
  Result := frameTreeRosterSend.GetCheckedList;
end;

procedure TfrmSendContact.Button1Click(Sender: TObject);
begin
  with GetSelectList do
  try
    if Count <= 0 then
    begin
      ShowRiserWindow(nil, '请选择要发送的联系人名单', ico_info);
      abort;
      //raise Exception.Create('请选择要发送的联系人名单');
    end;
  finally
    Free;
  end;

  with GetSendList do
  try
    if Count <= 0 then
    begin
      ShowRiserWindow(nil, '请选择要把联系人名单发给谁', ico_info);
      abort;
      //raise Exception.Create('请选择要把联系人名单发给谁');
    end;
  finally
    Free;
  end;

  ModalResult := mrok;
end;

procedure TfrmSendContact.CheckSelect(List: TList);
begin
  frameTreeRosterSelect.Check(List);
end;

procedure TfrmSendContact.CheckSend(List: TList);
begin
  frameTreeRosterSend.Check(List);
end;

procedure TfrmSendContact.CheckSelectAll;
begin
  frameTreeRosterSelect.CheckAll;
end;

end.
