// スクリーンキャプチャ void ScreenCapture() { LayoutParameter target_parameter = GetTargetParameter(); UIntPtr window = target_parameter.Window; if (!ExternalAPI.IsWindow(window)) { return; } IntPtr window_dc = ExternalAPI.GetDC(window); if (window_dc == IntPtr.Zero) { // 不正なウィンドウなので何もしない return; } Graphics graphics = Graphics.FromImage(captured_bitmap_); IntPtr captured_bitmap_dc = graphics.GetHdc(); // BitBlt ExternalAPI.BitBlt(captured_bitmap_dc, 0, 0, captured_bitmap_.Width, captured_bitmap_.Height, window_dc, target_parameter.ClippingX, target_parameter.ClippingY, ExternalAPI.SRCCOPY); graphics.ReleaseHdc(captured_bitmap_dc); graphics.Dispose(); ExternalAPI.ReleaseDC(window, window_dc); }
public void SetPrimaryDesktopWindow() { ExternalAPI.RECT primary_desktop_rect; ExternalAPI.GetClientRect(ExternalAPI.GetDesktopWindow(), out primary_desktop_rect); this.SetWindowWithClippingRegion(ExternalAPI.GetDesktopWindow(), primary_desktop_rect.left, primary_desktop_rect.top, primary_desktop_rect.right, primary_desktop_rect.bottom); }
public void ShowHighscore(string tableId) { if (!TryIsInitialized()) { return; } ExternalAPI.ShowHighscore(tableId, ExternalAPI.JsCallback); }
//------------------------------------------------------------------- void Apply() { // フォームのクライアント領域をスクリーン座標に変換 Rectangle window_rect = RectangleToScreen(this.ClientRectangle); // デスクトップ取り込みに変更 ((LayoutParameter)layout_parameters_.Current).SetWindowWithClippingRegion( ExternalAPI.GetDesktopWindow(), window_rect.X, window_rect.Y, window_rect.Width, window_rect.Height); }
public void SaveHighscore(string tableId, int score) { if (!TryIsInitialized()) { return; } if (!TryIsLoggedIn()) { return; } ExternalAPI.SaveHighscore(tableId, score, ExternalAPI.JsCallback); }
//=================================================================== // イベントハンドラ //=================================================================== private void target_MouseDown(object sender, MouseEventArgs e) { var mouse_down_control_location = e.Location; mode_ = GetModeFromMouseControlLocation(mouse_down_control_location); last_mouse_container_location_ = ControlToContainer(mouse_down_control_location); current_container_location_ = target_.Location; current_size_ = target_.Size; if (mode_ != Mode.kNop && mode_ != Mode.kMove) { ExternalAPI.ReleaseCapture(); int hittest_result = GetHitTestResult(mode_); ExternalAPI.SendMessage(target_.Handle, ExternalAPI.WM_NCLBUTTONDOWN, new IntPtr(hittest_result), IntPtr.Zero); } }
/// @brief 検証 void Validate() { errors_.Clear(); // もっとも危険な状態になりやすいウィンドウからチェック if (this.Window == UIntPtr.Zero || !ExternalAPI.IsWindow(this.Window)) { errors_["Window"] = "Specified window is invalid"; } // 境界設定のチェック if (this.BoundRelativeTop >= this.BoundRelativeBottom) { errors_["BoundRelativeTop"] = "Specified bound-top is invalid"; errors_["BoundRelativeBottom"] = "Specified bound-bottom is invalid"; } if (this.BoundRelativeLeft >= this.BoundRelativeRight) { errors_["BoundRelativeLeft"] = "Specified bound-left is invalid"; errors_["BoundRelativeRight"] = "Specified bound-right is invalid"; } // クリッピングリージョンの判定 Rectangle bound_rectangle = this.WindowRectangle; Rectangle clipping_rectangle = this.ClippingRectangle; if (this.ClippingWidth == 0) { errors_["ClippingWidth"] = "Clipping-width is invalid"; } if (this.ClippingHeight == 0) { errors_["ClippingHeight"] = "Clipping-height is invalid"; } if (!bound_rectangle.Contains(clipping_rectangle)) { // bound_rectangleが(0,0,0,0)なら必ず実行される errors_["ClippingX"] = "Clipping-x is invalid"; errors_["ClippingY"] = "Clipping-y is invalid"; errors_["ClippingWidth"] = "Clipping-width is invalid"; errors_["ClippingHeight"] = "Clipping-height is invalid"; } }
//------------------------------------------------------------------- /// @brief コンストラクタ public MovableAndResizable(Control target, bool is_parent_exists) { // デスクトップ領域外へは行かないように if (is_parent_exists) { bounds_ = Rectangle.Empty; } else { bounds_ = scff_app.Utilities.GetWindowRectangle(ExternalAPI.GetDesktopWindow()); } target_ = target; // イベントハンドラの登録 target_.MouseDown += target_MouseDown; target_.MouseMove += target_MouseMove; target_.MouseUp += target_MouseUp; target_.SizeChanged += target_SizeChanged; }
public API(string appId) { ExternalAPI.Init(appId, ExternalAPI.JsCallback); }