Esempio n. 1
0
        //FirstSeries Update
        public static void UpdateFirstSeries(LiveCharts.WinForms.CartesianChart input, ComboBox combo1, ComboBox combo2, MetroDateTime startDate, MetroDateTime endDate)
        {
            //First Data Series
            if (combo1.SelectedItem == null)
            {
                return;
            }

            string ticker1 = VisualizeComboBox.GetComboBoxKey(combo1);

            var currentIndex = ProvideIndexHistoricalData.Provide(
                ticker1,
                CreateDatePicker.GetDate(startDate),
                CreateDatePicker.GetDate(endDate),
                "d");

            ChartValues1 = new ChartValues <DataPoint>(currentIndex.HistoricalData);

            //Indexer is not support. Thus, I need to remove the old Series
            input.Series.RemoveAt(0);

            input.Series.Insert(0, new LineSeries
            {
                Title           = VisualizeComboBox.GetComboBoxKey(combo1),
                Values          = ChartValues1,
                PointGeometry   = null,
                Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 174, 219)),
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromArgb(35, 0, 174, 219)),
                StrokeThickness = 2.5
            });
        }
Esempio n. 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);
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
        //SecondSeries Update
        public static void UpdateSecondSeries(LiveCharts.WinForms.CartesianChart input, ComboBox c1, ComboBox c2, MetroDateTime startDate, MetroDateTime endDate)
        {
            //Second Data Series
            if (c2.SelectedItem == null)
            {
                return;
            }
            if (VisualizeComboBox.GetComboBoxKey(c2) == "")
            {
                if (input.Series.Count == 2)
                {
                    input.Series.Remove(input.Series[1]);
                }
                return;
            }

            string ticker2 = VisualizeComboBox.GetComboBoxKey(c2);

            var additionalIndex = ProvideIndexHistoricalData.Provide(
                ticker2,
                CreateDatePicker.GetDate(startDate),
                CreateDatePicker.GetDate(endDate),
                "d");

            ChartValues2 = new ChartValues <DataPoint>(additionalIndex.HistoricalData);

            if (input.Series.Count == 2)
            {
                input.Series.RemoveAt(1);
            }
            input.Series.Add(new LineSeries
            {
                Title           = VisualizeComboBox.GetComboBoxKey(c2),
                Values          = ChartValues2,
                PointGeometry   = null,
                Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(124, 65, 153)),
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromArgb(35, 124, 65, 153)),
                StrokeThickness = 2.5
            });
        }
 private void ChooseEndDate_ValueChanged(object sender, EventArgs e)
 {
     CreateDatePicker.DateChanged(this.StockIndexLineChart, this.ChooseStockIndex1, this.ChooseStockIndex2, this.ChooseStartDate, this.ChooseEndDate);
 }
Esempio n. 7
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
        }