BSOne.SFC/Tocsg.Module/RemoteSecu/EXE_RemoteSecuClient/DImgView.pas

225 lines
5.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit DImgView;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, hyieutils, iexBitmaps, hyiedefs,
iesettings, iexLayers, iexRulers, ieview, imageenview, Vcl.ExtCtrls,
Vcl.StdCtrls, Vcl.Menus, Vcl.Buttons, imageen;
type
TDlgImgView = class(TForm)
pnClient: TPanel;
pnBottom: TPanel;
OpenDialog: TOpenDialog;
popFun: TPopupMenu;
miSetFit: TMenuItem;
miSetOrgSize: TMenuItem;
pnTop: TPanel;
Label1: TLabel;
edPath: TEdit;
SpeedButton1: TSpeedButton;
chOpenDir: TCheckBox;
SpeedButton2: TSpeedButton;
btnWaterSave: TSpeedButton;
lbPName: TLabel;
imgEn: TImageEn;
procedure imgEnMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure miSetFitClick(Sender: TObject);
procedure miSetOrgSizeClick(Sender: TObject);
procedure btnWaterSaveClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
ms_: TMemoryStream;
dwPid_: DWORD;
hRcvWnd_: HWND;
sPath_: String;
procedure SetImageFit(bVal: Boolean);
public
{ Public declarations }
Constructor Create(aOwner: TComponent; ms: TMemoryStream; sPath: String; dwPid: DWORD; hRcvHwnd: HWND);
Destructor Destroy; override;
function LoadFromFile(sPath: String): Boolean;
function LoadFromStream(aStream: TStream): Boolean;
procedure process_WM_SYSCOMMAND(var msg: TWMSysCommand); Message WM_SYSCOMMAND;
end;
var
DlgImgView: TDlgImgView;
implementation
uses
// BoxedAppSDK_Static,
Tocsg.Process, Tocsg.Safe, Tocsg.Watermark, Tocsg.Network, Tocsg.Shell,
Tocsg.Trace, imageenio;
{$R *.dfm}
Constructor TDlgImgView.Create(aOwner: TComponent; ms: TMemoryStream; sPath: String; dwPid: DWORD; hRcvHwnd: HWND);
var
PList: TProcessEntList;
pInfo: PProcessEntInfo;
sDesc: String;
begin
Inherited Create(aOwner);
ms_ := ms;
dwPid_ := dwPid;
hRcvWnd_ := hRcvHwnd;
sPath_ := sPath;
sDesc := '';
Guard(PList, TProcessEntList.Create(true));
pInfo := PList.GetProcInfoByPid(dwPid);
if pInfo <> nil then
begin
if pInfo.sDescription <> '' then
lbPName.Caption := Format('%s (%s)', [pInfo.sModuleBaseName, pInfo.sDescription])
else
lbPName.Caption := pInfo.sModuleBaseName;
end else
lbPName.Caption := GetProcessNameByPid(dwPid);
edPath.Text := StringReplace(sPath, 'V@', '', [rfReplaceAll]);
// BoxedAppSDK_SetContext('21f2f010-06e4-465f-af8f-cde6a3752c39');
// BoxedAppSDK_Init;
// if BoxedAppSDK_IsAttachedProcessId(GetCurrentProcessId) then
// begin
// ShowMessage('BoxedAppSDK_IsAttachedProcessId() .. Yes');
// BoxedAppSDK_EnableOption(DEF_BOXEDAPPSDK_OPTION__ALL_CHANGES_ARE_VIRTUAL, FALSE);
// BoxedAppSDK_EnableOption(DEF_BOXEDAPPSDK_OPTION__ENABLE_VIRTUAL_FILE_SYSTEM, FALSE);
// BoxedAppSDK_EnableOption(DEF_BOXEDAPPSDK_OPTION__RECREATE_VIRTUAL_FILE_AS_VIRTUAL, FALSE);
// BoxedAppSDK_DetachFromProcess(GetCurrentProcess);
// BoxedAppSDK_DeleteFileFromVirtualFileSystem(PChar(sPath));
// end;
end;
Destructor TDlgImgView.Destroy;
begin
if ms_ <> nil then
FreeAndNil(ms_);
Inherited;
end;
procedure TDlgImgView.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := TCloseAction.caFree;
end;
procedure TDlgImgView.SetImageFit(bVal: Boolean);
begin
begin
imgEn.AutoFit := bVal;
if bVal then
imgEn.Fit
else
imgEn.Zoom := 100;
imgEn.Update;
miSetFit.Checked := bVal;
miSetOrgSize.Checked := not bVal;
end;
end;
procedure TDlgImgView.SpeedButton2Click(Sender: TObject);
begin
//exit;
if OpenDialog.Execute(Handle) then
begin
end;
end;
procedure TDlgImgView.btnWaterSaveClick(Sender: TObject);
var
sWaterTxt: String;
Font: TFont;
ms: TMemoryStream;
begin
Guard(Font, TFont.Create);
Font.Size := 20;
Font.Name := 'Arial';
Font.Style := Font.Style + [fsBold];
sWaterTxt := DateTimeToStr(Now); // + ' / ' + GetCurrentHostName + ' / ' + GetHostIP;
// WriteLnFileEndUTF8('C:\Users\tocsg\Documents\<5C>ݵ<EFBFBD>ī<EFBFBD>޶<EFBFBD>\wwwwwwwwwwwwwww.txt', 'test');
// Hide;
AddWatermarkTextLayer(imgEn, Font, sWaterTxt, 25, false);
// ShowMessage(edPath.Text);
// BoxedAppSDK_DeleteFileFromVirtualFileSystem(PChar(edPath.Text));
// if FileExists(edPath.Text) then
// DeleteFile(edPath.Text);
imgEn.IO.SaveToFile(edPath.Text);
// Guard(ms, TMemoryStream.Create);
// imgEn.IO.SaveToStream(ms, IEFilenameToInternalFileType(edPath.Text));
// ms.SaveToFile(edPath.Text);
// ms.SaveToFile('C:\Users\tocsg\Documents\<5C>ݵ<EFBFBD>ī<EFBFBD>޶<EFBFBD>\wwww.png');
if chOpenDir.Checked then
ExplorerSelectedPath(edPath.Text);
Close;
end;
procedure TDlgImgView.imgEnMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
if imgEn.AutoFit then
begin
imgEn.AutoFit := false;
miSetFit.Checked := false;
end else
if miSetOrgSize.Checked then
miSetOrgSize.Checked := false;
end;
function TDlgImgView.LoadFromStream(aStream: TStream): Boolean;
begin
Result := false;
try
aStream.Position := 0;
Result := imgEn.IO.LoadFromStream(aStream);
except
// ..
end;
end;
procedure TDlgImgView.miSetFitClick(Sender: TObject);
begin
SetImageFit(true);
end;
procedure TDlgImgView.miSetOrgSizeClick(Sender: TObject);
begin
SetImageFit(false);
end;
function TDlgImgView.LoadFromFile(sPath: String): Boolean;
begin
Result := false;
try
Result := imgEn.IO.LoadFromFile(sPath);
except
// ..
end;
end;
procedure TDlgImgView.process_WM_SYSCOMMAND(var msg: TWMSysCommand);
begin
if msg.CmdType = SC_CLOSE then
begin
if MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ĸ<>ĵ<EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.'+#13+#10+'<27><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?'),
PChar(Caption), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
end;
Inherited;
end;
end.