Esempio n. 1
0
        public SbtResult ExecuteCommand(OperationCode opCode, string inXML, out string outXML, int scannerID)
        {
            if (inXML == null)
            {
                throw new ArgumentNullException("inXML");
            }
            IntPtr outXMLValue = IntPtr.Zero;

            var nsinXML = NSString.CreateNative(inXML);

            SbtResult ret;

            ret = (SbtResult)global::ApiDefinitions.ZebraMessaging.UInt32_objc_msgSend_int_IntPtr_ref_IntPtr_int(this.Handle, Selector.GetHandle("sbtExecuteCommand:aInXML:aOutXML:forScanner:"), (int)opCode, nsinXML, ref outXMLValue, scannerID);
            NSString.ReleaseNative(nsinXML);

            outXML = NSString.FromHandle(outXMLValue);

            return(ret);
        }
Esempio n. 2
0
        public static string GetPreferredTag(string uti, string tagClass)
        {
            if (uti == null)
            {
                throw new ArgumentNullException("uti");
            }
            if (tagClass == null)
            {
                throw new ArgumentNullException("tagClass");
            }

            var a   = NSString.CreateNative(uti);
            var b   = NSString.CreateNative(tagClass);
            var ret = NSString.FromHandle(UTTypeCopyPreferredTagWithClass(a, b));

            NSString.ReleaseNative(a);
            NSString.ReleaseNative(b);
            return(ret);
        }
Esempio n. 3
0
        /// <summary>
        /// Obtem os IMEIs do aparelho.
        /// </summary>
        /// <remarks>Caso o aparelho tenha mais de um slot de chip, retorna mais de um EMEI.</remarks>
        /// <returns>Lista de IMEI</returns>
        public string[] ObtemImei()
        {
            string[] serial         = new string[1];
            uint     platformExpert = IOServiceGetMatchingService(0, IOServiceMatching("IOPlatformExpertDevice"));

            if (platformExpert != 0)
            {
                NSString key          = (NSString)"IOPlatformSerialNumber";
                IntPtr   serialNumber = IORegistryEntryCreateCFProperty(platformExpert, key.Handle, IntPtr.Zero, 0);
                if (serialNumber != IntPtr.Zero)
                {
                    serial[0] = NSString.FromHandle(serialNumber);
                }

                IOObjectRelease(platformExpert);
            }

            return(serial);
        }
Esempio n. 4
0
        public string GetIdentifier()
        {
            var serial         = string.Empty;
            var platformExpert = IOServiceGetMatchingService(0, IOServiceMatching("IOPlatformExpertDevice"));

            if (platformExpert != 0)
            {
                var key          = (NSString)"IOPlatformSerialNumber";
                var serialNumber = IORegistryEntryCreateCFProperty(platformExpert, key.Handle, IntPtr.Zero, 0);
                if (serialNumber != IntPtr.Zero)
                {
                    serial = NSString.FromHandle(serialNumber);
                }

                IOObjectRelease(platformExpert);
            }

            return(serial);
        }
Esempio n. 5
0
        public static string GetSerialNumber()
        {
            string serial         = string.Empty;
            uint   platformExpert = IOServiceGetMatchingService(0, IOServiceMatching("IOPlatformExpertDevice"));

            if (platformExpert != 0)
            {
                NSString key          = new NSString("IOPlatformSerialNumber");
                IntPtr   serialNumber = IORegistryEntryCreateCFProperty(platformExpert, key.Handle, IntPtr.Zero, 0);
                if (serialNumber != IntPtr.Zero)
                {
                    //serial = new NSString (serialNumber);
                    serial = NSString.FromHandle(serialNumber);
                }
                IOObjectRelease(platformExpert);
            }

            return(serial);
        }
Esempio n. 6
0
        public static Person GetPerson(string numberOrEmail)
        {
            IntPtr person;
            string formattedPhoneNumber = numberOrEmail;

            foreach (string code in countryCodes)
            {
                // Remove any country codes from the phone number so it can detect correctly.
                formattedPhoneNumber = formattedPhoneNumber.Replace(code, "");
            }
            person = GetPersonFromNumber(formattedPhoneNumber);
            if (person == IntPtr.Zero)
            {
                person = GetPersonFromEmail(numberOrEmail);
                if (person == IntPtr.Zero)
                {
                    return new Person()
                           {
                               name = numberOrEmail, picture = null
                           }
                }
                ;
            }
            Person result = new Person();

            result.name = NSString.FromHandle(GetNameFromPerson(person));
            if (string.IsNullOrEmpty(result.name.Trim())) // We don't need any blank names!
            {
                result.name = numberOrEmail;
            }
            IntPtr pictureSrc = GetPictureFromPerson(person);

            if (pictureSrc != IntPtr.Zero)
            {
                uint   pictureLength = GetPictureLengthFromPerson(person);
                byte[] picture       = new byte[pictureLength];
                Marshal.Copy(pictureSrc, picture, 0, (int)pictureLength);
                result.picture = picture;
            }
            return(result);
        }
    }
Esempio n. 7
0
            public static string GetBundleName()
            {
                IntPtr mainBundle = GetMainBundle();

                if (mainBundle == IntPtr.Zero)
                {
                    return(null);
                }
                IntPtr infoDictionary = GetInfoDictionary(mainBundle);

                if (infoDictionary == IntPtr.Zero)
                {
                    return(null);
                }
                IntPtr intPtr    = NSString.CreateNative("CFBundleName", false);
                IntPtr usrhandle = NSDictionary.ObjectForKey(infoDictionary, intPtr);

                NSString.ReleaseNative(intPtr);
                return(NSString.FromHandle(usrhandle));
            }
Esempio n. 8
0
        public static string PathForResource(string name, string ext)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (ext == null)
            {
                throw new ArgumentNullException("ext");
            }
            var nsname = NSString.CreateNative(name);
            var nsext  = NSString.CreateNative(ext);

            string ret;

            ret = NSString.FromHandle(MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(class_ptr, selPathForResourceOfType_Handle, nsname, nsext));
            NSString.ReleaseNative(nsname);
            NSString.ReleaseNative(nsext);

            return(ret);
        }
        public static string GetStringVariableWithName(this CleverTap This, string name, string defaultValue)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (defaultValue == null)
            {
                throw new ArgumentNullException("defaultValue");
            }
            var nsname         = NSString.CreateNative(name);
            var nsdefaultValue = NSString.CreateNative(defaultValue);

            string ret;

            ret = NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(This.Handle, Selector.GetHandle("getStringVariableWithName:defaultValue:"), nsname, nsdefaultValue));
            NSString.ReleaseNative(nsname);
            NSString.ReleaseNative(nsdefaultValue);

            return(ret);
        }
Esempio n. 10
0
        static string GetDeviceName()
        {
            var computerNameHandle = SCDynamicStoreCopyComputerName(IntPtr.Zero, IntPtr.Zero);

            if (computerNameHandle == IntPtr.Zero)
            {
                return(null);
            }

            try
            {
#pragma warning disable CS0618 // Type or member is obsolete
                return(NSString.FromHandle(computerNameHandle));

#pragma warning restore CS0618 // Type or member is obsolete
            }
            finally
            {
                CFRelease(computerNameHandle);
            }
        }
Esempio n. 11
0
        public static string GetStringForKey(string key, string resetValue)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (resetValue == null)
            {
                throw new ArgumentNullException("resetValue");
            }
            var nskey        = NSString.CreateNative(key);
            var nsresetValue = NSString.CreateNative(resetValue);

            string ret;

            ret = NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(class_ptr, Selector.GetHandle("getStringForKey:withResetValue:"), nskey, nsresetValue));
            NSString.ReleaseNative(nskey);
            NSString.ReleaseNative(nsresetValue);

            return(ret);
        }
Esempio n. 12
0
        public virtual string Hello(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            var nsname = new NSString(name);

            string ret;

            if (IsDirectBinding)
            {
                ret = NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, selHello_, nsname.Handle));
            }
            else
            {
                ret = NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, selHello_, nsname.Handle));
            }
            nsname.Dispose();

            return(ret);
        }
Esempio n. 13
0
        public virtual string GetProperty(PropertyType type, string param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            var nsparam = NSString.CreateNative(param);

            string ret;

            if (IsDirectBinding)
            {
                ret = NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_UInt32_IntPtr(this.Handle, Selector.GetHandle("getProperty:withParameter:"), (UInt32)type, nsparam));
            }
            else
            {
                ret = NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSendSuper_UInt32_IntPtr(this.SuperHandle, Selector.GetHandle("getProperty:withParameter:"), (UInt32)type, nsparam));
            }
            NSString.ReleaseNative(nsparam);

            return(ret);
        }
Esempio n. 14
0
        bool AcceptDragSource(NSDraggingInfo sender)
        {
            if (_dropOperation == null)
            {
                return(false);
            }
            try
            {
                // Check correct file type
                var pasteboard = sender.DraggingPasteboard;

                if (!pasteboard.Types.Contains(NSPasteboard.NSFilenamesType))
                {
                    return(false);
                }

                var data = pasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray;
                if (data == null || data.Count < 1)
                {
                    return(false);
                }

                var pathString = NSString.FromHandle(data.ValueAt(0));

                _droppedFile = AbsoluteFilePath.Parse(pathString);
                if (!File.Exists(_droppedFile.NativePath))
                {
                    _dropOperation.OnError.OnNext("Dragged file not found: " + _droppedFile.NativePath);
                    return(false);
                }

                return(_dropOperation.CanDrop(_droppedFile));
            }
            catch (Exception e)
            {
                _dropOperation.OnError.OnNext(e.Message);
            }
            return(false);
        }
        public static string GetRoleDescription(NSString role, NSString subrole)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            IntPtr subroleHandle;

            if (subrole == null)
            {
                subroleHandle = IntPtr.Zero;
            }
            else
            {
                subroleHandle = subrole.Handle;
            }

            IntPtr handle = NSAccessibilityRoleDescription(role.Handle, subroleHandle);

            return(NSString.FromHandle(handle));
        }
Esempio n. 16
0
        /// <summary>
        /// Process any drag operations initialized by the user to this <see cref="AppKit.TextKit.Formatter.SourceTextView"/>.
        /// If one or more files have dragged in, the contents of those files will be copied into the document at the
        /// current cursor location.
        /// </summary>
        /// <returns><c>true</c>, if drag operation was performed, <c>false</c> otherwise.</returns>
        /// <param name="sender">The caller that initiated the drag operation.</param>
        /// <remarks>
        /// See Apple's drag and drop docs for more details (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html)
        /// </remarks>
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            // Attempt to read filenames from pasteboard
            var plist = (NSArray)sender.DraggingPasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType);

            // Was a list of files returned from Finder?
            if (plist != null)
            {
                // Yes, process list
                for (uint n = 0; n < plist.Count; ++n)
                {
                    // Get the current file
                    var path     = NSString.FromHandle(plist.ValueAt(n));
                    var url      = NSUrl.FromString(path);
                    var contents = File.ReadAllText(path);

                    // Insert contents at cursor
                    NSRange range = SelectedRange;
                    TextStorage.BeginEditing();
                    Replace(range, contents);
                    TextStorage.EndEditing();

                    // Expand range to fully encompass new content and
                    // reformat
                    range = new NSRange((int)range.Location, contents.Length);
                    range = Formatter.FindLineBoundries(TextStorage.Value, range);
                    Formatter.HighlightSyntaxRegion(TextStorage.Value, range);
                }

                // Inform caller of success
                return(true);
            }
            else
            {
                // No, allow base class to handle
                return(base.PerformDragOperation(sender));
            }
        }
Esempio n. 17
0
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            Console.WriteLine("Drag Delegate received 'PerformDragOperation' sender: {0}", sender);

            //It seems that browserView does not send this message when it is an internal move.
            //It does all the work by sending a moveitems message to the datasource,
            // but I return false here just to be safe.

            NSObject obj = sender.DraggingSource;

            if (obj != null && obj.Equals(browserView))
            {
                Console.WriteLine("\tLet the image browser handle it.");
                return(false);
            }

            NSPasteboard pb   = sender.DraggingPasteboard;
            NSArray      data = null;

            //			if (pb.Types.Contains (NSPasteboard.NSUrlType))
            //				data = pb.GetPropertyListForType (NSPasteboard.NSUrlType) as NSArray;
            if (pb.Types.Contains(NSPasteboard.NSFilenamesType))
            {
                data = pb.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray;
            }
            if (data != null)
            {
                for (int i = 0; i < (int)data.Count; i++)
                {
                    string path = (string)NSString.FromHandle(data.ValueAt((uint)i));
                    Console.WriteLine("From pasteboard Item {0} = {1}", i, path);
                    ((BrowseData)browserView.DataSource).AddImages(
                        NSUrl.FromFilename(path), (int)browserView.GetIndexAtLocationOfDroppedItem());
                    browserView.ReloadData();
                }
            }
            return(true);
        }
        /// <summary>
        /// his delegate method is the only opportunity for accessing and loading
        /// the data representations offered in the drag item.The drop coordinator
        /// supports accessing the dropped items, updating the table view, and specifying
        /// optional animations.Local drags with one item go through the existing
        /// `tableView(_:moveRowAt:to:)` method on the data source.
        /// </summary>
        public void PerformDrop(UITableView tableView, IUITableViewDropCoordinator coordinator)
        {
            NSIndexPath indexPath, destinationIndexPath;

            // TODO: confirm this port is accurate
            if (coordinator.DestinationIndexPath != null)
            {
                indexPath            = coordinator.DestinationIndexPath;
                destinationIndexPath = indexPath;
            }
            else
            {
                // Get last index path of table view
                var section = tableView.NumberOfSections() - 1;
                var row     = tableView.NumberOfRowsInSection(section);
                destinationIndexPath = NSIndexPath.FromRowSection(row, section);
            }

            coordinator.Session.LoadObjects <NSString>((items) =>
            {
                // Consume drag items
                List <string> stringItems = new List <string>();
                foreach (var i in items)
                {
                    var q = NSString.FromHandle(i.Handle);
                    stringItems.Add(q.ToString());
                }
                var indexPaths = new List <NSIndexPath>();
                for (var j = 0; j < stringItems.Count; j++)
                {
                    var indexPath1 = NSIndexPath.FromRowSection(destinationIndexPath.Row + j, destinationIndexPath.Section);
                    model.AddItem(stringItems[j], indexPath1.Row);
                    indexPaths.Add(indexPath1);
                }
                tableView.InsertRows(indexPaths.ToArray(), UITableViewRowAnimation.Automatic);
            });
        }
Esempio n. 19
0
            public bool GetObjectValue(IntPtr obj, IntPtr strPtr, IntPtr errorDescription)
            {
                // monomac can't handle out params that pass a null pointer (errorDescription), so we marshal manually here
                var h = Handler;

                if (h.NeedsFormat)
                {
                    double result;
                    var    str  = NSString.FromHandle(strPtr);
                    var    text = str;
                    if (h.HasFormatString)
                    {
                        text = Regex.Replace(text, $@"(?!\d|{Regex.Escape(h.CultureInfo.NumberFormat.NumberDecimalSeparator)}|{Regex.Escape(h.CultureInfo.NumberFormat.NegativeSign)}).", "");                         // strip any non-numeric value
                    }
                    if (double.TryParse(text, NumberStyles.Any, h.CultureInfo, out result))
                    {
                        // test to see if it matches the negative string format
                        if (h.HasFormatString && result > 0 && NumberStringsMatch((-result).ToString(h.ComputedFormatString, h.CultureInfo), str))
                        {
                            result = -result;
                        }

                        var nsresult = new NSNumber(result);
                        Marshal.WriteIntPtr(obj, 0, nsresult.Handle);
                        return(true);
                    }
                    // test to see if it matches the zero format which could be blank or some other text
                    if (h.HasFormatString && NumberStringsMatch(0.0.ToString(h.ComputedFormatString, h.CultureInfo), str))
                    {
                        var nsresult = new NSNumber(0);
                        Marshal.WriteIntPtr(obj, 0, nsresult.Handle);
                        return(true);
                    }
                }
                return(Messaging.bool_objc_msgSendSuper_IntPtr_IntPtr_IntPtr(SuperHandle, sel_getObjectValue, obj, strPtr, errorDescription));
            }
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            NSPasteboard pb   = sender.DraggingPasteboard;
            NSArray      data = null;

            if (pb.Types.Contains(NSPasteboard.NSFilenamesType))
            {
                data = pb.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray;
            }
            if (data != null)
            {
                for (int i = 0; i < data.Count; i++)
                {
                    string path = (string)NSString.FromHandle(data.ValueAt((uint)i));
                    Console.WriteLine("From pasteboard Item {0} = {1}", i, path);
                    var outlineView = Subviews [0].Subviews [0] as NSOutlineView;
                    ((TreeDataSource)outlineView.DataSource).Directories.Add(
                        new Directory(NSUrl.FromFilename(path).AbsoluteString));
                    outlineView.ReloadData();
                    return(true);
                }
            }
            return(false);
        }
 public static string GetAccountRegion(this ICleverTapInstanceConfig This)
 {
     return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("accountRegion"))));
 }
Esempio n. 22
0
 public static string AppName()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("appName"))));
 }
Esempio n. 23
0
 public static string UrlForLinkAtIndex(this ICleverTapInboxMessageContent This, int index)
 {
     return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_int(This.Handle, Selector.GetHandle("urlForLinkAtIndex:"), index)));
 }
Esempio n. 24
0
 public static string PublisherSecret()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("publisherSecret"))));
 }
Esempio n. 25
0
 public static string VisitorID()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("visitorID"))));
 }
Esempio n. 26
0
 public static string DevModel()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("devModel"))));
 }
Esempio n. 27
0
 public static string CurrentVersion()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("currentVersion"))));
 }
Esempio n. 28
0
 public static string CrossPublisherId()
 {
     return(NSString.FromHandle(ApiDefinition.Messaging.IntPtr_objc_msgSend(class_ptr, Selector.GetHandle("crossPublisherId"))));
 }
Esempio n. 29
0
 public static string GetLocation(this IEpos2LineDisplay This)
 {
     return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("getLocation"))));
 }
Esempio n. 30
0
 public static string GetMessageColor(this ICleverTapInboxMessageContent This)
 {
     return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("messageColor"))));
 }