Exemplo n.º 1
0
 public MoneyForm(TokenMachine machine, string totalPrice, Label due)
 {
     InitializeComponent();
     _machine    = machine;
     _totalPrice = totalPrice.Substring(0, 1) == "£" ? totalPrice.Substring(1) : totalPrice;
     _due        = due;
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public TokenMachineGUI(Counter _counter)
        {
            InitializeComponent();

            //SetupFile();
            dayPassPrice = decimal.Round((decimal)rand.NextDouble(), 2) * 10;
            _machine     = new TokenMachine(dayPassPrice);
            //var hold = Persister.ReadFromBinaryFile<List<Station>>(@"Stations.txt");
            //cbStartStation.DataSource = hold;
            //cbStartStation.Text = "location";

            LoadStations();

            foreach (var station in _stations.GetStations())
            {
                cbStartStation.Items.Add(station);
            }
            cbStartStation.SelectedIndex = 0;
            foreach (var route in _routes.GetRoutesFromStation((Station)cbStartStation.SelectedItem))
            {
                cbEndStation.Items.Add(route.GetEndPoint());
            }
            if (cbEndStation.Items.Count > 0)
            {
                cbEndStation.SelectedIndex = 0;
            }
            SetupLanguages();
            DisplayLangList();
            counter = _counter;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Used to clear any control on the form.
        /// Useful when resetting back to main screen to ensure the next user has a blank canvas and no previous details are kept.
        /// </summary>
        private void ResetControls()
        {
            foreach (var x in Controls.OfType <Button>())
            {
                x.Text = "";
            }

            foreach (var x in Controls.OfType <Label>())
            {
                if (x.Name == "lblAccountUsername")
                {
                    Controls.Remove(x);
                }
                //x.Text = "";
            }

            foreach (var x in Controls.OfType <TextBox>())
            {
                x.Text = "";
            }

            foreach (var x in Controls.OfType <ListBox>())
            {
                x.Items.Clear();
            }

            foreach (var x in Controls.OfType <NumericUpDown>())
            {
                x.Value = 1;
            }

            foreach (var x in Controls.OfType <ComboBox>())
            {
                // x.Items.Clear();
                // Cannot do this as it's bound by a datasource. Need to change the datasource to change the items in the combobox.
                // So when changing language, set the new datasource.
            }

            foreach (var x in Controls.OfType <PictureBox>())
            {
                if (x.Name.Contains("account"))
                {
                    Controls.Remove(x);
                    x.Dispose();
                }
            }

            _actionStack.Clear();
            _account = new Account().Logout(_account);
            _machine = new TokenMachine(dayPassPrice);
        }