本文整理汇总了C#中MonoMac.Foundation.NSString类的典型用法代码示例。如果您正苦于以下问题:C# NSString类的具体用法?C# NSString怎么用?C# NSString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSString类属于MonoMac.Foundation命名空间,在下文中一共展示了NSString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EtoLoadNibNamed
static bool EtoLoadNibNamed (IntPtr self, IntPtr sel, IntPtr filePath, IntPtr owner)
{
var str = new NSString (filePath);
if (str.Length == 0)
return true;
return Messaging.bool_objc_msgSend_IntPtr_IntPtr (self, selEtoLoadNibNamed, filePath, owner);
}
示例2: BestDepth
public static NSWindowDepth BestDepth (NSString colorspace, int bitsPerSample, int bitsPerPixel, bool planar, ref bool exactMatch)
{
if (colorspace == null)
throw new ArgumentNullException ("colorpsace");
return NSBestDepth (colorspace.Handle, bitsPerSample, bitsPerPixel, planar, ref exactMatch);
}
示例3: SetFont
public void SetFont (string fontName)
{
if (fontName == null)
throw new ArgumentNullException ("fontName");
using (var nss = new NSString (fontName))
_Font = nss.Handle;
}
示例4: SetItem
public void SetItem(IListItem value)
{
var imgitem = value as IImageListItem;
if (imgitem != null && imgitem.Image != null)
Image = ((IImageSource)imgitem.Image.Handler).GetImage();
Text = (NSString)value.Text;
}
示例5: GetProxiesForAutoConfigurationScript
public static CFProxy[] GetProxiesForAutoConfigurationScript(NSString proxyAutoConfigurationScript, NSUrl targetURL)
{
if (proxyAutoConfigurationScript == null)
throw new ArgumentNullException ("proxyAutoConfigurationScript");
if (targetURL == null)
throw new ArgumentNullException ("targetURL");
NSArray array = CopyProxiesForAutoConfigurationScript (proxyAutoConfigurationScript, targetURL);
if (array == null)
return null;
NSDictionary[] dictionaries = NSArray.ArrayFromHandle<NSDictionary> (array.Handle);
array.Dispose ();
if (dictionaries == null)
return null;
CFProxy[] proxies = new CFProxy [dictionaries.Length];
for (int i = 0; i < dictionaries.Length; i++)
proxies[i] = new CFProxy (dictionaries[i]);
return proxies;
}
示例6: SparkleMacWatcher
public SparkleMacWatcher (string path)
{
Path = path;
m_callback = DoCallback;
NSString [] s = new NSString [1];
s [0] = new NSString (path);
NSArray path_p = NSArray.FromNSObjects (s);
m_stream = FSEventStreamCreate ( // note that the stream will always be valid
IntPtr.Zero, // allocator
m_callback, // callback
IntPtr.Zero, // context
path_p.Handle, // pathsToWatch
kFSEventStreamEventIdSinceNow, // sinceWhen
2, // latency (in seconds)
FSEventStreamCreateFlags.kFSEventStreamCreateFlagNone); // flags
FSEventStreamScheduleWithRunLoop (
m_stream, // streamRef
CFRunLoopGetMain(), // runLoop
kCFRunLoopDefaultMode); // runLoopMode
bool started = FSEventStreamStart (m_stream);
if (!started) {
GC.SuppressFinalize (this);
throw new InvalidOperationException ("Failed to start FSEvent stream for " + path);
}
}
示例7: ObjectForKey
public NSObject this [NSString key] {
get {
return ObjectForKey (key);
}
set {
SetObjectForKey (value, key);
}
}
示例8: CFException
public CFException(string description, NSString domain, int code, string failureReason, string recoverySuggestion)
: base(description)
{
Code = code;
Domain = domain;
FailureReason = failureReason;
RecoverySuggestion = recoverySuggestion;
}
示例9: CalculateSize
void CalculateSize ()
{
NSString str = new NSString (badgeNumber.ToString());
NSDictionary attibutedStringAttributed = NSDictionary.FromObjectAndKey(Font, NSAttributedString.FontAttributeName);
numberSize = str.StringSize (attibutedStringAttributed);
Frame = new RectangleF (Frame.Location, new SizeF (Math.Max (numberSize.Width, height), height));
}
示例10: NeedsDisplayForKey
static bool NeedsDisplayForKey (NSString key)
{
switch (key.ToString ()) {
case "clockColor":
return true;
default:
return CALayer.NeedsDisplayForKey (key);
}
}
示例11: GlobalGetClass
public static Class GlobalGetClass(string codedName)
{
if (codedName == null)
throw new ArgumentNullException ("codedName");
using (var nsname = new NSString (codedName))
return new Class (
MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (
class_ptr, selClassForClassName_, nsname.Handle));
}
示例12: OpenApplication
public static ProcessSerialNumber OpenApplication (ApplicationStartInfo application)
{
if (application == null)
throw new ArgumentNullException ("application");
if (string.IsNullOrEmpty (application.Application) || !System.IO.Directory.Exists (application.Application))
throw new ArgumentException ("Application is not valid");
var appParams = new LSApplicationParameters ();
if (application.NewInstance)
appParams.flags |= LSLaunchFlags.NewInstance;
if (application.Async)
appParams.flags |= LSLaunchFlags.Async;
NSArray argv = null;
if (application.Args != null && application.Args.Length > 0) {
var args = application.Args;
NSObject[] arr = new NSObject[args.Length];
for (int i = 0; i < args.Length; i++)
arr[i] = new NSString (args[i]);
argv = NSArray.FromNSObjects (arr);
appParams.argv = argv.Handle;
}
NSDictionary dict = null;
if (application.Environment.Count > 0) {
dict = new NSMutableDictionary ();
foreach (var kvp in application.Environment)
dict.SetValueForKey (new NSString (kvp.Value), new NSString (kvp.Key));
appParams.environment = dict.Handle;
}
var cfUrl = global::MonoMac.CoreFoundation.CFUrl.FromFile (application.Application);
ProcessSerialNumber psn;
try {
appParams.application = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (FSRef)));
if (!CoreFoundation.CFURLGetFSRef (cfUrl.Handle, appParams.application))
throw new Exception ("Could not create FSRef from CFUrl");
var status = LSOpenApplication (ref appParams, out psn);
if (status != OSStatus.Ok)
throw new Exception ("Failed to start process: " + ((int)status).ToString ());
} finally {
if (appParams.application != IntPtr.Zero)
Marshal.FreeHGlobal (appParams.application);
appParams.application = IntPtr.Zero;
if (dict != null)
dict.Dispose (); //also ensures the NSDictionary is kept alive for the params
if (argv != null)
argv.Dispose (); //also ensures the NSArray is kept alive for the params
}
return psn;
}
示例13: LibraryBrowserItem
public LibraryBrowserItem(LibraryBrowserEntity entity)
{
Entity = entity;
StringValue = new NSString(entity.Title);
// Create empty list of subitems
SubItems = new List<LibraryBrowserItem>();
foreach(LibraryBrowserEntity subEntity in entity.SubItems)
SubItems.Add(new LibraryBrowserItem(subEntity));
}
示例14: AddLoginItem
public static void AddLoginItem (string path)
{
if (path == null)
throw new ArgumentNullException ("path");
var nspath = new NSString (path);
MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (class_ptr, selAddLoginItem, nspath.Handle);
nspath.Dispose ();
}
示例15: CVPixelFormatDescription
static CVPixelFormatDescription ()
{
var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
if (handle == IntPtr.Zero)
return;
try {
NameKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatName");
ConstantKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatConstant");
CodecTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCodecType");
FourCCKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatFourCC");
PlanesKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatPlanes");
BlockWidthKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockWidth");
BlockHeightKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockHeight");
BitsPerBlockKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBitsPerBlock");
BlockHorizontalAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockHorizontalAlignment");
BlockVerticalAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockVerticalAlignment");
BlackBlockKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlackBlock");
HorizontalSubsamplingKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatHorizontalSubsampling");
VerticalSubsamplingKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatVerticalSubsampling");
OpenGLFormatKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLFormat");
OpenGLTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLType");
OpenGLInternalFormatKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLInternalFormat");
CGBitmapInfoKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGBitmapInfo");
QDCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatQDCompatibility");
CGBitmapContextCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGBitmapContextCompatibility");
CGImageCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGImageCompatibility");
OpenGLCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLCompatibility");
FillExtendedPixelsCallbackKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatFillExtendedPixelsCallback");
}
finally {
Dlfcn.dlclose (handle);
}
}