Rectangle GetPreviewWindowRect() { var parentWindow = VisualTreeHelperEx.FindAncestorByType <Window>(this); var relativePt = PreviewTarget.TranslatePoint(new System.Windows.Point(0, 0), parentWindow); var rect = new RectangleF((float)relativePt.X, (float)relativePt.Y, (float)PreviewTarget.ActualWidth, (float)PreviewTarget.ActualHeight); // Maintain Aspect Ratio if (_webcamModel.WebcamCapture != null) { float w = _webcamModel.WebcamCapture.Width; float h = _webcamModel.WebcamCapture.Height; var imgWbyH = w / h; var frameWbyH = rect.Width / rect.Height; if (imgWbyH > frameWbyH) { var newH = rect.Width / imgWbyH; rect.Y += (rect.Height - newH) / 2; rect.Height = newH; } else { var newW = rect.Height * imgWbyH; rect.X += (rect.Width - newW) / 2; rect.Width = newW; } } return(rect.ApplyDpi()); }
Rectangle GetPreviewWindowRect() { var camControl = GetWebCamControl(); var rect = new RectangleF(5, 40, (float)camControl.ActualWidth, (float)camControl.ActualHeight); return(rect.ApplyDpi()); }
Rectangle GetPreviewWindowRect() { var parentWindow = VisualTreeHelperEx.FindAncestorByType <Window>(this); var relativePt = PreviewTarget.TranslatePoint(new System.Windows.Point(0, 0), parentWindow); var rect = new RectangleF((float)relativePt.X, (float)relativePt.Y, (float)PreviewTarget.ActualWidth, (float)PreviewTarget.ActualHeight); return(rect.ApplyDpi()); }
Rectangle GetPreviewWindowRect() { var parentWindow = VisualTreeHelperEx.FindAncestorByType <Window>(this); var relativePt = PreviewGrid.TranslatePoint(new System.Windows.Point(0, 0), parentWindow); var position = _reactor.Location.Value; var size = _reactor.Size.Value; var rect = new RectangleF((float)(relativePt.X + position.X), (float)(relativePt.Y + position.Y), (float)(size.Width), (float)(size.Height)); return(rect.ApplyDpi()); }