protected override string FormatItem(AltaxoVariant item) { if (item.IsType(AltaxoVariant.Content.VDateTime) && !string.IsNullOrEmpty(_formatString)) { var dt = item.ToDateTime(); switch (_timeConversion) { case TimeConversion.ToLocal: dt = dt.ToLocalTime(); break; case TimeConversion.ToUtc: dt = dt.ToUniversalTime(); break; } bool showAlternate = false; showAlternate |= (_showAlternateFormattingAtMidnight && Math.Abs(dt.TimeOfDay.TotalSeconds) < 1); showAlternate |= (_showAlternateFormattingAtNoon && Math.Abs((dt.TimeOfDay - TimeSpan.FromHours(12)).TotalSeconds) < 1); try { return(string.Format(showAlternate ? _formatStringAlternate : _formatString, dt)); } catch (Exception) { } } return(item.ToString()); }
private string DefaultTextConverter(AltaxoVariant x) { string s = x.ToString(); s = s.Replace('\r', ' '); s = s.Replace('\n', ' '); return(s); }
protected override string FormatItem(AltaxoVariant item) { if (!string.IsNullOrEmpty(_formatString)) { try { return(string.Format(_formatString, item.ToObject())); } catch (Exception) { } } return(item.ToString()); }
public static CSPlaneID FromPhysicalVariant(int perpendicularAxisNumber, AltaxoVariant physicalValue) { #pragma warning disable CS1718 // Comparison made to same variable if (!(physicalValue == physicalValue)) { throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValue.ToString()); } #pragma warning restore CS1718 // Comparison made to same variable return(new CSPlaneID(perpendicularAxisNumber, double.NaN, true, physicalValue)); }
/// <summary> /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis. /// </summary> /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param> /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param> /// <returns>A freshly created 2D line identifier.</returns> public static CSLineID FromPhysicalVariant(int parallelAxisNumber, AltaxoVariant physicalValueOther) { if (parallelAxisNumber < 0 || parallelAxisNumber > 2) { throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString()); } if (!physicalValueOther.Equals(physicalValueOther)) { throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValueOther.ToString()); } CSLineID id = new CSLineID(); id._parallelAxisNumber = parallelAxisNumber; id._physicalValueFirstOther = physicalValueOther; id._logicalValueFirstOther = double.NaN; id._usePhysicalValueFirstOther = true; id._logicalValueSecondOther = double.NaN; return(id); }
public static CSPlaneID FromPhysicalVariant(int perpendicularAxisNumber, AltaxoVariant physicalValue) { if (!(physicalValue == physicalValue)) { throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValue.ToString()); } CSPlaneID id = new CSPlaneID(); id._perpendicularAxisNumber = perpendicularAxisNumber; id._physicalValue = physicalValue; id._logicalValue = double.NaN; id._usePhysicalValue = true; return(id); }