public void SetUpHandCursorModule() { /* Set Module */ HandCursorModule handCursorModule; handCursorModule = HandCursorModule.Activate(manager.SenseManager); if (handCursorModule == null) { manager.SetStatus("Failed Loading Module"); return; } // Creates CurserConfiguration and returns instance cursorConfiguration = handCursorModule.CreateActiveConfiguration(); if (cursorConfiguration == null) { manager.SetStatus("Failed Create Configuration"); return; } // Create cursorData instance to store Dae from recognition cursorData = handCursorModule.CreateOutput(); if (cursorData == null) { manager.SetStatus("Failed Create Output"); return; } }
void Awake() { m_DefaultCursorSettings = new CursorData { m_Visible = Cursor.visible, m_LockMode = Cursor.lockState }; m_IsDefaultSettings = true; }
public void SetCursor(CursorType type, bool force = false) { if (type == currentType && !force) { return; } CursorData toUse = cursors[(int)type]; if (type == CursorType.None) { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); Cursor.visible = visible; spriteRenderer.enabled = false; } else { if (currentType == CursorType.None && Cursor.visible) { Cursor.visible = false; } spriteRenderer.enabled = visible; spriteRenderer.sprite = toUse.cursor; } currentType = type; }
protected ImageInfo ExecuteRegionCapture(TaskSettings taskSettings) { ImageInfo imageInfo = new ImageInfo(); CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(RegionCaptureMode.Annotation, taskSettings.CaptureSettingsReference.SurfaceOptions /*, img*/)) { if (cursorData != null && cursorData.IsVisible) { form.AddCursor(cursorData.Handle, CaptureHelpers.ScreenToClient(cursorData.Position)); } form.Closable = false; ScreenRecordManager.recordForm.StopRequested += () => { form.Closable = true; form.Close(); }; form.ShowDialog(); } return(imageInfo); }
public void HideCustomCursor(CursorData c) { if (c != null) { SafeSetActive(c.UpStateObject, false); SafeSetActive(c.DownStateObject, false); } }
protected ImageInfo ExecuteRegionCapture(TaskSettings taskSettings) { ImageInfo imageInfo = new ImageInfo(); RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; Image img = screenshot.CaptureFullscreen(); CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, img)) { if (cursorData != null && cursorData.IsValid) { form.AddCursor(cursorData.Handle, cursorData.Position); cursorData.Dispose(); } form.ShowDialog(); imageInfo.Image = form.GetResultImage(); if (imageInfo.Image != null) { if (form.IsModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern) { WindowInfo windowInfo = form.GetWindowInfo(); imageInfo.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; } } return(imageInfo); }
protected TaskMetadata ExecuteRegionCapture(TaskSettings taskSettings) { TaskMetadata metadata = new TaskMetadata(); RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; Bitmap bmp = screenshot.CaptureFullscreen(); CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, bmp)) { if (cursorData != null && cursorData.IsVisible) { form.AddCursor(cursorData.Handle, CaptureHelpers.ScreenToClient(cursorData.Position)); } form.ShowDialog(); metadata.Image = form.GetResultImage(); if (metadata.Image != null) { if (form.IsImageModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region) { WindowInfo windowInfo = form.GetWindowInfo(); metadata.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; } } return(metadata); }
public void ShowCustomCursor(CursorData c) { if (c != null) { if (c.UpStateObject == null) { c.UpStateObject = MakeObject(c.UpStatePrefab, c.Name + "Up"); } if (c.DownStateObject == null) { c.DownStateObject = MakeObject(c.DownStatePrefab, c.Name + "Down"); } SafeSetActive(c.UpStateObject, FingerUp); SafeSetActive(c.DownStateObject, !FingerUp); } }
/// <summary> /// 初始化陣列 /// </summary> public void InitList() { for (int i = 0; i < MaxSize - 1; i++) { _myArr[i] = new CursorData() { cur = i + 1, last = i - 1 } } ; //目前靜態鏈結串列為空,最後一個元素的Cur為0 _myArr[MaxSize - 1] = new CursorData() { cur = 1 }; _myArr[0].data = "$"; }
// Internal function public void SetCursor(CursorData c) { HideCustomCursor(CurrentCustomCursor); if (c == null) { // Standard cursor CurrentCustomCursor = null; CurrentCustomCursorName = ""; return; } else { // Custom cursor ShowCustomCursor(c); CurrentCustomCursor = c; CurrentCustomCursorName = c.Name; } }
private Bitmap CaptureRectangleNative(IntPtr handle, Rectangle rect, bool captureCursor = false) { if (rect.Width == 0 || rect.Height == 0) { return(null); } if (UseWinRTCaptureAPI && ModernCaptureSignletonManager.Instance.IsAvailable) { return(CaptureRectangleDirect3D11(handle, rect, captureCursor)); } else { IntPtr hdcSrc = NativeMethods.GetWindowDC(handle); IntPtr hdcDest = NativeMethods.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = NativeMethods.CreateCompatibleBitmap(hdcSrc, rect.Width, rect.Height); IntPtr hOld = NativeMethods.SelectObject(hdcDest, hBitmap); NativeMethods.BitBlt(hdcDest, 0, 0, rect.Width, rect.Height, hdcSrc, rect.X, rect.Y, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt); if (captureCursor) { try { CursorData cursorData = new CursorData(); cursorData.DrawCursor(hdcDest, rect.Location); } catch (Exception e) { DebugHelper.WriteException(e, "Cursor capture failed."); } } NativeMethods.SelectObject(hdcDest, hOld); NativeMethods.DeleteDC(hdcDest); NativeMethods.ReleaseDC(handle, hdcSrc); Bitmap bmp = Image.FromHbitmap(hBitmap); NativeMethods.DeleteObject(hBitmap); return(bmp); } }
public static Image CaptureRectangleNative(IntPtr handle, Rectangle rect, bool captureCursor = false) { if (rect.Width == 0 || rect.Height == 0) { return(null); } IntPtr hdcSrc = NativeMethods.GetWindowDC(handle); IntPtr hdcDest = NativeMethods.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = NativeMethods.CreateCompatibleBitmap(hdcSrc, rect.Width, rect.Height); IntPtr hOld = NativeMethods.SelectObject(hdcDest, hBitmap); NativeMethods.BitBlt(hdcDest, 0, 0, rect.Width, rect.Height, hdcSrc, rect.X, rect.Y, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt); if (captureCursor) { Point cursorOffset = CaptureHelpers.ScreenToClient(rect.Location); try { using (CursorData cursorData = new CursorData()) { cursorData.DrawCursorToHandle(hdcDest, cursorOffset); } } catch (Exception e) { DebugHelper.WriteException(e, "Cursor capture failed."); } } NativeMethods.SelectObject(hdcDest, hOld); NativeMethods.DeleteDC(hdcDest); NativeMethods.ReleaseDC(handle, hdcSrc); Image img = Image.FromHbitmap(hBitmap); NativeMethods.DeleteObject(hBitmap); return(img); }
public static BitmapSource CaptureRectangleNative(IntPtr handle, Rect rect, bool captureCursor = false) { if (rect.Width == 0 || rect.Height == 0) { return(null); } IntPtr hdcSrc = NativeMethods.GetWindowDC(handle); IntPtr hdcDest = NativeMethods.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = NativeMethods.CreateCompatibleBitmap(hdcSrc, (int)rect.Width, (int)rect.Height); IntPtr hOld = NativeMethods.SelectObject(hdcDest, hBitmap); NativeMethods.BitBlt(hdcDest, 0, 0, (int)rect.Width, (int)rect.Height, hdcSrc, (int)rect.X, (int)rect.Y, System.Drawing.CopyPixelOperation.SourceCopy | System.Drawing.CopyPixelOperation.CaptureBlt); if (captureCursor) { Point cursorOffset = CaptureHelper.ScreenToClient(rect.Location); try { using (CursorData cursorData = new CursorData()) { cursorData.DrawCursorToHandle(hdcDest, cursorOffset); } } catch (Exception e) { DebugHelper.WriteException(e, "Cursor capture failed."); } } NativeMethods.SelectObject(hdcDest, hOld); NativeMethods.DeleteDC(hdcDest); NativeMethods.ReleaseDC(handle, hdcSrc); BitmapSource bmp = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); NativeMethods.DeleteObject(hBitmap); return(bmp); }
public Image CaptureWindowTransparent(IntPtr handle) { if (handle.ToInt32() > 0) { Rectangle rect = CaptureHelpers.GetWindowRectangle(handle); if (CaptureShadow && !NativeMethods.IsZoomed(handle) && NativeMethods.IsDWMEnabled()) { rect.Inflate(ShadowOffset, ShadowOffset); Rectangle intersectBounds = Screen.AllScreens.Select(x => x.Bounds).Where(x => x.IntersectsWith(rect)).Combine(); rect.Intersect(intersectBounds); } Bitmap whiteBackground = null, blackBackground = null, whiteBackground2 = null; CursorData cursorData = null; bool isTransparent = false, isTaskbarHide = false; try { if (AutoHideTaskbar) { isTaskbarHide = NativeMethods.SetTaskbarVisibilityIfIntersect(false, rect); } if (CaptureCursor) { try { cursorData = new CursorData(); } catch (Exception e) { DebugHelper.WriteException(e, "Cursor capture failed."); } } using (Form form = new Form()) { form.BackColor = Color.White; form.FormBorderStyle = FormBorderStyle.None; form.ShowInTaskbar = false; form.StartPosition = FormStartPosition.Manual; form.Location = new Point(rect.X, rect.Y); form.Size = new Size(rect.Width, rect.Height); NativeMethods.ShowWindow(form.Handle, (int)WindowShowStyle.ShowNoActivate); if (!NativeMethods.SetWindowPos(form.Handle, handle, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE)) { form.Close(); DebugHelper.WriteLine("Transparent capture failed. Reason: SetWindowPos fail."); return(CaptureWindow(handle)); } Thread.Sleep(10); Application.DoEvents(); whiteBackground = (Bitmap)CaptureRectangleNative(rect); form.BackColor = Color.Black; Application.DoEvents(); blackBackground = (Bitmap)CaptureRectangleNative(rect); form.BackColor = Color.White; Application.DoEvents(); whiteBackground2 = (Bitmap)CaptureRectangleNative(rect); form.Close(); } Bitmap transparentImage; if (ImageHelpers.IsImagesEqual(whiteBackground, whiteBackground2)) { transparentImage = CreateTransparentImage(whiteBackground, blackBackground); isTransparent = true; } else { DebugHelper.WriteLine("Transparent capture failed. Reason: Images not equal."); transparentImage = whiteBackground2; } if (cursorData != null) { cursorData.DrawCursor(transparentImage, rect.Location); } if (isTransparent) { transparentImage = ImageHelpers.AutoCropImage(transparentImage); if (!CaptureShadow) { TrimShadow(transparentImage); } } return(transparentImage); } finally { if (isTaskbarHide) { NativeMethods.SetTaskbarVisibility(true); } if (whiteBackground != null) { whiteBackground.Dispose(); } if (blackBackground != null) { blackBackground.Dispose(); } if (isTransparent && whiteBackground2 != null) { whiteBackground2.Dispose(); } } } return(null); }
public MyListCursor(int maxSize) { _maxSize = maxSize; _myArr = new CursorData[_maxSize]; InitList(); }
protected TaskMetadata ExecuteRegionCapture(TaskSettings taskSettings) { RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Bitmap canvas; Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; if (taskSettings.CaptureSettings.SurfaceOptions.ActiveMonitorMode) { canvas = screenshot.CaptureActiveMonitor(); } else { canvas = screenshot.CaptureFullscreen(); } CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, canvas)) { if (cursorData != null && cursorData.IsVisible) { form.AddCursor(cursorData.ToBitmap(), form.PointToClient(cursorData.DrawPosition)); } form.ShowDialog(); Bitmap result = form.GetResultImage(); if (result != null) { TaskMetadata metadata = new TaskMetadata(result); if (form.IsImageModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region) { WindowInfo windowInfo = form.GetWindowInfo(); metadata.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; return(metadata); } } return(null); }
public static ImageCapture CaptureWindowTransparent(IntPtr handle) { if (handle.ToInt32() > 0) { Rect rect = CaptureHelper.GetWindowRectangle(handle); if (CaptureShadow && !NativeMethods.IsZoomed(handle) && NativeMethods.IsDWMEnabled()) { rect.Inflate(ShadowOffset, ShadowOffset); rect.Intersect(CaptureHelper.GetScreenBounds()); } BitmapSource whiteBackground = null, blackBackground = null, whiteBackground2 = null; CursorData cursor = null; bool isTransparent = false, isTaskbarHide = false; try { if (AutoHideTaskbar) { isTaskbarHide = NativeMethods.SetTaskbarVisibilityIfIntersect(false, rect); } if (CaptureCursor) { try { cursor = new CursorData(); } catch (Exception e) { DebugHelper.WriteException(e, "Cursor capture failed."); } } Window form = new Window(); form.Background = new SolidColorBrush(Colors.White); form.WindowStyle = WindowStyle.None; form.ShowInTaskbar = false; form.WindowStartupLocation = WindowStartupLocation.Manual; form.Left = rect.Left; form.Top = rect.Top; form.RenderSize = new Size(rect.Width, rect.Height); IntPtr formHandle = new WindowInteropHelper(form).Handle; NativeMethods.ShowWindow(formHandle, (int)WindowShowStyle.ShowNoActivate); if (!NativeMethods.SetWindowPos(formHandle, handle, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE)) { form.Close(); DebugHelper.WriteLine("Transparent capture failed. Reason: SetWindowPos fail."); return(CaptureWindow(handle)); } Thread.Sleep(10); form.UpdateLayout(); whiteBackground = CaptureRectangleNative(rect); form.Background = new SolidColorBrush(Colors.Black); form.UpdateLayout(); blackBackground = CaptureRectangleNative(rect); form.Background = new SolidColorBrush(Colors.White); form.UpdateLayout(); whiteBackground2 = CaptureRectangleNative(rect); form.Close(); return(new ImageCapture(whiteBackground2)); // TODO: Transparent window - with WPF alternative to UnsafeBitmap /* * BitmapSource transparentImage; * * if (whiteBackground.IsEqual(whiteBackground2)) * { * transparentImage = CreateTransparentImage(whiteBackground, blackBackground); * isTransparent = true; * } * else * { * DebugHelper.WriteLine("Transparent capture failed. Reason: Images not equal."); * transparentImage = whiteBackground2; * } * * if (cursor != null && cursor.IsVisible) * { * Point cursorOffset = CaptureHelper.ScreenToClient(rect.Location); * cursor.DrawCursorToImage(transparentImage, cursorOffset); * } * * if (isTransparent) * { * transparentImage = TrimTransparent(transparentImage); * * if (!CaptureShadow) * { * TrimShadow(transparentImage); * } * } * * return transparentImage; */ } finally { if (isTaskbarHide) { NativeMethods.SetTaskbarVisibility(true); } if (cursor != null) { cursor.Dispose(); } } } return(null); }
private void CursorUpdate(CursorData data) { if ((data != null) && (data.Image != null)) { // Unpack the data. // Image cursor; int cursorX, cursorY; Utils.UnpackCursorCaptureData(data, out cursor, out cursorX, out cursorY); _viewerSession.Cursor = cursor; _viewerSession.CursorX = cursorX; _viewerSession.CursorY = cursorY; UpdateScreenImage(); } }