using System; using System.Drawing; using System.Linq; using System.Windows.Forms; using System.Collections.Generic; using BrokerInterfaceAlpaca; using log4net; using TradeIdeas.TIProGUI; namespace BrokerInterfaceAlpaca.UI { public partial class frmSettings : Form { private AlpacaManager _manager; private static readonly string LOCAL_ORDERS_UNREGISTER_EXPLANATION = "The option to Unregister your User Session with Alpaca is currently disabled because you have one or more local orders being managed on our servers."; private static readonly string LOCAL_ORDERS_UNREGISTER_DISCLAIMER_1 = "If would like switch your connection to another Alpaca User Account, then please close this dialog, and cancel your local orders. Local order identifiers are prefixed with the letter 'L'."; private static readonly string UNREGISTER_EXPLANATION = "If would like switch your connection to another Alpaca User Account, then please click the 'Unregister User' Button."; private static readonly string UNREGISTER_DISCLAIMER_1 = "This will automatically disconnet your current session."; private static readonly string UNREGISTER_DISCLAIMER_2 = "The next time you connect, you will be taken to Alpaca's Sign in page to re-authenticate with your user credentials."; private bool _diconnectFlag; public bool DiconnectFlag { get { return _diconnectFlag; } } public frmSettings(AlpacaManager manager) { InitializeComponent(); Font = GuiEnvironment.FontSettings; _manager = manager; if (_manager.HasLocalOrders()) { cmdRemoveToken.Enabled = false; lblUnregisterExplanation.Text = LOCAL_ORDERS_UNREGISTER_EXPLANATION; lblUnregisterDisclaimer.Text = LOCAL_ORDERS_UNREGISTER_DISCLAIMER_1; } else { cmdRemoveToken.Enabled = true; lblUnregisterExplanation.Text = UNREGISTER_EXPLANATION; lblUnregisterDisclaimer.Text = UNREGISTER_DISCLAIMER_2; if (!_manager.IsConnected()) lblUnregisterDisclaimer.Text.Insert(0, $"{UNREGISTER_DISCLAIMER_1 } "); } } private void frmSettings_Load(object sender, EventArgs e) { try { Size = new Size(780, 238); tabStripSettings.ItemSize = new Size(90, 30); tabStripSettings.SelectedIndex = 0; } catch (Exception ex) { throw ex; } } private void cmdExit_Click(object sender, EventArgs e) { Close(); } private void cmdRemoveToken_Click(object sender, EventArgs e) { _manager.UnregisterUser(); _diconnectFlag = _manager.IsConnected(); Close(); } private void cmdExitFromUnregister_Click(object sender, EventArgs e) { Close(); } private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { if (tabStripSettings.SelectedIndex == 0) Size = new Size(780, 238); else Size = new Size(1024, 412); } private void lblUnregisterDisclaimer_Click(object sender, EventArgs e) { } } }