Question

I'm trying to make it so when you click on a the end tick on my digital waveform graph, the format that pops up is something along the lines of "s.fff", instead of the default "mm/dd/yyyy hh/mm/ss". I found the XAxis.EditDateTimeFormatMode property, but it looks like you can only assign a "long format mode" or "Short format mode" to that, neither of which are very suitable for small scales. Is there a way to make your own DateTimeFormatMode that would make the expanded edit field just have seconds and milliseconds (for more precise zooming / repositioning on the graph) instead of the default huge scale? Just for reference, this is the code that implements the "short" format mode, which isn't nearly short enough:

this.digitalWaveformGraph1.XAxis.EditDateTimeFormatMode = NationalInstruments.UI.DateTimeFormatMode.CreateShortTimeMode();

I realize this is a little bit of a precise question, but was hoping someone here might have had the same problem when working with fast signals. Thanks a bunch!

Was it helpful?

Solution

This will only get you pointed in the right direction, but the general idea is to create a class that inherits NationalInstruments.UI.DateTimeFormatMode - something like this:

public class SecondsEditRangeFormat : DateTimeFormatMode
{
    public override string FormatValue(object context, DateTimeFormatModeArgs args)
    {
        return args.Value.ToString("s.fff");
    }

    public override bool TryParse(string s, out DateTime value)
    {   
        value = DateTime.ParseExact(s, "s.fff", CultureInfo.CurrentCulture);
        return true;
    }
}

and then assign an instance of your class to that property:

digitalWaveformGraph1.XAxis.EditRangeDateTimeFormatMode = new SecondsEditRangeFormat();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top