本文整理匯總了C#中MonoMac.AppKit.NSView.RespondsToSelector方法的典型用法代碼示例。如果您正苦於以下問題:C# NSView.RespondsToSelector方法的具體用法?C# NSView.RespondsToSelector怎麽用?C# NSView.RespondsToSelector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoMac.AppKit.NSView
的用法示例。
在下文中一共展示了NSView.RespondsToSelector方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Colourize
public static void Colourize(NSView control, Color color, Action drawAction)
{
var size = control.Frame.Size;
if (size.Width <= 0 || size.Height <= 0)
return;
var image = new NSImage(size);
image.LockFocusFlipped(control.IsFlipped);
drawAction();
image.UnlockFocus();
var ciImage = CIImage.FromCGImage(image.CGImage);
SD.SizeF realSize;
if (control.RespondsToSelector(selConvertSizeToBacking))
realSize = control.ConvertSizeToBacking(size);
else
realSize = control.ConvertSizeToBase(size);
if (control.IsFlipped)
{
var affineTransform = new NSAffineTransform();
affineTransform.Translate(0, realSize.Height);
affineTransform.Scale(1, -1);
var filter1 = new CIAffineTransform();
filter1.Image = ciImage;
filter1.SetValueForKey(affineTransform, CIInputTransform);
ciImage = filter1.ValueForKey(CIOutputImage) as CIImage;
}
var filter2 = new CIColorControls();
filter2.SetDefaults();
filter2.Image = ciImage;
filter2.Saturation = 0.0f;
ciImage = filter2.ValueForKey(CIOutputImage) as CIImage;
var filter3 = new CIColorMatrix();
filter3.SetDefaults();
filter3.Image = ciImage;
filter3.RVector = new CIVector(0, color.R, 0);
filter3.GVector = new CIVector(color.G, 0, 0);
filter3.BVector = new CIVector(0, 0, color.B);
ciImage = filter3.ValueForKey(CIOutputImage) as CIImage;
ciImage.Draw(new SD.RectangleF(SD.PointF.Empty, size), new SD.RectangleF(SD.PointF.Empty, realSize), NSCompositingOperation.SourceOver, 1);
}
示例2: Colourize
public static void Colourize(NSView control, Color color, Action drawAction)
{
var size = control.Frame.Size;
if (size.Width <= 0 || size.Height <= 0)
return;
var image = new NSImage(size);
image.LockFocusFlipped(!control.IsFlipped);
drawAction();
image.UnlockFocus();
var ciImage = CIImage.FromCGImage(image.CGImage);
CGSize realSize;
if (control.RespondsToSelector(selConvertSizeToBacking))
realSize = control.ConvertSizeToBacking(size);
else
realSize = control.ConvertSizeToBase(size);
var filter2 = new CIColorControls();
filter2.SetDefaults();
filter2.Image = ciImage;
filter2.Saturation = 0.0f;
ciImage = (CIImage)filter2.ValueForKey(CIOutputImage);
var filter3 = new CIColorMatrix();
filter3.SetDefaults();
filter3.Image = ciImage;
filter3.RVector = new CIVector(0, color.R, 0);
filter3.GVector = new CIVector(color.G, 0, 0);
filter3.BVector = new CIVector(0, 0, color.B);
ciImage = (CIImage)filter3.ValueForKey(CIOutputImage);
// create separate context so we can force using the software renderer, which is more than fast enough for this
var ciContext = CIContext.FromContext(NSGraphicsContext.CurrentContext.GraphicsPort, new CIContextOptions { UseSoftwareRenderer = true });
ciContext.DrawImage(ciImage, new CGRect(CGPoint.Empty, size), new CGRect(CGPoint.Empty, realSize));
}