Это мой первый пост здесь, на этом приветственном сайте.
Я опытный пользователь C #, .Net и Mono, но Noob в MonoMac,
Я пытаюсь написать приложение, которое получает папку в NSView и использует свой путь для работы с файлами внутри папки ...
Платформа MonoMac не реализовала draggingEntered:, draggingUpdated:, draggingExited:, prepareForDragOperation:, performDragOperation:, concludeDragOperation: and draggingEnded:
Поэтому я попытался реализовать их самостоятельно:
[Register("TargetView")]
public class TargetView:NSView
{
private static IntPtr selDraggingEntered = Selector.GetHandle ("draggingEntered:");
private static IntPtr selDraggingUpdated = Selector.GetHandle ("draggingUpdated:");
private static IntPtr selDraggingExited = Selector.GetHandle ("draggingExited:");
private static IntPtr selPrepareForDragOperation = Selector.GetHandle ("prepareForDragOperation:");
private static IntPtr selPerformDragOperation = Selector.GetHandle ("performDragOperation:");
private static IntPtr selConcludeDragOperation = Selector.GetHandle ("concludeDragOperation:");
private static IntPtr selDraggingEnded = Selector.GetHandle ("draggingEnded:");
public TargetView():base(){
}
public TargetView(NSCoder coder):base(coder){
}
public TargetView(NSObjectFlag t):base(t){
}
public TargetView(IntPtr handle):base(handle){
}
public TargetView(RectangleF frameRect):base(frameRect){
}
[Export ("draggingEntered:")]
public virtual NSDragOperation DraggingEntered (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
return (NSDragOperation)Messaging.int_objc_msgSend_int (base.Handle, TargetView.selDraggingEntered, (int)sender.DraggingSourceOperationMask);
}
return (NSDragOperation)Messaging.int_objc_msgSendSuper_int (base.Handle, TargetView.selDraggingEntered, (int)sender.DraggingSourceOperationMask);
}
[Export ("draggingUpdated:")]
public virtual NSDragOperation DraggingUpdated (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
return (NSDragOperation)Messaging.int_objc_msgSend_int (base.Handle, TargetView.selDraggingUpdated, (int)sender.DraggingSourceOperationMask);
}
return (NSDragOperation)Messaging.int_objc_msgSendSuper_int (base.Handle, TargetView.selDraggingUpdated, (int)sender.DraggingSourceOperationMask);
}
[Export ("draggingExited:")]
public virtual void DraggingExited (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
Messaging.void_objc_msgSend_int (base.Handle, TargetView.selDraggingExited, (int)sender.DraggingSourceOperationMask);
}
Messaging.void_objc_msgSendSuper_int (base.Handle, TargetView.selDraggingExited, (int)sender.DraggingSourceOperationMask);
}
[Export ("prepareForDragOperation:")]
public virtual bool PrepareForDragOperation (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
return Messaging.bool_objc_msgSend_int (base.Handle, TargetView.selPrepareForDragOperation, (int)sender.DraggingSourceOperationMask);
}
return Messaging.bool_objc_msgSendSuper_int (base.Handle, TargetView.selPrepareForDragOperation, (int)sender.DraggingSourceOperationMask);
}
[Export ("performDragOperation:")]
public virtual bool PerformDragOperation (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
return Messaging.bool_objc_msgSend_int (base.Handle, TargetView.selPerformDragOperation, (int)sender.DraggingSourceOperationMask);
}
return Messaging.bool_objc_msgSendSuper_int (base.Handle, TargetView.selPerformDragOperation, (int)sender.DraggingSourceOperationMask);
}
[Export ("concludeDragOperation:")]
public virtual void ConcludeDragOperation (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
Messaging.void_objc_msgSend_int (base.Handle, TargetView.selConcludeDragOperation, (int)sender.DraggingSourceOperationMask);
}
Messaging.void_objc_msgSendSuper_int (base.Handle, TargetView.selConcludeDragOperation, (int)sender.DraggingSourceOperationMask);
}
[Export ("draggingEnded:")]
public virtual void DraggingEnded (NSDraggingInfo sender)
{
if (sender == null)
{
throw new ArgumentNullException ("sender");
}
if (this.IsDirectBinding)
{
Messaging.void_objc_msgSend_int (base.Handle, TargetView.selDraggingEnded, (int)sender.DraggingSourceOperationMask);
}
Messaging.void_objc_msgSendSuper_int (base.Handle, TargetView.selDraggingEnded, (int)sender.DraggingSourceOperationMask);
}
}
Но методы не вызываются!
Я также пытался RegisterForDraggedTypes
, но я понятия не имею, что передать в массив строк как тип!
Пожалуйста, помогите мне разобраться. Я искал в Google для 48 сейчас!