コード例 #1
0
ファイル: HtmlToolTip.cs プロジェクト: massreuy/3P
        /// <summary>
        /// On tooltip appear set the html by the associated control, layout and set the tooltip size by the html size.
        /// </summary>
        protected virtual void OnToolTipPopup(PopupEventArgs e)
        {
            //Create fragment container
            HtmlContainer.SetHtml(YamuiThemeManager.WrapToolTipText(GetToolTip(e.AssociatedControl)), YamuiThemeManager.CurrentThemeCss);
            HtmlContainer.MaxSize = MaximumSize;

            //Measure size of the container
            using (var g = e.AssociatedControl.CreateGraphics()) {
                g.TextRenderingHint = _textRenderingHint;
                HtmlContainer.PerformLayout(g);
            }

            //Set the size of the tooltip
            var desiredWidth  = (int)Math.Ceiling(MaximumSize.Width > 0 ? Math.Min(HtmlContainer.ActualSize.Width, MaximumSize.Width) : HtmlContainer.ActualSize.Width);
            var desiredHeight = (int)Math.Ceiling(MaximumSize.Height > 0 ? Math.Min(HtmlContainer.ActualSize.Height, MaximumSize.Height) : HtmlContainer.ActualSize.Height);

            e.ToolTipSize = new Size(desiredWidth, desiredHeight);

#if !MONO
            // start mouse handle timer
            if (_allowLinksHandling)
            {
                _associatedControl = e.AssociatedControl;
                _linkHandlingTimer.Start();
            }
#endif
        }
コード例 #2
0
ファイル: HtmlToolTip.cs プロジェクト: devjerome/3P
 /// <summary>
 /// Propagate the image load event from root container.
 /// </summary>
 protected virtual void OnImageLoad(HtmlImageLoadEventArgs e) {
     var handler = ImageLoad;
     if (handler != null)
         handler(this, e);
     if (!e.Handled)
         YamuiThemeManager.GetHtmlImages(e);
 }
コード例 #3
0
        public SettingAppearance()
        {
            InitializeComponent();

            var colorList = new[] {
                Color.FromArgb(164, 196, 0),
                Color.FromArgb(96, 169, 23),
                Color.FromArgb(0, 138, 0),
                Color.FromArgb(0, 171, 169),
                Color.FromArgb(27, 161, 226),
                Color.FromArgb(0, 80, 239),
                Color.FromArgb(106, 0, 255),
                Color.FromArgb(170, 0, 255),
                Color.FromArgb(244, 114, 208),
                Color.FromArgb(216, 0, 115),
                Color.FromArgb(162, 0, 37),
                Color.FromArgb(229, 20, 0),
                Color.FromArgb(250, 104, 0),
                Color.FromArgb(240, 163, 10),
                Color.FromArgb(227, 200, 0),
                Color.FromArgb(130, 90, 44),
                Color.FromArgb(109, 135, 100),
                Color.FromArgb(100, 118, 135),
                Color.FromArgb(118, 96, 138),
                Color.FromArgb(135, 121, 78)
            };

            // AccentColors picker
            int x = 0;
            int y = 0;

            foreach (var accentColor in colorList)
            {
                var newColorPicker = new YamuiColorRadioButton();
                _simplePanelAccentColor.Controls.Add(newColorPicker);
                newColorPicker.CheckedChanged += NewColorPickerOnCheckedChanged;
                newColorPicker.BackColor       = accentColor;
                newColorPicker.Bounds          = new Rectangle(x, y, 50, 50);
                if (y + 2 * newColorPicker.Height > _simplePanelAccentColor.Height)
                {
                    x += newColorPicker.Width;
                    y  = 0;
                }
                else
                {
                    y += newColorPicker.Height;
                }
                if (YamuiThemeManager.Current.AccentColor == accentColor)
                {
                    _checkButton           = newColorPicker;
                    newColorPicker.Checked = true;
                }
            }

            // themes comob box
            comboTheme.DataSource    = YamuiThemeManager.GetThemesList().Select(theme => theme.ThemeName).ToList();
            comboTheme.SelectedIndex = YamuiThemeManager.GetThemesList().IndexOf(YamuiThemeManager.Current);

            comboTheme.SelectedIndexChanged += ComboThemeOnSelectedIndexChanged;
        }
コード例 #4
0
 /// <summary>
 /// Propagate the image load event from root container.
 /// </summary>
 protected virtual void OnImageLoad(HtmlImageLoadEventArgs e)
 {
     ImageLoad?.Invoke(this, e);
     if (!e.Handled)
     {
         YamuiThemeManager.GetHtmlImages(e);
     }
 }
コード例 #5
0
        /// <summary>
        /// Propagate the image load event from root container.
        /// </summary>
        protected virtual void OnImageLoad(HtmlImageLoadEventArgs e)
        {
            YamuiThemeManager.OnHtmlImageLoad(e);
            var handler = ImageLoad;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #6
0
ファイル: Utilities.cs プロジェクト: massreuy/3P
        /// <summary>
        /// Returns a fair width in which an html can be displayed
        /// </summary>
        public static int MeasureHtmlPrefWidth(string htmlContent, int minWidth, int maxWidth)
        {
            // find max height taken by the html
            // Measure the size of the html
            using (var gImg = new Bitmap(1, 1))
                using (var g = Graphics.FromImage(gImg)) {
                    string content = YamuiThemeManager.WrapLabelText(htmlContent);

                    // this should retrieve the best width, however it will not be the case if there are some width='100%' for instance
                    var calcWidth = (int)HtmlRender.Measure(g, content, 99999, YamuiThemeManager.CurrentThemeCss, null, (sender, args) => YamuiThemeManager.GetHtmlImages(args)).Width;

                    if (calcWidth >= 9999)
                    {
                        // get the minimum size required to display everything
                        var sizef = HtmlRender.Measure(g, content, 10, YamuiThemeManager.CurrentThemeCss, null, (sender, args) => YamuiThemeManager.GetHtmlImages(args));
                        minWidth = ((int)sizef.Width).Clamp(minWidth, maxWidth);

                        // set to max Width, get the height at max Width
                        sizef = HtmlRender.Measure(g, content, maxWidth, YamuiThemeManager.CurrentThemeCss, null, (sender, args) => YamuiThemeManager.GetHtmlImages(args));
                        var prefHeight = sizef.Height;

                        // now we got the final height, resize width until height changes
                        int j     = 0;
                        int detla = maxWidth / 2;
                        calcWidth = maxWidth;
                        do
                        {
                            calcWidth -= detla;
                            calcWidth  = calcWidth.Clamp(minWidth, maxWidth);

                            sizef = HtmlRender.Measure(g, content, calcWidth, YamuiThemeManager.CurrentThemeCss, null, (sender, args) => YamuiThemeManager.GetHtmlImages(args));

                            if (sizef.Height > prefHeight)
                            {
                                calcWidth += detla;
                                detla     /= 2;
                            }

                            if (calcWidth == maxWidth || calcWidth == minWidth)
                            {
                                break;
                            }

                            j++;
                        } while (j < 6);
                    }

                    return(calcWidth.Clamp(minWidth, maxWidth));
                }
        }
コード例 #7
0
 /// <summary>
 /// Changing theme
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void ComboThemeOnSelectedIndexChanged(object sender, EventArgs eventArgs)
 {
     try {
         YamuiThemeManager.Current             = YamuiThemeManager.GetThemesList()[comboTheme.SelectedIndex];
         YamuiThemeManager.Current.AccentColor = YamuiThemeManager.Current.ThemeAccentColor;
         _checkButton.Checked = false;
     } catch (Exception) {
         // ignored
     } finally {
         if (Program.MainForm != null)
         {
             PlsRefresh();
         }
     }
 }