public static void CopyText(this WealthScript obj, string text) public static void CopyObject(this WealthScript obj, object ob)public static void CopyText(string text) public static void CopyObject(object ob)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class ClipboardDemo : WealthScript { protected override void Execute() { SMA sma = SMA.Series( Close,20 ); char sep = '\t'; string s = "Date" + sep + "Open" + sep + "High" + sep + "Low" + sep + "SMAbar \n"; for(int i = sma.FirstValidValue; i < Bars.Count; i++) { s += ( Datei.ToShortDateString() + sep + Openi + sep + Highi + sep + Lowi + sep + Closei + sep + Bars.FormatValue( smai ) + "\n" ); } this.CopyText( s ); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using System.Windows.Forms;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { private void PasteBitmap(RichTextBox richTextBox, Bitmap myBitmap) { // Copy the bitmap to the clipboard. this.CopyObject(myBitmap); DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap); if(richTextBox.CanPaste(myFormat)) richTextBox.Paste(myFormat); } protected override void Execute() { const string newLine = "\n"; // We're using a RichTextBox control to save some formatted text and an image as RTF RichTextBox richTextBox1 = new RichTextBox(); // Location of your output RTF document string location = @"c:\Temp\test.rtf"; // Define new font style Font font = new Font("Times New Roman", 14, FontStyle.Bold); richTextBox1.SelectionFont = font; richTextBox1.SelectionColor = Color.Red; // A text sentence richTextBox1.AppendText("Let me share a chart with you..." + newLine); // Take a screenshot Bitmap bm = GetChartBitmap( 300, 200 ); // Paste the screenshot as bitmap PasteBitmap( richTextBox1, bm ); // Define yet another font style Font font2 = new Font("Arial", 12, FontStyle.Bold); richTextBox1.SelectionFont = font2; richTextBox1.SelectionColor = Color.Blue; // A text sentence richTextBox1.AppendText(newLine + "This was my Wealth-Lab chart!"); richTextBox1.SaveFile(location, RichTextBoxStreamType.RichText); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class ClipboardDemo : WealthScript { protected override void Execute() { SMA sma = SMA.Series( Close,20 ); char sep = '\t'; string s = "Date" + sep + "Open" + sep + "High" + sep + "Low" + sep + "SMAbar \n"; for(int i = sma.FirstValidValue; i < Bars.Count; i++) { s += ( Datei.ToShortDateString() + sep + Openi + sep + Highi + sep + Lowi + sep + Closei + sep + Bars.FormatValue( smai ) + "\n" ); } MyClipboard.CopyText( s ); } } }