双轨制二叉树节点对象

// 双轨制二叉树节点对象
unit unitOBJPosNodeClass;
interface
uses
  Windows, Graphics, ExtCtrls, SysUtils;
type
  TPosNode = class (TObject)
  private
    FPosition: TPoint;             //位置
    FLayer: Integer;               //层号,本节点所在的层,设计用于绘图
    FBH: String;                   //会员编号
    FXM: String;                   //姓名
    FZW: String;                   //职务
    FHYJB: String;                 //会员级别
    FJHRQ: TDateTime;              //激活日期
    FColor : TColor;               //会员颜色
    FInTopArea: String;            //相对于顶点,本节点所在的区,设计用于绘图
    FAPoint: Integer;              //A区点
    FBPoint: Integer;              //B区点
    FATotal: Integer;              //A总
    FBTotal: Integer;              //B总
    FARemainder: Integer;          //A余
    FBRemainder: Integer;          //B余
    FYHYJB: String;                //会员原级别
    FSJSM: String;                 //会员升级说明
    FSJRQ: TDateTime;              //升级日期
    FYColor : TColor;
    FTopArea: String;              //原会员颜色
    FHeight: Integer;              //节点图高度
    FWidth: Integer;               //节点图宽度
    procedure SetFLayer(Value: Integer);
    procedure SetFPosition(Value: TPoint);
    procedure SetFBH(Value: String);
    procedure SetFXM(Value: String);
    procedure SetFZW(Value: String);
    procedure SetFHYJB(Value: String);
    procedure SetFJHRQ(Value: TDateTime);
    procedure SetFInTopArea(Value: String);
    procedure SetFAPoint(Value: Integer);
    procedure SetFBPoint(Value: Integer);
    procedure SetFATotal(Value: Integer);
    procedure SetFBTotal(Value: Integer);
    procedure SetFARemainder(Value: Integer);
    procedure SetFBRemainder(Value: Integer);
    procedure SetFYHYJB(Value: String);
    procedure SetFSJSM(Value: String);
    procedure SetFSJRQ(Value: TDateTime);
  public
    Name: string;
    Father: TObject;
    constructor create; overload;

    function DrawSelf(img: TImage):Boolean;
    function DrawLinkLine(img: TImage):Boolean;

    property Layer: Integer read FLayer write SetFLayer default 0;
    property Position: TPoint read FPosition write SetFPosition;
    property BH: String read FBH write SetFBH;
    property XM: String read FXM write SetFXM;
    property ZW: String read FZW write SetFZW;
    property HYJB: String read FHYJB write SetFHYJB;
    property JHRQ: TDateTime read FJHRQ write SetFJHRQ;
    property InTopArea: String read FTopArea write SetFInTopArea;
    property APoint: Integer read FAPoint write SetFAPoint default 0;
    property BPoint: Integer read FBPoint write SetFBPoint default 0;
    property ATotal: Integer read FATotal write SetFATotal default 0;
    property BTotal: Integer read FBTotal write SetFBTotal default 0;
    property ARemainder: Integer read FARemainder write SetFARemainder default 0;
    property BRemainder: Integer read FBRemainder write SetFBRemainder default 0;
    property YHYJB: String read FYHYJB write SetFYHYJB;
    property SJSM: String read FSJSM write SetFSJSM;
    property SJRQ: TDateTime read FSJRQ write SetFSJRQ;
    property Width: Integer read FWidth;
    property Height: Integer read FHeight;
  end;
const
  clMColor = TColor($00ECFFFF);    //主色
  clAColor = TColor($0071C8F2);    //钻卡颜色
  clBColor = TColor($009E77FB);    //金卡颜色
  clCColor = TColor($00FFC6C6);    //银卡颜色
  wgHeight = 16;                   //网格高度
  wgWidth  = 36;                   //网格宽度
implementation

{
********************************** TPosNode **********************************
}
constructor TPosNode.create;
begin
  DateSeparator := '-';
  ShortDateFormat := 'yyyy-MM-dd';
  LongDateFormat := 'yyyy-MM-dd hh:mm:ss';

  Name:='PosNode1';
  FHeight := 112;
  FWidth  := 108;
  FBH := 'CN88888888';
  FXM := '总公司';
  FZW := '';
  FHYJB := '';
  FSJSM := '';
  FJHRQ := DATE();
  FColor := clAColor;
  FYHYJB := '';
  FYColor := clCColor;
  FSJRQ := strtodate('2016-05-16');

end;

function TPosNode.DrawSelf(img: TImage): Boolean;
var
  c:TCanvas;
  p1,p2:TPoint;
  uHeight,uWidth,uI,uX,uY: integer;
  uStr:String;
  dtf:TFormatSettings;
begin
//  c := TCanvas.Create;
//  c.Handle := GetDC(pnl.Handle);
  dtf.ShortDateFormat :='yyyy-MM-dd';
  c := img.Canvas;
  c.FillRect(c.ClipRect);
  c.Font.Name :='宋体';
  c.Font.Size :=9;
  uHeight:=c.TextHeight('W');

  //第1,2行
  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 0;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 2*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := FColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出FBH
  uWidth := c.TextWidth(FBH);
  uX := FPosition.X + round((3*wgWidth-uWidth)/2);
  uY := FPosition.Y + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,FBH);

  //输出FZW+' '+FXM
  uWidth:=c.TextWidth(FZW+' '+FXM);
  uX := FPosition.X + round((3*wgWidth-uWidth)/2);
  uY := FPosition.Y + 1*wgHeight + 2;
  c.Brush.Style :=bsClear;     //文本不带背景输出
  c.Font.Color :=clBlack;
  c.TextOut(uX,uY,FZW+' '+FXM);

  //第3行
  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 2*wgHeight;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 3*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出FHYJB
  uWidth:=c.TextWidth(FHYJB+FSJSM);
  uX := FPosition.X + round((3*wgWidth-uWidth)/2);
  uY := FPosition.Y + 2*wgHeight + 2;
  c.Brush.Style :=bsClear;     //文本不带背景输出
  c.Font.Color :=clBlack;
  c.TextOut(uX,uY,FHYJB+FSJSM);

  //左边三行
  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 3*wgHeight;
  p2.X := FPosition.X + 1*wgWidth;
  p2.Y := FPosition.Y + 4*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 4*wgHeight;
  p2.X := FPosition.X + 1*wgWidth;
  p2.Y := FPosition.Y + 5*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 5*wgHeight;
  p2.X := FPosition.X + 1*wgWidth;
  p2.Y := FPosition.Y + 6*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出FAPoint
  uStr:=inttostr(FAPoint);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 3*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出FATotal
  uStr:=inttostr(FATotal);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 4*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出FARemainder
  uStr:=inttostr(FARemainder);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 5*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //中间三行
  p1.X := FPosition.X + 1*wgWidth;
  p1.Y := FPosition.Y + 3*wgHeight;
  p2.X := FPosition.X + 2*wgWidth;
  p2.Y := FPosition.Y + 4*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 1*wgWidth;
  p1.Y := FPosition.Y + 4*wgHeight;
  p2.X := FPosition.X + 2*wgWidth;
  p2.Y := FPosition.Y + 5*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 1*wgWidth;
  p1.Y := FPosition.Y + 5*wgHeight;
  p2.X := FPosition.X + 2*wgWidth;
  p2.Y := FPosition.Y + 6*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出'点'
  uStr:='点';
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 3*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出'总'
  uStr:='总';
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 4*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出'余'
  uStr:='余';
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 5*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //右边三行
  p1.X := FPosition.X + 2*wgWidth;
  p1.Y := FPosition.Y + 3*wgHeight;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 4*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 2*wgWidth;
  p1.Y := FPosition.Y + 4*wgHeight;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 5*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  p1.X := FPosition.X + 2*wgWidth;
  p1.Y := FPosition.Y + 5*wgHeight;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 6*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := clMColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出FBPoint
  uStr:=inttostr(FBPoint);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 3*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出FBTotal
  uStr:=inttostr(FBTotal);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 4*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //输出FBRemainder
  uStr:=inttostr(FBRemainder);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);
  uY := FPosition.Y + 5*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

  //第7行
  p1.X := FPosition.X + 0;
  p1.Y := FPosition.Y + 6*wgHeight;
  p2.X := FPosition.X + 3*wgWidth;
  p2.Y := FPosition.Y + 7*wgHeight;
  c.Pen.Color := FColor;
  c.Brush.Color := FYColor;
  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);

  //输出FJHRQ
  uStr:=DateToStr(FJHRQ,dtf);
  uWidth:=c.TextWidth(uStr);
  uX := FPosition.X + round((3*wgWidth-uWidth)/2);
  uY := FPosition.Y + 6*wgHeight + 2;
  c.Brush.Style := bsClear;     //文本不带背景输出
  c.Font.Color := clBlack;
  c.TextOut(uX,uY,uStr);

//  DrawLinkLine(img);

  Result := true;
end;

function TPosNode.DrawLinkLine(img: TImage):Boolean;
var
  c:TCanvas;
begin
  if Assigned(Father) then
  begin
    c := img.Canvas;
    c.Pen.Color := clBlack;
    c.MoveTo(FPosition.X+54,FPosition.Y);
    c.LineTo(TPosNode(Father).FPosition.X+54,TPosNode(Father).FPosition.Y+112);
  end;
  Result := true;
end;

procedure TPosNode.SetFLayer(Value: Integer);
begin
  FLayer := Value;
end;

procedure TPosNode.SetFPosition(Value: TPoint);
begin
  FPosition := Value;
end;

procedure TPosNode.SetFBH(Value: String);
begin
  FBH := Value;
end;

procedure TPosNode.SetFXM(Value: String);
begin
  FXM := Value;
end;

procedure TPosNode.SetFZW(Value: String);
begin
  FZW := Value;
end;

procedure TPosNode.SetFHYJB(Value: String);
begin
  FHYJB := Value;
  if (FHYJB='钻卡') then
    FColor := clAColor
  else if (FHYJB='金卡') then
    FColor := clBColor
  else
    FColor := clCColor;
end;

procedure TPosNode.SetFJHRQ(Value: TDateTime);
begin
  FJHRQ := Value;
end;

procedure TPosNode.SetFInTopArea(Value: String);
begin
  FInTopArea := Value;
end;

procedure TPosNode.SetFAPoint(Value: Integer);
begin
  FAPoint := Value;
end;

procedure TPosNode.SetFBPoint(Value: Integer);
begin
  FBPoint := Value;
end;

procedure TPosNode.SetFATotal(Value: Integer);
begin
  FATotal := Value;
end;

procedure TPosNode.SetFBTotal(Value: Integer);
begin
  FBTotal := Value;
end;

procedure TPosNode.SetFARemainder(Value: Integer);
begin
  FARemainder := Value;
end;

procedure TPosNode.SetFBRemainder(Value: Integer);
begin
  FBRemainder := Value;
end;

procedure TPosNode.SetFSJSM(Value: String);
begin
  FSJSM := Value;
end;

procedure TPosNode.SetFSJRQ(Value: TDateTime);
begin
  FSJRQ := Value;
end;

procedure TPosNode.SetFYHYJB(Value: String);
begin
  FYHYJB := Value;
  if (FYHYJB='钻卡') then
    FYColor := clAColor
  else if (FYHYJB='金卡') then
    FYColor := clBColor
  else if (FYHYJB='银卡') then
    FYColor := clCColor
  else
    FYColor := FColor;
end;

end.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彖爻之辞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值