Exemple #1
0
        private void CreateAndAddBox(MotivationModel motivationModel)
        {
            //actual creation
            ItemsControl itemsControl = new ItemsControl()
            {
                Height = 105, Width = 1146, BorderBrush = Brushes.Black, BorderThickness = new Thickness(5, 5, 5, 5)
            };
            Label motivationNameLabel = new Label()
            {
                Content = motivationModel.Aim, FontSize = 15, FontWeight = FontWeights.Bold, Focusable = false
            };
            ProgressBar motivationProgress = new ProgressBar()
            {
                Height = 25, Width = 1118, Maximum = motivationModel.FinalValue, Focusable = false
            };



            motivationProgress.Value = motivationModel.CurrentValue;

            Label motivationValueLabel = new Label()
            {
                Content = motivationProgress.Value + "/" + motivationProgress.Maximum + "€", FontSize = 13, FontWeight = FontWeights.DemiBold, Focusable = false
            };

            //the inclusion
            itemsControl.Items.Add(motivationNameLabel);
            itemsControl.Items.Add(motivationValueLabel);
            itemsControl.Items.Add(motivationProgress);
            MainListBox.Items.Add(itemsControl);
        }
Exemple #2
0
 private void LoadContent(MotivationModel model)
 {
     motivationToEdit      = model;
     originalMotivation    = model;
     AimNameText.Text      = model.Aim;
     CurrentValueText.Text = model.CurrentValue.ToString();
     AimValueText.Text     = model.FinalValue.ToString();
     DescriptionText.Text  = model.Description;
 }
        public MotivationModel GetByAim(string Aim)
        {
            MotivationModel returningModel = null;

            foreach (var model in Models)
            {
                if (model.Aim == Aim)
                {
                    returningModel = model;
                    break;
                }
            }
            return(returningModel);
        }
Exemple #4
0
        private void DescriptionButton(object sender, RoutedEventArgs e)
        {
            ItemsControl selectedItemsControl = (ItemsControl)MainListBox.SelectedItem;

            if (selectedItemsControl == null)
            {
                MessageBox.Show("Please select an item to show description");
            }
            else
            {
                string            fullStringToProcess      = selectedItemsControl.Items.GetItemAt(0).ToString();
                string            selectedAim              = fullStringToProcess.Substring(31);
                MotivationModel   motivationForDescription = Data.GetByAim(selectedAim);
                DescriptionWindow descriptionWindow        = new DescriptionWindow(motivationForDescription);
                descriptionWindow.Show();
            }
        }
Exemple #5
0
        private void SearchOnlineButton(object sender, RoutedEventArgs e)
        {
            ItemsControl selectedItemsControl = (ItemsControl)MainListBox.SelectedItem;

            if (selectedItemsControl == null)
            {
                MessageBox.Show("Please select an item to be searched online");
            }
            else
            {
                string          fullStringToProcess = selectedItemsControl.Items.GetItemAt(0).ToString();
                string          selectedAim         = fullStringToProcess.Substring(31);
                MotivationModel motivationToSearch  = Data.GetByAim(selectedAim);

                string searchString = Regex.Replace(selectedAim, " ", "+");

                System.Diagnostics.Process.Start($"https://www.amazon.de/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords={searchString}");
            }
        }
Exemple #6
0
        private void SaveButton(object sender, RoutedEventArgs e)
        {
            MotivationModel newModel = new MotivationModel();

            newModel.Aim          = AimNameText.Text;
            newModel.CurrentValue = Convert.ToDouble(CurrentValueText.Text);
            newModel.FinalValue   = Convert.ToDouble(AimValueText.Text);
            newModel.Description  = DescriptionText.Text;

            if (newModel.CurrentValue > newModel.FinalValue)
            {
                MessageBox.Show("You can't go above the target value");
                this.Close();
            }
            else
            {
                ((MainWindow)Application.Current.MainWindow).Data.EditUsingName(newModel, originalMotivation);
                ((MainWindow)Application.Current.MainWindow).ShowData();
                this.Close();
            }
        }
 public void EditUsingName(MotivationModel model, MotivationModel originalModel)
 {
     RemoveByAim(originalModel.Aim);
     Add(model);
     UpdateData();
 }
 public void Add(MotivationModel model)
 {
     Models.Add(model);
     UpdateData();
 }
Exemple #9
0
 public EditMotivationWindow(MotivationModel model)
 {
     InitializeComponent();
     LoadContent(model);
 }
Exemple #10
0
 private void LoadContent(MotivationModel motivationModel)
 {
     TitleBlock.Text       = motivationModel.Aim;
     DescriptionBlock.Text = motivationModel.Description;
 }
Exemple #11
0
 public DescriptionWindow(MotivationModel motivationModel)
 {
     InitializeComponent();
     LoadContent(motivationModel);
 }