コード例 #1
0
ファイル: HtmlPanel.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Adjust the scrollbar of the panel on html element by the given id.<br/>
        /// The top of the html element rectangle will be at the top of the panel, if there
        /// is not enough height to scroll to the top the scroll will be at maximum.<br/>
        /// </summary>
        /// <param name="elementId">the id of the element to scroll to</param>
        public void ScrollToElement(string elementId)
        {
            ArgChecker.AssertArgNotNullOrEmpty(elementId, "elementId");

            if (_htmlContainer != null)
            {
                RectangleF?rect = _htmlContainer.GetElementRectangle(elementId);
                if (rect.HasValue)
                {
                    UpdateScroll(Point.Round(rect.Value.Location));
                    _htmlContainer.HandleMouseMove(this,
                                                   new MouseEventArgs(MouseButtons, 0, MousePosition.X, MousePosition.Y,
                                                                      0));
                }
            }
        }
コード例 #2
0
ファイル: HtmlLabel.cs プロジェクト: rajeshwarn/Creek
 /// <summary>
 /// Handle mouse move to handle hover cursor and text selection.
 /// </summary>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (_htmlContainer != null)
     {
         _htmlContainer.HandleMouseMove(this, e);
     }
 }
コード例 #3
0
ファイル: HtmlToolTip.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Raised on link handling timer tick, used for:
        /// 1. Know when the tooltip is hidden by checking the visibility of the tooltip window.
        /// 2. Call HandleMouseMove so the mouse cursor will react if over a link element.
        /// 3. Call HandleMouseDown and HandleMouseUp to simulate click on a link if one was clicked.
        /// </summary>
        private void OnLinkHandlingTimerTick(object sender, EventArgs eventArgs)
        {
            try
            {
                IntPtr handle = _tooltipHandle;
                if (handle != IntPtr.Zero && Win32Utils.IsWindowVisible(handle))
                {
                    Point        mPos     = Control.MousePosition;
                    MouseButtons mButtons = Control.MouseButtons;
                    Rectangle    rect     = Win32Utils.GetWindowRectangle(handle);
                    if (rect.Contains(mPos))
                    {
                        _htmlContainer.HandleMouseMove(_associatedControl,
                                                       new MouseEventArgs(mButtons, 0, mPos.X - rect.X, mPos.Y - rect.Y,
                                                                          0));
                    }
                }
                else
                {
                    _linkHandlingTimer.Stop();
                    _tooltipHandle = IntPtr.Zero;

                    Point        mPos     = Control.MousePosition;
                    MouseButtons mButtons = Control.MouseButtons;
                    Rectangle    rect     = Win32Utils.GetWindowRectangle(handle);
                    if (rect.Contains(mPos))
                    {
                        if (mButtons == MouseButtons.Left)
                        {
                            var args = new MouseEventArgs(mButtons, 1, mPos.X - rect.X, mPos.Y - rect.Y, 0);
                            _htmlContainer.HandleMouseDown(_associatedControl, args);
                            _htmlContainer.HandleMouseUp(_associatedControl, args);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                OnRenderError(this,
                              new HtmlRenderErrorEventArgs(HtmlRenderErrorType.General,
                                                           "Error in link handling for tooltip", ex));
            }
        }