示例#1
0
//---------------------------------------------------------------------------
void TPictureViewer::UpdateImage(const AnsiString FileName, const bool Transparent)
{
  ZoomPageB->Visible = false;
  ZoomOneB->Visible  = false;
  FullViewB->Visible = false;
  ShapeZoomPageB->Visible = false;
  ShapeZoomOneB->Visible  = false;
  ShapeFullViewB->Visible = false;
  if (FileName.data()) {
    LoadTransparentBitmap(Image, FileName, Transparent);
    if (Image->Picture->Bitmap->Width > Width || Image->Picture->Bitmap->Height > Height) {
      ZoomPageB->Visible = true;
      ZoomOneB->Visible  = true;
      FullViewB->Visible = true;
      ShapeZoomPageB->Visible = true;
      ShapeZoomOneB->Visible  = true;
      ShapeFullViewB->Visible = true;
      Image->Center = false;
      ZoomPageBClick(NULL);
    } else {
      Image->Center  = true;
      ZoomOneBClick(NULL);
    }
    Image->Visible = true;
  } else {
    Image->Visible = false;
  }
}
示例#2
0
//---------------------------------------------------------------------------
void __fastcall TKeyGenerator::SaveKey(const AnsiString FileName,
  const AnsiString Passphrase, TKeyFormat Format)
{
  DebugAssert(FSSH2Key);
  DebugAssert(FState == kgComplete);
  DebugAssert((Format != kfOpenSSH && Format != kfSSHCom) || IsSSH2);

  int Result;

  if (IsSSH2)
  {
    switch (Format)
    {
      case kfPutty:
        Result = ssh2_save_userkey(FileName.c_str(), FSSH2Key,
          (char*)Passphrase.data());
        break;

      case kfOpenSSH:
        Result = export_ssh2(FileName.c_str(), SSH_KEYTYPE_OPENSSH, FSSH2Key,
          (char*)Passphrase.data());
        break;

      case kfSSHCom:
        Result = export_ssh2(FileName.c_str(), SSH_KEYTYPE_SSHCOM, FSSH2Key,
          (char*)Passphrase.data());
        break;

      default:
        DebugFail();
    }
  }
  else
  {
    DebugAssert(Format == kfPutty);
    Result = saversakey(FileName.c_str(), FRSAKey,
      (char*)Passphrase.data());
  }

  if (Result <= 0)
    throw Exception(FMTLOAD(SAVE_KEY_ERROR, (FileName)));
}
示例#3
0
void ansi_to_unicode(UnicodeString& u_str, const AnsiString& a_str) {
  unsigned size = a_str.size() + 1;
  int res = MultiByteToWideChar(CP_ACP, 0, a_str.data(), size, u_str.buf(a_str.size()), size);
  if (res == 0) FAIL(SystemError());
  u_str.set_size(res - 1);
}