public void SetData(SelectionData selection_data, uint info)
            {
                if (selection_data == null)
                {
                    return;
                }
                switch (info)
                {
                case TextType:
                    selection_data.Text = copiedDocument.Text;
                    break;

                case RichTextType:
                    selection_data.Set(RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes(GenerateRtf(copiedDocument, mode, docStyle, options)));
                    break;

                case MonoTextType:
                    byte[] rawText = System.Text.Encoding.UTF8.GetBytes(monoDocument.Text);
                    byte[] data    = new byte [rawText.Length + 1];
                    rawText.CopyTo(data, 1);
                    data[0] = 0;
                    if (isBlockMode)
                    {
                        data[0] |= 1;
                    }
                    if (isLineSelectionMode)
                    {
                        data[0] |= 2;
                    }
                    selection_data.Set(MD_ATOM, UTF8_FORMAT, data);
                    break;
                }
            }
            public void SetData(SelectionData selection_data, uint info)
            {
                if (selection_data == null)
                {
                    return;
                }
                switch (info)
                {
                case TextType:
                    // Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
                    // Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.
                    if (Platform.IsWindows)
                    {
                        selection_data.Text = copiedDocument.Text.Replace("\r\n", "\n");
                    }
                    else
                    {
                        selection_data.Text = copiedDocument.Text;
                    }
                    break;

                case RichTextType:
                    var rtf = RtfWriter.GenerateRtf(copiedColoredChunks, docStyle, options);
                    selection_data.Set(RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes(rtf));
                    break;

                case HTMLTextType:
                    var html = HtmlWriter.GenerateHtml(copiedColoredChunks, docStyle, options);
//					Console.WriteLine ("html:" + html);
                    selection_data.Set(HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes(html));
                    break;

                case MonoTextType:
                    byte[] rawText        = Encoding.UTF8.GetBytes(monoDocument.Text);
                    var    copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
                    var    dataOffset     = 1 + 1 + copyDataLength;
                    byte[] data           = new byte [rawText.Length + dataOffset];
                    data [1] = copyDataLength;
                    if (copyDataLength > 0)
                    {
                        copyData.CopyTo(data, 2);
                    }
                    rawText.CopyTo(data, dataOffset);
                    data [0] = 0;
                    if (isBlockMode)
                    {
                        data [0] |= 1;
                    }
                    if (isLineSelectionMode)
                    {
                        data [0] |= 2;
                    }
                    selection_data.Set(MD_ATOM, UTF8_FORMAT, data);
                    break;
                }
            }
Exemple #3
0
        /// <summary>
        /// Gets complex data from item and sets as content when requested.
        /// </summary>
        /// <param name="clipboard">Clipboard.</param>
        /// <param name="selectionData">Selection data.</param>
        /// <param name="info">Target index.</param>
        internal void GetDataFunc(Gtk.Clipboard clipboard, SelectionData selectionData, uint info)
        {
            switch (info)
            {
            case 0:
                selectionData.Set(this.Target, 8, this.Data);
                break;

            case 1:
            default:
                selectionData.Set(Targets.Atoms[Targets.UtfString], 8, this.DataText);
                break;
            }
        }
Exemple #4
0
    private void GetClipboardText(SelectionData data)
    {
        var atom  = Gdk.Atom.Intern("UTF8_STRING", false);
        var bytes = System.Text.Encoding.UTF8.GetBytes(text);

        data.Set(atom, 8, bytes);
    }
        public static void SetCopyFiles(this SelectionData selection_data, UriList uri_list)
        {
            var uris = (from p in uri_list select p.ToString()).ToArray();
            var data = Encoding.UTF8.GetBytes("copy\n" + string.Join("\n", uris));

            selection_data.Set(Atom.Intern("x-special/gnome-copied-files", true), 8, data, data.Length);
        }
Exemple #6
0
            public void SetData(SelectionData selection_data, uint info)
            {
                if (selection_data == null)
                {
                    return;
                }
                switch (info)
                {
                case TextType:
                    selection_data.Text = GetCopiedPlainText();
                    break;

                case RichTextType:
                    var rtf = RtfWriter.GenerateRtf(copiedColoredChunks, docStyle, options);
                    selection_data.Set(RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes(rtf));
                    break;

                case HTMLTextType:
                    var html = HtmlWriter.GenerateHtml(copiedColoredChunks, docStyle, options);
//					Console.WriteLine ("html:" + html);
                    selection_data.Set(HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes(html));
                    break;

                case MonoTextType:
                    byte[] rawText        = Encoding.UTF8.GetBytes(GetCopiedPlainText());
                    var    copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
                    var    dataOffset     = 1 + 1 + copyDataLength;
                    byte[] data           = new byte [rawText.Length + dataOffset];
                    data [1] = copyDataLength;
                    if (copyDataLength > 0)
                    {
                        copyData.CopyTo(data, 2);
                    }
                    rawText.CopyTo(data, dataOffset);
                    data [0] = 0;
                    if (isBlockMode)
                    {
                        data [0] |= 1;
                    }
                    if (isLineSelectionMode)
                    {
                        data [0] |= 2;
                    }
                    selection_data.Set(MD_ATOM, UTF8_FORMAT, data);
                    break;
                }
            }
Exemple #7
0
            public void SetData(SelectionData selection_data, uint info)
            {
                if (selection_data == null)
                {
                    return;
                }
                switch (info)
                {
                case TextType:
                    // Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
                    // Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.
                    if (Platform.IsWindows)
                    {
                        selection_data.Text = copiedDocument.Text.Replace("\r\n", "\n");
                    }
                    else
                    {
                        selection_data.Text = copiedDocument.Text;
                    }
                    break;

                case RichTextType:
                    selection_data.Set(RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes(RtfWriter.GenerateRtf(copiedDocument, mode, docStyle, options)));
                    break;

                case HTMLTextType:
                    selection_data.Set(HTML_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes(HtmlWriter.GenerateHtml(copiedDocument, mode, docStyle, options)));
                    break;

                case MonoTextType:
                    byte[] rawText = System.Text.Encoding.UTF8.GetBytes(monoDocument.Text);
                    byte[] data    = new byte [rawText.Length + 1];
                    rawText.CopyTo(data, 1);
                    data [0] = 0;
                    if (isBlockMode)
                    {
                        data [0] |= 1;
                    }
                    if (isLineSelectionMode)
                    {
                        data [0] |= 2;
                    }
                    selection_data.Set(MD_ATOM, UTF8_FORMAT, data);
                    break;
                }
            }
Exemple #8
0
        public static void Serialize(SelectionData data, object d)
        {
            IFormatter   formatter = new BinaryFormatter();
            MemoryStream stream    = new MemoryStream();

            formatter.Serialize(stream, d);
            stream.Close();
            data.Set(data.Target, 8, stream.ToArray());
        }
 void FillSelectionData(SelectionData aData, uint aInfo)
 {
     if (aInfo < (int)TransferDataType.X_Special)
     {
         aData.Set(aData.Target, 8, System.Text.Encoding.UTF8.GetBytes(copyBuffer.ToShortDateString()),
                   System.Text.Encoding.UTF8.GetBytes(copyBuffer.ToShortDateString()).Length);
     }
     else
     {
         byte[] num  = BitConverter.GetBytes(copyBuffer.Year);
         byte[] data = new byte[num.Length * 3];
         num.CopyTo(data, 0);
         num = BitConverter.GetBytes(copyBuffer.Month);
         num.CopyTo(data, num.Length);
         num = BitConverter.GetBytes(copyBuffer.Day);
         num.CopyTo(data, num.Length * 2);
         aData.Set(aData.Target, 8, data, data.Length);
     }
 }
 void FillSelectionData(SelectionData aData, uint aInfo)
 {
     if (aInfo < (int)TransferDataType.X_Special)
     {
         aData.Set(aData.Target, 8, System.Text.Encoding.UTF8.GetBytes(GetTimeAsString(copyBuffer)),
                   System.Text.Encoding.UTF8.GetBytes(GetTimeAsString(copyBuffer)).Length);
     }
     else
     {
         byte[] num  = BitConverter.GetBytes(copyBuffer.Hour);
         byte[] data = new byte[num.Length * 4];
         num.CopyTo(data, 0);
         num = BitConverter.GetBytes(copyBuffer.Minute);
         num.CopyTo(data, num.Length);
         num = BitConverter.GetBytes(copyBuffer.Second);
         num.CopyTo(data, num.Length * 2);
         num = BitConverter.GetBytes(copyBuffer.Millisecond);
         num.CopyTo(data, num.Length * 3);
         aData.Set(aData.Target, 8, data, data.Length);
     }
 }
Exemple #11
0
        //<summary>Called when an application wants to get our clipboard data</summary>
        private void OnClipboardGet(Clipboard cb, SelectionData sd, uint n)
        {
            // if application accepts text
            if (sd.Target.Name == "UTF8_STRING")
            {
                switch (this.FocusedArea.Type)
                {
                case "hexadecimal":
                    sd.Text = ByteArray.ToString(clipdata, 16);
                    break;

                case "decimal":
                    sd.Text = ByteArray.ToString(clipdata, 10);
                    break;

                case "octal":
                    sd.Text = ByteArray.ToString(clipdata, 8);
                    break;

                case "binary":
                    sd.Text = ByteArray.ToString(clipdata, 2);
                    break;

                case "ascii":
                    sd.Set(sd.Target, 8, clipdata);
                    break;

                default:
                    break;
                }
            }     // if application accepts raw bytes
            else if (sd.Target.Name == "application/octet-stream")
            {
                sd.Set(sd.Target, 8, clipdata);
            }
        }
 protected override void OnDragDataGet(Gdk.DragContext context, SelectionData selection_data, uint info, uint time)
 {
     if (info == Banshee.Gui.DragDrop.DragDropTarget.UriList.Info)
     {
         ITrackModelSource track_source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;
         if (track_source != null)
         {
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
             foreach (TrackInfo track in track_source.TrackModel.SelectedItems)
             {
                 sb.Append(track.Uri);
                 sb.Append("\r\n");
             }
             byte [] data = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
             selection_data.Set(context.Targets[0], 8, data, data.Length);
         }
     }
 }
        public static void SetTagsData(this SelectionData selection_data, Tag [] tags, Atom target)
        {
            byte [] data = new byte [tags.Length * sizeof(uint)];

            int i = 0;

            foreach (Tag tag in tags)
            {
                byte [] bytes = System.BitConverter.GetBytes(tag.Id);

                foreach (byte b in bytes)
                {
                    data [i] = b;
                    i++;
                }
            }

            selection_data.Set(target, 8, data, data.Length);
        }
        public static void SetPhotosData(this SelectionData selection_data, Photo [] photos, Atom target)
        {
            byte [] data = new byte [photos.Length * sizeof(uint)];

            int i = 0;

            foreach (Photo photo in photos)
            {
                byte [] bytes = System.BitConverter.GetBytes(photo.Id);

                foreach (byte b in bytes)
                {
                    data [i] = b;
                    i++;
                }
            }

            selection_data.Set(target, 8, data, data.Length);
        }
 /// <summary>
 /// Fills selection with data
 /// </summary>
 /// <param name="aData">
 /// Data <see cref="SelectionData"/>
 /// </param>
 /// <param name="aInfo">
 /// Type <see cref="System.UInt32"/>
 /// </param>
 private void FillSelectionData(SelectionData aData, uint aInfo)
 {
     aData.Set(aData.Target, 8, System.Text.Encoding.UTF8.GetBytes(Color.GetGdkColor().ToHtmlColor()),
               System.Text.Encoding.UTF8.GetBytes(Color.GetGdkColor().ToHtmlColor()).Length);
 }
Exemple #16
0
 /// <summary>
 /// Fills selection with data
 /// </summary>
 /// <param name="aData">
 /// Data <see cref="SelectionData"/>
 /// </param>
 /// <param name="aInfo">
 /// Type <see cref="System.UInt32"/>
 /// </param>
 private void FillSelectionData(SelectionData aData, uint aInfo)
 {
     aData.Set(aData.Target, 8, System.Text.Encoding.UTF8.GetBytes(TargetUrl),
               System.Text.Encoding.UTF8.GetBytes(TargetUrl).Length);
 }
		void FillSelectionData (SelectionData aData, uint aInfo) 
		{
			if (aInfo < (int) TransferDataType.X_Special)
				aData.Set (aData.Target, 8, System.Text.Encoding.UTF8.GetBytes (copyBuffer.ToShortDateString()),
				           System.Text.Encoding.UTF8.GetBytes (copyBuffer.ToShortDateString()).Length);
			else {
				byte[] num = BitConverter.GetBytes (copyBuffer.Year);
				byte[] data = new byte[num.Length*3];
				num.CopyTo (data, 0);
				num = BitConverter.GetBytes (copyBuffer.Month);
				num.CopyTo (data, num.Length);
				num = BitConverter.GetBytes (copyBuffer.Day);
				num.CopyTo (data, num.Length*2);
				aData.Set (aData.Target, 8, data, data.Length);
			}
		}
        public static void SetUriListData(this SelectionData selection_data, UriList uri_list, Atom target)
        {
            Byte [] data = Encoding.UTF8.GetBytes(uri_list.ToString());

            selection_data.Set(target, 8, data, data.Length);
        }
Exemple #19
0
        private void ClearGet(Clipboard clipboard, SelectionData selection, uint info)
        {
            var temp = $"copy\n{source}";

            selection.Set(selection.Target, 8, Encoding.UTF8.GetBytes(temp));
        }
Exemple #20
0
    private void GetClipboardIgnore(SelectionData data)
    {
        var atom = Gdk.Atom.Intern("application/x-copysharp-ignore", false);

        data.Set(atom, 8, new byte[] {});
    }