コード例 #1
0
ファイル: HtmlToolTip.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// On tooltip appear set the html by the associated control, layout and set the tooltip size by the html size.
        /// </summary>
        private void OnToolTipPopup(object sender, PopupEventArgs e)
        {
            //Create fragment container
            string cssClass = string.IsNullOrEmpty(_tooltipCssClass)
                                  ? null
                                  : string.Format(" class=\"{0}\"", _tooltipCssClass);
            string toolipHtml = string.Format("<div{0}>{1}</div>", cssClass, GetToolTip(e.AssociatedControl));

            _htmlContainer.SetHtml(toolipHtml, _baseCssData);
            _htmlContainer.MaxSize = MaximumSize;

            //Measure size of the container
            using (Graphics g = e.AssociatedControl.CreateGraphics())
            {
                _htmlContainer.PerformLayout(g);
            }

            //Set the size of the tooltip
            e.ToolTipSize = new Size((int)Math.Ceiling(_htmlContainer.ActualSize.Width),
                                     (int)Math.Ceiling(_htmlContainer.ActualSize.Height));

            // start mouse handle timer
            if (_allowLinksHandling)
            {
                _associatedControl = e.AssociatedControl;
                _linkHandlingTimer.Start();
            }
        }
コード例 #2
0
ファイル: HtmlPanel.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Perform html container layout by the current panel client size.
        /// </summary>
        private void PerformHtmlLayout()
        {
            if (_htmlContainer != null)
            {
                _htmlContainer.MaxSize = new SizeF(ClientSize.Width, 0);

                using (Graphics g = CreateGraphics())
                {
                    _htmlContainer.PerformLayout(g);
                }

                AutoScrollMinSize = Size.Round(_htmlContainer.ActualSize);
            }
        }
コード例 #3
0
ファイル: HtmlLabel.cs プロジェクト: rajeshwarn/Creek
        /// <summary>
        /// Perform the layout of the html in the control.
        /// </summary>
        protected override void OnLayout(LayoutEventArgs levent)
        {
            if (_htmlContainer != null)
            {
                if (AutoSize)
                {
                    _htmlContainer.MaxSize = SizeF.Empty;
                }
                else if (AutoSizeHeightOnly)
                {
                    _htmlContainer.MaxSize = new SizeF(Width, 0);
                }
                else
                {
                    _htmlContainer.MaxSize = Size;
                }

                using (Graphics g = CreateGraphics())
                {
                    _htmlContainer.PerformLayout(g);

                    if (AutoSize || _autoSizeHight)
                    {
                        if (AutoSize)
                        {
                            Size = Size.Round(_htmlContainer.ActualSize);
                            if (MaximumSize.Width > 0 && MaximumSize.Width < _htmlContainer.ActualSize.Width)
                            {
                                // to allow the actual size be smaller than max we need to set max size only if it is really larger
                                _htmlContainer.MaxSize = MaximumSize;
                                _htmlContainer.PerformLayout(g);

                                Size = Size.Round(_htmlContainer.ActualSize);
                            }
                            else if (MinimumSize.Width > 0 && MinimumSize.Width > _htmlContainer.ActualSize.Width)
                            {
                                // if min size is larger than the actual we need to re-layout so all 100% layouts will be correct
                                _htmlContainer.MaxSize = new SizeF(MinimumSize.Width, 0);
                                _htmlContainer.PerformLayout(g);

                                Size = Size.Round(_htmlContainer.ActualSize);
                            }
                        }
                        else if (_autoSizeHight && Height != (int)_htmlContainer.ActualSize.Height)
                        {
                            int prevWidth = Width;

                            // make sure the height is not lower than min if given
                            Height = MinimumSize.Height > 0 && MinimumSize.Height > _htmlContainer.ActualSize.Height
                                         ? MinimumSize.Height
                                         : (int)_htmlContainer.ActualSize.Height;

                            // handle if changing the height of the label affects the desired width and those require re-layout
                            if (prevWidth != Width)
                            {
                                OnLayout(levent);
                            }
                        }
                    }
                }
            }

            base.OnLayout(levent);
        }