0

Linear gauge scripts for start time and scale max

Hello, 

I am trying to use scripts to use a date time picker value as the start time for a linear gauge and a value box as the scale max in the same linear gauge, but I am getting errors for both. Below is the code I am using. 

Start time error: Could not get delegate of type "AxiomCore2.Events.EventDelegates+OnValueChange" for event named "LinearGauge1_OnBeginValueChange"Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.

scale max error: CS1061

public void DateTimePicker1_OnDateTimeChange(object sender, DateTime dateTime)
        {
            string startTime = dateTime.ToString("o");
            ValueBox1.AggregateStartTime = startTime;
            LinearGauge1.AggregateStartTime = startTime;
            LinearGauge1.ScaleMax = ValueBox2.Value?.Value;
        }

3 replies

null
    • smason
    • 2 wk ago
    • Reported - view

    Hi ,

    In your script you are referencing two different ValueBoxes, 1 and 2. Is that your intent? Are you wanting to grab the value of the ValueBox at the time specified from the DateTimePicker, or is it just going to use the most recent value?

      • ruppc
      • 2 wk ago
      • Reported - view

      Hi  , 

      Sorry you can ignore the line referring to ValueBox1, I am trying to use the most recent value of ValueBox2 as the scale max value of the linear gauge 

    • smason
    • 13 days ago
    • Reported - view

    Try this:

    public void DateTimePicker1_OnDateTimeChange(object sender, DateTime dateTime)
        {
                string startTime = dateTime.ToString("o");
                LinearGauge1.AggregateStartTime = startTime;
    
                // get reference to a control in the current screen assuming there is
                // a ValueBox control named "ValueBox1"
                string valueBoxName = "ValueBox1";
                ControlValueBox valueBox = Screen.ScreenControls[valueBoxName] as ControlValueBox;
                // change scale of LinearGauge based on the ValueBox's value
                double number;
                TVQ tvq = valueBox.Value; // GET ControlValueBox.Value property
                object value = tvq?.Value;
                if (double.TryParse(value?.ToString() ?? "NaN", out number))
                {
                double scaleMax = number;
                LinearGauge1.ScaleMax = scaleMax; // SET LinearGauge.ScaleMax property
                LinearGauge1.MajorInterval = scaleMax/4; //SET LinearGauge.MajorInterval property
                }
        }
    

    This will only update the ScaleMax when the DateTime picker is updated. If you want to update the ScaleMax every time the ValueBox changes, that would require another function, OnBeginValueChange.

Content aside

print this pagePrint this page
  • 13 days agoLast active
  • 3Replies
  • 16Views
  • 2 Following