当前位置: 首页>>代码示例>>C#>>正文


C# MaskedTextResultHint类代码示例

本文整理汇总了C#中MaskedTextResultHint的典型用法代码示例。如果您正苦于以下问题:C# MaskedTextResultHint类的具体用法?C# MaskedTextResultHint怎么用?C# MaskedTextResultHint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MaskedTextResultHint类属于命名空间,在下文中一共展示了MaskedTextResultHint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clear

    public void Clear(out MaskedTextResultHint resultHint)
    {
      Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(2)) <= Contract.ValueAtReturn(out resultHint));
      Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4)));

      resultHint = default(MaskedTextResultHint);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.ComponentModel.MaskedTextProvider.cs

示例2: Add

    public bool Add(string input, out int testPosition, out MaskedTextResultHint resultHint)
    {
      Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-54)) <= Contract.ValueAtReturn(out resultHint));

      testPosition = default(int);
      resultHint = default(MaskedTextResultHint);

      return default(bool);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:9,代码来源:System.ComponentModel.MaskedTextProvider.cs

示例3: InsertAtInt

        /// <devdoc>
        ///     Attempts to insert the characters in the specified string in at the specified position in the test string,
        ///     shifting characters at upper positions (if any) to make room for the input.
        ///     It performs the insertion if the testOnly parameter is false and the test passes.
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful, 
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        private bool InsertAtInt(string input, int position, out int testPosition, out MaskedTextResultHint resultHint, bool testOnly)
        {
            Debug.Assert(input != null && position >= 0 && position < this.testString.Length, "input param out of range.");

            if (input.Length == 0) // nothing to insert.
            {
                testPosition = position;
                resultHint   = MaskedTextResultHint.NoEffect;
                return true;
            }

            // Test input string first.  testPosition will containt the position of the last inserting character from the input.
            if (!TestString(input, position, out testPosition, out resultHint))
            {
                return false;
            }

            // Now check if we need to open room for the input characters (shift characters right) and if so test the shifting characters.

            int  srcPos          = FindEditPositionFrom(position, forward);               // source position.
            bool shiftNeeded     = FindAssignedEditPositionInRange(srcPos, testPosition, forward) != invalidIndex;
            int  lastAssignedPos = this.LastAssignedPosition;

            if( shiftNeeded && (testPosition == this.testString.Length - 1)) // no room for shifting.
            {
                resultHint   = MaskedTextResultHint.UnavailableEditPosition;
                testPosition = this.testString.Length;
                return false;
            }
            
            int dstPos = FindEditPositionFrom(testPosition + 1, forward);  // destination position.

            if (shiftNeeded)
            {
                // Temp hint used not to overwrite the primary operation result hint (from TestString).
                MaskedTextResultHint tempHint = MaskedTextResultHint.Unknown;

                // Test shifting characters.
                while (true)
                {
                    if (dstPos == invalidIndex)
                    {
                        resultHint   = MaskedTextResultHint.UnavailableEditPosition;
                        testPosition = this.testString.Length;
                        return false;
                    }

                    CharDescriptor chDex = this.stringDescriptor[srcPos];

                    if (chDex.IsAssigned) // only test assigned positions.
                    {
                        if (!TestChar(this.testString[srcPos], dstPos, out tempHint))
                        {
                            resultHint   = tempHint;
                            testPosition = dstPos;
                            return false;
                        }
                    }

                    if (srcPos == lastAssignedPos) // all shifting positions tested?
                    {
                        break;
                    }

                    srcPos = FindEditPositionFrom(srcPos + 1, forward);
                    dstPos = FindEditPositionFrom(dstPos + 1, forward);
                }

                if (tempHint > resultHint)
                {
                    resultHint = tempHint;
                }
            }

            if (testOnly)
            {
                return true; // test done!
            }

            // Tests passed so we can go ahead and shift the existing characters (if needed) and insert the new ones.

            if (shiftNeeded)
            {
                while (srcPos >= position)
                {
                    CharDescriptor chDex = this.stringDescriptor[srcPos];

                    if (chDex.IsAssigned)
                    {
                        SetChar(this.testString[srcPos], dstPos);
                    }
//.........这里部分代码省略.........
开发者ID:REALTOBIZ,项目名称:mono,代码行数:101,代码来源:MaskedTextProvider.cs

示例4: PlaceChar

 /// <devdoc>
 ///     Insert or replaces the specified character into the control's text and updates the caret position.  
 ///     If overwrite is true, it replaces the character at the selection start position.
 /// </devdoc>
 private bool PlaceChar(char ch, int startPosition, int length, bool overwrite,
     out MaskedTextResultHint hint)
 {
     return PlaceChar(this.maskedTextProvider, ch, startPosition, length, overwrite, out hint );
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:9,代码来源:MaskedTextBox.cs

示例5: PostprocessKeyboardInput

		void PostprocessKeyboardInput (bool result, int newPosition, int testPosition, MaskedTextResultHint resultHint)
		{
			if (!result)
				OnMaskInputRejected (new MaskInputRejectedEventArgs (testPosition, resultHint));
			else {
				if (newPosition != MaskedTextProvider.InvalidIndex)
					SelectionStart = newPosition;
				else
					SelectionStart = provider.Length;

				UpdateVisibleText ();
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:MaskedTextBox.cs

示例6: Replace

    public bool Replace(string input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint)
    {
      Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-55)) <= Contract.ValueAtReturn(out resultHint));
      Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4)));

      testPosition = default(int);
      resultHint = default(MaskedTextResultHint);

      return default(bool);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:10,代码来源:System.ComponentModel.MaskedTextProvider.cs

示例7: InsertAt

    public bool InsertAt(char input, int position, out int testPosition, out MaskedTextResultHint resultHint)
    {
      testPosition = default(int);
      resultHint = default(MaskedTextResultHint);

      return default(bool);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.ComponentModel.MaskedTextProvider.cs

示例8: Clear

        /// <devdoc>
        ///     Resets the state of the test string edit chars. (Remove all characters from the virtual string).
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        /// </devdoc>
        public void Clear( out MaskedTextResultHint resultHint )
        {
            if (this.assignedCharCount == 0)
            {
                resultHint = MaskedTextResultHint.NoEffect;
                return;
            }

            resultHint = MaskedTextResultHint.Success;

            for( int position = 0; position < this.testString.Length; position++ )
            {
                ResetChar( position );
            }
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:19,代码来源:MaskedTextProvider.cs

示例9: Replace

        /// <devdoc>
        ///     Replaces the characters in the specified range with the characters in the input string and shifts 
        ///     characters appropriately (removing or inserting characters according to whether the input string is
        ///     shorter or larger than the specified range.
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful, 
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        public bool Replace(string input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (endPosition >= this.testString.Length)
            {
                testPosition = endPosition;
                resultHint   = MaskedTextResultHint.PositionOutOfRange;
                return false;
                //throw new ArgumentOutOfRangeException("endPosition");
            }

            if (startPosition < 0 || startPosition > endPosition)
            {
                testPosition = startPosition;
                resultHint   = MaskedTextResultHint.PositionOutOfRange;
                return false;
                //throw new ArgumentOutOfRangeException("startPosition");
            }

            if (input.Length == 0) // remove character at position.
            {
                return RemoveAt( startPosition, endPosition, out testPosition, out resultHint );
            }
        
            // If replacing the entire text with a same-lenght text, we are just setting (not replacing) the test string to the new value;
            // in this case we just call SetString.
            // If the text length is different than the specified range we would need to remove or insert characters; there are three possible
            // cases as follows:
            // 1. The text length is the same as edit positions in the range (or no assigned chars): just replace the text, no additional operations needed.
            // 2. The text is shorter: replace the text in the text string and remove (range - text.Length) characters.
            // 3. The text is larger: replace range count characters and insert (range - text.Length) characters.
            
            // Test input string first and get the last test position to determine what to do.
            if( !TestString( input, startPosition, out testPosition, out resultHint ))
            {
                return false;
            }

            if (this.assignedCharCount > 0)
            {
                // cache out params to preserve the ones from the primary operation (in case of success).
                int tempPos;
                MaskedTextResultHint tempHint;

                if (testPosition < endPosition) // Case 2. Replace + Remove.
                {
                    // Test removing remaining characters.
                    if (!RemoveAtInt(testPosition + 1, endPosition, out tempPos, out tempHint, /*testOnly*/ false))
                    {
                        testPosition = tempPos;
                        resultHint = tempHint;
                        return false;
                    }

                    // If current result hint is not success (no effect), and character shifting is actually performed, hint = side effect.
                    if (tempHint == MaskedTextResultHint.Success && resultHint != tempHint)
                    {
                        resultHint = MaskedTextResultHint.SideEffect;
                    }
                }
                else if (testPosition > endPosition) // Case 3. Replace + Insert.
                {
                    // Test shifting existing characters to make room for inserting part of the input.
                    int lastAssignedPos = this.LastAssignedPosition;
                    int dstPos = testPosition + 1;
                    int srcPos = endPosition + 1;

                    while (true)
                    {
                        srcPos = FindEditPositionFrom(srcPos, forward);
                        dstPos = FindEditPositionFrom(dstPos, forward);

                        if (dstPos == invalidIndex)
                        {
                            testPosition = this.testString.Length;
                            resultHint = MaskedTextResultHint.UnavailableEditPosition;
                            return false;
                        }

                        if (!TestChar(this.testString[srcPos], dstPos, out tempHint))
                        {
                            testPosition = dstPos;
                            resultHint = tempHint;
                            return false;
                        }

                        // If current result hint is not success (no effect), and character shifting is actually performed, hint = success effect.
//.........这里部分代码省略.........
开发者ID:REALTOBIZ,项目名称:mono,代码行数:101,代码来源:MaskedTextProvider.cs

示例10: RemoveAtInt

        /// <devdoc>
        ///     Removes all characters in edit position from in the test string at the specified start and end positions 
        ///     and shifts any remaining characters left.
        ///     If testOnly parameter is set to false and the test passes it performs the operations on the characters.
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful, 
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        private bool RemoveAtInt(int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint, bool testOnly)
        {
            Debug.Assert(startPosition >= 0 && startPosition <= endPosition && endPosition < this.testString.Length, "Out of range input value.");

            // Check if we need to shift characters left to occupied the positions left by the characters being removed.
            int lastAssignedPos = this.LastAssignedPosition;
            int dstPos          = FindEditPositionInRange(startPosition, endPosition, forward); // first edit position in range.

            resultHint = MaskedTextResultHint.NoEffect;

            if (dstPos == invalidIndex || dstPos > lastAssignedPos) // nothing to remove.
            {
                testPosition = startPosition;
                return true;
            }

            testPosition = startPosition;    // On remove range, testPosition remains the same as startPosition.

            bool shiftNeeded = endPosition < lastAssignedPos; // last assigned position is upper.

            // if there are assigned characters to be removed (could be that the range doesn't have one, in such case we may be just 
            // be shifting chars), the result hint is success, let's check.
            if (FindAssignedEditPositionInRange(startPosition, endPosition, forward) != invalidIndex)
            {
                resultHint = MaskedTextResultHint.Success;
            }

            if (shiftNeeded)
            {
                // Test shifting characters.

                int srcPos = FindEditPositionFrom(endPosition + 1, forward);  // first position to shift left.
                int shiftStart = srcPos; // cache it here so we don't have to search for it later if needed.
                MaskedTextResultHint testHint;

                startPosition = dstPos; // actual start position.

                while(true)
                {
                    char srcCh = this.testString[srcPos];
                    CharDescriptor chDex = this.stringDescriptor[srcPos];
                    
                    // if the shifting character is the prompt and it is at an unassigned position we don't need to test it.
                    if (srcCh != this.PromptChar || chDex.IsAssigned)
                    {
                        if (!TestChar(srcCh, dstPos, out testHint))
                        {
                            resultHint   = testHint;
                            testPosition = dstPos; // failed position.
                            return false;
                        }
                    }

                    if (srcPos == lastAssignedPos)
                    {
                        break;
                    }

                    srcPos = FindEditPositionFrom( srcPos + 1, forward);
                    dstPos = FindEditPositionFrom( dstPos + 1, forward);
                }

                // shifting characters is a resultHint == sideEffect, update hint if no characters removed (which would be hint == success).
                if( MaskedTextResultHint.SideEffect > resultHint )
                {
                    resultHint = MaskedTextResultHint.SideEffect;
                }

                if (testOnly)
                {
                    return true; // test completed.
                }

                // test passed so shift characters.
                srcPos = shiftStart;
                dstPos = startPosition;

                while(true)
                {
                    char srcCh = this.testString[srcPos];
                    CharDescriptor chDex = this.stringDescriptor[srcPos];
                    
                    // if the shifting character is the prompt and it is at an unassigned position we just reset the destination position.
                    if (srcCh == this.PromptChar && !chDex.IsAssigned)
                    {
                        ResetChar(dstPos);
                    }
                    else
                    {
                        SetChar(srcCh, dstPos);
                        ResetChar( srcPos );
//.........这里部分代码省略.........
开发者ID:REALTOBIZ,项目名称:mono,代码行数:101,代码来源:MaskedTextProvider.cs

示例11: RemoveAt

        /// <devdoc>
        ///     Removes all characters in edit position from in the test string at the specified start and end positions 
        ///     and shifts any remaining characters left.
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful, 
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        public bool RemoveAt(int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint)
        {
            if (endPosition >= this.testString.Length)
            {
                testPosition = endPosition;
                resultHint   = MaskedTextResultHint.PositionOutOfRange;
                return false;
                //throw new ArgumentOutOfRangeException("endPosition");
            }

            if (startPosition < 0 || startPosition > endPosition)
            {
                testPosition = startPosition;
                resultHint   = MaskedTextResultHint.PositionOutOfRange;
                return false;
                //throw new ArgumentOutOfRangeException("startPosition");
            }

            return RemoveAtInt(startPosition, endPosition, out testPosition, out resultHint, /*testOnly*/ false);
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:28,代码来源:MaskedTextProvider.cs

示例12: Remove

        /// <devdoc>
        ///     Removes the last character from the formatted string. (Remove last character in virtual string).
        ///     On exit the out param contains the position where the operation was actually performed.
        ///     This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        public bool Remove(out int testPosition, out MaskedTextResultHint resultHint)
        {
            int lastAssignedPos = this.LastAssignedPosition;

            if (lastAssignedPos == invalidIndex)
            {
                testPosition = 0;
                resultHint = MaskedTextResultHint.NoEffect;
                return true; // nothing to remove.
            }

            ResetChar(lastAssignedPos);

            testPosition = lastAssignedPos;
            resultHint   = MaskedTextResultHint.Success;

            return true;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:25,代码来源:MaskedTextProvider.cs

示例13: Add

        /// <devdoc>
        ///     Attempts to add the specified charactert to the last unoccupied positions in the test string (append text to 
        ///     the virtual string).
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful,
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives a hint about the operation result reason.
        ///     Returns true on success, false otherwise.
        /// </devdoc>
        public bool Add( char input, out int testPosition, out MaskedTextResultHint resultHint )
        {
            int lastAssignedPos = this.LastAssignedPosition;

            if( lastAssignedPos == this.testString.Length - 1 )    // at the last edit char position.
            {
                testPosition = this.testString.Length;
                resultHint = MaskedTextResultHint.UnavailableEditPosition;
                return false;
            }

            // Get position after last assigned position.
            testPosition = lastAssignedPos + 1;
            testPosition = FindEditPositionFrom( testPosition, forward );

            if( testPosition == invalidIndex )
            {
                resultHint = MaskedTextResultHint.UnavailableEditPosition;
                testPosition = this.testString.Length;
                return false;
            }

            if( !TestSetChar( input, testPosition, out resultHint ) )
            {
                return false;
            }

            return true;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:37,代码来源:MaskedTextProvider.cs

示例14: Set

        /// <devdoc>
        ///     Sets the edit characters in the test string to the ones specified in the input string if all characters
        ///     are valid.
        ///     On exit the testPosition contains last position where the primary operation was actually performed if successful, 
        ///     otherwise the first position that made the test fail. This position is relative to the test string.
        ///     The MaskedTextResultHint out param gives more information about the operation result.
        ///     If passwordChar is assigned, it is rendered in the output string instead of the user-supplied values.
        /// </devdoc>
        public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            resultHint = MaskedTextResultHint.Unknown;
            testPosition = 0;

            if (input.Length == 0) // Clearing the input text.
            {
                Clear(out resultHint);
                return true;
            }

            if (!TestSetString(input, testPosition, out testPosition, out resultHint))
            {
                return false;
            }

            // Reset remaining characters (if any).
            int resetPos = FindAssignedEditPositionFrom(testPosition + 1, forward);

            if (resetPos != invalidIndex)
            {
                ResetString(resetPos, this.testString.Length - 1);
            }

            return true;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:39,代码来源:MaskedTextProvider.cs

示例15: GetOperationResultFromHint

    public static bool GetOperationResultFromHint(MaskedTextResultHint hint)
    {
      Contract.Ensures(Contract.Result<bool>() == (hint > ((System.ComponentModel.MaskedTextResultHint)(0))));

      return default(bool);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:6,代码来源:System.ComponentModel.MaskedTextProvider.cs


注:本文中的MaskedTextResultHint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。