コード例 #1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DateTime     dp                = this.dateTimePicker1.Value;
            DateTime     start             = new DateTime(dp.Year, dp.Month, dp.Day, dp.Hour, dp.Minute, dp.Second);
            string       name              = this.IdTextBox.Text;
            int          timeStepLength    = Convert.ToInt32(this.textBoxTimeStepLength.Text);
            int          numberOfTimesteps = Convert.ToInt32(this.textBoxNumberOfTimeSteps.Text);
            double       defaultValue      = Convert.ToDouble(this.DefaultValueTextBox.Text);
            TimestepUnit timeStepUnit      = new TimestepUnit();


            if (this.comboBoxTimeStepLength.Text == "Years")
            {
                timeStepUnit = TimestepUnit.Years;
            }
            else if (this.comboBoxTimeStepLength.Text == "Months")
            {
                timeStepUnit = TimestepUnit.Months;
            }
            else if (this.comboBoxTimeStepLength.Text == "Days")
            {
                timeStepUnit = TimestepUnit.Days;
            }
            else if (this.comboBoxTimeStepLength.Text == "Hours")
            {
                timeStepUnit = TimestepUnit.Hours;
            }
            else if (this.comboBoxTimeStepLength.Text == "Minutes")
            {
                timeStepUnit = TimestepUnit.Minutes;
            }
            else if (this.comboBoxTimeStepLength.Text == "Seconds")
            {
                timeStepUnit = TimestepUnit.Seconds;
            }
            else
            {
                throw new System.Exception("invalid timestep length unit");
            }

            if (this.timestampBasedRadioButton.Checked)
            {
                timeSeries = new TimestampSeries(name, start, numberOfTimesteps, timeStepLength, timeStepUnit, defaultValue);
            }
            else if (this.timespanBasedRadioButton.Checked)
            {
                timeSeries = new TimespanSeries(name, start, numberOfTimesteps, timeStepLength, timeStepUnit, defaultValue);
            }
            else
            {
                throw new Exception("Unexpected exception in TimeSeriesCreationDialog");
            }

            this.Close();
        }
コード例 #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DateTime dp = this.dateTimePicker1.Value;
            DateTime start = new DateTime(dp.Year, dp.Month, dp.Day, dp.Hour, dp.Minute, dp.Second);
            string name = this.IdTextBox.Text;
            int timeStepLength = Convert.ToInt32(this.textBoxTimeStepLength.Text);
            int numberOfTimesteps = Convert.ToInt32(this.textBoxNumberOfTimeSteps.Text);
            double defaultValue = Convert.ToDouble(this.DefaultValueTextBox.Text);
            TimestepUnit timeStepUnit = new TimestepUnit();
            

            if (this.comboBoxTimeStepLength.Text == "Years")
            {
                timeStepUnit = TimestepUnit.Years;
            }
            else if (this.comboBoxTimeStepLength.Text == "Months")
            {
                timeStepUnit = TimestepUnit.Months;
            }
            else if (this.comboBoxTimeStepLength.Text == "Days")
            {
                timeStepUnit = TimestepUnit.Days;
            }
            else if (this.comboBoxTimeStepLength.Text == "Hours")
            {
                timeStepUnit = TimestepUnit.Hours;
            }
            else if (this.comboBoxTimeStepLength.Text == "Minutes")
            {
                timeStepUnit = TimestepUnit.Minutes;
            }
            else if (this.comboBoxTimeStepLength.Text == "Seconds")
            {
                timeStepUnit = TimestepUnit.Seconds;
            }
            else
            {
                throw new System.Exception("invalid timestep length unit");
            }

            if (this.timestampBasedRadioButton.Checked)
            {
                timeSeries = new TimestampSeries(name, start, numberOfTimesteps, timeStepLength, timeStepUnit, defaultValue);
            }
            else if (this.timespanBasedRadioButton.Checked)
            {
                timeSeries = new TimespanSeries(name, start, numberOfTimesteps, timeStepLength, timeStepUnit, defaultValue);
            }
            else
            {
                throw new Exception("Unexpected exception in TimeSeriesCreationDialog");
            }
           
            this.Close();
        }
コード例 #3
0
    public TimespanSeries(string name, DateTime startTime, int numberOfTimesteps, int timestepLength, TimestepUnit timestepLengthUnit, double defaultValue)
      : this()
    {
      this.name = name;

      for (int i = 0; i < numberOfTimesteps; i++)
      {

        if (timestepLengthUnit == TimestepUnit.Years)
        {
          items.Add(new TimespanValue(startTime.AddYears(i * timestepLength), startTime.AddYears((i + 1) * timestepLength), defaultValue));
        }
        else if (timestepLengthUnit == TimestepUnit.Months)
        {
          items.Add(new TimespanValue(startTime.AddMonths(i * timestepLength), startTime.AddMonths((i + 1) * timestepLength), defaultValue));
        }
        else if (timestepLengthUnit == TimestepUnit.Days)
        {
          items.Add(new TimespanValue(startTime.AddDays(i * timestepLength), startTime.AddDays((i + 1) * timestepLength), defaultValue));
        }
        else if (timestepLengthUnit == TimestepUnit.Hours)
        {
          items.Add(new TimespanValue(startTime.AddHours(i * timestepLength), startTime.AddHours((i + 1) * timestepLength), defaultValue));
        }
        else if (timestepLengthUnit == TimestepUnit.Minutes)
        {
          items.Add(new TimespanValue(startTime.AddMinutes(i * timestepLength), startTime.AddMinutes((i + 1) * timestepLength), defaultValue));
        }
        else if (timestepLengthUnit == TimestepUnit.Seconds)
        {
          items.Add(new TimespanValue(startTime.AddSeconds(i * timestepLength), startTime.AddSeconds((i + 1) * timestepLength), defaultValue));
        }
        else
        {
          throw new Exception("Unexpected exception");
        }
      }
    }
コード例 #4
0
 public TimestampSeries2(string name, DateTime startTime, int numberOfTimesteps, int timestepLength, TimestepUnit timestepLengthUnit, double defaultValue, Unit unit) : this (name, startTime, numberOfTimesteps, timestepLength, timestepLengthUnit, defaultValue)
 {
     this.unit = unit;
 }
コード例 #5
0
 public TimestampSeries(string name, DateTime startTime, int numberOfTimesteps, int timestepLength, TimestepUnit timestepLengthUnit, double defaultValue, Unit unit) : this(name, startTime, numberOfTimesteps, timestepLength, timestepLengthUnit, defaultValue)
 {
     this.unit = unit;
 }
コード例 #6
0
        public TimestampSeries(string name, DateTime startTime, int numberOfTimesteps, int timestepLength, TimestepUnit timestepLengthUnit, double defaultValue)
            : this()
        {
            items.Add(new TimestampValue(startTime, defaultValue));

            this.name = name;

            for (int i = 1; i < numberOfTimesteps; i++)
            {
                if (timestepLengthUnit == TimestepUnit.Years)
                {
                    items.Add(new TimestampValue(startTime.AddYears(timestepLength * i), defaultValue));
                }
                else if (timestepLengthUnit == TimestepUnit.Months)
                {
                    items.Add(new TimestampValue(startTime.AddMonths(timestepLength * i), defaultValue));
                }
                else if (timestepLengthUnit == TimestepUnit.Days)
                {
                    items.Add(new TimestampValue(startTime.AddDays(timestepLength * i), defaultValue));
                }
                else if (timestepLengthUnit == TimestepUnit.Hours)
                {
                    items.Add(new TimestampValue(startTime.AddHours(timestepLength * i), defaultValue));
                }
                else if (timestepLengthUnit == TimestepUnit.Minutes)
                {
                    items.Add(new TimestampValue(startTime.AddMinutes(timestepLength * i), defaultValue));
                }
                else if (timestepLengthUnit == TimestepUnit.Seconds)
                {
                    items.Add(new TimestampValue(startTime.AddSeconds(timestepLength * i), defaultValue));
                }
                else
                {
                    throw new Exception("Unexpected exception");
                }
            }
        }