public TradeScreen(ScreenComponent manager, IInventory trader, IInventory player)
            : base(manager, new Point(400, 300))
        {
            this.trader = trader;
            this.player = player;

            Controls.Add(new Panel(manager)
            {
                Position = new Rectangle(20, 20, 360, 40)
            });
            Controls.Add(new Label(manager)
            {
                Text = "Shop", Position = new Rectangle(40, 30, 0, 0)
            });

            // Verkaufbare Items des Trader-Inventars auf die Liste setzen
            list = new TraderList(manager)
            {
                Position = new Rectangle(20, 70, 360, 210)
            };
            list.OnInteract += OnInteract;
            foreach (var item in trader.Inventory.Where(i => i.Value.HasValue).OrderBy(i => i.Value))
            {
                list.Items.Add(new TradingItem()
                {
                    Tag   = item,
                    Text  = item.Name,
                    Icon  = item.Icon,
                    Value = item.Value.Value
                });
            }
            Controls.Add(list);
            CheckAvailability();
        }
        private void View_UserList_Loaded(object sender, RoutedEventArgs e)
        {
            List <Trader> userList = new List <Trader>();
            TraderList    dblist   = new TraderList();

            userList = dblist.SearchForUser(0);

            listBox_reportList.ItemsSource = userList;
        }
        private void button_ViewProfile_Click(object sender, RoutedEventArgs e)
        {
            //need to differentiate Mod and Trader view also..
            //For now implement the Trader view
            Trader_Profile_View_Trader frm = new Trader_Profile_View_Trader();
            TraderList    tl = new TraderList();
            List <Trader> lt = tl.SearchForUser(textBlock_SellerName.Text);

            frm.DataContext = lt[0];
            frm.Show();
        }
        private void resultListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Listing      li = (Listing)resultsListBox.SelectedItem; //selected listing
            Listing_View lv = new Listing_View();

            lv.DataContext = li;                               //data binding
            TraderList    tl = new TraderList();
            List <Trader> lt = tl.SearchForUser(li.Trader_id); //look for username using trader_id

            lv.textBlock_SellerName.DataContext = lt[0];       //bind the Textblock to list of trader (ideally list consists of 1 object though)
            lv.Show();
        }
Beispiel #5
0
        private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            Trader        login        = new Trader();
            TraderList    userlist     = new TraderList();
            List <Trader> searchResult = userlist.SearchForUser(usernameTextBox.Text);

            if (searchResult.Count == 0)
            {
                Invalid_Login badLogin = new Invalid_Login();
                badLogin.Show();
            }
            else
            {
                for (int i = 0; i < searchResult.Count; i++)
                {
                    if (searchResult[i].Password == passwordBox.Password)
                    {
                        login = searchResult[i];

                        if (login.isModerator())
                        {
                            Moderator      mod     = new Moderator(login.Username, login.Password, login.FirstName, login.LastName, login._Email.ToString(), login.Trader_id, login.isModerator());
                            Moderator_Home modhome = new Moderator_Home(mod);
                            modhome.Show();
                            this.Close();
                        }
                        else
                        {
                            TraderHome tradehome = new TraderHome(login);
                            tradehome.Show();
                            this.Close();
                        }

                        break;
                    }
                }
            }
        }
        public TradeScreen(ScreenComponent manager, IInventory trader, IInventory player)
            : base(manager, new Point(400, 300))
        {
            this.trader = trader;
            this.player = player;

            Controls.Add(new Panel(manager) { Position = new Rectangle(20, 20, 360, 40) });
            Controls.Add(new Label(manager) { Text = "Shop", Position = new Rectangle(40, 30, 0, 0) });

            // Verkaufbare Items des Trader-Inventars auf die Liste setzen
            list = new TraderList(manager) { Position = new Rectangle(20, 70, 360, 210) };
            list.OnInteract += OnInteract;
            foreach (var item in trader.Inventory.Where(i => i.Value.HasValue).OrderBy(i => i.Value))
                list.Items.Add(new TradingItem()
                    { 
                        Tag = item,
                        Text = item.Name, 
                        Icon = item.Icon, 
                        Value = item.Value.Value
                    });
            Controls.Add(list);
            CheckAvailability();
        }
        private void createAccountButton_Click(object sender, RoutedEventArgs e)
        {
            //int id = 0;
            Username_Taken takenWindow = new Username_Taken();
            TraderList     userList    = new TraderList();

            if (userList.UserExists(usernameBox.Text))
            {
                takenWindow.Show();
            }
            else
            {
                userList.CreateList();
                //if (userList.Traderlist.Count == 0)
                //    id = 0;
                //else
                //    id = userList.Traderlist.Count - 1;
                Trader newTrader = new Trader(usernameBox.Text, passwordBox.Password, firstNameBox.Text, lastNameBox.Text, emailBox.Text);
                userList.Add(newTrader);
                Login loginWindow = new Login();
                loginWindow.Show();
                this.Close();
            }
        }