Exemple #1
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Size maxsize = new Size(99999, 99999);


            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = _HPBar.GetPreferredSize(new Size(basearea.Width, 0));



            if (RepairTime != null)
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                Size sz_time = TextRenderer.MeasureText(timestr, MainFont, maxsize, TextFormatTime);

                TextRenderer.DrawText(g, timestr, MainFont, new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height), RepairFontColor, TextFormatTime);

                /*/
                 * g.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - BarThickness - BarBackgroundOffset - 1 ) );
                 * //*/
            }
            else
            {
                Size sz_text  = TextRenderer.MeasureText(Text, SubFont, maxsize, TextFormatText);
                Size sz_hpmax = TextRenderer.MeasureText(Math.Max(MaximumValue, MaximumDigit).ToString(), SubFont, maxsize, TextFormatHP);
                Size sz_slash = TextRenderer.MeasureText(" / ", SubFont, maxsize, TextFormatHP);
                Size sz_hpnow = TextRenderer.MeasureText(Math.Max(Value, MaximumDigit).ToString(), MainFont, maxsize, TextFormatHP);

                if (Text.Length > 0)
                {
                    sz_text.Width -= (int)(SubFont.Size / 2.0);
                }
                sz_hpmax.Width -= (int)(SubFont.Size / 2.0);
                sz_slash.Width -= (int)(SubFont.Size / 2.0);
                sz_hpnow.Width -= (int)(MainFont.Size / 2.0);



                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - sz_text.Height + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, sz_text), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_text ) );

                p.X = basearea.Right - sz_hpmax.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, sz_hpmax), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_hpmax ) );

                p.X -= sz_slash.Width;
                TextRenderer.DrawText(g, " / ", SubFont, new Rectangle(p, sz_slash), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_slash ) );

                p.X -= sz_hpnow.Width;
                p.Y  = basearea.Bottom - barSize.Height - sz_hpnow.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, sz_hpnow), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_hpnow ) );
            }

            _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
        }
Exemple #2
0
 public void ValueChanged(object param)
 {
     if (Value != null)
     {
         if (param is Syncfusion.Windows.Shared.PercentTextBox)
         {
             Syncfusion.Windows.Shared.PercentTextBox textBox = param as Syncfusion.Windows.Shared.PercentTextBox;
             if (Value.Value > MaximumValue && !textBox.IsFocused && textBox.MaxValidation != MaxValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MaximumValue.ToString());
             }
             else if (Value.Value < MinimumValue && !textBox.IsFocused && textBox.MinValidation != MinValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MinimumValue.ToString());
             }
             else
             {
                 AddLog("Value Changed: " + Value.ToString());
             }
         }
         else
         {
             AddLog("Value Changed: " + Value.ToString());
         }
     }
     else
     {
         AddLog("Value Changed: NULL");
     }
 }
        /// <summary>
        /// Renders any data validator.
        /// </summary>
        /// <param name="writer">The writer.</param>
        protected override void RenderDataValidator(HtmlTextWriter writer)
        {
            _customValidator.Attributes.Add("min", MinimumValue ?? int.MinValue.ToString());
            _customValidator.Attributes.Add("max", MaximumValue ?? int.MaxValue.ToString());
            _customValidator.Attributes.Add("control", ClientID);

            decimal minValue = MinimumValue.AsDecimalOrNull() ?? decimal.MinValue;
            decimal maxValue = MaximumValue.AsDecimalOrNull() ?? decimal.MaxValue;

            string rangeMessageFormat = null;

            // if they are in the valid range, but not an integer, they'll see this message
            switch (NumberType)
            {
            case ValidationDataType.Integer:
                rangeMessageFormat = "{0} must be an integer";
                break;

            case ValidationDataType.Double:
                rangeMessageFormat = "{0} must be a decimal amount";
                break;

            case ValidationDataType.Currency:
                rangeMessageFormat = "{0} must be a currency amount";
                break;

            case ValidationDataType.Date:
                rangeMessageFormat = "{0} must be a date";
                break;

            case ValidationDataType.String:
                rangeMessageFormat = "{0} must be a string";
                break;
            }

            if (minValue > decimal.MinValue)
            {
                rangeMessageFormat = "{0} must be at least " + MinimumValue;
            }

            if (maxValue < decimal.MaxValue)
            {
                rangeMessageFormat = "{0} must be at most " + MaximumValue;
            }

            if ((minValue > decimal.MinValue) && (maxValue < decimal.MaxValue))
            {
                rangeMessageFormat = string.Format("{{0}} must be between {0} and {1} ", MinimumValue, MaximumValue);
            }

            if (!string.IsNullOrWhiteSpace(rangeMessageFormat))
            {
                _customValidator.ErrorMessage = string.Format(rangeMessageFormat, string.IsNullOrWhiteSpace(FieldName) ? "Value" : FieldName);
            }

            _customValidator.Attributes.Add("ErrorMessage", _customValidator.ErrorMessage);

            _customValidator.ValidationGroup = this.ValidationGroup;
            _customValidator.RenderControl(writer);
        }
Exemple #4
0
 public void MaxValueChanged(object param)
 {
     if (MaximumValue != null)
     {
         AddLog("MaxValue Changed: " + MaximumValue.ToString());
     }
 }
Exemple #5
0
        /// <summary>
        /// Renders the base control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderBaseControl(HtmlTextWriter writer)
        {
            string numberType = NumberType.ConvertToString();

            if (numberType == "Integer")
            {
                this.Attributes["pattern"] = "[0-9]*";
            }

            var minValue = MinimumValue.AsIntegerOrNull();

            if (minValue.HasValue)
            {
                this.Attributes["min"] = minValue.ToString();
            }

            var maxValue = MaximumValue.AsIntegerOrNull();

            if (maxValue.HasValue)
            {
                this.Attributes["max"] = maxValue.ToString();
            }

            base.RenderBaseControl(writer);
        }
Exemple #6
0
 public override void MakeSchemaCompliant()
 {
     base.MakeSchemaCompliant();
     MinimumValue.MakeSchemaCompliant();
     MaximumValue.MakeSchemaCompliant();
     VerticalCRS.MakeSchemaCompliant();
 }
Exemple #7
0
        public bool Equals(DestinyStatDisplayDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     StatHash == input.StatHash ||
                     (StatHash.Equals(input.StatHash))
                     ) &&
                 (
                     MaximumValue == input.MaximumValue ||
                     (MaximumValue.Equals(input.MaximumValue))
                 ) &&
                 (
                     DisplayAsNumeric == input.DisplayAsNumeric ||
                     (DisplayAsNumeric != null && DisplayAsNumeric.Equals(input.DisplayAsNumeric))
                 ) &&
                 (
                     DisplayInterpolation == input.DisplayInterpolation ||
                     (DisplayInterpolation != null && DisplayInterpolation.SequenceEqual(input.DisplayInterpolation))
                 ));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (UnitOfMeasure != null)
         {
             hashCode = hashCode * 59 + UnitOfMeasure.GetHashCode();
         }
         if (MinimumValue != null)
         {
             hashCode = hashCode * 59 + MinimumValue.GetHashCode();
         }
         if (MaximumValue != null)
         {
             hashCode = hashCode * 59 + MaximumValue.GetHashCode();
         }
         if (RateApplicationMethod != null)
         {
             hashCode = hashCode * 59 + RateApplicationMethod.GetHashCode();
         }
         if (ApplicabilityConditions != null)
         {
             hashCode = hashCode * 59 + ApplicabilityConditions.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemple #9
0
 public void ValueChanged(object param)
 {
     if (Value != null)
     {
         if (param is IntegerTextBox)
         {
             IntegerTextBox textBox = param as IntegerTextBox;
             if (Value.Value > MaximumValue && !textBox.IsFocused && textBox.MaxValidation != MaxValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MaximumValue.ToString());
             }
             else if (Value.Value < MinimumValue && !textBox.IsFocused && textBox.MinValidation != MinValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MinimumValue.ToString());
             }
             else
             {
                 AddLog("Value Changed: " + Value.ToString());
             }
         }
         else
         {
             AddLog("Value Changed: " + Value.ToString());
         }
     }
     else
     {
         AddLog("Value Changed: NULL");
     }
 }
Exemple #10
0
        public void Terminate()
        {
            MaximumValue maximumValue = new MaximumValue();

            Assert.True(maximumValue.Terminate(50, 50));
            Assert.True(maximumValue.Terminate(100, 50));
            Assert.False(maximumValue.Terminate(50, 100));
        }
Exemple #11
0
        public void CalculateCompletion()
        {
            MaximumValue maximumValue = new MaximumValue();

            Assert.AreEqual(maximumValue.CalculateCompletion(-1, 100), 0);
            Assert.AreEqual(maximumValue.CalculateCompletion(0, 100), 0);
            Assert.AreEqual(maximumValue.CalculateCompletion(50, 100), 0.5);
            Assert.AreEqual(maximumValue.CalculateCompletion(100, 100), 1.0);
            Assert.AreEqual(maximumValue.CalculateCompletion(100, 50), 1.0);

            Assert.Throws <ArgumentException>(() => maximumValue.CalculateCompletion(0, 0));
        }
Exemple #12
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = ShowHPBar ? _HPBar.GetPreferredSize(new Size(basearea.Width, 0)) : Size.Empty;



            if (RepairTimeShowMode == ShipStatusHPRepairTimeShowMode.Visible ||
                (RepairTimeShowMode == ShipStatusHPRepairTimeShowMode.MouseOver && _onMouse))
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                var  rect = new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height);
                Font font;
                if (rect.Width >= RepairTimeSizeCache.Width)
                {
                    font = MainFont;
                }
                else
                {
                    font = SubFont;
                }

                TextRenderer.DrawText(g, timestr, font, rect, RepairFontColor, TextFormatTime);
            }
            else
            {
                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - Math.Max(TextSizeCache.Height, MaximumValueSizeCache.Height) + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, TextSizeCache), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, TextSizeCache ) );

                p.X = basearea.Right - MaximumValueSizeCache.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, MaximumValueSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, MaximumValueSizeCache ) );

                p.X -= SlashSizeCache.Width;
                TextRenderer.DrawText(g, SlashText, SubFont, new Rectangle(p, SlashSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, SlashSizeCache ) );

                p.X -= ValueSizeCache.Width;
                p.Y  = basearea.Bottom - barSize.Height - ValueSizeCache.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, ValueSizeCache), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, ValueSizeCache ) );
            }

            if (ShowHPBar)
            {
                _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
            }
        }
Exemple #13
0
        /// <summary>
        /// Renders any data validator.
        /// </summary>
        /// <param name="writer">The writer.</param>
        protected override void RenderDataValidator(HtmlTextWriter writer)
        {
            _rangeValidator.Type         = NumberType;
            _rangeValidator.MinimumValue = this.MinimumValue;
            _rangeValidator.MaximumValue = this.MaximumValue;
            string dataTypeText = string.Empty;

            int minValue = MinimumValue.AsIntegerOrNull() ?? int.MinValue;
            int maxValue = MaximumValue.AsIntegerOrNull() ?? int.MaxValue;

            string rangeMessageFormat = null;

            // if they are in the valid range, but not an integer, they'll see this message
            switch (_rangeValidator.Type)
            {
            case ValidationDataType.Integer: rangeMessageFormat = "{0} must be an integer"; break;

            case ValidationDataType.Double: rangeMessageFormat = "{0} must be a decimal amout"; break;

            case ValidationDataType.Currency: rangeMessageFormat = "{0} must be a currency amount"; break;

            case ValidationDataType.Date: rangeMessageFormat = "{0} must be a date"; break;

            case ValidationDataType.String: rangeMessageFormat = "{0} must be a string"; break;
            }

            if (minValue > int.MinValue)
            {
                rangeMessageFormat = "{0} must be at least " + MinimumValue;
            }

            if (maxValue < int.MaxValue)
            {
                rangeMessageFormat = "{0} must be at most " + MaximumValue;
            }

            if ((minValue > int.MinValue) && (maxValue < int.MaxValue))
            {
                rangeMessageFormat = string.Format("{{0}} must be between {0} and {1} ", MinimumValue, MaximumValue);
            }

            if (!string.IsNullOrWhiteSpace(rangeMessageFormat))
            {
                _rangeValidator.ErrorMessage = string.Format(rangeMessageFormat, string.IsNullOrWhiteSpace(FieldName) ? "Value" : FieldName);
            }

            _rangeValidator.ValidationGroup = this.ValidationGroup;
            _rangeValidator.RenderControl(writer);
        }
Exemple #14
0
        private void ServerValidation(object source, ServerValidateEventArgs args)
        {
            var min = MinimumValue.IsNotNullOrWhiteSpace() ? Convert.ToDecimal(MinimumValue) : int.MinValue;
            var max = MaximumValue.IsNotNullOrWhiteSpace() ? Convert.ToDecimal(MaximumValue) : int.MaxValue;

            var value = args.Value.AsDecimalInvariantCultureOrNull();

            if (value == null)
            {
                args.IsValid = false;
                return;
            }

            args.IsValid = value <= max && value >= min;
        }
        /// <summary>
        /// Returns true if BankingProductRateTier instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingProductRateTier to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingProductRateTier other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     UnitOfMeasure == other.UnitOfMeasure ||
                     UnitOfMeasure != null &&
                     UnitOfMeasure.Equals(other.UnitOfMeasure)
                 ) &&
                 (
                     MinimumValue == other.MinimumValue ||
                     MinimumValue != null &&
                     MinimumValue.Equals(other.MinimumValue)
                 ) &&
                 (
                     MaximumValue == other.MaximumValue ||
                     MaximumValue != null &&
                     MaximumValue.Equals(other.MaximumValue)
                 ) &&
                 (
                     RateApplicationMethod == other.RateApplicationMethod ||
                     RateApplicationMethod != null &&
                     RateApplicationMethod.Equals(other.RateApplicationMethod)
                 ) &&
                 (
                     ApplicabilityConditions == other.ApplicabilityConditions ||
                     ApplicabilityConditions != null &&
                     ApplicabilityConditions.SequenceEqual(other.ApplicabilityConditions)
                 ) &&
                 (
                     SubTier == other.SubTier ||
                     SubTier != null &&
                     SubTier.Equals(other.SubTier)
                 ));
        }
Exemple #16
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);

            if (RenderUplevel)
            {
#if NET_2_0
                RegisterExpandoAttribute(ClientID, "evaluationfunction", "RangeValidatorEvaluateIsValid");
                RegisterExpandoAttribute(ClientID, "minimumvalue", MinimumValue, true);
                RegisterExpandoAttribute(ClientID, "maximumvalue", MaximumValue, true);
#else
                writer.AddAttribute("evaluationfunction", "RangeValidatorEvaluateIsValid", false);                 // FIXME - we need to define this in client code
                writer.AddAttribute("minimumValue", MinimumValue.ToString(Helpers.InvariantCulture));
                writer.AddAttribute("maximumValue", MaximumValue.ToString(Helpers.InvariantCulture));
#endif
            }
        }
        private void OnFormLoad(object sender, EventArgs e)
        {
            switch (ClassificationScheme)
            {
            case "Jenk's-Fisher's":
                break;

            case "Equal interval":
                lblMinValue.Text += MinimumValue.ToString();
                lblMaxValue.Text += MaximumValue.ToString();
                tabControl.TabPages["tabEqualInterval"].Select();
                break;

            case "User defined":
                tabControl.TabPages["tabUserDefined"].Select();
                break;
            }
            Text = ParameterToClassify;
            txtEndTarget.Enabled     = false;
            txtNumberOfSteps.Enabled = false;
        }
Exemple #18
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = _HPBar.GetPreferredSize(new Size(basearea.Width, 0));



            if (RepairTime != null)
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                TextRenderer.DrawText(g, timestr, MainFont, new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height), RepairFontColor, TextFormatTime);

                /*/
                 * g.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - BarThickness - BarBackgroundOffset - 1 ) );
                 * //*/
            }
            else
            {
                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - Math.Max(TextSizeCache.Height, MaximumValueSizeCache.Height) + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, TextSizeCache), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, TextSizeCache ) );

                p.X = basearea.Right - MaximumValueSizeCache.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, MaximumValueSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, MaximumValueSizeCache ) );

                p.X -= SlashSizeCache.Width;
                TextRenderer.DrawText(g, SlashText, SubFont, new Rectangle(p, SlashSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, SlashSizeCache ) );

                p.X -= ValueSizeCache.Width;
                p.Y  = basearea.Bottom - barSize.Height - ValueSizeCache.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, ValueSizeCache), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, ValueSizeCache ) );
            }

            _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
        }
        public bool Equals(DestinyStatGroupDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     MaximumValue == input.MaximumValue ||
                     (MaximumValue.Equals(input.MaximumValue))
                     ) &&
                 (
                     UiPosition == input.UiPosition ||
                     (UiPosition.Equals(input.UiPosition))
                 ) &&
                 (
                     ScaledStats == input.ScaledStats ||
                     (ScaledStats != null && ScaledStats.SequenceEqual(input.ScaledStats))
                 ) &&
                 (
                     Overrides == input.Overrides ||
                     (Overrides != null && Overrides.SequenceEqual(input.Overrides))
                 ) &&
                 (
                     Hash == input.Hash ||
                     (Hash.Equals(input.Hash))
                 ) &&
                 (
                     Index == input.Index ||
                     (Index.Equals(input.Index))
                 ) &&
                 (
                     Redacted == input.Redacted ||
                     (Redacted != null && Redacted.Equals(input.Redacted))
                 ));
        }
        private String EvaluateAndFill(Int32 multiply)
        {
            Decimal value = (CurrentValue / MaximumValue.ToNonZero() * multiply).Round(PercentFractionalCount, Rounding);

            Int32 digits = value.GetDigitsCountAfterPoint();

            String zeros;

            if (FixedDecimalNumber)
            {
                zeros = String.Concat(Enumerable.Repeat("0", PercentFractionalCount - digits));

                if (digits <= 0)
                {
                    zeros = zeros.AddPrefix(".");
                }
            }
            else
            {
                zeros = String.Empty;
            }

            return($"{value.ToString(Culture)}{zeros}");
        }
Exemple #21
0
        /// <summary>
        /// Gets the size of the font.
        /// </summary>
        /// <returns></returns>
        private int getFontSize()
        {
            var len = MaximumValue.ToString().Length;

            return((int)Font.Size * len + 5);
        }
Exemple #22
0
 /// <summary>
 /// Returns the maximum number of characters for the maximum value or the minimum value.
 /// Used to autosize a NumberEntry.
 /// </summary>
 /// <returns></returns>
 public override int CalculateMaxCharacters()
 {
     return(Math.Max(MaximumValue.ToString().Length,
                     MinimumValue.ToString().Length));
 }