using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Linq; using System.Text; using TradeIdeas.Extensions; using TradeIdeas.TIProGUI; /* This project shows how to create an extension to TI Pro. * * This information is strictly confidential. It is only available to Trade Ideas staff and * a few select partners who have signed a non-disclosure. * * This comes with no support. We do not document this execept for what you see here. * * There is no gaurentee that an extension will continue to work with new builds of TI Pro. * For best results rebuild your extension any time you get a new version of TI Pro. * TIProExtensions.DLL was designed to change less often than the rest of the program, but * there are no gaurentees. * * I linked this directly to the DLL files installed with TI Pro. You can see items like * C:\Program Files\Trade-Ideas\Trade-Ideas Alerts 3\TIProExtensions.dll in the project * references. */ namespace ClassLibrary1 { public class ExtensionMain : IMainInit { /// /// When TI Pro starts it will look at all DLLs in the appliction's directory. It will /// search for classes which implement IMainInit. For each such class it will call /// the GetExtensions static method. /// /// /// This provides basic services from the main program. /// /// A list of extensions to run. public static IList GetExtensions(Object mainProgram) { List result = new List(1); result.Add(new ExtensionMain((IMainProgram)mainProgram)); return result; } private readonly IMainProgram _mainProgram; private ExtensionMain(IMainProgram mainProgram) { _mainProgram = mainProgram; } /// /// This is called at an appropriate time for the extension to do most of its /// initialization. E.g. creating menus. This method is only called because /// GetExtensions returned this object. /// public void MainInit() { // This is the most common way to interact with the main program. You can // add a menu item to the tools menu. That menu item can do almost anything // you want. _mainProgram.AddToToolsMenu("Simple Test", delegate { MessageBox.Show("Hello World"); }); // You can save the menu item. This is useful with checkboxes and submenus. ToolStripMenuItem menuItem = null; menuItem = _mainProgram.AddToToolsMenu("Save Menu Item Test", delegate { if (menuItem.Checked) menuItem.Text = "Save Menu Item Test (Checked)"; else menuItem.Text = "Save Menu Item Test (Unchecked)"; if (menuItem.ForeColor == Color.Red) menuItem.ForeColor = Color.Blue; else if (menuItem.ForeColor == Color.Blue) menuItem.ForeColor = Color.Green; else menuItem.ForeColor = Color.Red; }); menuItem.CheckOnClick = true; _mainProgram.AddToToolsMenu("New Alert Window", delegate { // Note that we strip off the "HTTP" part. The collaborate window usually shows that part to the user. // The user can enter the collaborate string with or without that part. The rest of the code only sees // the short part, shown here. string collaborate = "O=20000000000000000000000000000000000000000000004000000000_1D_0&QRUN=0.15&MaxPrice=150&MinATR=0.656418&MinPrice=10&MinRV=2&MinVol3M=1000000&WN=Long+Strategy+-++High+Options+Call+Volume+-+Swing++5+Day+Hold&show0=D_Symbol&show1=D_Type&show2=D_Time&show3=D_Desc&show4=FCP&show5=R5D&col_ver=1"; AlertForm alertForm = new AlertForm(_mainProgram.ConnectionMaster, collaborate); alertForm.Show(); // I had to add references to // C:\Program Files\Trade-Ideas\Trade-Ideas Alerts 3\TIProGUI.dll // and // C:\Program Files\Trade-Ideas\Trade-Ideas Alerts 3\TIProData.dll // to make this part compile. }); _mainProgram.AddToToolsMenu("New Top List Window", delegate { // Remember that we strip off the "HTTP" part. See above. string collaborate = "form=1&show0=D_Symbol&show1=Vol3M&show2=PV&show3=D_Name&show4=Price&show5=FCP&show6=R20D&show7=TV&show8=STP&show9=U84&show10=U9&show11=U99&col_ver=1&MinPrice=10&MinVol3M=500000&MaxPrice=500&sort=MaxSTP&X_NYSE=on&X_ARCA=on&X_AMEX=on&XN=on&WN=Largest+%25+Increase+in+Social+Volume+with+Options+Data+X"; TopListForm topListForm = new TopListForm(_mainProgram.ConnectionMaster, collaborate); topListForm.Show(); }); _mainProgram.AddToToolsMenu("New Multi-Strategy Window", delegate { MultiStrategy multiStrategy = new MultiStrategy(_mainProgram.ConnectionMaster); multiStrategy.Show(); }); _mainProgram.AddToToolsMenu("New Compare Count Window", delegate { CompareCount compareCount = new CompareCount(_mainProgram.ConnectionMaster); compareCount.Show(); }); _mainProgram.AddToToolsMenu("New Channel Bar", delegate { string channelBarUrl = "http://www.trade-ideas.com/cms_static/ChannelBar/channelbar.html"; int width = 180; int height = 600; WelcomeScreen channelBar = new WelcomeScreen(true, channelBarUrl); channelBar.Text = "Channel Bar"; channelBar.Size = new Size(width, height); channelBar.Show(); }); _mainProgram.AddToToolsMenu("Load from File", delegate { // We use this in several places. The user can explicitly load or save a layout. // We also use this to load the default alert window, etc. string userDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string fileName = userDir + "\\TradeIdeasPro\\DEFAULT_LAYOUT.LTI"; // If this file doesn't exist the user gets a simple error message. bool clearOldLayout = true; // This is usually false for a window, true for an entire layout. LayoutManager.Instance().Restore(fileName, clearOldLayout); }); } } }