/// <summary>
        /// 
        /// </summary>
        public AccountStatisticsControl(Account account)
        {
            InitializeComponent();

            if (this.DesignMode)
            {
                return;
            }

            _account = account;

            _account.UpdatedEvent += new Account.AccountUpdateDelegate(_account_UpdateEvent);
            chartPane1.Add(_chartSeries);
        }
        void _account_UpdateEvent(Account account)
        {
            if (this.DesignMode)
            {
                return;
            }

            WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(250), UpdateUI);
        }
 void _account_UpdateEvent(Account account)
 {
     UpdateValues();
 }
 void _executionAccount_UpdateEvent(Account accountInfo)
 {
     WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI);
 }
        public void UnInitialize()
        {
            bool update = false;
            lock (_syncRoot)
            {
                if (_account != null)
                {
                    _account.UpdatedEvent -= new Account.AccountUpdateDelegate(_account_UpdateEvent);
                    _account.OperationalStateChangedEvent -= new CommonSupport.OperationalStateChangedDelegate(_account_OperationalStatusChangedEvent);

                    IOrderSink executor = _account.OrderExecutionProvider;
                    if (executor != null)
                    {
                        executor.OrdersUpdatedEvent -= new OrdersUpdateDelegate(OrderExecutionProvider_OrderUpdatedEvent);
                        update = true;
                    }
                    _account = null;
                }
            }

            if (update)
            {
                UpdateOrdersStatistics();
            }
        }
        public bool Initialize(Account account)
        {
            SystemMonitor.CheckWarning(IsInitialized == false, "Instance already initialized.");

            if (IsInitialized)
            {
                return false;
            }

            lock (_syncRoot)
            {
                _equityHistory = new Dictionary<DateTime, Decimal>();

                _account = account;
                _account.UpdatedEvent += new Account.AccountUpdateDelegate(_account_UpdateEvent);
                _account.OperationalStateChangedEvent += new CommonSupport.OperationalStateChangedDelegate(_account_OperationalStatusChangedEvent);

                if (account.Info.Equity.HasValue)
                {
                    _initialEquity = account.Info.Equity.Value;
                }
                else
                {
                    _initialEquity = null;
                }

                IOrderSink executor = account.OrderExecutionProvider;
                if (executor != null)
                {
                    executor.OrdersUpdatedEvent += new OrdersUpdateDelegate(OrderExecutionProvider_OrderUpdatedEvent);
                    //OrderExecutionProvider_OrderUpdatedEvent(executor, _account.Info, new string[] { }, new OrderInfo[] { }, new Order.UpdateTypeEnum[] { });
                }
            }

            return true;
        }
 void AddAccountControl(Account account)
 {
     AccountControl control = new AccountControl();
     control.Account = account;
     _accountControls.Add(control);
     this.Controls.Add(control);
 }
        void PlatformSourceOrderExecutionProvider_OperationalStateChangedEvent(IOperational operational, OperationalStateEnum previousOperationState)
        {
            if (OperationalState == OperationalStateEnum.Operational && _accounts.Length == 0)
            {
                if (base.SubscribeToAccounts() == false)
                {
                    SystemMonitor.Error("Failed to subscribe to source. Further operations will not proceed as expected.");
                }

                AccountInfo[] accountInfos;
                if (base.GetAvailableAccountInfos(out accountInfos) && accountInfos.Length > 0)
                {
                    lock (this)
                    {
                        _accounts = new Account[accountInfos.Length];
                        for (int i = 0; i < accountInfos.Length; i++)
                        {
                            _accounts[i] = new RemoteExecutionAccount(accountInfos[i]);
                            _accounts[i].SetInitialParameters(_manager, this, _manager.GetDataDelivery(_dataSourced));
                            _accounts[i].Initialize(this);
                        }

                        if (_accounts.Length > 0)
                        {
                            _defaultAccount = _accounts[0];
                        }
                        else
                        {
                            _defaultAccount = null;
                        }
                    }
                }
                else
                {
                    SystemMonitor.Warning("Failed to establish accounts (default account) on Order Execution Provider.");
                }
            }
        }
        public void UnInitialize()
        {
            lock (this)
            {
                if (_account != null)
                {
                    _account.UpdatedEvent -= new Account.AccountUpdateDelegate(_account_UpdateEvent);
                    _account.OperationalStateChangedEvent -= new CommonSupport.OperationalStateChangedDelegate(_account_OperationalStatusChangedEvent);

                    IOrderSink executor = _account.OrderExecutionProvider;
                    if (executor != null)
                    {
                        executor.OrdersUpdatedEvent -= new OrdersUpdateDelegate(OrderExecutionProvider_OrderUpdatedEvent);
                        UpdateOrdersStatistics();
                    }
                    _account = null;
                }
            }
        }