Esempio n. 1
0
		/// <summary>
		///   Initializes a new instance of the Behavior class by associating it with a TextBoxBase derived object. </summary>
		/// <param name="textBox">
		///   The TextBoxBase object to associate with this behavior.  It must not be null. </param>
		/// <param name="addEventHandlers">
		///   If true, the textBox's event handlers are tied to the corresponding methods on this behavior object. </param>
		/// <exception cref="ArgumentNullException">textBox is null. </exception>
		/// <remarks>
		///   This constructor is <c>protected</c> since this class is only meant to be used as a base for other behaviors. </remarks>
		/// <seealso cref="System.Windows.Forms.TextBoxBase" />	
		/// <seealso cref="AddEventHandlers" />	
		protected Behavior(TextBoxBase textBox, bool addEventHandlers)
		{
			if (textBox == null)
				throw new ArgumentNullException("textBox");
			
			m_textBox = textBox;
			m_selection = new Selection(m_textBox);
			m_selection.TextChanging += new EventHandler(HandleTextChangingBySelection);
			
			if (addEventHandlers)
				AddEventHandlers();				
		}
Esempio n. 2
0
			/// <summary>
			///   Initializes a new instance of the Saver class by associating it with a TextBoxBase derived object 
			///   and passing the start and end position of the selection. </summary>
			/// <param name="textBox">
			///   The TextBoxBase object for which the selection is being saved. </param>
			/// <param name="start">
			///   The zero-based start position of the selection. </param>
			/// <param name="end">
			///   The zero-based end position of the selection. It must not be less than the start position. </param>
			/// <remarks>
			///   This constructor does not save the textbox's start and end position of the selection.
			///   Instead, it saves the two given parameters. </remarks>
			/// <seealso cref="System.Windows.Forms.TextBoxBase" />	
			public Saver(TextBoxBase textBox, int start, int end)
			{
				m_textBox = textBox;
				m_selection = new Selection(textBox);
				Debug.Assert(start <= end);

				m_start = start;
				m_end = end;
			}
Esempio n. 3
0
			/// <summary>
			///   Initializes a new instance of the Saver class by associating it with a TextBoxBase derived object. </summary>
			/// <param name="textBox">
			///   The TextBoxBase object for which the selection is being saved. </param>
			/// <remarks>
			///   This constructor saves the textbox's start and end position of the selection inside private fields. </remarks>
			/// <seealso cref="System.Windows.Forms.TextBoxBase" />	
			public Saver(TextBoxBase textBox)
			{
				m_textBox = textBox;
				m_selection = new Selection(textBox);
				m_selection.Get(out m_start, out m_end);			
			}