using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.IO; using System.Windows.Controls; using System.Windows.Forms; using System.Xml; using TradeIdeas.MiscSupport; using TradeIdeas.TIProData; using TradeIdeas.TIProData.Configuration; using TradeIdeas.TIProData.Interfaces; using TradeIdeas.XML; using static TradeIdeas.TIProData.InsiderTrade; namespace TradeIdeas.TIProGUI.EnhancedSingleStockWindow { public partial class EnhancedSingleStockWindow : Form, IDemoMode, ISnapToGrid, IAcceptSymbolLinking, ISupportLimitedMode, ISaveLayout, IContextMenuStrip, IFont, IRowSelect { struct ColumnSetting { public int dIndex; public DataGridLength width; } private string _id = ""; private string _demoDisclaimer = ""; List _phrases; private bool _pinned = false; private bool _limitedMode = false; private bool _symbolLinkingEnabled = true; ISendManager _sendManager; private LayoutManager _layoutManager = LayoutManager.Instance(); private string _fileNameSaved; private const string FORM_TYPE = "SINGLE_STOCK_WINDOW"; private const string _defaultFileName = "DEFAULT_SINGLE_STOCK.WTI"; static XmlNode _defaultSingleStockSettings = null; private System.Windows.Controls.DataGrid _insidersGrid; private DetailsTab _detailsTab; private InsidersTab _insidersTab; private SimilarTab _similarTab; private List _selectedFilters = new List(); TransactionsWindow _tWindow; private bool _filterPopupInUse = false; private bool _viewModePopupInUse = false; /// /// True = a window is open that should cause surfing to continue to be paused. For example, the Congiguration /// form has been chosen from the context menu. The config code in this file is responsible for turning /// this variable to false and calling UnPauseSurfing. /// private bool _remainPaused = false; public delegate void ReceiveInsiderSelectedTransactions(List selectedItems); public event ReceiveInsiderSelectedTransactions onTransactionSelectedUpdate; public static HashSet _listsForSingleStock = new HashSet(); private ConfigurationWindowManager _configurationWindowManager; // new variable to set that dock panel is being used - RVH20210329 private bool _dockPanelMode = true; public EnhancedSingleStockWindow() { InitializeComponent(); viewModeToolStripMenuItem.Visible = false; if (_listsForSingleStock.Count == 0) { if (_configurationWindowManager != null) { _configurationWindowManager.Abandon(); } _configurationWindowManager = new ConfigurationWindowManager(); _configurationWindowManager.LoadFromServer(GuiEnvironment.FindConnectionMaster(""), ConfigurationType.TopList,OnLoaded, "", skipStrategies:false); } competitorsToolStripMenuItem.Checked = true; priceActionToolStripMenuItem.Checked = false; Guid obj = Guid.NewGuid(); _id = obj.ToString(); _limitedMode = GuiEnvironment.LimitedMode; SetSnapToGrid(GuiEnvironment.SnapToGrid); _demoDisclaimer = GuiEnvironment.XmlConfig.Node("COMMON_PHRASES").Node("DEMO_DISCLAIMER").PropertyForCulture("TEXT", "***"); _phrases = GuiEnvironment.XmlConfig.Node("SINGLE_SYMBOL_WINDOW").Node("PHRASES"); wpF_SingleStock1.onWindowNameUpdate += wpf_onWindowNameUpdate; wpF_SingleStock1.receiveSymbolFromComboEvent += WpF_SingleStock1_receiveSymbolFromComboEvent; wpF_SingleStock1.MouseEnter += Wpf_SingleStock1_MouseEnter; wpF_SingleStock1.MouseLeave += Wpf_SingleStock1_MouseLeave; wpF_SingleStock1.onSymbolUpdate += WpF_SingleStock1_onSymbolUpdate; VisibleChanged += EnhancedSingleStockWindow_VisibleChanged; saveToCloudToolStripMenuItem.Image = SaveToCloud.WindowIconCache.MenuImage; _detailsTab = wpF_SingleStock1.detailsTab; _insidersTab = wpF_SingleStock1.insidersTab; _insidersTab.setId(_id); _similarTab = wpF_SingleStock1.similarTab; WindowIconCache.SetIcon(this); wpF_SingleStock1.setId(_id); wpF_SingleStock1.Tag = this;//this is how we'll communicate with the InsidersTab. We transport an instance of this winform object so we can set up the delegate for selections of transaction (ReceiveInsiderSelectedTransactions); _insidersGrid = wpF_SingleStock1.insidersDataGrid; _sendManager = GuiEnvironment.FindConnectionMaster("").SendManager; populateStrings(); UpdateSymbolLinkingCheckboxStatus(); Text = ""; } private void WpF_SingleStock1_onSymbolUpdate(string symbol) { _similarTab.setCurrentSymbol(symbol); } private void EnhancedSingleStockWindow_VisibleChanged(object sender, EventArgs e) { if (this.Visible) { this.Invalidate(); wpF_SingleStock1.refreshDetailsTab(); } } private void OnLoaded(ConfigurationWindowManager configurationWindowManager) { //must load here or else may receive null exceptions foreach (SymbolList s in _configurationWindowManager.SymbolListsInOrder) if (!s.InternalCode.Contains("SL_0_") && !s.InternalCode.Contains("SL_1_")) _listsForSingleStock.Add(s); } public void setFilterPopupInUse(bool value) { _filterPopupInUse = value; } public bool getFilterPopupInUse() { return _filterPopupInUse; } public void setViewModePopupInUse(bool value) { _viewModePopupInUse = value; } public bool getViewModePopupInUse() { return _viewModePopupInUse; } public string getId() { return _id; } private void WpF_SingleStock1_receiveSymbolFromComboEvent(string symbol) { if (SymbolLinkingEnabled) SendToExternalLinking(); } private void Wpf_SingleStock1_MouseLeave(object sender, EventArgs e) { if (SymbolLinkingEnabled) UnPauseSurfing(); } private void Wpf_SingleStock1_MouseEnter(object sender, EventArgs e) { if (SymbolLinkingEnabled) PauseSurfing(); } private void PauseSurfing() { // temporarily pause surfing if the context menu is opened Surfer.SurfManager surfManager = Surfer.SurfManager.Instance(); if (null != surfManager) { if (surfManager.IsRunning) surfManager.Stop(true); } } private void UnPauseSurfing() { Surfer.SurfManager surfManager = Surfer.SurfManager.Instance(); if (null != surfManager) { if (surfManager.Paused && !_remainPaused) surfManager.Start(false); } } // change parameters to accommodate dock panel changes - RVH20210402 //static public void OpenNewSingleStockWindow(string initialSymbol, Form parentForm) static public void OpenNewSingleStockWindow(string initialSymbol, Form parentForm, bool dockPanelMode = false, string mainDockPanelName = "", string mainDockPanelTitle = "", string dockPanelID = "") { List _phs; _phs = GuiEnvironment.XmlConfig.Node("SINGLE_SYMBOL_WINDOW").Node("PHRASES"); string singleStockFileName = "DEFAULT_SINGLE_STOCK.WTI"; LayoutManager layoutManager = LayoutManager.Instance(); string programDirFileName = layoutManager.Directory + "\\" + singleStockFileName; string readOnlyDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string sharedDirFileName = readOnlyDir + "\\" + GuiEnvironment.AppNameInternal + "\\" + singleStockFileName; string singleStockConfig = _phs.Node("NEW_SINGLE_STOCK_WINDOW_DEFAULT").Property("TEXT"); XmlNode singleStockDefinition = null; if (System.IO.File.Exists(programDirFileName)) //check if it's there in user's home dir singleStockDefinition = layoutManager.GetXmlFromFile(programDirFileName); else if (System.IO.File.Exists(sharedDirFileName)) //check for default in shared folder... singleStockDefinition = layoutManager.GetXmlFromFile(sharedDirFileName); EnhancedSingleStockWindow singleStockWindow; if (null != singleStockDefinition) { EnhancedSingleStockWindow.SetDefaultSingleStockSettings(singleStockDefinition); singleStockConfig = singleStockDefinition.Node("WINDOW").Property("CONFIG", ""); if (initialSymbol == null) { initialSymbol = singleStockDefinition.Node("WINDOW").Property("SYMBOL", null); } singleStockWindow = new EnhancedSingleStockWindow(); // change parameters to accommodate dock panel changes - RVH20210402 //singleStockWindow.Restore(_defaultSingleStockSettings, false, false); singleStockWindow.Restore(_defaultSingleStockSettings, false, false, dockPanelMode, mainDockPanelName, mainDockPanelTitle, dockPanelID); singleStockWindow.setNewSymbol(initialSymbol, singleStockConfig); } else { singleStockWindow = new EnhancedSingleStockWindow(); if (initialSymbol != null) { singleStockWindow.setNewSymbol(initialSymbol, singleStockConfig); } else { singleStockWindow.setNewSymbol("SPY", singleStockConfig); } singleStockWindow.Show(); } GuiEnvironment.SetWindowOpeningPosition(singleStockWindow, parentForm); } static public void SetDefaultSingleStockSettings(XmlNode description) { _defaultSingleStockSettings = XmlHelper.Node(description, "WINDOW"); } public static readonly WindowIconCache WindowIconCache = new WindowIconCache("SINGLE_SYMBOL_WINDOW"); private void SendToExternalLinking() { string currentSymbol = wpF_SingleStock1.getCurrentSymbol(); // Link only if enabled if (SymbolLinkingEnabled && (null != currentSymbol) && ("" != currentSymbol)) { RecordExternalLinkUseCase(currentSymbol); SymbolDetailsCacheManager.Info info = GuiEnvironment.FindConnectionMaster("").SymbolDetailsCacheManager.Request(currentSymbol); string exchange = (null == info) ? "" : info.Exchange; GuiEnvironment.sendSymbolToExternalConnector(currentSymbol, exchange, "", this); } } private void RecordExternalLinkUseCase(string symbol) { GuiEnvironment.RecordExternalLinkingUseCase(symbol, "SS", GuiEnvironment.FindConnectionMaster("").SendManager); } public Rectangle? ActualSize { get; set; } /// /// This gets called before any other code in the SaveLayout function. Currently this is aimed at the Scottrade addin but anything can set this code(no more Scottrade, but will leave this in nevertheless. /// public Action
PreSaveLayoutCode { get; set; } /// /// This is the xml that was used to restore this form. If this form wasn't layout-restored then this will be null. /// public XmlNode RestoredLayout { get; set; } WindowIconCache ISaveLayout.WindowIconCache { get { return WindowIconCache; } } /// /// This gets called after SaveBase and it passes the XmlNode that the form is being saved to. This allows extensions to add properties to the layout. Access the layout XmlNode /// from a form using RestoredLayout. /// public Action SaveLayoutCode { get; set; } private void populateStrings() { configureToolStripMenuItem.Text = _phrases.Node("CONFIGURE").PropertyForCulture("TEXT", "***"); duplicateToolStripMenuItem.Text = _phrases.Node("DUPLICATE").PropertyForCulture("TEXT", "***"); smallBordersToolStripMenuItem.Text = _phrases.Node("SMALL_BORDERS").PropertyForCulture("TEXT", "***"); saveAsDefaultToolStripMenuItem.Text = _phrases.Node("SAVE_AS_DEFAULT").PropertyForCulture("TEXT", "***"); saveAsToolStripMenuItem.Text = _phrases.Node("SAVE_AS").PropertyForCulture("TEXT", "***"); outsideMarketHoursToolStripMenuItem.Text = _phrases.Node("OUTSIDE_HOURS").PropertyForCulture("TEXT", "***"); doSymbolLinkingToolStripMenuItem.Text = _phrases.Node("SYMBOL_LINKING").PropertyForCulture("TEXT", "***"); } public void SetSnapToGrid(bool enabled) { formSnapper1.Enabled = enabled; if (GuiEnvironment.RunningWin10 && enabled) { formSnapper1.Win10HeightAdjustment = GuiEnvironment.HEIGHT_INCREASE; formSnapper1.Win10WidthAdjustment = GuiEnvironment.WIDTH_INCREASE; } } public void setNewSymbol(string initialSymbol, string singleStockConfig,bool? omh = false) { wpF_SingleStock1.setSingleStockWindowParameters(GuiEnvironment.FindConnectionMaster(""), singleStockConfig, true, initialSymbol,omh);//remnant from the original Winform SingleStockWindow wpF_SingleStock1.setNewSymbol(initialSymbol); } private void wpf_onWindowNameUpdate(string nameUpdate) { Text = nameUpdate; if (GuiEnvironment.FindConnectionMaster("").LoginManager.IsDemo) Text = nameUpdate + _demoDisclaimer; else Text = nameUpdate; // change Text of parent form if running in dock panel mode - RVH20210329 if (_dockPanelMode) { Form parent = (Form)this.Parent; if (parent != null) parent.Text = this.Text; } } public void OnDemoModeChanged() { if (GuiEnvironment.FindConnectionMaster("").LoginManager.IsDemo) Text = wpF_SingleStock1.getWindowName() + _demoDisclaimer; } private void ConfigureToolStripMenuItem_Click(object sender, EventArgs e) { _remainPaused = true; doConfiguration(); _remainPaused = false; UnPauseSurfing(); } private void doConfiguration() { ConfigWindowWrapper configWindowWrapper = ConfigWindowWrapper.DefaultFactory(ConfigurationType.TopList, GuiEnvironment.FindConnectionMaster("")); configWindowWrapper.InitialConfig = wpF_SingleStock1.getCurrentConfigString(); configWindowWrapper.AllowOkayImmediately = true; configWindowWrapper.IsSingleStock = true; int leftSideCount = wpF_SingleStock1.getLeftSideColInfoCount(); int rightSideCount = wpF_SingleStock1.getRightSideColInfoCount(); int sideRightLeft = wpF_SingleStock1.getSideRightLeftIndicator(); if (leftSideCount == rightSideCount) { if (sideRightLeft == 1) { //sideRightLeft = 0; wpF_SingleStock1.setSideRightLeftIndicator(0); } } configWindowWrapper.SingleStockWindowValue = wpF_SingleStock1.getDisplayBeginPopulate(); configWindowWrapper.ShowIt(); if (!configWindowWrapper.Canceled) { wpF_SingleStock1.setSideRightLeftIndicator(configWindowWrapper.SingleStockWindowValue); wpF_SingleStock1.setDisplayBeginPopulate(configWindowWrapper.SingleStockWindowValue); TopListStrategy strategy = (TopListStrategy)configWindowWrapper.Strategy; // Make sure we store _currentSymbol and _outsideMarketHours back into the collaborate // string. The new client ignores those. We will also store them directly into the // XML file. The new client reads these directly from the XML file. But the older // client will ignore the symbol that we store directly into the XML file. It will only // look at the symbol that we store here. There are similar issues with the // OutsideMarketHours flag. In that case the older client actually looks at both // places and if they don't match things might not work well. // // If you only have the new client, you don't have to worry about any of this. The // next three lines are useless but they don't hurt anything. // // If you have a new client but you want to be compatible with old and new clients, // the following three lines will help. (E.g. if Brad is making a new cloud layout // to share with a lof of people, this applies to him.) If you want to make a layout // that everyone can use, start by setting the symbol and OMH the way you want them. // Then start the config window. Then hit OK (not Cancel) in the config window. Then // save your layout. strategy.SingleSymbol = wpF_SingleStock1.getCurrentSymbol(); strategy.SymbolListDisposition = SymbolListDisposition.SingleSymbol; strategy.OutsideMarketHours = wpF_SingleStock1.getOutSideMarkeHours(); wpF_SingleStock1.clearChildrenFromDetailsPanel(); wpF_SingleStock1.SetConfiguration(strategy.MakeConfigString()); } } private void OutsideMarketHoursToolStripMenuItem_Click(object sender, EventArgs e) { setMarketHours(); } private void DoSymbolLinkingToolStripMenuItem_Click(object sender, EventArgs e) { SymbolLinkingEnabled = !SymbolLinkingEnabled; UpdateSymbolLinkingCheckboxStatus(); } private void UpdateSymbolLinkingCheckboxStatus() { doSymbolLinkingToolStripMenuItem.Checked = SymbolLinkingEnabled; } private void DuplicateToolStripMenuItem_Click(object sender, EventArgs e) { _layoutManager.Duplicate(this); } private void CopyToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { CopyProfileDataToClipboard(); ; } private void CopyProfileDataToClipboard() { System.Windows.Clipboard.Clear(); System.Windows.Clipboard.SetText(wpF_SingleStock1.getProfileData()); } private void SmallBordersToolStripMenuItem_Click(object sender, EventArgs e) { setBorders(); } private void SmallToolStripMenuItem_Click(object sender, EventArgs e) { UncheckAllSizes(); this.fontSmallToolStripMenuItem.Checked = true; //this._detailsControl.SetFontSize(FontSize.SMALL); } private void NormalToolStripMenuItem_Click(object sender, EventArgs e) { UncheckAllSizes(); this.fontNormalToolStripMenuItem.Checked = true; //this._detailsControl.SetFontSize(FontSize.NORMAL); } private void LargeToolStripMenuItem_Click(object sender, EventArgs e) { UncheckAllSizes(); this.fontLargeToolStripMenuItem.Checked = true; //this._detailsControl.SetFontSize(FontSize.LARGE); } /// /// This implementation uncheck all submenus from the FontSizeToolStrip submenu. /// private void UncheckAllSizes() { foreach (var item in this.fontSizeToolStripMenuItem.DropDownItems) { var toolStripM = item as ToolStripMenuItem; if (toolStripM != null) toolStripM.Checked = false; } } private void PinnedToolStripMenuItem_Click(object sender, EventArgs e) { _pinned = pinnedToolStripMenuItem.Checked; } private void SaveToCloudToolStripMenuItem_Click(object sender, EventArgs e) { _remainPaused = true; SaveToCloud.DoIt(_sendManager, this); _remainPaused = false; UnPauseSurfing(); } private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { _remainPaused = true; GuiEnvironment.RecordUseCase("SingleStockWindow.RightClick.SaveAs", _sendManager); LayoutManager layoutManager = LayoutManager.Instance(); SaveFileDialog dialog = new SaveFileDialog(); if (null != layoutManager.Directory) dialog.InitialDirectory = layoutManager.Directory; dialog.Filter = _phrases.Node("WINDOW_FILTER").PropertyForCulture("TEXT", "***"); dialog.DefaultExt = "WTI"; string fileName = ""; if (_fileNameSaved == null) { fileName = _phrases.Node("FILE_PREFIX").PropertyForCulture("TEXT", "***") + _detailsTab.getShortWindowName(); } else { fileName = _fileNameSaved; } dialog.FileName = FileNameMethod.QuoteFileName(fileName); if (dialog.ShowDialog() == DialogResult.OK) { layoutManager.SaveOne(this, dialog.FileName); _fileNameSaved = Path.GetFileName(dialog.FileName); } dialog.Dispose(); _remainPaused = false; UnPauseSurfing(); } private void SaveAsDefaultToolStripMenuItem_Click(object sender, EventArgs e) { GuiEnvironment.RecordUseCase("SingleStockWindow.RightClick.SaveAsDefault", _sendManager); string programDirFileName = _layoutManager.Directory + "\\" + _defaultFileName; _layoutManager.SaveOne(this, programDirFileName); } private void setBorders() { if (smallBordersToolStripMenuItem.Checked) { FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; } else { FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; } } private void setMarketHours() { wpF_SingleStock1.setOutSideMarkeHours(outsideMarketHoursToolStripMenuItem.Checked); String cfg = wpF_SingleStock1.getCurrentConfigString(); cfg = putOutSideMarketHours(cfg, outsideMarketHoursToolStripMenuItem.Checked); wpF_SingleStock1.SetConfiguration(cfg); } public void ChangeSymbol(string symbol, RowData rowData, string sourceWindow) { if (SymbolLinkingEnabled) { wpF_SingleStock1.clearChildrenFromDetailsPanel(); wpF_SingleStock1.setNewSymbol(symbol); } } public string CurrentSymbol() { return wpF_SingleStock1.getCurrentSymbol(); } public bool Pinned { get { return _pinned; } set { _pinned = value; } } public bool SymbolLinkingEnabled { get { return _symbolLinkingEnabled; } set { _symbolLinkingEnabled = value; _similarTab.setSymbolLinking(value); UpdateSymbolLinkingCheckboxStatus(); } } public string LinkChannel { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public bool LinkEnabled { get { return SymbolLinkingEnabled; } set { SymbolLinkingEnabled = value; } } public bool LimitedMode { get { return _limitedMode; } set { _limitedMode = value; } } public ContextMenuStrip MyContextMenuStrip { get { return contextMenuStrip1; } } private void ContextMenuStrip1_Opening(object sender, CancelEventArgs e) { string symbl = wpF_SingleStock1.getCurrentSymbol(); copyToClipboardToolStripMenuItem.Visible = false; if (wpF_SingleStock1.getSelectedTabIndex() == 0) { configureToolStripMenuItem.Visible = true; outsideMarketHoursToolStripMenuItem.Visible = true; } else { configureToolStripMenuItem.Visible = false; } if (wpF_SingleStock1.getSelectedTabIndex() == 1) { outsideMarketHoursToolStripMenuItem.Visible = false; } if (wpF_SingleStock1.getSelectedTabIndex() == 2) { outsideMarketHoursToolStripMenuItem.Visible = false; if (GuiEnvironment.DevelopmentMode) copyToClipboardToolStripMenuItem.Visible = true; } if (wpF_SingleStock1.getSelectedTabIndex() == 3) { tradeFiltersStripMenuItem.Visible = true; tradeFiltersStripMenuItem.Checked = (_selectedFilters.Count > 0); outsideMarketHoursToolStripMenuItem.Visible = false; } else { tradeFiltersStripMenuItem.Visible = false; } if (wpF_SingleStock1.getSelectedTabIndex() == 4) { // viewModeToolStripMenuItem.Visible = true; popOutToolStripMenuItem.Visible = true; outsideMarketHoursToolStripMenuItem.Visible = true; } else { // viewModeToolStripMenuItem.Visible = false; popOutToolStripMenuItem.Visible = false; } if (null != GuiEnvironment.RobotStrategyMenuCode) GuiEnvironment.RobotStrategyMenuCode(contextMenuStrip1, symbl, "SS", null); GuiEnvironment.HideMenuItems(contextMenuStrip1.Items); GuiEnvironment.EnforceLimitedMode(contextMenuStrip1); } private void ContextMenuStrip1_Closed(object sender, ToolStripDropDownClosedEventArgs e) { _remainPaused = false; } static public void RegisterLayout() { // change parameters to accommodate dock panel changes - RVH20210402 //LayoutManager.Instance().AddRestoreRule(FORM_TYPE, (RestoreLayout)delegate(XmlNode description, bool ignorePosition, bool cascadePosition) LayoutManager.Instance().AddRestoreRule(FORM_TYPE, (RestoreLayout)delegate (XmlNode description, bool ignorePosition, bool cascadePosition, bool dockPanelMode, string mainDockPanelName, string mainDockPanelTitle, string dockPanelID) { IConnectionMaster connectionMaster = GuiEnvironment.FindConnectionMaster(description.Property("CONNECTION")); if (null == connectionMaster) { // We could report an error here, but it's simpler just to do nothing. Any error message we tried to // report would probably be confusing at best to the user. } else { EnhancedSingleStockWindow singleStockWindow = new EnhancedSingleStockWindow(); // change parameters to accommodate dock panel changes - RVH20210402 //singleStockWindow.Restore(description, ignorePosition, cascadePosition); singleStockWindow.Restore(description, ignorePosition, cascadePosition, dockPanelMode, mainDockPanelName, mainDockPanelTitle, dockPanelID); singleStockWindow.RestoredLayout = description; } }); } public void SaveLayout(XmlNode parent) { string currentSymbol = wpF_SingleStock1.getCurrentSymbol(); string config = wpF_SingleStock1.getCurrentConfigString(); if (null != PreSaveLayoutCode) { PreSaveLayoutCode(this); } XmlNode description = LayoutManager.SaveBase(parent, this, FORM_TYPE, ActualSize); if (null != SaveLayoutCode) { SaveLayoutCode(this, description); } if (null != config) { description.SetProperty("CONFIG", config); } //for Similar Tab description = _similarTab.saveGridColumnForDuplication(description); description.SetProperty("SUB_INDUSTRY", _similarTab.getSubindustryString()); description.SetProperty("SYMBOL", wpF_SingleStock1.getCurrentSymbol()); description.SetProperty("SIMILAR_TAB_CONFIG", _similarTab.getConfigString()); description.SetProperty("SMALL_BORDERS", smallBordersToolStripMenuItem.Checked.ToString()); description.SetProperty("OUTSIDE_MARKET_HOURS", outsideMarketHoursToolStripMenuItem.Checked); description.SetProperty("LOCALSORTENABLED", _similarTab.getLocalSortEnabled()); description.SetProperty("LOCALSORTCODE", _similarTab.getLocalSortCode()); description.SetProperty("LOCALSORTTYPE", _similarTab.getLocalSortType()); //description.SetProperty("CONTRACTED_WINDOW", _contractedWindow); description.SetProperty("SIDE_RIGHT_LEFT", wpF_SingleStock1.getSideRightLeftIndicator()); description.SetProperty("DISPLAY_BEGIN_POPULATE", wpF_SingleStock1.getDisplayBeginPopulate()); description.SetProperty("SYMBOL_LINKING_ENABLED", SymbolLinkingEnabled); description.SetProperty("SAVED_WINDOW", true); description.SetProperty("PINNED", _pinned); description.SetProperty("IN_BLANK_MODE", false); //remnant from scottrade(no longer exist) int selectedTabIndex = wpF_SingleStock1.getSelectedTabIndex(); description.SetProperty("ACTIVE_TAB", selectedTabIndex); description.SetProperty("VIEW_MODE",_similarTab.getViewMode().ToString()); XmlNode columnsChild = description.NewNode("COLUMNS"); ObservableCollection colList = _insidersGrid.Columns; foreach (DataGridColumn col in colList) { XmlNode column = columnsChild.NewNode("COLUMN"); column.SetProperty("HEADER", col.Header); column.SetProperty("DISPLAY_INDEX", col.DisplayIndex); column.SetProperty("WIDTH",col.Width.Value); } //filters XmlNode transactionFiltersNode = description.NewNode("FILTERS"); foreach (InsiderTransactionType t in _selectedFilters) { XmlNode transactionFilterNode = transactionFiltersNode.NewNode("FILTER"); transactionFilterNode.SetProperty("TRANSACTION", t.ToString()); } } // change parameters to accommodate dock panel changes - RVH20210402 //public void Restore(XmlNode description, bool ignorePosition, bool cascadePosition) public void Restore(XmlNode description, bool ignorePosition, bool cascadePosition, bool dockPanelMode = false, string mainDockPanelName = "", string mainDockPanelTitle = "", string dockPanelID = "") { string config = description.Property("CONFIG", GuiEnvironment.XmlConfig.Node("SINGLE_SYMBOL_WINDOW").Node("NEW_SINGLE_STOCK_WINDOW_DEFAULT").Property("TEXT")); string symbol = description.Property("SYMBOL", null); bool? outsideMarketHours = description.PropertyBool("OUTSIDE_MARKET_HOURS") ?? false; // change parameters to accommodate dock panel changes - RVH20210402 // LayoutManager.RestoreBase(description, this, ignorePosition, cascadePosition); LayoutManager.RestoreBase(description, this, ignorePosition, cascadePosition, null, false, dockPanelMode, mainDockPanelName, mainDockPanelTitle, dockPanelID); _dockPanelMode = dockPanelMode; smallBordersToolStripMenuItem.Checked = description.Property("SMALL_BORDERS", false); outsideMarketHoursToolStripMenuItem.Checked = outsideMarketHours.Value; // only call this if not in dock panel mode - RVH20210329 if (!_dockPanelMode) setBorders(); // User maybe loading a contracted window saved under a different font size // so we need to set _contractedWindow correctly // int contractedWindow = description.Property("CONTRACTED_WINDOW", _contractedWindowDefault); // if (contractedWindow > _contractedWindow) // _contractedWindow = contractedWindow; Dictionary dictionary = new Dictionary(); foreach (XmlNode node in description.Node("COLUMNS").Enum()) { String header = node.Property("HEADER",""); int? displayIndex = XmlHelper.PropertyInt32(node, "DISPLAY_INDEX"); double? width = XmlHelper.PropertyDouble(node, "WIDTH"); if (header != "" && displayIndex != null && displayIndex != -1 && width != null) { DataGridLength dGL = new DataGridLength(width.Value, DataGridLengthUnitType.Star); ColumnSetting s; s.dIndex = displayIndex.Value; s.width = dGL; dictionary.Add(header, s); } } _selectedFilters.Clear(); if (null != description.Node("FILTERS") && description.Node("FILTERS").HasChildNodes) { XmlNodeList filtersNodeList = description.Node("FILTERS").ChildNodes; foreach (XmlNode filterNode in filtersNodeList) { InsiderTransactionType transType = filterNode.PropertyEnum("TRANSACTION", InsiderTransactionType.Buy); if (!_selectedFilters.Contains(transType)) { _selectedFilters.Add(transType); } } } _filterPopupInUse = false; _viewModePopupInUse = false; //If there were changes to the insider grid (e.g. width, order), and the grid has actually been accessed (index won't be -1 in this case) // then the dictionary d, should have 7 members (number of columns of the grid within the Insider tab. if (dictionary.Count == 7) { ObservableCollection temp = new ObservableCollection(_insidersGrid.Columns); _insidersGrid.Columns.Clear(); foreach (DataGridColumn col in temp) { String header = col.Header.ToString(); ColumnSetting setting; dictionary.TryGetValue(header, out setting); col.DisplayIndex = setting.dIndex; col.Width = setting.width; _insidersGrid.Columns.Add(col); } } setNewSymbol(symbol, config, outsideMarketHours); wpF_SingleStock1.setSideRightLeftIndicator(description.Property("SIDE_RIGHT_LEFT", 0)); wpF_SingleStock1.setDisplayBeginPopulate(description.Property("DISPLAY_BEGIN_POPULATE", 0)); SymbolLinkingEnabled = description.Property("SYMBOL_LINKING_ENABLED", false); _pinned = description.Property("PINNED", false); pinnedToolStripMenuItem.Checked = _pinned; //_savedWindow = description.Property("SAVED_WINDOW", false); //SIMILAR TAB: String viewModeString = description.Property("VIEW_MODE", "Competitor"); String similarTabConfigString = description.Property("SIMILAR_TAB_CONFIG", ""); String sInd = description.Property("SUB_INDUSTRY", null); _similarTab.setSubindustryOnRestore(sInd); TopListPanel.ViewMode vM; if (viewModeString == "Competitor") { competitorsToolStripMenuItem.Checked = true; priceActionToolStripMenuItem.Checked = false; vM = TopListPanel.ViewMode.Competitor; if (description.Node("SIMILAR_COLUMNS") != null) _similarTab.setCompetitorNode(description.Node("SIMILAR_COLUMNS")); } else { competitorsToolStripMenuItem.Checked = false; priceActionToolStripMenuItem.Checked = true; vM = TopListPanel.ViewMode.PriceAction; if (description.Node("SIMILAR_COLUMNS") != null) _similarTab.setPriceActionNode(description.Node("SIMILAR_COLUMNS")); } if (null != description.Property("LOCALSORTENABLED")) _similarTab.setLocalSortEnabled(bool.Parse(description.Property("LOCALSORTENABLED", "False"))); if (null != description.Property("LOCALSORTTYPE")) { TopListSortType localSortType = (TopListSortType)Enum.Parse(typeof(TopListSortType), description.Property("LOCALSORTTYPE", "ServerSort")); _similarTab.setLocalSortType(localSortType); } if ("" != description.Property("LOCALSORTCODE")) { _similarTab.setLocalSortCode(description.Property("LOCALSORTCODE")); } _similarTab.setViewModeOnRestore(vM); wpF_SingleStock1.updateToggleText(vM); int activeTab = description.Property("ACTIVE_TAB", 0); wpF_SingleStock1.setTabControlSelectedIndex(activeTab); setMarketHours(); } private void EnhancedSingleStockWindow_Activated(object sender, EventArgs e) { wpF_SingleStock1.mainWindowActivated(); } public List getSelectedFIlterList() { return _selectedFilters; } //for receiving updates using the dialog checked listbox for selecting transactions public void receiveCheckedFilters(List chosenFilters) { _selectedFilters = new List(chosenFilters); fetchSelectedFilters(); } public void fetchSelectedFilters() { List< InsiderTransactionType > temp = new List(_selectedFilters); if (onTransactionSelectedUpdate != null) onTransactionSelectedUpdate(temp); } private void TradeFiltersStripMenuItem_Click(object sender, EventArgs e) { if(_filterPopupInUse == false) { _filterPopupInUse = true; _tWindow = new TransactionsWindow(this); _tWindow.ShowDialog(); } } private void EnhancedSingleStockWindow_FormClosing(object sender, FormClosingEventArgs e) { if (_tWindow != null) { _tWindow.Close(); } wpF_SingleStock1.onWindowNameUpdate -= wpf_onWindowNameUpdate; wpF_SingleStock1.receiveSymbolFromComboEvent -= WpF_SingleStock1_receiveSymbolFromComboEvent; wpF_SingleStock1.MouseEnter -= Wpf_SingleStock1_MouseEnter; wpF_SingleStock1.MouseLeave -= Wpf_SingleStock1_MouseLeave; wpF_SingleStock1.onSymbolUpdate -= WpF_SingleStock1_onSymbolUpdate; } private void contextMenuStrip1_Opened(object sender, EventArgs e) { if (SymbolLinkingEnabled) { _remainPaused = true; PauseSurfing(); } } public WPF_SingleStock getWPF_SingleStock() { return wpF_SingleStock1; } private void popOutToolStripMenuItem_Click(object sender, EventArgs e) { _similarTab.duplicate(); } public static string putOutSideMarketHours(String cfg, bool inOutsideMarketHours) { string retVal = ""; if (cfg.Contains("omh=1")) { if (inOutsideMarketHours) retVal = cfg; else retVal = cfg.Replace("omh=1", "omh=0"); } else if (cfg.Contains("omh=0")) { if (inOutsideMarketHours) retVal = cfg.Replace("omh=0", "omh=1"); else retVal = cfg; } else if (!cfg.Contains("omh")) { if (inOutsideMarketHours) retVal = cfg.Replace("col_ver=1", "omh=1&col_ver=1"); else retVal = cfg.Replace("col_ver=1", "omh=1&col_ver=0"); } return retVal; } private void competitorsToolStripMenuItem_Click(object sender, EventArgs e) { if (competitorsToolStripMenuItem.Checked) return; priceActionToolStripMenuItem.Checked = false; competitorsToolStripMenuItem.Checked = true; _similarTab.getTopListPanel().setViewMode(TopListPanel.ViewMode.Competitor); } private void priceActionToolStripMenuItem_Click(object sender, EventArgs e) { if (priceActionToolStripMenuItem.Checked) return; competitorsToolStripMenuItem.Checked = false; priceActionToolStripMenuItem.Checked = true; _similarTab.getTopListPanel().setViewMode(TopListPanel.ViewMode.PriceAction); } public void selectTheFont() { Font = GuiEnvironment.FontSettings; contextMenuStrip1.Font = Font; } public void chooseRowSelect() { _similarTab.getTopListPanel().chooseRowSelect(); } } }