// constructor internal FTConfigureForm(FTConfiguration oldSettings, ref InfoSite infoSite) { this.infoSite = infoSite; InitializeComponent(); if (oldSettings == null) { oldSettings = FTConfiguration.GetDefaultConfigObject(); } // read and set values in controlls textBoxIPAddress.Text = oldSettings.Host; textBoxIPPort.Text = oldSettings.Port.ToString(); textBoxHostId.Text = oldSettings.ClientId.ToString(); checkBoxAutoRefreshEnabled.Checked = oldSettings.AutoRefreshEnabled; dateTimePickerAutoRefreshTime.Value = oldSettings.AutoRefreshTime; numericUpDownAutoRefreshDays.Value = oldSettings.AutoRefreshDays; checkBoxFilter.Checked = oldSettings.BadTickFilter; checkBoxVerboseLog.Checked = oldSettings.VerboseLog; checkBoxRthOnly.Checked = oldSettings.RthOnly; checkBoxSymbolUpdate.Checked = oldSettings.SymbolUpdate; SetControlState(); buttonOk.Enabled = ValidateAll(); }
public static string GetConfigString(FTConfiguration configuration) { XmlSerializer serializer = new XmlSerializer(typeof(FTConfiguration)); Stream stream = new MemoryStream(); serializer.Serialize(XmlWriter.Create(stream), configuration); stream.Seek(0, SeekOrigin.Begin); StreamReader streamReader = new StreamReader(stream); return(streamReader.ReadToEnd()); }
public static new string Configure(string oldSettings, ref InfoSite infoSite) { FTConfiguration ibConfiguration = FTConfiguration.GetConfigObject(oldSettings); FTConfigureForm ibConfigureForm = new FTConfigureForm(ibConfiguration, ref infoSite); if (ibConfigureForm.ShowDialog() == DialogResult.OK) { return(FTConfiguration.GetConfigString(ibConfigureForm.GetNewSettings())); } else { return(oldSettings); } }
// build config string from the dialog data internal FTConfiguration GetNewSettings() { FTConfiguration newSettings = new FTConfiguration(); newSettings.Host = textBoxIPAddress.Text; newSettings.Port = int.Parse(textBoxIPPort.Text); newSettings.ClientId = int.Parse(textBoxHostId.Text); newSettings.AutoRefreshEnabled = checkBoxAutoRefreshEnabled.Checked; newSettings.AutoRefreshTime = dateTimePickerAutoRefreshTime.Value; newSettings.AutoRefreshDays = (int)numericUpDownAutoRefreshDays.Value; newSettings.BadTickFilter = checkBoxFilter.Checked; newSettings.VerboseLog = checkBoxVerboseLog.Checked; newSettings.RthOnly = checkBoxRthOnly.Checked; newSettings.SymbolUpdate = checkBoxSymbolUpdate.Checked; return(newSettings); }
public static FTConfiguration GetDefaultConfigObject() { FTConfiguration defConfig = new FTConfiguration(); defConfig.Host = "127.0.0.1"; defConfig.Port = 7496; defConfig.ClientId = 0; defConfig.AutoRefreshEnabled = true; defConfig.AutoRefreshTime = DateTime.Now.Date.AddHours(1); defConfig.AutoRefreshDays = 1; defConfig.RthOnly = false; defConfig.BadTickFilter = true; defConfig.SymbolUpdate = true; #if DEBUG defConfig.VerboseLog = true; #else defConfig.VerboseLog = false; #endif return(defConfig); }
public override bool Notify(ref PluginNotification notifyData) { bool result = true; switch (notifyData.Reason) { case Reason.DatabaseLoaded: // if database is loaded if (controller != null) { // disconnect from TWS and reset all data controller.Disconnect(); ((IDisposable)controller).Dispose(); controller = null; } Workspace = notifyData.Workspace; DatabasePath = notifyData.DatabasePath; MainWindowHandle = notifyData.MainWnd; AllowMixedEODIntra = Workspace.AllowMixedEODIntra != 0; // start logging the opening of the database LogAndMessage.Log(MessageType.Info, "Database: " + DatabasePath); LogAndMessage.Log(MessageType.Info, "Mixed EOD/Intra: " + (Workspace.AllowMixedEODIntra != 0)); LogAndMessage.Log(MessageType.Info, "Number of bars: " + Workspace.NumBars); LogAndMessage.Log(MessageType.Info, "Database config: " + Settings); // create the config object IBConfiguration = FTConfiguration.GetConfigObject(Settings); LogAndMessage.VerboseLog = IBConfiguration.VerboseLog; RthOnly = IBConfiguration.RthOnly; CalcNextAutoRefreshTime(); // create new controller connectionRetryTime = DateTime.Now.AddSeconds(ConnectionRetryInterval); prevPluginState = IBPluginState.Disconnected; firstConnection = true; controller = new FTController(); // connect database to tws controller.Connect(false); if (rtWindowTickersBck.Count > 0) { for (int i = 0; i < rtWindowTickersBck.Count; i++) { controller.GetRecentInfo(rtWindowTickersBck[i]); } } break; // user changed the db case Reason.DatabaseUnloaded: // disconnect from TWS if (controller != null) { controller.Disconnect(); ((IDisposable)controller).Dispose(); controller = null; } // clean up Workspace = new Workspace(); DatabasePath = null; MainWindowHandle = IntPtr.Zero; searchForm = null; break; // seams to be obsolete case Reason.SettingsChanged: break; // user right clicks data plugin area in AB case Reason.RightMouseClick: if (controller != null) { currentSI = notifyData.CurrentSI; if (currentSI != null) { currentTicker = currentSI.ShortName; if (currentTicker.Length > 10) { currentTickerShortend = currentTicker.Substring(0, 7) + "..."; } else { currentTickerShortend = currentTicker; } } else { currentTicker = null; currentTickerShortend = null; } } SetContextMenuState(); ShowContextMenu(mContextMenu); break; default: result = false; break; } return(result); }