/// <summary>
        /// Converts a custom number serialisation to the invariant .NET Framework serialisation.
        /// </summary>
        /// <param name="customSerialisation"></param>
        /// <returns></returns>
        private string ToInvariantSerialisation(string customSerialisation)
        {
            var invariantSerialisation = customSerialisation;

            // Remove the group delimiter.
            GroupSeparator.InvokeNotDefault(el =>
            {
                if (GroupSeparator == NonBreakingSpaceChar)
                {
                    invariantSerialisation = invariantSerialisation.Replace(BreakingSpaceChar, NonBreakingSpaceChar);
                }

                invariantSerialisation = invariantSerialisation.Replace(GroupSeparatorChar, String.Empty);
            }
                                            );

            if (DecimalSeparatorChar != CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator)
            {
                // The turn to the CultureInfo.InvariantCulture.
                invariantSerialisation = invariantSerialisation.Replace(
                    DecimalSeparatorChar,
                    CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator);
            }

            return(invariantSerialisation);
        }
コード例 #2
0
        /// <summary>
        /// Get the current code to the AI
        /// </summary>
        /// <param name="barcodeString">The row data from the scanner</param>
        /// <param name="ai">The current AI</param>
        /// <param name="index">The refrence of the current position</param>
        /// <returns>the data to the current AI</returns>
        private string GetCode(string barcodeString, GS1BarcodeItem ai, ref int index)
        {
            // get the max lenght to read.
            int lenghtToRead = Math.Min(ai.LengthOfData, barcodeString.Length - index);

            string data;

            try
            {
                // get the data of the current AI
                data = barcodeString.Substring(index, lenghtToRead);
            }
            catch (Exception ex)
            {
                var appException = new ApplicationException("Data for AI substring failed, see inner exception", ex);
                appException.Data.Add("barcodeString", barcodeString);
                appException.Data.Add("index", index);
                appException.Data.Add("lenghtToRead", lenghtToRead);

                throw appException;
            }



            // check if the AI support a group seperator
            if (ai.Fnc1)
            {
                // try to find the index of the group seperator
                int indexOfGroupTermination = data.IndexOf(GroupSeparator);
                if (indexOfGroupTermination >= 0)
                {
                    lenghtToRead = indexOfGroupTermination + 1;
                }

                try
                {
                    // get the data of the current AI till the gorup seperator
                    data = barcodeString.Substring(index, lenghtToRead);
                }
                catch (Exception ex)
                {
                    var appException = new ApplicationException("Data for AI substring failed, see inner exception", ex);
                    appException.Data.Add("barcodeString", barcodeString);
                    appException.Data.Add("index", index);
                    appException.Data.Add("lenghtToRead", lenghtToRead);

                    throw appException;
                }

                if (data.Contains(GroupSeparator.ToString()))
                {
                    data = data.Remove(data.IndexOf(GroupSeparator), 1);
                }
            }

            // Shift the index to the next
            index += lenghtToRead;
            return(data);
        }
コード例 #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = DisplaySymbol.GetHashCode();
         hashCode = (hashCode * 397) ^ (IsoCode != null ? IsoCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SymbolFirst.GetHashCode();
         hashCode = (hashCode * 397) ^ (CurrencySymbol != null ? CurrencySymbol.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DecimalDigits;
         hashCode = (hashCode * 397) ^ (DecimalSeparator != null ? DecimalSeparator.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (GroupSeparator != null ? GroupSeparator.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ExampleFormat != null ? ExampleFormat.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #4
0
        /// <inheritdoc/>
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            if (Rendered)
            {
                var decimalsChanged                    = isIntegerType ? false : parameters.TryGetValue <int>(nameof(Decimals), out var paramDecimals) && !Decimals.IsEqual(paramDecimals);
                var decimalSeparatorChanged            = parameters.TryGetValue <string>(nameof(DecimalSeparator), out var paramDecimalSeparator) && !DecimalSeparator.IsEqual(paramDecimalSeparator);
                var alternativeDecimalSeparatorChanged = parameters.TryGetValue <string>(nameof(AlternativeDecimalSeparator), out var paramAlternativeDecimalSeparator) && !AlternativeDecimalSeparator.IsEqual(paramAlternativeDecimalSeparator);

                var groupSeparatorChanged = parameters.TryGetValue <string>(nameof(GroupSeparator), out var paramGroupSeparator) && !GroupSeparator.IsEqual(paramGroupSeparator);
                var groupSpacingChanged   = parameters.TryGetValue <string>(nameof(GroupSpacing), out var paramGroupSpacing) && !GroupSpacing.IsEqual(paramGroupSpacing);

                var currencySymbolChanged          = parameters.TryGetValue <string>(nameof(CurrencySymbol), out var paramCurrencySymbol) && !CurrencySymbol.IsEqual(paramCurrencySymbol);
                var currencySymbolPlacementChanged = parameters.TryGetValue <CurrencySymbolPlacement>(nameof(CurrencySymbolPlacement), out var paramCurrencySymbolPlacement) && !CurrencySymbolPlacement.IsEqual(paramCurrencySymbolPlacement);

                var roundingMethodChanged = parameters.TryGetValue <NumericRoundingMethod>(nameof(RoundingMethod), out var paramRoundingMethod) && !RoundingMethod.IsEqual(paramRoundingMethod);

                var minChanged = parameters.TryGetValue <TValue>(nameof(Min), out var paramMin) && !Min.IsEqual(paramMin);
                var maxChanged = parameters.TryGetValue <TValue>(nameof(Max), out var paramMax) && !Max.IsEqual(paramMax);
                var minMaxLimitsOverrideChanged = parameters.TryGetValue <NumericMinMaxLimitsOverride>(nameof(MinMaxLimitsOverride), out var paramMinMaxLimitsOverride) && !MinMaxLimitsOverride.IsEqual(paramMinMaxLimitsOverride);

                var selectAllOnFocusChanged = parameters.TryGetValue <bool>(nameof(SelectAllOnFocus), out var paramSelectAllOnFocus) && !SelectAllOnFocus.IsEqual(paramSelectAllOnFocus);

                var allowDecimalPaddingChanged         = parameters.TryGetValue <NumericAllowDecimalPadding>(nameof(AllowDecimalPadding), out var paramAllowDecimalPadding) && !AllowDecimalPadding.IsEqual(paramAllowDecimalPadding);
                var alwaysAllowDecimalSeparatorChanged = parameters.TryGetValue <bool>(nameof(AlwaysAllowDecimalSeparator), out var paramAlwaysAllowDecimalSeparator) && !AlwaysAllowDecimalSeparator.IsEqual(paramAlwaysAllowDecimalSeparator);

                var modifyValueOnWheelChanged = parameters.TryGetValue <bool>(nameof(ModifyValueOnWheel), out var paramModifyValueOnWheel) && !ModifyValueOnWheel.IsEqual(paramModifyValueOnWheel);
                var wheelOnChanged            = parameters.TryGetValue <NumericWheelOn>(nameof(WheelOn), out var paramWheelOn) && !WheelOn.IsEqual(paramWheelOn);

                if (decimalsChanged || decimalSeparatorChanged || alternativeDecimalSeparatorChanged ||
                    groupSeparatorChanged || groupSpacingChanged ||
                    currencySymbolChanged || currencySymbolPlacementChanged ||
                    roundingMethodChanged ||
                    minChanged || maxChanged ||
                    selectAllOnFocusChanged ||
                    allowDecimalPaddingChanged || alwaysAllowDecimalSeparatorChanged ||
                    modifyValueOnWheelChanged)
                {
                    ExecuteAfterRender(async() => await JSModule.UpdateOptions(ElementRef, ElementId, new
                    {
                        Decimals                    = new { Changed = decimalsChanged, Value = GetDecimals() },
                        DecimalSeparator            = new { Changed = decimalSeparatorChanged, Value = paramDecimalSeparator },
                        AlternativeDecimalSeparator = new { Changed = alternativeDecimalSeparatorChanged, Value = paramAlternativeDecimalSeparator },
                        GroupSeparator              = new { Changed = groupSeparatorChanged, Value = paramGroupSeparator },
                        GroupSpacing                = new { Changed = groupSpacingChanged, Value = paramGroupSpacing },
                        CurrencySymbol              = new { Changed = currencySymbolChanged, Value = paramCurrencySymbol },
                        CurrencySymbolPlacement     = new { Changed = currencySymbolPlacementChanged, Value = paramCurrencySymbolPlacement.ToCurrencySymbolPlacement() },
                        RoundingMethod              = new { Changed = roundingMethodChanged, Value = paramRoundingMethod.ToNumericRoundingMethod() },
                        AllowDecimalPadding         = new { Changed = allowDecimalPaddingChanged, Value = paramAllowDecimalPadding.ToNumericDecimalPadding() },
                        AlwaysAllowDecimalSeparator = new { Changed = alwaysAllowDecimalSeparatorChanged, Value = paramAlwaysAllowDecimalSeparator },
                        Min = new { Changed = minChanged, Value = paramMin },
                        Max = new { Changed = maxChanged, Value = paramMax },
                        MinMaxLimitsOverride = new { Changed = minMaxLimitsOverrideChanged, Value = paramMinMaxLimitsOverride },
                        SelectAllOnFocus     = new { Changed = selectAllOnFocusChanged, Value = paramSelectAllOnFocus },
                        ModifyValueOnWheel   = new { Changed = modifyValueOnWheelChanged, Value = paramModifyValueOnWheel },
                        WheelOn = new { Changed = wheelOnChanged, Value = paramWheelOn },
                    }));
                }

                var valueChanged = parameters.TryGetValue <TValue>(nameof(Value), out var paramValue) && !Value.IsEqual(paramValue);

                if (valueChanged)
                {
                    ExecuteAfterRender(async() => await JSModule.UpdateValue(ElementRef, ElementId, paramValue));
                }
            }

            // This make sure we know that Min or Max parameters are defined and can be checked against the current value.
            // Without we cannot determine if Min or Max has a default value when TValue is non-nullable type.
            MinDefined = parameters.TryGetValue <TValue>(nameof(Min), out var min);
            MaxDefined = parameters.TryGetValue <TValue>(nameof(Max), out var max);

            await base.SetParametersAsync(parameters);

            if (ParentValidation != null)
            {
                if (parameters.TryGetValue <Expression <Func <TValue> > >(nameof(ValueExpression), out var expression))
                {
                    await ParentValidation.InitializeInputExpression(expression);
                }

                if (parameters.TryGetValue <string>(nameof(Pattern), out var pattern))
                {
                    // make sure we get the newest value
                    var value = parameters.TryGetValue <TValue>(nameof(Value), out var inValue)
                        ? inValue
                        : InternalValue;

                    await ParentValidation.InitializeInputPattern(pattern, value);
                }

                await InitializeValidation();
            }
        }
コード例 #5
0
        private void CreateControls()
        {
            const int height   = 27;
            const int hmargin  = 6;
            const int vspacing = -4;
            int       width    = Width - hmargin * 2;
            int       yoffset  = 0;

            if (_chkAlignToGraph != null)
            {
                _chkAlignToGraph.Dispose();
            }
            _chkAlignToGraph                   = Style.CreateCheckBox();
            _chkAlignToGraph.Text              = Resources.StrAlignToGraph;
            _chkAlignToGraph.Image             = CachedResources.Bitmaps["ImgAlignToGraph"];
            _chkAlignToGraph.Control.Bounds    = new Rectangle(hmargin, yoffset, width, height);
            _chkAlignToGraph.Control.Parent    = this;
            _chkAlignToGraph.IsChecked         = Column.AlignToGraph;
            _chkAlignToGraph.IsCheckedChanged += OnAlignToGraphCheckedChanged;
            yoffset += height + vspacing;

            if (_grpVisibleReferences == null)
            {
                _grpVisibleReferences = new GroupSeparator()
                {
                    Text   = Resources.StrVisibleReferences,
                    Bounds = new Rectangle(0, yoffset + 2, Width - hmargin, height),
                    Parent = this,
                };
            }
            yoffset += height + vspacing;

            if (_chkLocalBranches != null)
            {
                _chkLocalBranches.Dispose();
            }
            _chkLocalBranches                   = Style.CreateCheckBox();
            _chkLocalBranches.Text              = Resources.StrLocalBranches;
            _chkLocalBranches.Image             = CachedResources.Bitmaps["ImgBranch"];
            _chkLocalBranches.Control.Bounds    = new Rectangle(hmargin, yoffset, width, height);
            _chkLocalBranches.Control.Parent    = this;
            _chkLocalBranches.IsChecked         = Column.ShowLocalBranches;
            _chkLocalBranches.IsCheckedChanged += OnLocalBranchesCheckedChanged;
            yoffset += height + vspacing;

            if (_chkRemoteBranches != null)
            {
                _chkRemoteBranches.Dispose();
            }
            _chkRemoteBranches                   = Style.CreateCheckBox();
            _chkRemoteBranches.Text              = Resources.StrRemoteBranches;
            _chkRemoteBranches.Image             = CachedResources.Bitmaps["ImgBranchRemote"];
            _chkRemoteBranches.Control.Bounds    = new Rectangle(hmargin, yoffset, width, height);
            _chkRemoteBranches.Control.Parent    = this;
            _chkRemoteBranches.IsChecked         = Column.ShowRemoteBranches;
            _chkRemoteBranches.IsCheckedChanged += OnRemoteBranchesCheckedChanged;
            yoffset += height + vspacing;

            if (_chkTags != null)
            {
                _chkTags.Dispose();
            }
            _chkTags                   = Style.CreateCheckBox();
            _chkTags.Text              = Resources.StrTags;
            _chkTags.Image             = CachedResources.Bitmaps["ImgTag"];
            _chkTags.Control.Bounds    = new Rectangle(hmargin, yoffset, width, height);
            _chkTags.Control.Parent    = this;
            _chkTags.IsChecked         = Column.ShowTags;
            _chkTags.IsCheckedChanged += OnTagsCheckedChanged;
            yoffset += height + vspacing;

            if (_chkStash != null)
            {
                _chkStash.Dispose();
            }
            _chkStash                   = Style.CreateCheckBox();
            _chkStash.Text              = Resources.StrStash;
            _chkStash.Image             = CachedResources.Bitmaps["ImgStash"];
            _chkStash.Control.Bounds    = new Rectangle(hmargin, yoffset, width, height);
            _chkStash.Control.Parent    = this;
            _chkStash.IsChecked         = Column.ShowStash;
            _chkStash.IsCheckedChanged += OnStashCheckedChanged;
        }