Beispiel #1
0
        /// <summary>
        /// Updates the Targets of every field. This is done when changes get discarded. So the values get overridden with the values in the source of the binding
        /// </summary>
        private void UpdateTargets()
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null)
            {
                be.UpdateTarget();
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Checks if the scenario details need saving or not
        /// </summary>
        /// <returns></returns>
        public bool NeedSave()
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Updates the changes in the scenario values into the datamodel. Occurs when the save button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveDataButton_OnClickDataButton_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null)
            {
                be.UpdateSource();
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            WorkbookModel workbook = new WorkbookModel(Globals.ThisAddIn.Application.ActiveWorkbook);

            workbook.ShouldScanAfterSave = false;
            Globals.ThisAddIn.Application.ActiveWorkbook.Save();
            workbook.ShouldScanAfterSave = true;
        }
Beispiel #4
0
        private void ScenarioDetailPane_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (DataContext == null || !(DataContext is Scenario))
            {
                return;
            }

            var myScenario = DataContext as Scenario;

            //update bindings

            #region binding definitions

            var titleBinding = new Binding()
            {
                Source = myScenario,
                Path   = new PropertyPath("Title"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            var authorBinding = new Binding()
            {
                Source = myScenario,
                Path   = new PropertyPath("Author"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            var creationDateBinding = new Binding()
            {
                Source = myScenario,
                Path   = new PropertyPath("CrationDate"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            var ratingBinding = new Binding()
            {
                Source = myScenario,
                Path   = new PropertyPath("Rating"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            var descriptionBinding = new Binding()
            {
                Source = myScenario,
                Path   = new PropertyPath("Description"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };

            #endregion

            #region set bindings

            //task pane title
            PaneTitle.SetBinding(TextBlock.TextProperty, titleBinding);

            //general

            #region general

            //title

            TitleTextBox.SetBinding(TextBox.TextProperty, titleBinding);

            //author
            AuthorTextbox.SetBinding(TextBox.TextProperty, authorBinding);

            //creation date
            CreateDatePicker.SetBinding(DatePicker.SelectedDateProperty, creationDateBinding);

            //rating
            RatingTextBox.SetBinding(TextBox.TextProperty, ratingBinding);

            #endregion

            //description
            DescriptionTextBox.SetBinding(TextBox.TextProperty, descriptionBinding);

            // input, intermediate and result cells data
            ScenarioDataCollection = new CompositeCollection();

            #region collection container

            var inputDataCContainer = new CollectionContainer()
            {
                Collection = (DataContext as Scenario).Inputs
            };
            ScenarioDataCollection.Add(inputDataCContainer);

            var intermediateCContainer = new CollectionContainer()
            {
                Collection = (DataContext as Scenario).Intermediates
            };
            ScenarioDataCollection.Add(intermediateCContainer);

            var resultDataCContainer = new CollectionContainer()
            {
                Collection = (DataContext as Scenario).Results
            };
            ScenarioDataCollection.Add(resultDataCContainer);

            #endregion

            ScenarioDataListBox.ItemsSource = ScenarioDataCollection;

            #endregion
        }