コード例 #1
0
 private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (AboutDialogWindow.IsVisible)
     {
         AboutDialogWindow.CenterDialogWindow();
     }
     if (BuySellDialogWindow.IsVisible)
     {
         BuySellDialogWindow.CenterDialogWindow();
     }
 }
コード例 #2
0
        internal void ShowBuySellDialog(StockTransactionViewModel transaction, bool isBuying = false)
        {
            BuySellDialogWindow.DataContext = transaction;
            var content = BuySellDialogWindow.Content as BuySellDialogContent;

            if (isBuying)
            {
                content.MaxSellableUnits = Int16.MaxValue;
            }
            else
            {
                content.MaxSellableUnits = transaction.StockPosition.Quantity;
            }
            content.StockTransactionCompleted -= ContentStockTransactionCompleted;
            content.StockTransactionCompleted += new EventHandler <EventArgs>(ContentStockTransactionCompleted);
            BuySellDialogWindow.Show();
        }
コード例 #3
0
        void ContentStockTransactionCompleted(object sender, EventArgs e)
        {
            var stockTransaction = BuySellDialogWindow.DataContext as StockTransactionViewModel;

            if (stockTransaction == null)
            {
                return;
            }

            if
            (
                stockTransaction.Quantity == 0 ||
                stockTransaction.CurrentPricePerShare == 0
                //prevent the user from selling more units than they currently have
                || (stockTransaction.TransactionType == TransactionType.Sell && stockTransaction.Quantity > stockTransaction.StockPosition.Quantity)
            )
            {
                return;
            }

            var content = BuySellDialogWindow.Content as BuySellDialogContent;

            if (content == null)
            {
                return;
            }

            if (stockTransaction.TransactionType == TransactionType.Buy)
            {
                this._vm.BuyStock(stockTransaction);
            }
            else
            {
                this._vm.SellStock(stockTransaction);
            }

            BuySellDialogWindow.Close();
        }