示例#1
0
        virtual protected void StartOrder(string tickerSymbol, TransactionType transactionType)
        {
            if (String.IsNullOrEmpty(tickerSymbol))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "tickerSymbol"));
            }

            IRegion region = _regionManager.Regions[RegionNames.MainRegion];

            //Make Sure OrdersView is in CollapsibleRegion
            if (region.GetView("OrdersView") == null)
            {
                var ordersPresentationModel = _container.Resolve <IOrdersPresentationModel>();
                _ordersView = ordersPresentationModel.View;
                region.Add(_ordersView, "OrdersView");
                region.Activate(_ordersView);
            }

            IRegion ordersRegion = _regionManager.Regions[ORDERS_REGION];

            var orderCompositePresentationModel = _container.Resolve <IOrderCompositePresentationModel>();

            orderCompositePresentationModel.TransactionInfo     = new TransactionInfo(tickerSymbol, transactionType);
            orderCompositePresentationModel.CloseViewRequested += delegate
            {
                OrderModels.Remove(orderCompositePresentationModel);
                commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand);
                commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand);
                commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositePresentationModel.SubmitCommand);
                commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositePresentationModel.CancelCommand);
                ordersRegion.Remove(orderCompositePresentationModel.View);
            };

            ordersRegion.Add(orderCompositePresentationModel.View);
            OrderModels.Add(orderCompositePresentationModel);

            commandProxy.SubmitAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand);
            commandProxy.CancelAllOrdersCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand);

            //The following commands are Active Aware
            commandProxy.SubmitOrderCommand.RegisterCommand(orderCompositePresentationModel.SubmitCommand);
            commandProxy.CancelOrderCommand.RegisterCommand(orderCompositePresentationModel.CancelCommand);

            ordersRegion.Activate(orderCompositePresentationModel.View);
        }
示例#2
0
        virtual protected void StartOrder(string tickerSymbol, TransactionType transactionType)
        {
            if (string.IsNullOrEmpty(tickerSymbol))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "tickerSymbol"));
            }
            ShowOrdersView();

            IRegion ordersRegion = _regionManager.Regions[RegionNames.OrdersRegion];

            var orderCompositeViewModel = _containerProvider.Resolve <IOrderCompositeViewModel>();

            ordersRegion.Add(orderCompositeViewModel);
            OrderModels.Add(orderCompositeViewModel);

            orderCompositeViewModel.TransactionInfo     = new TransactionInfo(tickerSymbol, transactionType);
            orderCompositeViewModel.CloseViewRequested += delegate
            {
                OrderModels.Remove(orderCompositeViewModel);
                _commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositeViewModel.SubmitCommand);
                _commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositeViewModel.CancelCommand);
                _commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositeViewModel.SubmitCommand);
                _commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositeViewModel.CancelCommand);
                ordersRegion.Remove(orderCompositeViewModel);
                if (ordersRegion.Views.Count() == 0)
                {
                    RemoveOrdersView();
                }
            };


            _commandProxy.SubmitAllOrdersCommand.RegisterCommand(orderCompositeViewModel.SubmitCommand);
            _commandProxy.CancelAllOrdersCommand.RegisterCommand(orderCompositeViewModel.CancelCommand);
            _commandProxy.SubmitOrderCommand.RegisterCommand(orderCompositeViewModel.SubmitCommand);
            _commandProxy.CancelOrderCommand.RegisterCommand(orderCompositeViewModel.CancelCommand);

            ordersRegion.Activate(orderCompositeViewModel);
        }