Beispiel #1
0
            private Rectangle GetHotAreaBounds(IDeviceContext g, HotSpot area)
            {
                //GetPositionFromCharIndex give us the point at the top
                // left corner of this word. (see documentation on EM_POSFROMCHAR)
                Point start = _control.GetPositionFromCharIndex(area.Offset);
                // the following is necessary to work around a .Net bug
                int startX = (Int16)start.X;
                int startY = (Int16)start.Y;

                Size textSize =
                    TextRenderer.MeasureText(g,
                                             area.Text,
                                             _control.Font,
                                             _control.ClientSize,
                                             TextFormatFlags.TextBoxControl |
                                             TextFormatFlags.NoPadding |
                                             TextFormatFlags.WordBreak);

                return(new Rectangle(startX, startY, textSize.Width, textSize.Height));
            }
		public void Setup()
		{
			_hotSpotProvider = new HotSpotProvider();
			_textBox = new ClickableTextBox();
			_textBox.Width = 350;
			_textBox.Text = "Now is the time for ...";
			_spot1 = new HotSpot(_textBox, 7, 3);
			_spot2 = new HotSpot(_textBox, 16, 3);

			_hotSpotProvider.SetEnableHotSpots(_textBox, true);
			_hotSpotProvider.RetrieveHotSpots +=
				delegate(object sender, RetrieveHotSpotsEventArgs e)
					{
						e.AddHotSpot(_spot1);
						e.AddHotSpot(_spot2);
						e.Color = Color.Yellow;
					};
			_originalCursorPosition = Cursor.Position;

			_form = new Form();
			_form.Controls.Add(_textBox);
			_form.Show();
		}
		public void AddHotSpot(HotSpot hotSpot)
		{
			_hotSpots.Add(hotSpot);
		}
Beispiel #4
0
 public HotSpotInternal(HotSpot hotspot, Color underlineColor)
 {
     HotSpot        = hotspot;
     UnderlineColor = underlineColor;
 }
Beispiel #5
0
 public void AddHotSpot(HotSpot hotSpot)
 {
     _hotSpots.Add(hotSpot);
 }
			private Rectangle GetHotAreaBounds(IDeviceContext g, HotSpot area)
			{
				//GetPositionFromCharIndex give us the point at the top
				// left corner of this word. (see documentation on EM_POSFROMCHAR)
				Point start = _control.GetPositionFromCharIndex(area.Offset);
				// the following is necessary to work around a .Net bug
				int startX = (Int16) start.X;
				int startY = (Int16) start.Y;

				Size textSize =
					TextRenderer.MeasureText(g,
											 area.Text,
											 _control.Font,
											 _control.ClientSize,
											 TextFormatFlags.TextBoxControl |
											 TextFormatFlags.NoPadding |
											 TextFormatFlags.WordBreak);
				return new Rectangle(startX, startY, textSize.Width, textSize.Height);
			}
			public HotSpotInternal(HotSpot hotspot, Color underlineColor)
			{
				HotSpot = hotspot;
				UnderlineColor = underlineColor;
			}
		private void MoveMouseSoOverHotSpot(HotSpot hotSpot)
		{
			MoveMouseToPositionAtCharIndex(hotSpot.Offset);
			Application.DoEvents();
		}