/// <summary> /// Binds the vector to edit/create to this form. /// </summary> /// <param name="editedObject">The sequence of dates to edit/create.</param> public void Bind(IEditable editedObject) { this.editedObject = editedObject as ModelParameterArray; if (editedObject != null) { // Bind the ModelParameterArray information to the GUI this.textBoxName.Text = string.IsNullOrEmpty(this.editedObject.Name) ? string.Empty : this.editedObject.Name; this.publishingInfoControl.DataExchange(true, this.editedObject); if (this.editedObject is ModelParameterDateSequence) { // Binds the date sequence specific information to the GUI object startDateExpression = ((ModelParameterDateSequence)this.editedObject).StartDateExpression.Expr.GetValue(0, 0); if (startDateExpression is DateTime) { this.expressionStartDate.Text = ((DateTime)startDateExpression).ToShortDateString(); } else { this.expressionStartDate.Text = startDateExpression.ToString(); } object endDateExpression = ((ModelParameterDateSequence)this.editedObject).EndDateExpression.Expr.GetValue(0, 0); if (endDateExpression is DateTime) { this.expressionEndDate.Text = ((DateTime)endDateExpression).ToShortDateString(); } else { this.expressionEndDate.Text = endDateExpression.ToString(); } this.comboBoxFrequency.Text = ((ModelParameterDateSequence)this.editedObject).FrequencyExpression; this.expressionSkipPeriods.Text = ((ModelParameterDateSequence)this.editedObject).SkipPeriods.Expr.GetValue(0, 0).ToString(); this.expressionSkipPeriodsArray.Text = ((ModelParameterDateSequence)this.editedObject).SkipPeriodsArray?.Expr.GetValue(0, 0).ToString(); this.checkBoxFollowFrequency.Checked = ((ModelParameterDateSequence)this.editedObject).FollowFrequency; this.comboBoxDatesGeneration.SelectedIndex = ((ModelParameterDateSequence)this.editedObject).GenerateSequenceFromStartDate ? 0 : 1; this.expressionVectorRef.Text = ((ModelParameterDateSequence)this.editedObject).VectorReferenceExpr; } else { // Initialize the other elements of the GUI to their default this.expressionStartDate.Text = DateTime.Now.Date.ToShortDateString(); this.expressionEndDate.Text = DateTime.Now.Date.ToShortDateString(); this.comboBoxFrequency.SelectedIndex = 0; } } }
private bool ValidVectorRef() { bool useVector = false; ModelParameterArray arrayReference = null; if (!string.IsNullOrEmpty(this.VectorReferenceExpr)) { arrayReference = GetVectorRef(); if (!Engine.Parser.GetParserError() && arrayReference != null && arrayReference.Values.Count > 0) { useVector = true; } } return(useVector); }
/// <summary> /// Restores the values of the parameter. /// </summary> /// <param name="parameter">The parameter.</param> /// <param name="dictionary">A dictionary containing the values of the parameter.</param> private void RestoreValues(ModelParameterArray parameter, IDictionary <string, object> dictionary) { if (parameter is ModelParameterDateSequence) { var dateSequence = (ModelParameterDateSequence)parameter; dateSequence.StartDateExpression = (ModelParameter)dictionary["StartDateExpression"]; dateSequence.SkipPeriods = (ModelParameter)dictionary["SkipPeriods"]; dateSequence.FollowFrequency = (bool)dictionary["FollowFrequency"]; dateSequence.EndDateExpression = (ModelParameter)dictionary["EndDateExpression"]; dateSequence.FrequencyExpression = (string)dictionary["FrequencyExpression"]; dateSequence.GenerateSequenceFromStartDate = (bool)dictionary["GenerateSequenceFromStartDate"]; dateSequence.VectorReferenceExpr = (string)dictionary["VectorReferenceExpr"]; dateSequence.SkipPeriodsArray = (ModelParameter)dictionary["SkipPeriodsArray"]; } else { parameter.Expr = (Array)dictionary["Expr"]; } }
/// <summary> /// Saves the values of the parameter. /// </summary> /// <param name="parameter">The parameter.</param> /// <returns>A dictionary containing the values of the parameter.</returns> private IDictionary <string, object> StoreValues(ModelParameterArray parameter) { IDictionary <string, object> dictionary = new Dictionary <string, object>(); if (parameter is ModelParameterDateSequence) { var dateSequence = (ModelParameterDateSequence)parameter; dictionary.Add("StartDateExpression", dateSequence.StartDateExpression); dictionary.Add("SkipPeriods", dateSequence.SkipPeriods); dictionary.Add("FollowFrequency", dateSequence.FollowFrequency); dictionary.Add("EndDateExpression", dateSequence.EndDateExpression); dictionary.Add("FrequencyExpression", dateSequence.FrequencyExpression); dictionary.Add("GenerateSequenceFromStartDate", dateSequence.GenerateSequenceFromStartDate); dictionary.Add("VectorReferenceExpr", dateSequence.VectorReferenceExpr); dictionary.Add("SkipPeriodsArray", dateSequence.SkipPeriodsArray); } else { dictionary.Add("Expr", parameter.Expr); } return(dictionary); }
/// <summary> /// Binds the vector to edit/create to this form. /// </summary> /// <param name="editedObject">The sequence of dates to edit/create.</param> public void Bind(IEditable editedObject) { this.editedObject = editedObject as ModelParameterArray; if (editedObject != null) { // Bind the ModelParameterArray information to the GUI this.textBoxName.Text = string.IsNullOrEmpty(this.editedObject.Name) ? string.Empty : this.editedObject.Name; this.publishingInfoControl.DataExchange(true, this.editedObject); if (this.editedObject is ModelParameterDateSequence) { // Binds the date sequence specific information to the GUI this.expressionStartDate.Text = ((ModelParameterDateSequence)this.editedObject).StartDateExpression; this.expressionEndDate.Text = ((ModelParameterDateSequence)this.editedObject).EndDateExpression; this.comboBoxFrequency.Text = ((ModelParameterDateSequence)this.editedObject).FrequencyExpression; this.checkBoxExclude.Checked = ((ModelParameterDateSequence)this.editedObject).ExcludeStartDate; } else { // Initialize the other elements of the GUI to their default this.expressionStartDate.Text = DateTime.Now.Date.ToShortDateString(); this.expressionEndDate.Text = DateTime.Now.Date.ToShortDateString(); this.comboBoxFrequency.SelectedIndex = 0; } } }
/// <summary> /// Saves the values of the parameter. /// </summary> /// <param name="parameter">The parameter.</param> /// <returns>A dictionary containing the values of the parameter.</returns> private IDictionary<string, object> StoreValues(ModelParameterArray parameter) { IDictionary<string, object> dictionary = new Dictionary<string, object>(); if (parameter is ModelParameterDateSequence) { var dateSequence = (ModelParameterDateSequence)parameter; dictionary.Add("StartDateExpression", dateSequence.StartDateExpression); dictionary.Add("SkipPeriods", dateSequence.SkipPeriods); dictionary.Add("FollowFrequency", dateSequence.FollowFrequency); dictionary.Add("EndDateExpression", dateSequence.EndDateExpression); dictionary.Add("FrequencyExpression", dateSequence.FrequencyExpression); dictionary.Add("GenerateSequenceFromStartDate", dateSequence.GenerateSequenceFromStartDate); } else { dictionary.Add("Expr", parameter.Expr); } return dictionary; }
/// <summary> /// Restores the values of the parameter. /// </summary> /// <param name="parameter">The parameter.</param> /// <param name="dictionary">A dictionary containing the values of the parameter.</param> private void RestoreValues(ModelParameterArray parameter, IDictionary<string, object> dictionary) { if (parameter is ModelParameterDateSequence) { var dateSequence = (ModelParameterDateSequence)parameter; dateSequence.StartDateExpression = (ModelParameter)dictionary["StartDateExpression"]; dateSequence.SkipPeriods = (ModelParameter)dictionary["SkipPeriods"]; dateSequence.FollowFrequency = (bool)dictionary["FollowFrequency"]; dateSequence.EndDateExpression = (ModelParameter)dictionary["EndDateExpression"]; dateSequence.FrequencyExpression = (string)dictionary["FrequencyExpression"]; dateSequence.GenerateSequenceFromStartDate = (bool)dictionary["GenerateSequenceFromStartDate"]; } else { parameter.Expr = (Array)dictionary["Expr"]; } }
/// <summary> /// Binds the vector to edit/create to this form. /// </summary> /// <param name="editedObject">The sequence of dates to edit/create.</param> public void Bind(IEditable editedObject) { this.editedObject = editedObject as ModelParameterArray; if (editedObject != null) { // Bind the ModelParameterArray information to the GUI this.textBoxName.Text = string.IsNullOrEmpty(this.editedObject.Name) ? string.Empty : this.editedObject.Name; this.publishingInfoControl.DataExchange(true, this.editedObject); if (this.editedObject is ModelParameterDateSequence) { // Binds the date sequence specific information to the GUI object startDateExpression = ((ModelParameterDateSequence)this.editedObject).StartDateExpression.Expr.GetValue(0, 0); if (startDateExpression is DateTime) this.expressionStartDate.Text = ((DateTime)startDateExpression).ToShortDateString(); else this.expressionStartDate.Text = startDateExpression.ToString(); object endDateExpression = ((ModelParameterDateSequence)this.editedObject).EndDateExpression.Expr.GetValue(0, 0); if (endDateExpression is DateTime) this.expressionEndDate.Text = ((DateTime)endDateExpression).ToShortDateString(); else this.expressionEndDate.Text = endDateExpression.ToString(); this.comboBoxFrequency.Text = ((ModelParameterDateSequence)this.editedObject).FrequencyExpression; this.expressionSkipPeriods.Text = ((ModelParameterDateSequence)this.editedObject).SkipPeriods.Expr.GetValue(0, 0).ToString(); this.checkBoxFollowFrequency.Checked = ((ModelParameterDateSequence)this.editedObject).FollowFrequency; this.comboBoxDatesGeneration.SelectedIndex = ((ModelParameterDateSequence)this.editedObject).GenerateSequenceFromStartDate ? 0 : 1; } else { // Initialize the other elements of the GUI to their default this.expressionStartDate.Text = DateTime.Now.Date.ToShortDateString(); this.expressionEndDate.Text = DateTime.Now.Date.ToShortDateString(); this.comboBoxFrequency.SelectedIndex = 0; } } }