예제 #1
0
        private async Task Close()
        {
            await CancelSearch();

            Symbol = string.Empty;
            Contracts_List.Clear();

            IsVisible = false;
        }
예제 #2
0
        private async Task StartSearch(string smb)
        {
            IsSearchingInProgress = true;
            Contracts_List.Clear();

            List <ContractDetails> contractDetailsList;

            if (string.IsNullOrEmpty(smb))
            {
                contractDetailsList = TwsData.DataFeeder.GetContractDetailsList(new ContractData()
                {
                    Symbol = this.Symbol, SecType = "STK"
                });
            }
            else
            {
                contractDetailsList = TwsData.DataFeeder.GetContractDetailsList(new ContractData()
                {
                    Symbol = smb, SecType = "STK"
                });
            }

            foreach (ContractDetails cd in contractDetailsList)
            {
                ContractDetails_ViewModel contractVM = new ContractDetails_ViewModel(cd);
                await dispatcher.InvokeAsync(() => Contracts_List.Add(contractVM));

                contractVM.EndPriceUpdate_Event += ContractVM_EndPriceUpdate_Event;

                Thread t = new Thread(new ThreadStart(contractVM.StartDownloadData));
                t.Start();

                lock (countContractsUpdating_lock)
                {
                    ++countContractsUpdating;
                }
            }
        }
예제 #3
0
        //
        // Double click on contract will fire up ContractSelected_Event (to AddSymbol_ViewModel)
        //
        private async Task leftDoubleClicked()
        {
            if (SelectedReqId <= 0)
            {
                return;
            }

            ContractDetails_ViewModel contractVM = Contracts_List.FirstOrDefault(c => c.ReqId == SelectedReqId);

            if (contractVM.IsEnabled == false)
            {
                return;
            }

            // First cancel others ContractDetails requests
            foreach (ContractDetails_ViewModel cdVm in Contracts_List)
            {
                cdVm.CancelPriceUpdate();
            }

            ContractSelected_Event?.Invoke(this, new ContractDetailsRecv_EventArgs(SelectedReqId, contractVM.ContractDetails));

            await Close();
        }