private void Button_Click(object sender, RoutedEventArgs e) { try { DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2; if (dte.ActiveDocument != null) { var selection = (EnvDTE.TextSelection)dte.ActiveDocument.Selection; //selection.Unindent(100); string text = selection.Text; //text = text.Replace("\r\n", " "); // Modify the text, for example: text = "<kbd>" + text + "</kbd>"; ClipboardHandle.GetTextToClipboard(text); // Replace the selection with the modified text. //selection.Text = text; System.Windows.Forms.MessageBox.Show("Kopieret"); this.Close(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Noget gik galt: " + ex.Message); } }
private void GetToClipboard(Generico.Highlighter codeLang) { try { DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2; if (dte.ActiveDocument != null) { var selection = (EnvDTE.TextSelection)dte.ActiveDocument.Selection; //selection.Unindent(100); string code = selection.Text; string result = Generico.WrapCode(codeLang, code); ClipboardHandle.GetTextToClipboard(result); System.Windows.Forms.MessageBox.Show("Kopieret"); this.Close(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Noget gik galt: " + ex.Message); } }
private void CopyRefImg_Click(object sender, RoutedEventArgs e) { using (var c = new ClipboardHandle()) { c.Open(); c.SetImage(new BitmapImage(new Uri(ReferenceImagePath))); } }
public void U16toU16_Inline() { string round; using (var handle = new ClipboardHandle()) { handle.Open(); handle.SetFormat(ClipboardFormat.UnicodeText, _text); round = handle.GetFormatType(ClipboardFormat.UnicodeText); handle.Empty(); } StrCompare(round); }
public void ANSItoU16() { var reference = "Hello, I am a test! :)"; string round; using (var handle = new ClipboardHandle()) { handle.Open(); handle.SetFormat(ClipboardFormat.Text, reference); } using (var handle = new ClipboardHandle()) { handle.Open(); round = handle.GetFormatType(ClipboardFormat.UnicodeText); handle.Empty(); } StrCompare(round, reference); }
private void LoadClipImg_Click(object sender, RoutedEventArgs e) { using (var c = new ClipboardHandle()) { c.Open(); var img = c.GetImage(); imgClip.Source = img; if (img != null) { // undo wpf dpi to show image at actual size var tzoom = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.M11; imgClip.Width = img.PixelWidth / tzoom; imgClip.Height = img.PixelHeight / tzoom; Canvas.SetLeft(imgClip, (int)((imgCanvas.ActualWidth / 2) - (imgClip.Width / 2))); Canvas.SetTop(imgClip, (int)((imgCanvas.ActualHeight / 2) - (imgClip.Height / 2))); } } }
unsafe static void Main(string[] args) { //0-64 //0-256 //0b_1111_1000; //uint maskR = 0xF800; //uint bR = 0b1111_1000_0000_0000; //if (val & 0xFFFFFF00 == 0) //{ //} //if(val <= 0xFF) //maskG = 0x03e0; //maskB = 0x001f; using (var handle = new ClipboardHandle()) { handle.Open(); var formats = handle.GetPresentFormats().ToArray(); Console.WriteLine("Formats: "); foreach (var f in formats) { Console.WriteLine(" - " + f.Name); } //byte[] bytes; Console.ReadLine(); //Stopwatch sw = new Stopwatch(); //sw.Start(); //var v3s = sw.ElapsedMilliseconds; //bytes = handle.GetFormat((ClipboardFormat)ClipboardFormat.Dib); //var v3e = sw.ElapsedMilliseconds; //var v5s = sw.ElapsedMilliseconds; //bytes = handle.GetFormat((ClipboardFormat)ClipboardFormat.DibV5); //var v5e = sw.ElapsedMilliseconds; //var v3 = v3e - v5s; //var v5 = v5e - v5e; //Console.WriteLine(); //bytes = handle.GetFormat((ClipboardFormat)ClipboardFormat.Dib); //File.WriteAllBytes("ROMAN-2.bmp", bytes); //handle.SetFormat((ClipboardFormat)ClipboardFormat.Dib, bytes); //var formats = handle.GetPresentFormats().ToArray(); //var count = handle.count(); //string app = "paintdotnet"; //var desired = formats.First(f => f == ClipboardFormat.Dib || f == ClipboardFormat.DibV5); //bytes = handle.GetFormat((ClipboardFormat)desired); //File.WriteAllBytes($"clip-{app}-desired.bmp", bytes); //bytes = handle.GetFormat((ClipboardFormat)ClipboardFormat.DibV5); //File.WriteAllBytes($"clip-{app}-dibv5.bmp", bytes); //bytes = handle.GetFormat((ClipboardFormat)ClipboardFormat.Dib); //File.WriteAllBytes($"clip-{app}-dib.bmp", bytes); } }