⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bscolorctrls.pas

📁 实现网络流量的生成,为cs结构,可以控制流量大小
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        begin
          ColorValue := ColorValues[k];
          Break;
        end;
      Inc(X1, CW + 2);
    end;
    Inc(Y1, CH + 2);
  end;  
end;


constructor TbsColorViewer.Create(AOwner: TComponent);
begin
  inherited;
  ControlStyle := ControlStyle + [csOpaque];
  FColorValue := 0;
end;

procedure TbsColorViewer.Paint;
var
  B: TBitMap;
begin
  B := TBitMap.Create;
  B.Width := Width;
  B.Height := Height;
  with B.Canvas do
  begin
    Pen.Color := clBlack;
    Brush.Color := FColorValue;
    Rectangle(0, 0, Width, Height);
  end;
  Canvas.Draw(0, 0, B);
  B.Free;
end;

procedure TbsColorViewer.SetColorValue;
begin
  if FColorValue = Value then Exit;
  FColorValue := Value;
  RePaint;
end;

constructor TbsSkinColorDialog.Create;
begin
  inherited Create(AOwner);

  RGBStopCheck := False;
  HSLStopCheck := False;

  FColor := 0;

  FAlphaBlend := False;
  FAlphaBlendAnimation := False;
  FAlphaBlendValue := 200;

  FCaption := 'Set color';

  FButtonSkinDataName := 'button';
  FLabelSkinDataName := 'stdlabel';
  FEditSkinDataName := 'edit';

  FDefaultLabelFont := TFont.Create;
  FDefaultButtonFont := TFont.Create;
  FDefaultEditFont := TFont.Create;

  FUseSkinFont := True;

  with FDefaultLabelFont do
  begin
    Name := '宋体';
    Style := [];
    Height := 12;
  end;

  with FDefaultButtonFont do
  begin
    Name := '宋体';
    Style := [];
    Height := 12;
  end;

  with FDefaultEditFont do
  begin
    Name := '宋体';
    Style := [];
    Height := 12;
  end;
end;

destructor TbsSkinColorDialog.Destroy;
begin
  FDefaultLabelFont.Free;
  FDefaultButtonFont.Free;
  FDefaultEditFont.Free;
  inherited;
end;

procedure TbsSkinColorDialog.HSLEditChange(Sender: TObject);
var
  R, G, B: Byte;
begin
  if HSLStopCheck then Exit;
  HSLTORGB(R, G, B, HEdit.Value, SEdit.Value, LEdit.Value);
  ColorViewer.ColorValue := R_G_BToColor(R, G, B);
  RGBStopCheck := True;
  REdit.Value := R;
  GEdit.Value := G;
  BEdit.Value := B;
  RGBStopCheck := False;
end;

procedure TbsSkinColorDialog.RGBEditChange(Sender: TObject);
var
  R, G, B: Byte;
  H, S, L: Integer;
begin
  if RGBStopCheck then Exit;
  ColorViewer.ColorValue := R_G_BToColor(REdit.Value, GEdit.Value, BEdit.Value);
  ColorToR_G_B(ColorViewer.ColorValue, R, G, B);
  HSLStopCheck := True;
  RGBToHSL(R, G, B, H, S, L);
  HEdit.Value := H;
  SEdit.Value := S;
  LEdit.Value := L;
  HSLStopCheck := False;
end;

procedure TbsSkinColorDialog.ColorGridChange(Sender: TObject);
var
  R, G, B: Byte;
  H, S, L: Integer;
begin
  ColorToR_G_B(ColorGrid.ColorValue, R, G, B);
  RGBStopCheck := True;
  REdit.Value := R;
  GEdit.Value := G;
  BEdit.Value := B;
  RGBStopCheck := False;
  ColorViewer.ColorValue := ColorGrid.ColorValue;
  RGBToHSL(R, G, B, H, S, L);
  HSLStopCheck := True;
  HEdit.Value := H;
  SEdit.Value := S;
  LEdit.Value := L;
  HSLStopCheck := False;
end;

procedure TbsSkinColorDialog.SetDefaultLabelFont;
begin
  FDefaultLabelFont.Assign(Value);
end;

procedure TbsSkinColorDialog.SetDefaultEditFont;
begin
  FDefaultEditFont.Assign(Value);
end;

procedure TbsSkinColorDialog.SetDefaultButtonFont;
begin
  FDefaultButtonFont.Assign(Value);
end;

procedure TbsSkinColorDialog.Notification;
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
  if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
end;

function TbsSkinColorDialog.Execute: Boolean;
var
  Form: TForm;
  BSF: TbsBusinessSkinForm;
  ButtonTop, ButtonWidth, ButtonHeight: Integer;
  R, G, B: Byte;
begin
  Form := TForm.Create(Application);
  Form.BorderStyle := bsDialog;
  Form.Caption := FCaption;
  Form.Position := poScreenCenter;

  BSF := TbsBusinessSkinForm.Create(Form);
  BSF.BorderIcons := [];
  BSF.SkinData := SkinData;
  BSF.MenusSkinData := CtrlSkinData;
  BSF.AlphaBlend := AlphaBlend;
  BSF.AlphaBlendAnimation := AlphaBlendAnimation;
  BSF.AlphaBlendValue := AlphaBlendValue;

  try

    with Form do
    begin
      ClientWidth := 280;
    end;

   ColorGrid := TbsSkinColorGrid.Create(Form);
   with ColorGrid do
   begin
     Parent := Form;
     Align := alTop;
     Height := 105;
     SkinDataName := 'groupbox';
     SkinData := CtrlSkinData;
     OnChange := ColorGridChange;
   end;

  RLabel := TbsSkinStdLabel.Create(Form);
  with RLabel do
  begin
    Parent := Form;
    Left := 5;
    Top := ColorGrid.Top + ColorGrid.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'R:';
  end;

   REdit := TbsSkinTrackEdit.Create(Self);
   with REdit do
   begin
     Parent := Form;
     SetBounds(RLabel.Left + RLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
     TrackBarWidth := 260;
     MinValue := 0;
     MaxValue := 255;
     Value := 0;
     SkinData := CtrlSkinData;
     JumpWhenClick := True;
     OnChange := RGBEditChange;
   end;

  GLabel := TbsSkinStdLabel.Create(Form);
  with GLabel do
  begin
    Parent := Form;
    Left := REdit.Left + REdit.Width + 5;
    Top := ColorGrid.Top + ColorGrid.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'G:';
  end;

   GEdit := TbsSkinTrackEdit.Create(Self);
   with GEdit do
   begin
     Parent := Form;
     SetBounds(GLabel.Left + GLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
     TrackBarWidth := 260;
     MinValue := 0;
     MaxValue := 255;
     Value := 0;
     SkinData := CtrlSkinData;
     JumpWhenClick := True;
     OnChange := RGBEditChange;
   end;

  BLabel := TbsSkinStdLabel.Create(Form);
  with BLabel do
  begin
    Parent := Form;
    Left := GEdit.Left + GEdit.Width + 5;
    Top := ColorGrid.Top + ColorGrid.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'B:';
  end;

   BEdit := TbsSkinTrackEdit.Create(Self);
   with BEdit do
   begin
     Parent := Form;
     SetBounds(BLabel.Left + BLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
     TrackBarWidth := 260;
     MinValue := 0;
     MaxValue := 255;
     Value := 0;
     SkinData := CtrlSkinData;
     JumpWhenClick := True;
     OnChange := RGBEditChange;
   end;

  EqLabel := TbsSkinStdLabel.Create(Form);
  with EqLabel do
  begin
    Parent := Form;
    Left := BEdit.Left + BEdit.Width + 5;;
    Top := ColorGrid.Top + ColorGrid.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := '=';
  end;

  ColorViewer := TbsColorViewer.Create(Form);
  with ColorViewer do
  begin
    Parent := Form;
    SetBounds(EqLabel.Left + EqLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10,
     BEdit.Width, BEdit.Height);
  end;

  HLabel := TbsSkinStdLabel.Create(Form);
  with HLabel do
  begin
    Parent := Form;
    Left := 5;
    Top := ColorViewer.Top + ColorViewer.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'H:';
  end;

  HEdit := TbsSkinTrackEdit.Create(Self);
  with HEdit do
  begin
    Parent := Form;
    SetBounds(HLabel.Left + HLabel.Width + 5, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
    TrackBarWidth := 260;
    MinValue := 0;
    MaxValue := 359;
    Value := 0;
    SkinData := CtrlSkinData;
    JumpWhenClick := True;
    OnChange := HSLEditChange;
  end;

  SLabel := TbsSkinStdLabel.Create(Form);
  with SLabel do
  begin
    Parent := Form;
    Left := HEdit.Left + HEdit.Width + 5;
    Top := ColorViewer.Top + ColorViewer.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'S:';
  end;

  SEdit := TbsSkinTrackEdit.Create(Self);
  with SEdit do
  begin
    Parent := Form;
    SetBounds(SLabel.Left + SLabel.Width + 6, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
    TrackBarWidth := 120;
    MinValue := 0;
    MaxValue := 100;
    Value := 0;
    SkinData := CtrlSkinData;
    JumpWhenClick := True;
    OnChange := HSLEditChange;
  end;

  LLabel := TbsSkinStdLabel.Create(Form);
  with LLabel do
  begin
    Parent := Form;
    Left := SEdit.Left + SEdit.Width + 5;
    Top := ColorViewer.Top + ColorViewer.Height + 12;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinData := CtrlSkinData;
    Caption := 'L:';
  end;

  LEdit := TbsSkinTrackEdit.Create(Self);
  with LEdit do
  begin
    Parent := Form;
    SetBounds(LLabel.Left + LLabel.Width + 6, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
    TrackBarWidth := 120;
    MinValue := 0;
    MaxValue := 100;
    Value := 0;
    SkinData := CtrlSkinData;
    JumpWhenClick := True;
    OnChange := HSLEditChange;
  end;

  ButtonTop := HEdit.Top + HEdit.Height + 20;
  ButtonWidth := 70;
  ButtonHeight := 25;

   OkButton := TbsSkinButton.Create(Form);
   with OkButton do
   begin
     Parent := Form;
     DefaultFont := DefaultButtonFont;
     UseSkinFont := Self.UseSkinFont;
     Caption := 'OK';
     ModalResult := mrOk;
     Default := True;
     SetBounds(Form.ClientWidth - ButtonWidth * 2 - 20, ButtonTop, ButtonWidth,
               ButtonHeight);
     DefaultHeight := ButtonHeight;
     SkinDataName := FButtonSkinDataName;
     SkinData := CtrlSkinData;
   end;

  CancelButton := TbsSkinButton.Create(Form);
  with CancelButton do
  begin
    Parent := Form;
    DefaultFont := DefaultButtonFont;
    UseSkinFont := Self.UseSkinFont;
    Caption := 'Cancel';
    ModalResult := mrCancel;
    Cancel := True;
    SetBounds(Form.ClientWidth - ButtonWidth - 10, ButtonTop, ButtonWidth,
              ButtonHeight);
    DefaultHeight := ButtonHeight;
    SkinDataName := FButtonSkinDataName;
    SkinData := CtrlSkinData;
  end;


  with Form do
  begin
    ClientHeight := CancelButton.Top + CancelButton.Height + 10;
  end;

  ColorViewer.ColorValue := Color;
  ColorGrid.ColorValue := Color;
  ColorToR_G_B(Color, R, G, B);
  REdit.Value := R;
  GEdit.Value := G;
  BEdit.Value := B;

    if Form.ShowModal = mrOk
    then
      begin
        Color := ColorViewer.ColorValue;
        Result := True;
      end
    else
      Result := False;

  finally
    Form.Free;
  end;
end;



end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -