예제 #1
0
 public override FieldGrid addField(GridColumnData data)
 {
     if (dataGrid == null) return null;
     FieldGrid control = new FieldGrid();
     control.IsHitTestVisible = true;
     SellButton button = new SellButton();
     button.Label = data.value;
     if (data.value.Equals(""))
         button.Visibility = Visibility.Hidden;
     button.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(button_MouseLeftButtonDown);
     control.Children.Add(button);
     return control;
 }
예제 #2
0
 public virtual FieldGrid addField(GridColumnData data)
 {
     if (dataGrid == null) return null;
     FieldGrid control = new FieldGrid();
     TextBlock text = new TextBlock();
     text.TextAlignment = TextAlignment.Center;
     text.TextWrapping = TextWrapping.Wrap;
     text.Text = data.value;
     text.FontFamily = new FontFamily( "Trebuchet MS" );
     text.Margin = new Thickness(10, dataGrid.RowHeight / 2 - text.FontSize / 2, 10, 0);
     control.Children.Add(text);
     return control;
 }
예제 #3
0
        public void LoadData()
        {
            // get quotes based on QuotesParameter
            if (App.BSL == null || Login.UserInfo == null) return;

            try
            {
                Update.Text = "as of " + DateTime.Now;
                GetQuote.Text = QuotesParameter;
                string[] quotes = QuotesParameter.Split(new char[] { ' ', ',', ';' });
                DataProvider data = new DataProvider();
                foreach (string quote in quotes)
                {
                    string quoteTrim = quote.Trim();
                    if (!quoteTrim.Equals(""))
                    {
                        QuoteDataModel quoteData = App.BSL.getQuote(quoteTrim);
                        if (quoteData == null) continue;

                        RowDataProvider row = new RowDataProvider();
                        data.Add(row);
                        row.id = data.Count - 1;

                        GridColumnData symbol = new GridColumnData();
                        symbol.value = quoteData.symbol;
                        symbol.numeric = (int)(quoteData.price * 100);
                        row.Add(symbol);

                        GridColumnData company = new GridColumnData();
                        company.value = quoteData.companyName;
                        company.numeric = (int)(quoteData.price * 100);
                        row.Add(company);

                        GridColumnData volume = new GridColumnData();
                        volume.value = string.Format("{0:0,0}", quoteData.volume);
                        volume.numeric = (int)(quoteData.volume * 100);
                        row.Add(volume);

                        GridColumnData range = new GridColumnData();
                        range.value = string.Format("{0:C}", quoteData.low) + " - " + string.Format("{0:C}", quoteData.high);
                        range.numeric = (int)(quoteData.low * 100);
                        row.Add(range);

                        GridColumnData open = new GridColumnData();
                        open.value = string.Format("{0:C}", quoteData.open);
                        open.numeric = (int)(quoteData.low * 100);
                        row.Add(open);

                        GridColumnGainData current = new GridColumnGainData();
                        current.value = string.Format("{0:C}", quoteData.price);
                        current.numeric = (int)(quoteData.price * 100);
                        current.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(current);

                        GridColumnGainData gain = new GridColumnGainData();
                        gain.value = string.Format("{0:C}", quoteData.change);
                        gain.numeric = (int)(quoteData.change * 100);
                        gain.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(gain);

                        GridColumnData buy = new GridColumnData();
                        buy.value = "BUY";
                        buy.numeric = (int)(quoteData.change * 100);
                        row.Add(buy);
                    }
                }

                QuoteGrid.setData(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }