Exemplo n.º 1
0
        private static void OnBackgroundColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IBCanvasControl sender = d as IBCanvasControl;

            if (sender != null)
            {
                sender.glControl.MakeCurrent();
                GL.ClearColor(sender.BackgroundColor.R / 255.0f, sender.BackgroundColor.G / 255.0f, sender.BackgroundColor.B / 255.0f, 255);
                sender.glControl.Refresh();
            }
        }
Exemplo n.º 2
0
        public static IBCoord GetImageCoord(IBCanvasControl source, System.Windows.Point mousePos, double zoom)
        {
            if (source.TargetLayer == null)
            {
                return(new IBCoord());
            }

            PresentationSource s    = PresentationSource.FromVisual(source);
            double             dpiX = s.CompositionTarget.TransformToDevice.M11;
            double             dpiY = s.CompositionTarget.TransformToDevice.M22;

            double resultX = (source.camX - (source.glControl.Width / 2 - mousePos.X * dpiX)) / zoom;
            double resultY = (source.TargetLayer.imageData.actualSize.Height * zoom - source.camY - (source.glControl.Height / 2 - mousePos.Y * dpiY)) / zoom;

            resultY += source.TargetLayer.Rect.OffsetY * 2.0;

            return(new IBCoord(resultX, resultY));
        }