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

📄 sskinmanager.pas

📁 Alpha Controls 5.40,delphi上的alpha开发源码控件包。没有密码。5.40版的最新版。
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  if Value = 0 then Exit;
  Value := - Value mod 101;
  with sManager do begin

    if Assigned(MasterBitmap) then begin
      h := MasterBitmap.Height - 1;
      w := MasterBitmap.Width - 1;
      for y := 0 to h do begin
        S1 := MasterBitmap.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) or ((C.R = C.G) and (C.R = C.B)) then Continue;
          C.C := ChangeSaturation(C.C, Value);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(ma);
    for i := 0 to l - 1 do if Assigned(ma[i].Bmp) then begin
      h := ma[i].Bmp.Height - 1;
      w := ma[i].Bmp.Width - 1;
      ma[i].Bmp.PixelFormat := pf24bit;
      for y := 0 to h do begin
        S1 := ma[i].Bmp.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) or ((C.R = C.G) and (C.R = C.B)) then Continue;
          C.C := ChangeSaturation(C.C, Value);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(gd);
    for i := 0 to l - 1 do begin

      gd[i].Color := ChangeSaturation(gd[i].Color, Value);
      gd[i].HotColor := ChangeSaturation(gd[i].HotColor, Value);

      if gd[i].FontColor[1] <> -1 then gd[i].FontColor[1] := ChangeSaturation(gd[i].FontColor[1], Value);
      if gd[i].FontColor[2] <> -1 then gd[i].FontColor[2] := ChangeSaturation(gd[i].FontColor[2], Value);
      if gd[i].FontColor[3] <> -1 then gd[i].FontColor[3] := ChangeSaturation(gd[i].FontColor[3], Value);
      if gd[i].FontColor[4] <> -1 then gd[i].FontColor[4] := ChangeSaturation(gd[i].FontColor[4], Value);
      if gd[i].FontColor[5] <> -1 then gd[i].FontColor[5] := ChangeSaturation(gd[i].FontColor[5], Value);

      if gd[i].HotFontColor[1] <> -1 then gd[i].HotFontColor[1] := ChangeSaturation(gd[i].HotFontColor[1], Value);
      if gd[i].HotFontColor[2] <> -1 then gd[i].HotFontColor[2] := ChangeSaturation(gd[i].HotFontColor[2], Value);
      if gd[i].HotFontColor[3] <> -1 then gd[i].HotFontColor[3] := ChangeSaturation(gd[i].HotFontColor[3], Value);
      if gd[i].HotFontColor[4] <> -1 then gd[i].HotFontColor[4] := ChangeSaturation(gd[i].HotFontColor[4], Value);
      if gd[i].HotFontColor[5] <> -1 then gd[i].HotFontColor[5] := ChangeSaturation(gd[i].HotFontColor[5], Value);

      w := WordCount(gd[i].GradientData, [';']) div 5;
      for j := 0 to w - 1 do begin
        gd[i].GradientArray[j].Color1 := ChangeSaturation(gd[i].GradientArray[j].Color1, Value);
        gd[i].GradientArray[j].Color2 := ChangeSaturation(gd[i].GradientArray[j].Color2, Value);
      end;

      w := Length(gd[i].HotGradientArray);
      for j := 0 to w - 1 do begin
        gd[i].HotGradientArray[j].Color1 := ChangeSaturation(gd[i].HotGradientArray[j].Color1, Value);
        gd[i].HotGradientArray[j].Color2 := ChangeSaturation(gd[i].HotGradientArray[j].Color2, Value);
      end;
    end;
    sManager.SkinData.Shadow1Color := ChangeSaturation(sManager.SkinData.Shadow1Color, Value);
    sManager.SkinData.BorderColor := ChangeSaturation(sManager.SkinData.BorderColor, Value);
  end;
end;

procedure ChangeSkinBrightness(sManager : TsSkinManager; Value : integer);
var
  S1 : PRGBArray;
  i, l, j, w, h, x, y : integer;
  C : TsColor;
begin
  if Value = 0 then Exit;
  with sManager do begin

    if Assigned(MasterBitmap) then begin
      h := MasterBitmap.Height - 1;
      w := MasterBitmap.Width - 1;
      for y := 0 to h do begin
        S1 := MasterBitmap.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) then Continue;
          C.C := ChangeBrightness(C.C, Value);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(ma);
    for i := 0 to l - 1 do if Assigned(ma[i].Bmp) then begin
      h := ma[i].Bmp.Height - 1;
      w := ma[i].Bmp.Width - 1;
      ma[i].Bmp.PixelFormat := pf24bit;
      for y := 0 to h do begin
        S1 := ma[i].Bmp.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) then Continue;
          C.C := ChangeBrightness(C.C, Value);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(gd);
    for i := 0 to l - 1 do begin

      gd[i].Color := ChangeBrightness(gd[i].Color, Value);
      gd[i].HotColor := ChangeBrightness(gd[i].HotColor, Value);

      if gd[i].FontColor[1] <> -1 then gd[i].FontColor[1] := ChangeBrightness(gd[i].FontColor[1], Value);
      if gd[i].FontColor[2] <> -1 then gd[i].FontColor[2] := ChangeBrightness(gd[i].FontColor[2], Value);
      if gd[i].FontColor[3] <> -1 then gd[i].FontColor[3] := ChangeBrightness(gd[i].FontColor[3], Value);
      if gd[i].FontColor[4] <> -1 then gd[i].FontColor[4] := ChangeBrightness(gd[i].FontColor[4], Value);
      if gd[i].FontColor[5] <> -1 then gd[i].FontColor[5] := ChangeBrightness(gd[i].FontColor[5], Value);

      if gd[i].HotFontColor[1] <> -1 then gd[i].HotFontColor[1] := ChangeBrightness(gd[i].HotFontColor[1], Value);
      if gd[i].HotFontColor[2] <> -1 then gd[i].HotFontColor[2] := ChangeBrightness(gd[i].HotFontColor[2], Value);
      if gd[i].HotFontColor[3] <> -1 then gd[i].HotFontColor[3] := ChangeBrightness(gd[i].HotFontColor[3], Value);
      if gd[i].HotFontColor[4] <> -1 then gd[i].HotFontColor[4] := ChangeBrightness(gd[i].HotFontColor[4], Value);
      if gd[i].HotFontColor[5] <> -1 then gd[i].HotFontColor[5] := ChangeBrightness(gd[i].HotFontColor[5], Value);

      w := WordCount(gd[i].GradientData, [';']) div 5;
      for j := 0 to w - 1 do begin
        gd[i].GradientArray[j].Color1 := ChangeBrightness(gd[i].GradientArray[j].Color1, Value);
        gd[i].GradientArray[j].Color2 := ChangeBrightness(gd[i].GradientArray[j].Color2, Value);
      end;

      w := Length(gd[i].HotGradientArray);
      for j := 0 to w - 1 do begin
        gd[i].HotGradientArray[j].Color1 := ChangeBrightness(gd[i].HotGradientArray[j].Color1, Value);
        gd[i].HotGradientArray[j].Color2 := ChangeBrightness(gd[i].HotGradientArray[j].Color2, Value);
      end;
    end;
  end;
end;

procedure ChangeSkinHue(sManager : TsSkinManager; Value : integer);
var
  S1 : PRGBArray;
  i, l, j, w, h, x, y : integer;
  C : TsColor;
begin
  if Value = 0 then Exit;
  with sManager do begin

    if Assigned(MasterBitmap) then begin
      h := MasterBitmap.Height - 1;
      w := MasterBitmap.Width - 1;
      for y := 0 to h do begin
        S1 := MasterBitmap.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) or ((C.R = C.G) and (C.R = C.B)) then Continue;
          C.C := ChangeHue(Value, C.C);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(ma);
    for i := 0 to l - 1 do if Assigned(ma[i].Bmp) then begin
      h := ma[i].Bmp.Height - 1;
      w := ma[i].Bmp.Width - 1;
      ma[i].Bmp.PixelFormat := pf24bit;
      for y := 0 to h do begin
        S1 := ma[i].Bmp.ScanLine[y];
        for x := 0 to w do with S1[X] do begin
          C.R := R; C.G := G; C.B := B;
          if (C.C = clFuchsia) or ((C.R = C.G) and (C.R = C.B)) then Continue;
          C.C := ChangeHue(Value, C.C);
          R := C.R; G := C.G; B := C.B
        end
      end;
    end;

    l := Length(gd);
    for i := 0 to l - 1 do begin

      gd[i].Color := ChangeHue(Value, gd[i].Color);
      gd[i].HotColor := ChangeHue(Value, gd[i].HotColor);

      if gd[i].FontColor[1] <> -1 then gd[i].FontColor[1] := ChangeHue(Value, gd[i].FontColor[1]);
      if gd[i].FontColor[2] <> -1 then gd[i].FontColor[2] := ChangeHue(Value, gd[i].FontColor[2]);
      if gd[i].FontColor[3] <> -1 then gd[i].FontColor[3] := ChangeHue(Value, gd[i].FontColor[3]);
      if gd[i].FontColor[4] <> -1 then gd[i].FontColor[4] := ChangeHue(Value, gd[i].FontColor[4]);
      if gd[i].FontColor[5] <> -1 then gd[i].FontColor[5] := ChangeHue(Value, gd[i].FontColor[5]);

      if gd[i].HotFontColor[1] <> -1 then gd[i].HotFontColor[1] := ChangeHue(Value, gd[i].HotFontColor[1]);
      if gd[i].HotFontColor[2] <> -1 then gd[i].HotFontColor[2] := ChangeHue(Value, gd[i].HotFontColor[2]);
      if gd[i].HotFontColor[3] <> -1 then gd[i].HotFontColor[3] := ChangeHue(Value, gd[i].HotFontColor[3]);
      if gd[i].HotFontColor[4] <> -1 then gd[i].HotFontColor[4] := ChangeHue(Value, gd[i].HotFontColor[4]);
      if gd[i].HotFontColor[5] <> -1 then gd[i].HotFontColor[5] := ChangeHue(Value, gd[i].HotFontColor[5]);

      w := WordCount(gd[i].GradientData, [';']) div 5;
      for j := 0 to w - 1 do begin
        gd[i].GradientArray[j].Color1 := ChangeHue(Value, gd[i].GradientArray[j].Color1);
        gd[i].GradientArray[j].Color2 := ChangeHue(Value, gd[i].GradientArray[j].Color2);
      end;

      w := Length(gd[i].HotGradientArray);
      for j := 0 to w - 1 do begin
        gd[i].HotGradientArray[j].Color1 := ChangeHue(Value, gd[i].HotGradientArray[j].Color1);
        gd[i].HotGradientArray[j].Color2 := ChangeHue(Value, gd[i].HotGradientArray[j].Color2);
      end;
    end;

    sManager.SkinData.Shadow1Color := ChangeHue(Value, sManager.SkinData.Shadow1Color);
    sManager.SkinData.BorderColor := ChangeHue(Value, sManager.SkinData.BorderColor);
  end;
end;

{ TsSkinManager }

procedure TsSkinManager.AfterConstruction;
begin
  inherited;
  if FSkinDirectory = '' then begin
    FSkinDirectory := DefSkinsDir;
  end;
end;

constructor TsSkinManager.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  if (DefaultManager = nil) then FIsDefault := True;
  SkinData := TsSkinData.Create;
  SkinData.Active := False;
  FBuiltInSkins := TsStoredSkins.Create(Self);
  FCommonSections := TStringList.Create;
  FSkinnedPopups := True;
  FHueOffset := 0;
  FMenuSupport := TacMenuSupport.Create;
  FAnimEffects := TacAnimEffects.Create;
  FAnimEffects.Manager := Self;
  FAnimEffects.Buttons.Manager := Self;
  FWorkMode := stFullAuto;
  GlobalHookInstalled := False;
  FSkinningRules := [srStdForms, srStdDialogs, srThirdParty];
  if (DefaultManager = nil) then begin
    DefaultManager := Self;
    if IsNT and not (csDesigning in ComponentState) then Application.HookMainWindow(MainWindowHook);
  end;
  FActive := True;
  FSkinableMenus := TsSkinableMenus.Create(Self);
  SetLength(gd, 0);
  SetLength(ma, 0);
  SetLength(pa, 0);
end;

destructor TsSkinManager.Destroy;
begin
{.$IFDEF LOGGED
  if LogLines <> nil then begin
    LogLines.SaveToFile(LogFile);
    LogLines.Free;
  end;
$ENDIF}
  Active := False;
  FreeAndNil(FAnimEffects);
  if Assigned(FBuiltInSkins) then FreeAndNil(FBuiltInSkins);
  if Assigned(FSkinableMenus) then FreeAndNil(FSkinableMenus);
  FreeAndNil(FCommonSections);
  if Assigned(SkinData) then SkinData.Free;
  FreeAndNil(FMenuSupport);
  FreeJpegs;
  FreeBitmaps;
  if (DefaultManager = Self) then begin
    if IsNT and not (csDesigning in ComponentState) then Application.UnHookMainWindow(MainWindowHook);
    DefaultManager := nil;
  end;
  inherited Destroy;
end;

procedure TsSkinManager.ExtractByIndex(Index: integer; const DestDir: string);
var
  i : integer;
  DirName, s : string;
  sf : TMemIniFile;
begin
  DirName := NormalDir(DestDir) + InternalSkins[Index].Name + ' extracted\';
  if not DirectoryExists(DirName) then begin
    if not CreateDir(DirName) then begin
{$IFNDEF ALITE}
      ShowError('Directory ' + DirName + ' creation error.');
{$ENDIF}
      Exit;
    end;
  end;
  sf := TMemIniFile.Create(DirName + OptionsDatName);
  try
    if Assigned(InternalSkins[Index].FMasterBitmap) then begin
      InternalSkins[Index].FMasterBitmap.SaveToFile(DirName + MasterBmpName);
      WriteIniStr(s_GLOBALINFO, s_MASTERBITMAP, UpperCase(MasterBmpName), sf);
    end;
    // Extract Bmp's
    for i := 0 to InternalSkins[Index].Images.Count - 1 do begin
      if (InternalSkins[Index].Images[i].Image <> nil) and (InternalSkins[Index].Images[i].Name <> '') then begin
        InternalSkins[Index].Images[i].Image.SaveToFile(DirName + InternalSkins[Index].Images[i].Name);
        WriteIniStr(InternalSkins[Index].Images[i].SectionName, InternalSkins[Index].Images[i].PropertyName, InternalSkins[Index].Images[i].Name, sf);
      end
      else begin
        if (InternalSkins[Index].Images[i].PropertyName = s_Pattern) or (InternalSkins[Index].Images[i].PropertyName = s_HotPattern) then begin
          s := TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].Left), 4) +
               TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].Top), 4) +
               TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].Right), 4) +
               TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].Bottom), 4) +
               TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].StretchMode), 2) + 
               TexChar + AddChar(ZeroChar, IntToStr(InternalSkins[Index].Images[i].MaskType), 1);
        end
        else begin
          s := '#(' + IntToStr(InternalSkins[Index].Images[i].Left) + ',' +
                      IntToStr(InternalSkins[Index].Images[i].Top) + ',' +
                      IntToStr(InternalSkins[Index].Images[i].Right) + ',' +
                      IntToStr(InternalSkins[Index].Images[i].Bottom) + '),' +
                      IntToStr(InternalSkins[Index].Images[i].ImageCount) + ',' +
                      IntToStr(InternalSkins[Index].Images[i].MaskType);
        end;
        WriteIniStr(InternalSkins[Index].Images[i].SectionName, InternalSkins[Index].Images[i].PropertyName, s, sf);
      end;
    end;
    // Extract Jpeg's
    for i := 0 to InternalSkins[Index].Patterns.Count - 1 do begin
      if InternalSkins[Index].Patterns[i].Name <> '' then begin
        InternalSkins[Index].Patterns[i].Image.SaveToFile(DirName + InternalSkins[Index].Patterns[i].Name);
        WriteIniStr(InternalSkins[Index].Patterns[i].SectionName, InternalSkins[Index].Patterns[i].PropertyName, InternalSkins[Index].Patterns[i].Name, sf);
{      end
      else begin
        s := '#(' + IntToStr(InternalSkins[Index].Patterns[i].R.Left) + ',' +
                    IntToStr(InternalSkins[Index].Patterns[i].R.Top) + ',' +
                    IntToStr(InternalSkins[Index].Patterns[i].R.Right) + ',' +

⌨️ 快捷键说明

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