Exemple #1
0
        private async void buyButton_click(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            sender.IsEnabled = true;
            if (!ClickedBuilding.IsBought())
            {
                if (ClickedBuilding.price < account.GetEarnings())
                {
                    account.setEarnings(account.GetEarnings() - ClickedBuilding.price);
                    List <AccountInfo> acc = new List <AccountInfo>();
                    acc.Add(account);
                    // await JsonSave.SavePersonalDataToJson(acc);
                    await buyBuilding(ClickedBuilding);

                    RedrawBuilding(ClickedBuilding);
                }
                else
                {
                    args.Cancel    = true;
                    sender.Title   = "not enough money";
                    sender.Content =
                        "You do not have enough money to buy the following building: " + ClickedBuilding.Name + ". \r \r you need to earn " +
                        (ClickedBuilding.price - account.GetEarnings()) + " more";
                    sender.PrimaryButtonText   = "close";
                    sender.SecondaryButtonText = "";
                    sender.UpdateLayout();
                    sender.FullSizeDesired = false;
                }
            }
        }
Exemple #2
0
        public async void EditClick(object sender, RoutedEventArgs e)
        {
            if (!DialogOpen)
            {
                DialogOpen = true;
                Button   obj      = sender as Button;
                String   objname  = obj.Name;
                String[] objnamer = objname.Split(',');
                objname = objnamer[0];
                //DBug.Text = objname.ToString() + " Edit";
                int           s          = Convert.ToInt16(objname);
                TextBlock     Namer      = LinePanel.Children[s] as TextBlock;
                var           Namer2     = Namer.Text;
                ContentDialog EditDialog = new ContentDialog
                {
                    Title               = "Editing " + Namer2,
                    PrimaryButtonText   = "Cancel",
                    SecondaryButtonText = "Accept"
                };
                TimePicker EditTime = new TimePicker();
                EditTime.TimeChanged += EditUpdater;
                EditTime.Header       = "Choose New Start Time";
                EditDialog.Content    = EditTime;
                EditDialog.UpdateLayout();
                ContentDialogResult result = await EditDialog.ShowAsync();

                if (result == ContentDialogResult.Secondary)
                {
                    Starter[s] = Convert.ToDateTime(EditTime.Time.ToString());
                    //DBug.Text = Starter[s].ToString();
                    StartBoxes[s].Text = Starter[s].ToString("hh:mm");
                }
                else
                {
                }
                this.UpdateLayout();
                DialogOpen = false;
            }
        }