Exemplo n.º 1
0
        /// <summary>Copies from another instance.</summary>
        /// <param name="obj">The other instance to copy from.</param>
        /// <returns>True if at least some data could be copied.</returns>
        public virtual bool CopyFrom(object obj)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            var from = obj as NumericScaleRescaleConditions;

            if (null == from)
            {
                return(false);
            }

            _orgRescaling = from._orgRescaling;
            _endRescaling = from._endRescaling;

            _userProvidedOrgRelativeTo = from._userProvidedOrgRelativeTo;
            _userProvidedEndRelativeTo = from._userProvidedEndRelativeTo;

            _userProvidedOrgValue = from._userProvidedOrgValue;
            _userProvidedEndValue = from._userProvidedEndValue;

            _dataBoundsOrg = from._dataBoundsOrg;
            _dataBoundsEnd = from._dataBoundsEnd;

            _resultingOrg = from._resultingOrg;
            _resultingEnd = from._resultingEnd;

            _resultingMinOrg = from._resultingMinOrg;
            _resultingMaxEnd = from._resultingMaxEnd;

            EhSelfChanged(EventArgs.Empty);

            return(true);
        }
Exemplo n.º 2
0
        public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
        {
            if (double.IsNaN(orgValue) || !Altaxo.Calc.RMath.IsFinite(orgValue) || orgValue <= 0)
            {
                if (orgRescaling == BoundaryRescaling.Auto)
                {
                    orgValue = DefaultOrgValue; // ignore this error and set org to 1
                }
                else
                {
                    throw new ArgumentOutOfRangeException("orgValue should be a finite and positive number but is " + orgValue.ToString());
                }
            }

            if (double.IsNaN(endValue) || !Altaxo.Calc.RMath.IsFinite(endValue) || endValue <= 0)
            {
                if (endRescaling == BoundaryRescaling.Auto)
                {
                    endValue = DefaultEndValue; // ignore this error and set org to 10
                }
                else
                {
                    throw new ArgumentOutOfRangeException("endValue should be a finite and positive number but is " + endValue.ToString());
                }
            }

            base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue);
        }
Exemplo n.º 3
0
        public virtual void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
        {
            bool isChange =

                _orgRescaling != orgRescaling ||
                _userProvidedOrgRelativeTo != orgRelativeTo ||
                _userProvidedOrgValue != orgValue ||
                _endRescaling != endRescaling ||
                _userProvidedEndRelativeTo != endRelativeTo ||
                _userProvidedEndValue != endValue;

            _orgRescaling = orgRescaling;
            _userProvidedOrgRelativeTo = orgRelativeTo;
            _userProvidedOrgValue      = orgValue;

            _endRescaling = endRescaling;
            _userProvidedEndRelativeTo = endRelativeTo;
            _userProvidedEndValue      = endValue;

            if (isChange)
            {
                ProcessOrg_UserParametersChanged();
                ProcessEnd_UserParametersChanged();
                EhSelfChanged();
            }
        }
		public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
		{
			if (orgRelativeTo != BoundariesRelativeTo.Absolute)
				throw new ArgumentException(string.Format("{0} does only support orgRelativeTo={1}", this.GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute)));
			if (endRelativeTo != BoundariesRelativeTo.Absolute)
				throw new ArgumentException(string.Format("{0} does only support endRelativeTo={1}", this.GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute)));

			if (double.IsNaN(orgValue) || !(0 < orgValue && orgValue < 1))
			{
				if (orgRescaling == BoundaryRescaling.Auto)
					orgValue = DefaultOrgValue;  // ignore this error and set org to 0
				else
					throw new ArgumentOutOfRangeException("orgValue should be a number 0 < orgValue < 1, but is " + orgValue.ToString());
			}

			if (double.IsNaN(endValue) || !(0 < endValue && endValue < 1))
			{
				if (endRescaling == BoundaryRescaling.Auto)
					endValue = DefaultEndValue;  // ignore this error and set end to 1
				else
					throw new ArgumentOutOfRangeException("endValue should be number 0 < endValue < 1, but is " + endValue.ToString());
			}

			base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue);
		}
Exemplo n.º 5
0
		public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
		{
			if (double.IsNaN(orgValue) || !Altaxo.Calc.RMath.IsFinite(orgValue))
			{
				if (orgRescaling == BoundaryRescaling.Auto)
					orgValue = DefaultOrgValue;  // ignore this error and set org to 0
				else
					throw new ArgumentOutOfRangeException("orgValue should be a finite number but is " + orgValue.ToString());
			}

			if (double.IsNaN(endValue) || !Altaxo.Calc.RMath.IsFinite(endValue))
			{
				if (endRescaling == BoundaryRescaling.Auto)
					endValue = DefaultEndValue;  // ignore this error and set end to 1
				else
					throw new ArgumentOutOfRangeException("endValue should be a finite number but is " + endValue.ToString());
			}

			base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue);
		}
        public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
        {
            if (orgRelativeTo != BoundariesRelativeTo.Absolute)
            {
                throw new ArgumentException(string.Format("{0} does only support orgRelativeTo={1}", GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute)));
            }
            if (endRelativeTo != BoundariesRelativeTo.Absolute)
            {
                throw new ArgumentException(string.Format("{0} does only support endRelativeTo={1}", GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute)));
            }

            if (double.IsNaN(orgValue) || !(0 < orgValue && orgValue < 1))
            {
                if (orgRescaling == BoundaryRescaling.Auto)
                {
                    orgValue = DefaultOrgValue; // ignore this error and set org to 0
                }
                else
                {
                    throw new ArgumentOutOfRangeException("orgValue should be a number 0 < orgValue < 1, but is " + orgValue.ToString());
                }
            }

            if (double.IsNaN(endValue) || !(0 < endValue && endValue < 1))
            {
                if (endRescaling == BoundaryRescaling.Auto)
                {
                    endValue = DefaultEndValue; // ignore this error and set end to 1
                }
                else
                {
                    throw new ArgumentOutOfRangeException("endValue should be number 0 < endValue < 1, but is " + endValue.ToString());
                }
            }

            base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue);
        }
Exemplo n.º 7
0
        void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue)
        {
            double orgV, endV;

            if (orgValue.CanConvertedToDouble)
            {
                orgV = orgValue.ToDouble();
            }
            else
            {
                throw new InvalidOperationException("Can not convert orgValue to a double value.");
            }

            if (orgValue.CanConvertedToDouble)
            {
                endV = endValue.ToDouble();
            }
            else
            {
                throw new InvalidOperationException("Can not convert endValue to a double value.");
            }

            SetUserParameters(orgRescaling, orgRelativeTo, orgV, endRescaling, endRelativeTo, endV);
        }
Exemplo n.º 8
0
        void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue)
        {
            long         orgV, endV;
            DateTimeKind orgK, endK;

            if (orgValue.IsType(Data.AltaxoVariant.Content.VDateTime))
            {
                var dt = orgValue.ToDateTime();
                orgV = dt.Ticks;
                orgK = dt.Kind;
            }
            else if (orgValue.CanConvertedToDouble)
            {
                double v = orgValue.ToDouble();
                orgV = (long)(v * 1E7);
                orgK = DateTimeKind.Utc;
            }
            else
            {
                throw new InvalidOperationException("Can not convert orgValue to either a DateTime or a double value.");
            }

            if (endValue.IsType(Data.AltaxoVariant.Content.VDateTime))
            {
                var dt = endValue.ToDateTime();
                endV = dt.Ticks;
                endK = dt.Kind;
            }
            else if (orgValue.CanConvertedToDouble)
            {
                double v = endValue.ToDouble();
                endV = (long)(v * 1E7);
                endK = DateTimeKind.Utc;
            }
            else
            {
                throw new InvalidOperationException("Can not convert endValue to either a DateTime or a double value.");
            }

            SetUserParameters(orgRescaling, orgRelativeTo, orgV, orgK, endRescaling, endRelativeTo, endV, endK);
        }
		void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue)
		{
			long orgV, endV;
			DateTimeKind orgK, endK;

			if (orgValue.IsType(Data.AltaxoVariant.Content.VDateTime))
			{
				var dt = orgValue.ToDateTime();
				orgV = dt.Ticks;
				orgK = dt.Kind;
			}
			else if (orgValue.CanConvertedToDouble)
			{
				double v = orgValue.ToDouble();
				orgV = (long)(v * 1E7);
				orgK = DateTimeKind.Utc;
			}
			else
			{
				throw new InvalidOperationException("Can not convert orgValue to either a DateTime or a double value.");
			}

			if (endValue.IsType(Data.AltaxoVariant.Content.VDateTime))
			{
				var dt = endValue.ToDateTime();
				endV = dt.Ticks;
				endK = dt.Kind;
			}
			else if (orgValue.CanConvertedToDouble)
			{
				double v = endValue.ToDouble();
				endV = (long)(v * 1E7);
				endK = DateTimeKind.Utc;
			}
			else
			{
				throw new InvalidOperationException("Can not convert endValue to either a DateTime or a double value.");
			}

			this.SetUserParameters(orgRescaling, orgRelativeTo, orgV, orgK, endRescaling, endRelativeTo, endV, endK);
		}
Exemplo n.º 10
0
		public virtual void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, long orgValue, DateTimeKind orgValueKind, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, long endValue, DateTimeKind endValueKind)
		{
			bool isChange =

			_orgRescaling != orgRescaling ||
			_userProvidedOrgRelativeTo != orgRelativeTo ||
			_userProvidedOrgValue != orgValue ||
			_endRescaling != endRescaling ||
			_userProvidedEndRelativeTo != endRelativeTo ||
			_userProvidedEndValue != endValue;

			_orgRescaling = orgRescaling;
			_userProvidedOrgRelativeTo = orgRelativeTo;
			_userProvidedOrgValue = orgValue;

			_endRescaling = endRescaling;
			_userProvidedEndRelativeTo = endRelativeTo;
			_userProvidedEndValue = endValue;

			if (isChange)
			{
				ProcessOrg_UserParametersChanged();
				ProcessEnd_UserParametersChanged();
				EhSelfChanged();
			}
		}
Exemplo n.º 11
0
		/// <summary>
		/// Copies the data from another object.
		/// </summary>
		/// <param name="obj">The object to copy the data from.</param>
		public virtual bool CopyFrom(object obj)
		{
			if (object.ReferenceEquals(this, obj))
				return true;

			var from = obj as DateTimeScaleRescaleConditions;
			if (null == from)
				return false;

			this._orgRescaling = from._orgRescaling;
			this._endRescaling = from._endRescaling;

			this._userProvidedOrgRelativeTo = from._userProvidedOrgRelativeTo;
			this._userProvidedEndRelativeTo = from._userProvidedEndRelativeTo;

			this._userProvidedOrgValue = from._userProvidedOrgValue;
			this._userProvidedOrgDateTimeKind = from._userProvidedOrgDateTimeKind;
			this._userProvidedEndValue = from._userProvidedEndValue;
			this._userProvidedEndDateTimeKind = from._userProvidedEndDateTimeKind;

			this._resultingOrg = from._resultingOrg;
			this._resultingEnd = from._resultingEnd;

			this._resultingMinOrg = from._resultingMinOrg;
			this._resultingMaxEnd = from._resultingMaxEnd;

			EhSelfChanged(EventArgs.Empty);

			return true;
		}
Exemplo n.º 12
0
		void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue)
		{
			double orgV, endV;
			if (orgValue.CanConvertedToDouble)
			{
				orgV = orgValue.ToDouble();
			}
			else
			{
				throw new InvalidOperationException("Can not convert orgValue to a double value.");
			}

			if (orgValue.CanConvertedToDouble)
			{
				endV = endValue.ToDouble();
			}
			else
			{
				throw new InvalidOperationException("Can not convert endValue to a double value.");
			}

			this.SetUserParameters(orgRescaling, orgRelativeTo, orgV, endRescaling, endRelativeTo, endV);
		}
Exemplo n.º 13
0
		public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue)
		{
			orgValue = 1 / orgValue;
			endValue = 1 / endValue;

			bool isChange =

			_orgRescaling != orgRescaling ||
			_userProvidedOrgRelativeTo != orgRelativeTo ||
			_userProvidedOrgValue != orgValue ||
			_endRescaling != endRescaling ||
			_userProvidedEndRelativeTo != endRelativeTo ||
			_userProvidedEndValue != endValue;

			_orgRescaling = orgRescaling;
			_userProvidedOrgRelativeTo = orgRelativeTo;
			_userProvidedOrgValue = orgValue;

			_endRescaling = endRescaling;
			_userProvidedEndRelativeTo = endRelativeTo;
			_userProvidedEndValue = endValue;

			if (isChange)
			{
				ProcessOrg_UserParametersChanged();
				ProcessEnd_UserParametersChanged();
				EhSelfChanged();
			}
		}