Esempio n. 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BadgeType != 0)
            {
                hash ^= BadgeType.GetHashCode();
            }
            if (Rank != 0)
            {
                hash ^= Rank.GetHashCode();
            }
            if (StartValue != 0)
            {
                hash ^= StartValue.GetHashCode();
            }
            if (EndValue != 0)
            {
                hash ^= EndValue.GetHashCode();
            }
            if (CurrentValue != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(CurrentValue);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BadgeType != 0)
            {
                hash ^= BadgeType.GetHashCode();
            }
            if (Rank != 0)
            {
                hash ^= Rank.GetHashCode();
            }
            if (StartValue != 0)
            {
                hash ^= StartValue.GetHashCode();
            }
            if (EndValue != 0)
            {
                hash ^= EndValue.GetHashCode();
            }
            if (CurrentValue != 0D)
            {
                hash ^= CurrentValue.GetHashCode();
            }
            return(hash);
        }
Esempio n. 3
0
            public IReadOnlyCollection <double> Evaluate(Bounds bounds, bool strict)
            {
                if (!bounds.IsProvided(StepValue?.RequiredBound ?? BoundType.None) ||
                    !bounds.IsProvided(StartValue.RequiredBound) || !bounds.IsProvided(EndValue.RequiredBound))
                {
                    if (strict)
                    {
                        throw new ArgumentException("Required bound not provided.");
                    }
                    return(EmptyArray <double> .Instance);
                }
                var startValue = StartValue.Evaluate(bounds);
                var endValue   = EndValue.Evaluate(bounds);

                if (strict)
                {
                    if (!bounds.Check(startValue))
                    {
                        throw new ArgumentException($"Start value '{startValue}' exceed bounds {bounds}.");
                    }
                    if (!bounds.Check(endValue))
                    {
                        throw new ArgumentException($"End value '{endValue}' exceed bounds {bounds}.");
                    }
                }
                return(ArrayUtils.Doubles(startValue, true, endValue, true, StepValue?.Evaluate(bounds) ?? 1));
            }
Esempio n. 4
0
        public override Xamarin.Forms.Animation CreateReverseAnimation()
        {
            double A = 0, R = 0, G = 0, B = 0;

            var Parent = new Xamarin.Forms.Animation((d) => Target.GetType().GetProperty(PropertyName).SetValue(Target, Xamarin.Forms.Color.FromRgba(R, G, B, A)), 0, 1, AnimationEasing);


            Parent.Add(0, 1, new Xamarin.Forms.Animation(d =>
            {
                A = d;
            }, Xamarin.Forms.Color.FromHex(EndValue.ToString()).A, Xamarin.Forms.Color.FromHex(StartValue.ToString()).A));


            Parent.Add(0, 1, new Xamarin.Forms.Animation(d =>
            {
                R = d;
            }, Xamarin.Forms.Color.FromHex(EndValue.ToString()).R, Xamarin.Forms.Color.FromHex(StartValue.ToString()).R));


            Parent.Add(0, 1, new Xamarin.Forms.Animation(d =>
            {
                G = d;
            }, Xamarin.Forms.Color.FromHex(EndValue.ToString()).G, Xamarin.Forms.Color.FromHex(StartValue.ToString()).G));

            Parent.Add(0, 1, new Xamarin.Forms.Animation(d =>
            {
                B = d;
            }, Xamarin.Forms.Color.FromHex(EndValue.ToString()).B, Xamarin.Forms.Color.FromHex(StartValue.ToString()).B));



            return(Parent);
        }
Esempio n. 5
0
        public string this[string columnName]
        {
            get
            {
                string error = null;

                switch (columnName)
                {
                case "TagName":
                    error = ValidateStringCannotBeNull(columnName, TagName);
                    break;

                case "Value":
                    if (ShowEndValue)
                    {
                        error = ValidateStringCannotBeNull(columnName, Value?.ToString() ?? string.Empty);
                    }
                    break;

                case "EndValue":
                    error = ValidateStringCannotBeNull(columnName, EndValue?.ToString() ?? string.Empty);
                    break;

                default:
                    throw new ArgumentException(ErrorResource.UnexpectedPropertyName, columnName);
                }

                return(error);
            }
        }
Esempio n. 6
0
        public override void OnSerialize(BinaryWriter stream, StringCacheTable cache)
        {
            base.OnSerialize(stream, cache);

            StartValue.OnSerialize(stream);
            EndValue.OnSerialize(stream);
        }
Esempio n. 7
0
 /// <summary>
 ///		Información de depuración
 /// </summary>
 protected override string GetDebugInfo(int indent)
 {
     return(Environment.NewLine + base.GetIndent(indent) +
            " Variable: " + IndexVariable.GetDebugInfo() +
            " StartValue: " + StartValue.GetDebugInfo() + " StartValueRPN: " + StartValueRPN.GetDebugInfo() +
            " EndValue: " + EndValue.GetDebugInfo() + " EndValueRPN: " + EndValueRPN.GetDebugInfo() +
            " StepValue: " + StepValue.GetDebugInfo() + " StepValueRPN: " + StepValueRPN.GetDebugInfo());
 }
Esempio n. 8
0
 public int CompareTo(Invoker other)
 {
     if (Type != other.Type)
     {
         throw new InvalidOperationException("Unexpected comparison of two invokers with different invoker types");
     }
     return(EndValue.CompareTo(other.EndValue));
 }
Esempio n. 9
0
    /// <summary>
    /// OnParametersSet 方法
    /// </summary>
    protected override void OnParametersSet()
    {
        base.OnParametersSet();

        Value ??= new DateTimeRangeValue();

        StartValue = Value.Start;
        EndValue   = Value.End;

        if (StartValue == DateTime.MinValue)
        {
            StartValue = DateTime.Now;
        }
        if (EndValue == DateTime.MinValue)
        {
            EndValue = StartValue.AddMonths(1);
        }

        SelectedValue.Start = StartValue;
        SelectedValue.End   = EndValue;

        StartPlaceHolderText ??= Localizer[nameof(StartPlaceHolderText)];
        EndPlaceHolderText ??= Localizer[nameof(EndPlaceHolderText)];
        SeparateText ??= Localizer[nameof(SeparateText)];

        ClearButtonText ??= Localizer[nameof(ClearButtonText)];
        ConfirmButtonText ??= Localizer[nameof(ConfirmButtonText)];
        TodayButtonText ??= Localizer[nameof(TodayButtonText)];

        DateFormat ??= Localizer[nameof(DateFormat)];

        if (StartValue.ToString("yyyy-MM") == EndValue.ToString("yyyy-MM"))
        {
            StartValue = StartValue.AddMonths(-1);
        }

        if (SidebarItems == null)
        {
            SidebarItems = new DateTimeRangeSidebarItem[]
            {
                new DateTimeRangeSidebarItem {
                    Text = Localizer["Last7Days"], StartDateTime = DateTime.Today.AddDays(-7), EndDateTime = DateTime.Today
                },
                new DateTimeRangeSidebarItem {
                    Text = Localizer["Last30Days"], StartDateTime = DateTime.Today.AddDays(-30), EndDateTime = DateTime.Today
                },
                new DateTimeRangeSidebarItem {
                    Text = Localizer["ThisMonth"], StartDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day), EndDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(1).AddDays(-1)
                },
                new DateTimeRangeSidebarItem {
                    Text = Localizer["LastMonth"], StartDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(-1), EndDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddDays(-1)
                },
            };
        }
    }
Esempio n. 10
0
        public override void StartKinetic(VisualPayload payload, Func <float, float> translateTimeToEffectProportion)
        {
            var labelVis = payload.VisualData.Bound.GetComponent <LabelVisualizer>();

            var startValue            = StartValue.GetFirstValue(payload.Data);
            var endValue              = EndValue.GetFirstValue(payload.Data);
            var transitionTimeInverse = 1f / TransitionTime.GetFirstValue(payload.Data);;
            var formatString          = FormatString.GetFirstValue(payload.Data);
            var startTime             = Time.time;

            var bound = payload.VisualData.Bound.CreateDependingBound("Lerp Value");

            bound.transform.parent = payload.VisualData.Bound.transform.parent;
            payload.VisualData.Bound.transform.parent = bound.transform;

            var valueSatellite =
                bound.gameObject.AddComponent <SetLabelSatellite>();

            valueSatellite.LabelVis = labelVis;

            var newPayload = new VisualPayload(payload.Data, new VisualDescription(bound));


            valueSatellite.UpdateFunc = (label) =>
            {
                float proportion = (Time.time - startTime) * transitionTimeInverse;

                if (proportion >= 1)
                {
                    label.Text = string.Format(formatString, endValue);

                    valueSatellite.Cleanup();
                    return;
                }

                proportion = translateTimeToEffectProportion(proportion);

                var currentValue = Mathf.Lerp(startValue, endValue, proportion);

                label.Text = string.Format(formatString, currentValue);
            };

            valueSatellite.CleanupFunc = (label) =>
            {
                JobManager.Instance.StartJob(
                    Finished.Transmit(newPayload), jobName: "Kinetic Finished", startImmediately: true,
                    maxExecutionsPerFrame: 1);
            };

            //throw new NotImplementedException();
        }
Esempio n. 11
0
        public override void Validate()
        {
            base.Validate();


            if (StartValue.GetType() != typeof(int))
            {
                throw new Exception($"Invalid {nameof(StartValue)}.");
            }
            if (EndValue.GetType() != typeof(int))
            {
                throw new Exception($"Invalid {nameof(EndValue)}.");
            }
        }
Esempio n. 12
0
        public override string ToString()
        {
            var s = StartValue.ToString();
            var e = EndValue.ToString();

            if (IsRange)
            {
                return(s + RangeDelimiter + e);
            }
            if (EndValue.Status != DateStatus.Unknown && string.IsNullOrEmpty(e))
            {
                return(s);
            }
            return(s + IntervalDelimiter + e);
        }
        public string ToLogString()
        {
            var sb = new StringBuilder()
                     .AppendLine($"[{nameof(ParametersPack)}]")
                     .AppendLine($"AnalysisProgramName: '{AnalysisProgramName}'")
                     .AppendLine($"AlgorithmType: {AlgorithmType.ToLogString()}")
                     .AppendLine($"StartValue: '{StartValue.ToString()}'")
                     .AppendLine($"EndValue: '{EndValue.ToString()}'")
                     .AppendLine($"ExtrapolationSegmentValue: '{ExtrapolationSegmentValue.ToString()}'")
                     .AppendLine($"LaunchesNumber: '{LaunchesNumber.ToString()}'")
                     .AppendLine($"Step: '{Step.ToString()}'")
                     .AppendLine($"OutputFilenamePattern: '{OutputFilenamePattern}'")
                     .AppendLine($"CommonAnalysisFilenameSuffix: '{CommonAnalysisFilenameSuffix}'")
                     .AppendLine($"OutputFileExtension: '{OutputFileExtension}'");

            return(sb.ToString());
        }
Esempio n. 14
0
        public override void Validate()
        {
            base.Validate();

            _structStartValues = StartValue.ToString().Split(',');

            _structEndValues = EndValue.ToString().Split(',');

            foreach (var startValue in _structStartValues)
            {
                if (!double.TryParse(startValue.ToString(), out double _))
                {
                    throw new Exception($"Invalid {nameof(StartValue)}.");
                }
            }


            foreach (var endValue in _structEndValues)
            {
                if (!double.TryParse(endValue.ToString(), out double _))
                {
                    throw new Exception($"Invalid {nameof(EndValue)}.");
                }
            }

            if (_structStartValues.Length != _structEndValues.Length)
            {
                throw new Exception($"{nameof(StartValue)} and {nameof(EndValue)} has different structure.");
            }
            switch (_structStartValues.Length)
            {
            case 1:
            case 2:
            case 4:
                break;

            default:
                throw new Exception($"Supported formats are 'double', 'double,double' and 'double,double,double,double'.");
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 속성 중 Attribute Node로 표현해야 한다.
        /// </summary>
        /// <param name="writer"></param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (StartValue.HasValue)
            {
                writer.WriteAttributeString("startValue", StartValue.ToString());
            }
            if (EndValue.HasValue)
            {
                writer.WriteAttributeString("endValue", EndValue.ToString());
            }

            if (ShowOnTop.HasValue)
            {
                writer.WriteAttributeString("showOnTop", ShowOnTop.GetHashCode().ToString());
            }
            if (ValueOnRight.HasValue)
            {
                writer.WriteAttributeString("valueOnRight", ValueOnRight.GetHashCode().ToString());
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Export to XML document
        /// </summary>
        /// <param name="doc">xml document</param>
        /// <param name="parent">parent xml element</param>
        public override void ExportToXML(ref XmlDocument doc, XmlElement parent)
        {
            XmlElement   brk        = doc.CreateElement("Break");
            XmlAttribute caption    = doc.CreateAttribute("Caption");
            XmlAttribute startValue = doc.CreateAttribute("StartValue");
            XmlAttribute endValue   = doc.CreateAttribute("EndValue");
            XmlAttribute color      = doc.CreateAttribute("Color");
            XmlAttribute isNoData   = doc.CreateAttribute("IsNoData");

            caption.InnerText    = Caption;
            startValue.InnerText = StartValue.ToString();
            endValue.InnerText   = EndValue.ToString();
            color.InnerText      = ColorTranslator.ToHtml(Color);
            isNoData.InnerText   = IsNoData.ToString();

            brk.Attributes.Append(caption);
            brk.Attributes.Append(startValue);
            brk.Attributes.Append(endValue);
            brk.Attributes.Append(color);
            brk.Attributes.Append(isNoData);

            parent.AppendChild(brk);
        }
Esempio n. 17
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (StartValue.HasValue)
            {
                writer.WriteAttributeString("StartValue", StartValue.ToString());
            }
            if (EndValue.HasValue)
            {
                writer.WriteAttributeString("EndValue", EndValue.ToString());
            }
            if (DisplayValue.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("DisplayValue", DisplayValue);
            }
            if (ValueInside.HasValue)
            {
                writer.WriteAttributeString("ValueInside", ValueInside.GetHashCode().ToString());
            }

            if (Color.HasValue)
            {
                writer.WriteAttributeString("Color", Color.Value.ToHexString());
            }
            if (Thickness.HasValue)
            {
                writer.WriteAttributeString("Thickness", Thickness.ToString());
            }

            if (ShowBorder.HasValue)
            {
                writer.WriteAttributeString("ShowBorder", ShowBorder.GetHashCode().ToString());
            }
            if (BorderColor.HasValue)
            {
                writer.WriteAttributeString("BorderColor", BorderColor.Value.ToHexString());
            }

            if (Radius.HasValue)
            {
                writer.WriteAttributeString("Radius", Radius.ToString());
            }
            if (InnerRadius.HasValue)
            {
                writer.WriteAttributeString("InnerRadius", InnerRadius.ToString());
            }

            if (Dashed.HasValue)
            {
                writer.WriteAttributeString("Dashed", Dashed.GetHashCode().ToString());
            }
            if (DashLen.HasValue)
            {
                writer.WriteAttributeString("DashLen", DashLen.ToString());
            }
            if (DashGap.HasValue)
            {
                writer.WriteAttributeString("DashGap", DashGap.ToString());
            }

            if (UseMarker.HasValue)
            {
                writer.WriteAttributeString("UseMarker", UseMarker.GetHashCode().ToString());
            }
            if (MarkerColor.HasValue)
            {
                writer.WriteAttributeString("MarkerColor", MarkerColor.Value.ToHexString());
            }
            if (MarkerBorderColor.HasValue)
            {
                writer.WriteAttributeString("MarkerBorderColor", MarkerBorderColor.Value.ToHexString());
            }
            if (MarkerRadius.HasValue)
            {
                writer.WriteAttributeString("MarkerRadius", MarkerRadius.ToString());
            }
            if (MarkerTooltext.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("MarkerTooltext", MarkerTooltext);
            }
        }
Esempio n. 18
0
        public string this[string columnName]
        {
            get
            {
                string error = null;

                switch (columnName)
                {
                case "TagName":
                    error = ValidateStringCannotBeNull(columnName, TagName);
                    break;

                case "Value":
                    if (ShowEndValue)
                    {
                        error = ValidateStringCannotBeNull(columnName, Value == null ? string.Empty : Value.ToString());
                    }
                    break;

                case "EndValue":
                    error = ValidateStringCannotBeNull(columnName, EndValue == null ? string.Empty : EndValue.ToString());
                    break;

                default:
                    throw new ArgumentException(@"Unexpected property name encountered", columnName);
                }

                return(error);
            }
        }
 /// <summary>
 /// 更新年时间方法
 /// </summary>
 /// <param name="d"></param>
 internal void UpdateEnd(DateTime d)
 {
     EndValue   = EndValue.AddYears(d.Year - EndValue.Year).AddMonths(d.Month - EndValue.Month);
     StartValue = EndValue.AddMonths(-1);
     StateHasChanged();
 }
Esempio n. 20
0
        /// <summary>
        /// 判断是否值相等
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>值相等,返回true</returns>
        public override bool Equals(object obj)
        {
            bool result = false;
            EndValueReadEventStatus <TValue> other = obj as EndValueReadEventStatus <TValue>;

            result = object.ReferenceEquals(this, other) || (base.Equals(obj) && other != null && EndValue.Equals(other.EndValue));

            return(result);
        }
Esempio n. 21
0
 /// <summary>
 /// 获取哈希值
 /// </summary>
 /// <returns>返回哈希值</returns>
 public override int GetHashCode()
 {
     return(base.GetHashCode() | EndValue.GetHashCode());
 }
Esempio n. 22
0
        private void Initialize()
        {
            if (null == _proxy)
            {
                InitProxy();
            }

            // check if interpolator not defined, and add one from defaults
            if (null != _proxy && null == _interpolator)
            {
                InitInterpolator();
            }

            //Debug.Log("Proxy is null: " + (null == _proxy));

            //Debug.Log("StartValue: " + StartValue);
            //Debug.Log("EndValue: " + EndValue);

            /**
             * Note: The priority is as follows:
             * 1) StartValue is checked. If set, skipping other checks
             * 2) StartValueReader is checked. If set, it reads the specified property
             * 3) StartValueReaderFunction is checked. If set, it is being run to get a property value.
             * - if niether of above steps resulted in having StartValue, we throw an exception
             * */

            if (null != StartValue)
            {
                // do nothing
            }

            else if (null != StartValueReader)
            {
                if (null == StartValueReader.Target && null != Target)
                {
                    StartValueReader.Target = Target;
                }
                if (null == StartValueReader.Property && null != Property)
                {
                    StartValueReader.Property = Property;
                }
                StartValue = StartValueReader.Read();
            }

            else if (null != StartValueReaderFunction)
            {
                StartValue = StartValueReaderFunction(Target);
            }

            if (CheckStartValue && null == StartValue)
            {
                throw new Exception("StartValue, StartValueGetter or StartValueReaderFunction not set: " + this);
            }

            if (null != EndValue)
            {
                // do nothing
            }

            if (null != EndValueReader)
            {
                if (null == EndValueReader.Target && null != Target)
                {
                    EndValueReader.Target = Target;
                }
                if (null == EndValueReader.Property && null != Property)
                {
                    EndValueReader.Property = Property;
                }
                EndValue = EndValueReader.Read();
            }

            else if (null != EndValueReaderFunction)
            {
                EndValue = EndValueReaderFunction(Target);
            }

            if (CheckEndValue && null == EndValue)
            {
                throw new Exception("EndValue, EndValueReader or EndValueReaderFunction not set: " + this);
            }

            // check if tween is needed

            if (null != StartValue && null != EndValue && EndValue.Equals(StartValue))
            {
#if DEBUG
                if (DebugMode)
                {
                    Debug.Log("EndValue equals StartValue. Returning...");
                }
#endif
                //if (IsChild)
                //{
                //    Parent.FinishedCount++;
                //}
                return;
            }

#if DEBUG
            if (DebugMode)
            {
                Debug.Log("Playing: " + this);
            }
#endif

            // go for a tween

            _startTime = DateTime.Now;

            //if (reset)
            _fraction = Starting;

            /**
             * Check if this is a root tween
             * If so, and not connected, connect
             * */
            /*if (null == Parent && !SystemManager.Instance.UpdateSignal.HasSlot(this))
             *  SystemManager.Instance.UpdateSignal.Connect(this);*/

            //Debug.Log("* INIT *");

            TweenRegistry.Instance.Add(this);

            _initialized = true;
        }