示例#1
0
 private static void ApplyMagnification(uImageControl image, double magnificationValue)
 {
     if (image.part_µImage != null)
     {
         ScaleTransform obj = (ScaleTransform)image.part_µImage.LayoutTransform;
         obj.ScaleX = obj.ScaleY = magnificationValue;
         RenderOptions.SetBitmapScalingMode(image.part_µImage, BitmapScalingMode.HighQuality);                 //ToDo: depends on zoom or external settings
         image.part_µZoom.Text = $"{magnificationValue*100:N0}%";
     }
     if (image.part_µROI != null)
     {
         ScaleTransform obj2 = (ScaleTransform)image.part_µROI.LayoutTransform;
         obj2.ScaleX = magnificationValue;
         obj2.ScaleY = magnificationValue;
     }
 }
示例#2
0
        //https://docs.microsoft.com/en-us/dotnet/api/system.windows.dependencypropertychangedeventargs?view=netcore-3.1
        private static void OnGetLastEventDataChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            uImageControl imageControl = (uImageControl)obj;

            ROIDescriptor.LastEventData lastEventData = (ROIDescriptor.LastEventData)args.NewValue;
            ROIDescriptor.LastEventData other         = (ROIDescriptor.LastEventData)args.OldValue;
            if (lastEventData.type == EventType.Draw)
            {
                ROIDescriptor lastROIDescriptor     = imageControl._lastROIDescriptor;
                ROIDescriptor previousROIDescriptor = imageControl.GetROIDescriptor();
                if (!lastEventData.IsChanged(other) || !previousROIDescriptor.IsChanged(lastROIDescriptor))
                {
                    imageControl._lastROIDescriptor = previousROIDescriptor;
                    imageControl.OnROIValueChanged(new ROIValueChangedEventArgs(lastEventData, lastROIDescriptor, previousROIDescriptor));
                }
            }
        }