RealICQUserCard.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. unit RealICQUserCard;
  2. interface
  3. uses
  4. SysUtils, Classes, Controls, ExtCtrls, StdCtrls, Graphics, Forms,ShellAPI, Windows,
  5. RealICQUIColor, RealICQColors, RealICQRoundBorderPanel, RealICQModel;
  6. type
  7. TRealICQUserCard = class(TRealICQRoundBorderPanel)
  8. private
  9. FEdPos,
  10. FEdTrueName,
  11. FEdBranch,
  12. FEdDuty,
  13. FEdTel,
  14. FEdMobile,
  15. FEdShortMobile,
  16. FEdEmail: TEdit;
  17. FLblBranch,
  18. FLblDuty,
  19. FLblTel,
  20. FLblMobile,
  21. FLblShortMobile,
  22. FLblEmail: TLabel;
  23. FIsSecret: Boolean;
  24. FProductType: TRealICQProductType;
  25. FUserType: TRealICQUserType;
  26. FRealICQUser: TRealICQUser;
  27. procedure SetControl(LB: TLabel; ED: TEdit; Value: String);
  28. procedure SetCaption;
  29. procedure Caption_Default;
  30. procedure Caption_NXSQ;
  31. procedure Caption_LBZQ;
  32. procedure SetContent;
  33. procedure Content_Default;
  34. procedure Content_NXSQ;
  35. procedure Content_LBZQ;
  36. procedure SetRealICQUser(Value: TRealICQUser);
  37. function GetCopyRight: String;
  38. public
  39. constructor Create(AOwner: TComponent); override;
  40. destructor Destroy; override;
  41. procedure ChangeUIColor(AColor: TColor);
  42. property ProductType: TRealICQProductType read FProductType write FProductType;
  43. property IsSecret: Boolean read FIsSecret write FIsSecret;
  44. property RealICQUser: TRealICQUser read FRealICQUser write SetRealICQUser;
  45. published
  46. property CopyRight: String read GetCopyRight;
  47. property Font;
  48. property Align;
  49. property Anchors;
  50. end;
  51. procedure Register;
  52. implementation
  53. var
  54. IsInit: Boolean;
  55. VS, HS: Integer;
  56. function TRealICQUserCard.GetCopyRight: String;
  57. begin
  58. Result := '版权所有(C) 2002-2016 浙江万赛软件科技有限公司 保留所有权利。';
  59. end;
  60. constructor TRealICQUserCard.Create(AOwner: TComponent);
  61. var
  62. i: Integer;
  63. begin
  64. inherited Create(AOwner);
  65. DoubleBuffered := True;
  66. BevelInner := bvNone;
  67. BevelOuter := bvNone;
  68. ParentColor := True;
  69. //放置光标
  70. FEdPos := TEdit.Create(Self);
  71. FEdPos.BorderStyle := bsNone;
  72. FEdPos.Font := Font;
  73. FEdPos.Font.Size := 9;
  74. FEdPos.Left := -9;
  75. FEdPos.Top := -9;
  76. FEdPos.Width := 9;
  77. FEdPos.Height := 9;
  78. Width := 96;
  79. VS := 5;
  80. HS := 3;
  81. FEdTrueName := TEdit.Create(Self);
  82. FEdTrueName.BorderStyle := bsNone;
  83. FEdTrueName.Font := Font;
  84. FEdTrueName.Font.Color := clBlack;
  85. FEdTrueName.Font.Size := 9;
  86. FEdTrueName.Font.Style := [fsBold];
  87. FEdTrueName.Anchors := [akLeft, akTop, akRight];
  88. FEdTrueName.AutoSize:= True;
  89. FEdTrueName.ReadOnly := True;
  90. FEdTrueName.ShowHint := True;
  91. FEdTrueName.ParentColor := True;
  92. FEdTrueName.Color := BackColor;
  93. FEdTrueName.Left := VS;
  94. FEdTrueName.Top := HS;
  95. FEdTrueName.Width := Width - 10;
  96. HS := FEdTrueName.Height + 3;
  97. FLblBranch := TLabel.Create(Self);
  98. FEdBranch := TEdit.Create(Self);
  99. FLblDuty := TLabel.Create(Self);
  100. FEdDuty := TEdit.Create(Self);
  101. FLblTel := TLabel.Create(Self);
  102. FEdTel := TEdit.Create(Self);
  103. FLblMobile := TLabel.Create(Self);
  104. FEdMobile := TEdit.Create(Self);
  105. FLblShortMobile := TLabel.Create(Self);
  106. FEdShortMobile := TEdit.Create(Self);
  107. FLblEmail := TLabel.Create(Self);
  108. FEdEmail := TEdit.Create(Self);
  109. for i := 0 to Self.Componentcount - 1 do
  110. begin
  111. if (Self.Components[i] is TEdit) then
  112. begin
  113. (Self.Components[i] as TEdit).Parent := Self;
  114. end;
  115. if (Self.Components[i] is TLabel) then
  116. begin
  117. (Self.Components[i] as TLabel).Parent := Self;
  118. end;
  119. end;
  120. IsInit := True;
  121. FProductType := ptBGZS;
  122. FUserType := utUnknown;
  123. SetCaption;
  124. Height := HS + 3;
  125. IsInit := False;
  126. end;
  127. procedure TRealICQUserCard.SetControl(LB: TLabel; ED: TEdit; Value: String);
  128. begin
  129. if IsInit then
  130. begin
  131. LB.AutoSize := True;
  132. LB.Transparent := True;
  133. LB.Font := Font;
  134. LB.Font.Color := clGray;
  135. LB.Font.Size := 9;
  136. LB.Anchors := [akLeft, akTop];
  137. LB.Caption := Value;
  138. LB.Color := BackColor;
  139. LB.Left := VS;
  140. LB.Top := HS;
  141. ED.BorderStyle := bsNone;
  142. ED.Font := Font;
  143. ED.Font.Color := clBlack;
  144. ED.Font.Size := 9;
  145. ED.Anchors := [akLeft, akTop, akRight];
  146. ED.ParentColor := True;
  147. ED.Color := BackColor;
  148. ED.ReadOnly := True;
  149. ED.Left := LB.Left + LB.Width + 3;
  150. ED.Top := LB.Top;
  151. ED.Width := Width - LB.Width - 10;
  152. HS := HS + LB.Height + 6;
  153. end
  154. else
  155. begin
  156. LB.Caption := Value;
  157. ED.Left := LB.Left + LB.Width + 3;
  158. ED.Width := Width - LB.Width - 10;
  159. end;
  160. end;
  161. procedure TRealICQUserCard.SetCaption;
  162. begin
  163. case FProductType of
  164. ptBGZS:
  165. Caption_Default;
  166. ptNXSQ:
  167. if (FUserType = utUnknown) OR (FUserType = utCompany) then
  168. Caption_NXSQ
  169. else
  170. Caption_Default;
  171. ptLBZQ:
  172. if (FUserType = utUnknown) OR (FUserType = utCompany) then
  173. Caption_LBZQ
  174. else
  175. Caption_Default;
  176. end;
  177. end;
  178. procedure TRealICQUserCard.Caption_Default;
  179. begin
  180. SetControl(FLblBranch, FEdBranch, '处室:');
  181. SetControl(FLblDuty, FEdDuty, '职务:');
  182. SetControl(FLblTel, FEdTel, '电话:');
  183. SetControl(FLblMobile, FEdMobile, '手机:');
  184. SetControl(FLblShortMobile, FEdShortMobile, '短号:');
  185. SetControl(FLblEmail, FEdEmail, '邮箱:');
  186. end;
  187. procedure TRealICQUserCard.Caption_NXSQ;
  188. begin
  189. SetControl(FLblBranch, FEdBranch, '所属行业:'); //Industry
  190. SetControl(FLblDuty, FEdDuty, '主管机关:'); //TaxOffices
  191. SetControl(FLblTel, FEdTel, '涉税电话:'); //TaxAgent
  192. SetControl(FLblMobile, FEdMobile, '办公电话:'); //OfficePhone
  193. SetControl(FLblShortMobile, FEdShortMobile, '财务电话:'); //FinancialPhone
  194. SetControl(FLblEmail, FEdEmail, '法人电话:'); //LegalPersonPhone
  195. end;
  196. procedure TRealICQUserCard.Caption_LBZQ;
  197. begin
  198. SetControl(FLblBranch, FEdBranch, '所属行业:'); //Industry
  199. SetControl(FLblDuty, FEdDuty, '主管机构:'); //TaxOffices
  200. SetControl(FLblTel, FEdTel, '联 系 人 :'); //TaxAgent
  201. SetControl(FLblMobile, FEdMobile, '办公电话:'); //OfficePhone
  202. SetControl(FLblShortMobile, FEdShortMobile, '财务电话:'); //FinancialPhone
  203. SetControl(FLblEmail, FEdEmail, '法人电话:'); //LegalPersonPhone
  204. end;
  205. procedure TRealICQUserCard.SetContent;
  206. begin
  207. case FProductType of
  208. ptBGZS:
  209. Content_Default;
  210. ptNXSQ:
  211. if (FUserType = utUnknown) OR (FUserType = utCompany) then
  212. Content_NXSQ
  213. else
  214. Content_Default;
  215. ptLBZQ:
  216. if (FUserType = utUnknown) OR (FUserType = utCompany) then
  217. Content_LBZQ
  218. else
  219. Content_Default;
  220. end;
  221. end;
  222. procedure TRealICQUserCard.Content_Default;
  223. begin
  224. FEdBranch.ShowHint := False;
  225. FEdDuty.ShowHint := False;
  226. FEdEmail.ShowHint := True;
  227. if Trim(FRealICQUser.TrueName) = '' then
  228. FEdTrueName.Text := FRealICQUser.DisplayName
  229. else
  230. FEdTrueName.Text := FRealICQUser.TrueName;
  231. FEdTrueName.ShowHint := True;
  232. FEdTrueName.Hint := FEdTrueName.Text;
  233. FEdBranch.Text := FRealICQUser.Branch;
  234. FEdDuty.Text := FRealICQUser.Duty;
  235. if FIsSecret then
  236. begin
  237. FEdTel.Text := FRealICQUser.Tel;
  238. FEdMobile.Text := FRealICQUser.Mobile;
  239. FEdShortMobile.Text := FRealICQUser.ShortMobile;
  240. FEdEmail.Text := FRealICQUser.Email;
  241. FEdEmail.Hint := FEdEmail.Text;
  242. end
  243. else
  244. begin
  245. FEdEmail.ShowHint := False;
  246. if Trim(FEdTel.Text) <> '' then FEdTel.Text :='******';
  247. if Trim(FEdMobile.Text) <> '' then FEdMobile.Text := '******';
  248. if Trim(FEdShortMobile.Text) <> '' then FEdShortMobile.Text := '******';
  249. if Trim(FEdEmail.Text) <> '' then FEdEmail.Text := '******';
  250. end;
  251. end;
  252. procedure TRealICQUserCard.Content_NXSQ;
  253. begin
  254. FEdBranch.ShowHint := True;
  255. FEdDuty.ShowHint := True;
  256. FEdEmail.ShowHint := False;
  257. if Trim(FRealICQUser.Enterprise) = '' then
  258. FEdTrueName.Text := FRealICQUser.DisplayName
  259. else
  260. FEdTrueName.Text := FRealICQUser.Enterprise;
  261. FEdTrueName.ShowHint := True;
  262. FEdTrueName.Hint := FEdTrueName.Text;
  263. FEdBranch.Text := FRealICQUser.Industry;
  264. FEdBranch.Hint := FEdBranch.Text;
  265. FEdDuty.Text := FRealICQUser.TaxOffices;
  266. FEdDuty.Hint := FEdDuty.Text;
  267. if FIsSecret then
  268. begin
  269. FEdTel.Text := FRealICQUser.TaxAgent;
  270. FEdMobile.Text := FRealICQUser.OfficePhone;
  271. FEdShortMobile.Text := FRealICQUser.FinancialPhone;
  272. FEdEmail.Text := FRealICQUser.LegalPersonPhone;
  273. end
  274. else
  275. begin
  276. if Trim(FEdTel.Text) <> '' then FEdTel.Text := '******';
  277. if Trim(FEdMobile.Text) <> '' then FEdMobile.Text := '******';
  278. if Trim(FEdShortMobile.Text) <> '' then FEdShortMobile.Text := '******';
  279. if Trim(FEdEmail.Text) <> '' then FEdEmail.Text := '******';
  280. end;
  281. end;
  282. procedure TRealICQUserCard.Content_LBZQ;
  283. begin
  284. FEdBranch.ShowHint := True;
  285. FEdDuty.ShowHint := True;
  286. FEdEmail.ShowHint := False;
  287. if Trim(FRealICQUser.Enterprise) = '' then
  288. FEdTrueName.Text := FRealICQUser.DisplayName
  289. else
  290. FEdTrueName.Text := FRealICQUser.Enterprise;
  291. FEdTrueName.Hint := FEdTrueName.Text;
  292. FEdBranch.Text := FRealICQUser.Industry;
  293. FEdBranch.Hint := FEdBranch.Text;
  294. FEdDuty.Text := FRealICQUser.TaxOffices;
  295. FEdDuty.Hint := FEdDuty.Text;
  296. if FIsSecret then
  297. begin
  298. FEdTel.Text := FRealICQUser.TaxAgent;
  299. FEdMobile.Text := FRealICQUser.OfficePhone;
  300. FEdShortMobile.Text := FRealICQUser.FinancialPhone;
  301. FEdEmail.Text := FRealICQUser.LegalPersonPhone;
  302. end
  303. else
  304. begin
  305. if Trim(FEdTel.Text) <> '' then FEdTel.Text := '******';
  306. if Trim(FEdMobile.Text) <> '' then FEdMobile.Text := '******';
  307. if Trim(FEdShortMobile.Text) <> '' then FEdShortMobile.Text := '******';
  308. if Trim(FEdEmail.Text) <> '' then FEdEmail.Text := '******';
  309. end;
  310. end;
  311. procedure TRealICQUserCard.SetRealICQUser(Value: TRealICQUser);
  312. begin
  313. FRealICQUser := Value;
  314. if Assigned(FRealICQUser) then
  315. begin
  316. if FUserType <> FRealICQUser.UserType then
  317. begin
  318. FUserType := FRealICQUser.UserType;
  319. SetCaption;
  320. end;
  321. SetContent;
  322. end;
  323. end;
  324. procedure TRealICQUserCard.ChangeUIColor(AColor: TColor);
  325. var
  326. i: Integer;
  327. begin
  328. inherited ChangeUIColor(AColor);
  329. BackColor := AColor;
  330. BorderColor := AColor;
  331. for i := 0 to Self.Componentcount - 1 do
  332. begin
  333. if Self.Components[i] is TEdit then
  334. begin
  335. (Self.Components[i] as TEdit).Color := AColor;
  336. end;
  337. end;
  338. end;
  339. destructor TRealICQUserCard.Destroy;
  340. begin
  341. try
  342. FreeAndNil(FEdTrueName);
  343. FreeAndNil(FEdBranch);
  344. FreeAndNil(FEdDuty);
  345. FreeAndNil(FEdTel);
  346. FreeAndNil(FEdMobile);
  347. FreeAndNil(FEdShortMobile);
  348. FreeAndNil(FEdEmail);
  349. FreeAndNil(FLblBranch);
  350. FreeAndNil(FLblDuty);
  351. FreeAndNil(FLblTel);
  352. FreeAndNil(FLblMobile);
  353. FreeAndNil(FLblShortMobile);
  354. FreeAndNil(FLblEmail);
  355. except
  356. end;
  357. inherited Destroy;
  358. end;
  359. procedure Register;
  360. begin
  361. RegisterComponents('RealICQ UI', [TRealICQUserCard]);
  362. end;
  363. end.