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

📄 deditor.pas

📁 KSDev.BlockEngine.v3.03.rar 界面控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      end
      else
        if Point.Hot then
          DrawImage(DResMod.ResizeImgs, X - W / 2, Y, 7)
        else
          DrawImage(DResMod.ResizeImgs, X - W / 2, Y, 3);
    pkLeftTop:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Rectangle(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.ResizeImgs, X - W, Y - H, 6)
        else
          DrawImage(DResMod.ResizeImgs, X - W, Y - H, 2);
    pkRightBottom:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Rectangle(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.ResizeImgs, X, Y, 6)
        else
          DrawImage(DResMod.ResizeImgs, X, Y, 2);
    pkLeftBottom:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Rectangle(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.ResizeImgs, X - W, Y, 4)
        else
          DrawImage(DResMod.ResizeImgs, X - W, Y, 0);
    pkRightTop:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Rectangle(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.ResizeImgs, X, Y - H, 4)
        else
          DrawImage(DResMod.ResizeImgs, X, Y - H, 0);
    pkRotateLeftTop:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.RotateImgs, X - RW, Y - RH, 4)
        else
          DrawImage(DResMod.RotateImgs, X - RW, Y - RH, 0);
    pkRotateRightTop:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.RotateImgs, X, Y - RH, 5)
        else
          DrawImage(DResMod.RotateImgs, X, Y - RH, 1);
    pkRotateLeftBottom:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.RotateImgs, X - RW, Y, 6)
        else
          DrawImage(DResMod.RotateImgs, X - RW, Y, 2);
    pkRotateRightBottom:
      if not FHotArrow then
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end
      else
        if Point.Hot then
          DrawImage(DResMod.RotateImgs, X, Y, 7)
        else
          DrawImage(DResMod.RotateImgs, X, Y, 3);
    pkRotate:
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end;
    pkRotateCenter:
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          C.Brush.Color := clWhite;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2 - 1, P.Y - GripSize div 2 - 1, P.X + GripSize div 2 + 1, P.Y + GripSize div 2 + 1);
      end;
    pkBlockPoint:
      begin
        C.Brush.Color := clYellow;
        if Point.Hot then
          C.Brush.Color := clRed;
        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Polygon([
          Classes.Point(P.X - GripSize div 2, P.Y),
          Classes.Point(P.X, P.Y - GripSize div 2),
          Classes.Point(P.X + GripSize div 2, P.Y),
          Classes.Point(P.X, P.Y + GripSize div 2)
        ]);
      end;
    pkFreePoint:
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;

        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Ellipse(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end;
    pkLeftRotate,
    pkTopRotate,
    pkRightRotate,
    pkBottomRotate:
      begin
        if Point.Hot then
          C.Brush.Color := clRed
        else
          if (dsFocused in ABlock.DesignState) then
            C.Brush.Color := clLime
          else
            C.Brush.Color := clAqua;

        C.Brush.Style := bsSolid;
        C.Pen.Color := clBlack;
        C.Pen.Style := psSolid;
        C.Rectangle(P.X - GripSize div 2, P.Y - GripSize div 2, P.X + GripSize div 2, P.Y + GripSize div 2);
      end;
  end;

  if (Point.ScreenUpdate) and FHotTrack then
  begin
    UpdateSceneRect(FP.X - 10 * DevicePixel, FP.Y - 10 * DevicePixel, FP.X + 10 * DevicePixel, FP.Y + 10 * DevicePixel);
  end;

  Point.Hot := SaveHot;
end;

procedure TBlockEditor.DoGetPointRect(Sender: TObject;
  ABlock: Block; APoint: BlockPoint; var R: FloatRect);
var
  W, H, RW, RH: Float;
begin
  if not FHotArrow then
  begin
    with APoint do
      R := MakeFloatRect(X - (FGripSize / 2) * DevicePixel, Y - (FGripSize / 2) * DevicePixel,
        X + (FGripSize / 2) * DevicePixel, Y + (FGripSize / 2) * DevicePixel);
    Exit;
  end;

  W := DResMod.ResizeImgs.Width * DevicePixel;
  H := DResMod.ResizeImgs.Height * DevicePixel;
  RW := (DResMod.RotateImgs.Width - 2) * DevicePixel;
  RH := (DResMod.RotateImgs.Height - 2) * DevicePixel;
  with APoint do
    case Kind of
      pkLeftTop:
        begin
          R := MakeFloatRect(X - W, Y - H, X, Y);
        end;
      pkLeftBottom:
        begin
          R := MakeFloatRect(X - W, Y, X, Y + H);
        end;
      pkRightTop:
        begin
          R := MakeFloatRect(X, Y - H, X + W, Y);
        end;
      pkRightBottom:
        begin
          R := MakeFloatRect(X, Y, X + W, Y + H);
        end;
      pkTop:
        begin
          R := MakeFloatRect(X - (W / 2), Y - H, X + (W / 2), Y);
        end;
      pkBottom:
        begin
          R := MakeFloatRect(X - (W / 2), Y, X + (W / 2), Y + H);
        end;
      pkLeft:
        begin
          R := MakeFloatRect(X - W, Y - (H / 2), X, Y + (H / 2));
        end;
      pkRight:
        begin
          R := MakeFloatRect(X, Y - (H / 2), X + W, Y + (H / 2));
        end;
      pkRotateLeftTop:
        begin
          R := MakeFloatRect(X - RW, Y - RH, X, Y);
        end;
      pkRotateRightTop:
        begin
          R := MakeFloatRect(X, Y - RH, X + RW, Y);
        end;
      pkRotateLeftBottom:
        begin
          R := MakeFloatRect(X - RW, Y, X, Y + RH);
        end;
      pkRotateRightBottom:
        begin
          R := MakeFloatRect(X, Y, X + RW, Y + RH);
        end;
    end;
end;

procedure TBlockEditor.DoUndoSaveState(Sender: TObject);
var
  UndoStream: TStream;
  CStream: TCompressionStream;
begin
  UndoStream := TMemoryStream.Create;
  CStream := TCompressionStream.Create(clDefault, UndoStream);
  try
    Document.BlockRoot.AddDesignStateToAll([dsUndoStream]);
    SaveBlockDocumentBinary(CStream, Document);
    Document.BlockRoot.RemoveDesignStateToAll([dsUndoStream]);
  finally
    CStream.Free;
  end;

  FUndoList.Add(UndoStream);

  { Clear old }
  if FUndoList.Count > MaxUndoState then
  begin
    TStream(FUndoList[0]).Free;
    FUndoList.Delete(0);
  end;
end;

procedure TBlockEditor.SaveUndo;
begin
  DoUndoSaveState(Self);
end;

procedure TBlockEditor.ClearUndo;
var
  i: integer;
begin
  for i := 0 to FUndoList.Count - 1 do
    TStream(FUndoList[i]).Free;
  FUndoList.Clear;
end;

procedure TBlockEditor.Undo;
var
  DStream: TDecompressionStream;
begin
  if CanUndo then
  begin
    Document.Clear;
    TStream(FUndoList[FUndoList.Count - 1]).Position := 0;
    DStream := TDecompressionStream.Create(TStream(FUndoList[FUndoList.Count - 1]));
    try
      Document.BlockRoot.AddDesignStateToAll([dsUndoStream]);
      LoadBlockDocumentBinary(DStream, Document);

⌨️ 快捷键说明

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