예제 #1
0
파일: TestForm.cs 프로젝트: sempuki/code
        private Content CoerceContent(ClipEventArgs args)
        {
            var content_type = new List<String>();
            var formats = args.Clip.GetFormats();

            foreach (var format in formats)
            {
                switch (format)
                {
                    case "PNG":
                        content_type.Add("image/png");
                        break;

                    case "DeviceIndependentBitmap":
                        content_type.Add("image/bmp");
                        break;

                    case "FileName":
                    case "FileDrop":
                        content_type.Add("text/path");
                        break;

                    case "HTML Format":
                    case "text/html":
                        content_type.Add("text/html");
                        var html = args.Clip.GetData("HTML Format", true);
                        break;

                    case "Text":
                    case "UnicodeText":
                    case "System.String":
                    case "text/plain":
                        content_type.Add("text/plain");
                        break;
                }
            }

            content_type = content_type.Distinct().ToList(); // eliminate duplicates
            var description = "Unable to find text description.";

            if (content_type.Contains("text/path"))
            {
                var builder = new StringBuilder();
                var files = args.Clip.GetData("FileName", true) as String[];
                foreach (var file in files)
                {
                    builder.Append(file);
                    builder.Append(';');
                }
                description = builder.ToString();
            }
            else if (content_type.Contains("text/plain"))
            {
                description = args.Clip.GetData("System.String", true) as String;
            }
            else if (content_type.Contains("text/html"))
            {
                description = args.Clip.GetData("HTML Format", true) as String;
            }

            return new Content () { Clip = args.Clip, ContentType = content_type, Description = description };
        }
예제 #2
0
파일: ClipManager.cs 프로젝트: sempuki/code
 protected void OnClipboardChanged(ClipEventArgs e)
 {
     if (ClipboardChanged != null)
         ClipboardChanged(this, e);
 }