Example #1
0
        public MainWindow()
        {
            this.currencyCalculator = CurrencyCalculatorFactory.GetCalculator();

            this.txtLeftValue = new TextBox()
            {
                Width  = 80,
                Margin = new Thickness(10)
            };

            this.txtRightValue = new TextBox()
            {
                Width  = 80,
                Margin = new Thickness(10)
            };

            this.cmbLeftCurrency = new ComboBox()
            {
                Margin = new Thickness(10)
            };

            this.cmbRightCurrency = new ComboBox()
            {
                Margin = new Thickness(10)
            };

            // Version 1:
            //foreach (var currency in currencyCalculator.GetCurrencyData())
            //{
            //    this.cmbLeftCurrency.Items.Add(currency);
            //    this.cmbRightCurrency.Items.Add(currency);
            //}

            // Version 2:
            var currencies = currencyCalculator.GetCurrencyData();

            this.cmbLeftCurrency.ItemsSource  = currencies;
            this.cmbRightCurrency.ItemsSource = currencies;

            StackPanel panel = new StackPanel();

            panel.Children.Add(txtLeftValue);
            panel.Children.Add(cmbLeftCurrency);
            panel.Children.Add(txtRightValue);
            panel.Children.Add(cmbRightCurrency);

            panel.Orientation = Orientation.Horizontal;

            this.cmbLeftCurrency.SelectedItem  = currencies.Where(p => p.Symbol == "CHF").First();
            this.cmbRightCurrency.SelectedItem = currencies.Where(p => p.Symbol == "EUR").First();

            this.cmbLeftCurrency.SelectionChanged  += OnSelectionChanged;
            this.cmbRightCurrency.SelectionChanged += OnSelectionChanged;

            this.Content = panel;

            this.SizeToContent = SizeToContent.WidthAndHeight;
        }
Example #2
0
        public CurrencyCalculatorWindow()
        {
            txtLeftValue = new TextBox()
            {
                Width = 80
            };
            txtRightValue = new TextBox()
            {
                Width = 80
            };
            cmbLeftCurrency = new ComboBox()
            {
                Margin = new Thickness(5, 0, 5, 0)
            };
            cmbRightCurrency = new ComboBox()
            {
                Margin = new Thickness(5, 0, 0, 0)
            };

            StackPanel panel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(10)
            };

            panel.Children.Add(txtLeftValue);
            panel.Children.Add(cmbLeftCurrency);
            panel.Children.Add(txtRightValue);
            panel.Children.Add(cmbRightCurrency);

            this.Content = panel;
            this.Title   = "WPF Currency Converter (Code)";

            // wie sich der content des windows anpassen soll
            this.SizeToContent = SizeToContent.WidthAndHeight;
            this.ResizeMode    = ResizeMode.NoResize;

            this.calculator = CurrencyCalculatorFactory.GetCalculator();

            foreach (CurrencyData currency in calculator.GetCurrencyData())
            {
                cmbLeftCurrency.Items.Add(currency);
                cmbRightCurrency.Items.Add(currency);
            }

            cmbLeftCurrency.SelectedIndex = cmbRightCurrency.SelectedIndex = 0;

            cmbLeftCurrency.SelectionChanged  += OnSelectionChanged;
            cmbRightCurrency.SelectionChanged += OnSelectionChanged;

            txtLeftValue.TextChanged  += OnTextChanged;
            txtRightValue.TextChanged += OnTextChanged;
        }
        public CurrencyCalculatorWindow()
        {
            InitializeComponent();

            calculator = CurrencyCalculatorFactory.GetCalculator();

            IEnumerable <CurrencyData> currencies = calculator.GetCurrencyData();

            cmbLeftCurrency.ItemsSource = cmbRightCurrency.ItemsSource = currencies;

            cmbLeftCurrency.SelectedItem  = currencies.First(c => c.Symbol == "EUR");
            cmbRightCurrency.SelectedItem = currencies.First(c => c.Symbol == "JPY");
        }
Example #4
0
        public MainWindow()
        {
            InitializeComponent();
            currencyCalcualtor = CurrencyCalculatorFactory.GetCalculator();
            var currency = currencyCalcualtor.GetCurrencyData();

            foreach (var currencyData in currency)
            {
                cmbLeftCurrency.Items.Add(currencyData);
                cmbRightCurrency.Items.Add(currencyData);
            }
            cmbLeftCurrency.SelectedItem  = currency.First(c => c.Symbol == "EUR");
            cmbRightCurrency.SelectedItem = currency.First(c => c.Symbol == "USD");
        }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();

            this.currencyCalculator = CurrencyCalculatorFactory.GetCalculator();

            var currencies = this.currencyCalculator.GetCurrencyData();

            this.cmbLeftCurrency.ItemsSource  = currencies;
            this.cmbRightCurrency.ItemsSource = currencies;

            this.cmbLeftCurrency.SelectedIndex  = 0;
            this.cmbRightCurrency.SelectedIndex = 0;

            rates.ItemsSource = this.currencyCalculator.MonthlyRatesOfExchange("CHF", "EUR", new DateTime(2016, 1, 1), new DateTime(2017, 1, 1));
        }
        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="T:System.Windows.Window"/>-Klasse.
        /// </summary>
        public CurrencyCalcualtorWindow()
        {
            txtLeftValue = new TextBox {
                Width = 80
            };
            txtRightValue = new TextBox {
                Width = 80
            };
            cmbLeftCurrency = new ComboBox {
                Margin = new Thickness(5, 0, 5, 0)
            };
            cmbRightCurrency = new ComboBox {
                Margin = new Thickness(5, 0, 0, 0)
            };

            currencyCalcualtor = CurrencyCalculatorFactory.GetCalculator();

            foreach (var currencyData in currencyCalcualtor.GetCurrencyData())
            {
                cmbLeftCurrency.Items.Add(currencyData);
                cmbRightCurrency.Items.Add(currencyData);
            }

            StackPanel panel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Orientation         = Orientation.Horizontal,
                Margin = new Thickness(10)
            };

            panel.Children.Add(txtLeftValue);
            panel.Children.Add(cmbLeftCurrency);
            panel.Children.Add(txtRightValue);
            panel.Children.Add(cmbRightCurrency);
            Content            = panel;
            this.SizeToContent = SizeToContent.WidthAndHeight;
            this.ResizeMode    = ResizeMode.NoResize;

            cmbLeftCurrency.SelectionChanged  += OnSelectionChanged;
            cmbRightCurrency.SelectionChanged += OnSelectionChanged;
        }