Ejemplo n.º 1
0
 public override bool vop_Subtraction_Rev(AltaxoVariant c2, out DataColumn c3)
 {
     if (c2.IsType(AltaxoVariant.Content.VDateTime))
     {
         var c22 = (DateTime)c2;
         c3 = c22 - this;
         return(true);
     }
     c3 = null;
     return(false);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// PhysicalVariantToNormal translates physical values into a normal value linear along the axis
 /// a physical value of the axis origin must return a value of zero
 /// a physical value of the axis end must return a value of one
 /// the function physicalToNormal must be provided by any derived class
 /// </summary>
 /// <param name="x">the physical value</param>
 /// <returns>
 /// the normalized value linear along the axis,
 /// 0 for axis origin, 1 for axis end</returns>
 public override double PhysicalVariantToNormal(Altaxo.Data.AltaxoVariant x)
 {
     if (x.IsType(AltaxoVariant.Content.VDateTime))
     {
         return(PhysicalToNormal((DateTime)x));
     }
     else if (x.CanConvertedToDouble)
     {
         return(PhysicalToNormal(new DateTime((long)(x.ToDouble() * 10000000))));
     }
     else
     {
         throw new ArgumentException("Variant x is neither DateTime nor numeric");
     }
 }
Ejemplo n.º 3
0
 public override double PhysicalVariantToNormal(Altaxo.Data.AltaxoVariant x)
 {
     if (x.IsType(Altaxo.Data.AltaxoVariant.Content.VString))
     {
         int idx = _dataBounds.IndexOf(x.ToString());
         return(idx < 0? double.NaN : (1 + idx - _cachedAxisOrg) * _cachedOneByAxisSpan);
     }
     else if (x.CanConvertedToDouble)
     {
         return((x.ToDouble() - _cachedAxisOrg) * _cachedOneByAxisSpan);
     }
     else
     {
         return(double.NaN);
     }
 }
Ejemplo n.º 4
0
 // indexers
 public override void SetValueAt(int i, AltaxoVariant val)
 {
   if(val.IsType(AltaxoVariant.Content.VDouble))
     this[i] = val.m_Double;
   else if(val.CanConvertedToDouble)
     this[i] = val.ToDouble();
   else
     throw new ApplicationException("Error: Try to set " + this.TypeAndName + "[" + i + "] with the string " + val.ToString());
 }
Ejemplo n.º 5
0
		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();
		}
Ejemplo n.º 6
0
		/// <summary>
		/// calculates the axis org and end using the databounds
		/// the org / end is adjusted only if it is not fixed
		/// and the DataBound object contains valid data
		/// </summary>
		public override void ProcessDataBounds(AltaxoVariant org, bool orgfixed, AltaxoVariant end, bool endfixed)
		{
			DateTime dorg;
			DateTime dend;
			if (org.IsType(AltaxoVariant.Content.VDateTime))
				dorg = (DateTime)org;
			else if (org.CanConvertedToDouble)
				dorg = new DateTime((long)(org.ToDouble() * 1E7));
			else
				throw new ArgumentException("Variant org is not a DateTime nor a numeric value");

			if (end.IsType(AltaxoVariant.Content.VDateTime))
				dend = (DateTime)end;
			else if (end.CanConvertedToDouble)
				dend = new DateTime((long)(end.ToDouble() * 1E7));
			else
				throw new ArgumentException("Variant end is not a DateTime nor a numeric value");

			ProcessDataBounds(dorg, orgfixed, dend, endfixed);
		}