Example #1
0
        public static void CopyToClipboard(string text)
        {
            NSPasteboard clipboard = NSPasteboard.GeneralPasteboard;

            clipboard.ClearContents();
            clipboard.WriteObjects(new NSString[] { (NSString)text });
        }
Example #2
0
        internal static void Store(NSPasteboard pboard, object data, int id)
        {
            if (id == 0)
            {
                pboard.ClearContents();
                managed.Clear();
                providers.Clear();
                return;
            }
            if (data == null)
            {
                return;
            }

            var name = DataFormats.GetFormat(id)?.Name ?? String.Empty;

            if (name == Clipboard.IDataObjectFormat)
            {
                managed[name] = data;

                var provider = new DataObjectProvider((IDataObject)data);
                var item     = new NSPasteboardItem();
                item.SetDataProviderForTypes(provider, provider.Types);
                pboard.WriteObject(item);
                providers.Add(provider);

                // Set flag that clipboard contains our data
                // Do it as the last step, to avoid fooling the FileMaker (and possibly other apps).
                pboard.SetStringForType(name, name);
            }
        }
        public static void SetDataObject(object data, bool copy)
        {
            if (data is DataObject dataObject)
            {
                pasteboard.ClearContents();

                foreach (var item in dataObject.Items)
                {
                    switch (item.Data)
                    {
                    case string stringData:
                        pasteboard.SetStringForType(
                            stringData,
                            item.Format);
                        break;

                    case bool boolItem:
                        pasteboard.SetDataForType(
                            NSData.FromArray(new byte[] { boolItem ? (byte)1 : (byte)0 }),
                            item.Format);
                        break;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Sets the clipboard.
        /// </summary>
        /// <returns>The clipboard.</returns>
        /// <param name="str">String.</param>
        public static void SetClipboard(string str)
        {
            NSString     stri       = (NSString)str;
            NSPasteboard pasteBoard = NSPasteboard.GeneralPasteboard;

            pasteBoard.ClearContents();
            pasteBoard.WriteObjects(new INSPasteboardWriting [] { stri });
        }
        public void CopyToClipboard(NbtClipboardData data)
        {
            NbtClipboardDataMac dataItem = new NbtClipboardDataMac(data);

            NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard;

            pasteboard.ClearContents();
            pasteboard.WriteObjects(new NSPasteboardReading[] { dataItem });
        }
Example #6
0
        public void WriteToPasteBoard(NSPasteboard pb)
        {
            // Copy data to the pasteboard
            pb.ClearContents();
            pb.DeclareTypes(pboardTypes, null);
            pb.SetStringForType(mLetter, pboardTypes[0]);
            CGRect r    = this.Bounds;
            NSData data = this.DataWithPdfInsideRect(r);

            pb.SetDataForType(data, pboardTypes[1]);
        }
        private bool setToPasteboard(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return(false);
            }

            generalPasteboard.ClearContents();
            generalPasteboard.WriteObjects(NSArray.ArrayWithObject(handle));
            return(true);
        }
Example #8
0
 void InitPasteboard(NSPasteboard pb, TransferDataSource data)
 {
     pb.ClearContents();
     foreach (var t in data.DataTypes)
     {
         if (t == TransferDataType.Text)
         {
             pb.AddTypes(new string[] { NSPasteboard.NSStringType }, null);
             pb.SetStringForType((string)data.GetValue(t), NSPasteboard.NSStringType);
         }
     }
 }
 public override void SetText(string selectedText)
 {
     generalPasteboard.ClearContents();
     generalPasteboard.WriteObjects(NSArray.ArrayWithObject(Cocoa.ToNSString(selectedText)));
 }
Example #10
0
 public void WriteToPasteBoard(NSPasteboard pb)
 {
     // Copy data to the pasteboard
     pb.ClearContents();
     pb.DeclareTypes(pboardTypes, null);
     pb.SetStringForType(mLetter, pboardTypes[0]);
     CGRect r = this.Bounds;
     NSData data = this.DataWithPdfInsideRect(r);
     pb.SetDataForType(data, pboardTypes[1]);
 }
Example #11
0
 /// <summary>
 /// Prepares the pasteboard.
 /// </summary>
 /// <param name="pasteboard">The pasteboard to use.</param>
 /// <param name="dataType">The data type to put on the pasteboard.</param>
 /// <param name="data">The wrapped data to put onto the pasteboard.</param>
 public static void PreparePasteboard(NSPasteboard pasteboard, string dataType, NSDataWrapper data)
 {
     pasteboard.ClearContents();
     pasteboard.SetDataForType(data, dataType);
     PasteboardHelperData[pasteboard] = data;
 }