本文整理汇总了C#中MObjc.NSObject.Call方法的典型用法代码示例。如果您正苦于以下问题:C# NSObject.Call方法的具体用法?C# NSObject.Call怎么用?C# NSObject.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MObjc.NSObject
的用法示例。
在下文中一共展示了NSObject.Call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayArg
public void ArrayArg()
{
NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
Class nsData = new Class("NSData");
long bytes = DoGetMemory();
for (int j = 1; j < 100; ++j)
{
for (int i = 0; i < NumIterations/100; ++i)
{
byte[] data = new byte[]{2, 5, 6, 3};
NSObject d = new NSObject(nsData.Call("alloc"));
NSObject e = (NSObject) d.Call("initWithBytes:length:", data, data.Length);
e.release();
}
GC.Collect();
}
pool.release();
GC.Collect();
GC.WaitForPendingFinalizers();
long delta = DoGetMemory() - bytes;
if (delta/NumIterations > 4)
Assert.Fail("ArrayArg used {0}K of memory ({1} bytes per iteration)!", delta/1024, delta/NumIterations);
}
示例2: setDefaultColor
public void setDefaultColor(NSObject sender)
{
NSColor color = sender.Call("color").To<NSColor>();
NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
NSData data = NSArchiver.archivedDataWithRootObject(color);
defaults.setObject_forKey(data, NSString.Create("text default color"));
Broadcaster.Invoke("text default color changed", null);
}
示例3: Dispatch
public void Dispatch(NSObject sender)
{
int i = sender.Call("tag").To<int>();
TextContextItem command = m_entries[i].Command;
string result = command.Handler(m_selection);
if (result != m_selection)
{
var range = NSValue.valueWithRange(m_range);
var newText = NSString.Create(result);
var undoText = NSString.Create(command.UndoText ?? command.Name);
NSArray args = NSArray.Create(range, newText, undoText);
m_view.Call("replaceSelection:", args);
}
m_entries.Clear(); // this has references to objects which we may want to GC
m_view = null;
}
示例4: changeAttributes
// Sent by NSFontManager up the responder chain when font attributes are changed via the font panel.
public void changeAttributes(NSObject sender)
{
m_attributes = sender.Call("convertAttributes:", m_attributes).To<NSDictionary>().Retain();
NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
NSData data = NSArchiver.archivedDataWithRootObject(m_attributes);
defaults.setObject_forKey(data, NSString.Create(m_styleName + " font attributes"));
DoUpdateButtonTitle(m_styleName);
Broadcaster.Invoke(m_styleName + " font changed-pre", true);
Broadcaster.Invoke(m_styleName + " font changed", true);
}
示例5: DoGetSubstrings
private List<NSRange> DoGetSubstrings(NSObject inStr, string inSubstr)
{
var ranges = new List<NSRange>();
var str = (inStr.isKindOfClass(NSString.Class) ? inStr : inStr.Call("string")).To<NSString>();
var substr = NSString.Create(inSubstr);
NSRange within = new NSRange(0, (int) str.length());
while (within.location < str.length())
{
NSRange range = str.rangeOfString_options_range(substr, Enums.NSLiteralSearch, within);
if (range.length == 0)
break;
within = new NSRange(range.location + range.length, (int) (str.length() - (range.location + range.length)));
ranges.Add(range);
}
return ranges;
}
示例6: handleContextItem
public void handleContextItem(NSObject item)
{
int i = item.Call("tag").To<int>();
m_items[i].Handler();
}
示例7: validateUserInterfaceItem
public bool validateUserInterfaceItem(NSObject item)
{
Selector sel = (Selector) item.Call("action");
bool valid = false;
if (sel.Name == "textHandler:")
{
int tag = (int) item.Call("tag");
var handler = m_boss.Get<IMenuHandler>();
MenuState state = handler.GetState(tag);
valid = (state & MenuState.Enabled) == MenuState.Enabled;
item.Call("setState:", (state & MenuState.Checked) == MenuState.Checked ? 1 : 0);
}
else if (sel.Name == "shiftLeft:" || sel.Name == "shiftRight:")
{
NSRange range = m_textView.Value.selectedRange();
valid = range.length > 0 && m_textView.Value.isEditable();
}
else if (sel.Name == "lookUpInDict:")
{
NSRange range = m_textView.Value.selectedRange();
NSString text = m_textView.Value.textStorage().string_().substringWithRange(range);
valid = NSApplication.sharedApplication().Call("canLookupInDictionary:", text).To<bool>();
}
else if (sel.Name == "showSpaces:")
{
if (StylesWhitespace)
{
Boss boss = ObjectModel.Create("Stylers");
var white = boss.Get<IWhitespace>();
Unused.Value = item.Call("setTitle:", white.ShowSpaces ? NSString.Create("Hide Spaces") : NSString.Create("Show Spaces"));
valid = true;
}
}
else if (sel.Name == "showTabs:")
{
if (StylesWhitespace)
{
Boss boss = ObjectModel.Create("Stylers");
var white = boss.Get<IWhitespace>();
Unused.Value = item.Call("setTitle:", white.ShowTabs ? NSString.Create("Hide Tabs") : NSString.Create("Show Tabs"));
valid = true;
}
}
else if (sel.Name == "toggleComment:")
{
valid = m_language != null && m_language.LineComment != null;
}
else if (sel.Name == "toggleWordWrap:")
{
Unused.Value = item.Call("setTitle:", m_wordWrap ? NSString.Create("Don't Wrap Lines") : NSString.Create("Wrap Lines"));
valid = true;
}
else if (sel.Name == "dirHandler:")
{
if (Path != null)
{
NSWindow window = DoGetDirEditor();
if (window != null)
valid = window.windowController().Call("validateUserInterfaceItem:", item).To<bool>();
else
valid = false;
}
}
else if (respondsToSelector(sel))
{
valid = true;
}
else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
{
valid = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", item).To<bool>();
}
return valid;
}
示例8: validateMenuItem
public bool validateMenuItem(NSObject menuItem)
{
bool enabled = false;
#if DEBUG
Selector selector = (Selector) menuItem.Call("action");
if (selector.Name == "memoryTest:")
{
NSObject text;
lock (m_lock)
{
if (m_checkingMemory)
text = (NSObject) new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("Stop Memory Test"));
else
text = (NSObject) new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("Start Memory Test"));
}
menuItem.Call("setTitle:", text);
enabled = true;
}
else if (respondsToSelector(selector))
{
return true;
}
#endif
return enabled;
}
示例9: validateUserInterfaceItem
public bool validateUserInterfaceItem(NSObject item)
{
Selector sel = (Selector) item.Call("action");
bool valid = false;
if (sel.Name == "removeDirs:")
{
NSIndexSet selections = m_dirsTable.Value.selectedRowIndexes();
valid = selections.count() > 0;
}
else if (respondsToSelector(sel))
{
valid = true;
}
else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
{
valid = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", item).To<bool>();
}
return valid;
}
示例10: validateUserInterfaceItem
public bool validateUserInterfaceItem(NSObject sender)
{
bool enabled = false;
Selector sel = (Selector) sender.Call("action");
if (sel.Name == "openWithFinder:" || sel.Name == "showInFinder:")
{
enabled = m_table.numberOfSelectedRows() > 0;
}
else if (respondsToSelector(sel))
{
enabled = true;
}
else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
{
enabled = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", sender).To<bool>();
}
return enabled;
}
示例11: Validate
public bool Validate(NSObject sender)
{
int i = sender.Call("tag").To<int>();
sender.Call("setState:", m_entries[i].Command.State);
return m_entries[i].Command.Handler != null;
}
示例12: DoAnimate
private void DoAnimate(IntPtr subview, NSRect frame)
{
NSObject view = new NSObject(subview);
view.Call("animator").Call("setFrame:", frame);
}
示例13: changeLayout
// Action method to change layout style.
public void changeLayout(NSObject sender)
{
m_layout = (Layout) (int) sender.Call("selectedTag");
DoLayout();
}
示例14: validateUserInterfaceItem
public bool validateUserInterfaceItem(NSObject sender)
{
bool enabled = false;
Selector sel = (Selector) sender.Call("action");
if (sel.Name == "dirHandler:")
{
int tag = (int) sender.Call("tag");
var handler = m_boss.Get<IMenuHandler>();
MenuState state = handler.GetState(tag);
enabled = (state & MenuState.Enabled) == MenuState.Enabled;
if (sender.respondsToSelector("setState:"))
sender.Call("setState:", (state & MenuState.Checked) == MenuState.Checked ? 1 : 0);
if (enabled && tag == 50 && sender.isMemberOfClass(NSMenuItem.Class))
{
Unused.Value = sender.Call("setTitle:", NSString.Create("Build " + m_name));
}
else if (enabled && tag == 1000 && sender.isMemberOfClass(NSMenuItem.Class))
{
Unused.Value = sender.Call("setTitle:", NSString.Create(m_name + " Preferences"));
}
}
else if (sel.Name == "targetChanged:")
{
enabled = m_builder != null && m_builder.CanBuild;
}
else if (sel.Name == "renameItem:")
{
NSIndexSet selections = m_table.selectedRowIndexes();
enabled = selections.count() == 1;
}
else if (sel.Name == "duplicate:")
{
NSIndexSet selections = m_table.selectedRowIndexes();
enabled = selections.count() > 0 && m_table.editedRow() < 0; // cocoa crashes if we do a duplicate while editing...
}
else if (respondsToSelector(sel))
{
enabled = true;
}
else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
{
enabled = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", sender).To<bool>();
}
return enabled;
}
示例15: DoNormalizeString
// Convert an NSString or an NSAttributedString to our internal (unix) endian.
private NSObject DoNormalizeString(NSObject str)
{
var result = str.Call("mutableCopy").To<NSObject>(); // use a dynamic call because NSAttributedString and NSString don't share a common base class
var replacement = NSString.Create("\n");
foreach (string endian in new string[]{"\r\n", "\r"})
{
List<NSRange> ranges = DoGetSubstrings(result, endian);
foreach (NSRange range in ranges)
{
result.Call("replaceCharactersInRange:withString:", range, replacement);
}
}
return result;
}