protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var ctx = Gdk.CairoHelper.Create(evnt.Window)) {
                if (mouseOver)
                {
                    DrawHoverBackground(ctx);
                }

                // Draw the icon
                DrawIcon(ctx);

                // Draw the text

                int textWidth = Allocation.Width - LeftTextPadding - InternalPadding * 2;

                using (var titleLayout = new Pango.Layout(PangoContext))
                {
                    titleLayout.Width     = Pango.Units.FromPixels(textWidth);
                    titleLayout.Ellipsize = Pango.EllipsizeMode.End;
                    titleLayout.SetMarkup(WelcomePageSection.FormatText(TitleFontFace, TitleFontSize, Pango.Weight.Bold, MediumTitleColor, title));

                    Pango.Layout subtitleLayout = null;

                    if (!string.IsNullOrEmpty(subtitle))
                    {
                        subtitleLayout           = new Pango.Layout(PangoContext);
                        subtitleLayout.Width     = Pango.Units.FromPixels(textWidth);
                        subtitleLayout.Ellipsize = Pango.EllipsizeMode.Start;
                        subtitleLayout.SetMarkup(WelcomePageSection.FormatText(SmallTitleFontFace, SmallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, subtitle));
                    }

                    int height = 0;
                    int w, h1, h2;
                    titleLayout.GetPixelSize(out w, out h1);
                    height += h1;

                    if (subtitleLayout != null)
                    {
                        height += Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                        subtitleLayout.GetPixelSize(out w, out h2);
                        height += h2;
                    }

                    int tx = Allocation.X + InternalPadding + LeftTextPadding;
                    int ty = Allocation.Y + (Allocation.Height - height) / 2;
                    DrawLayout(ctx, titleLayout, TitleFontFace, TitleFontSize, Pango.Weight.Bold, MediumTitleColor, tx, ty);

                    if (subtitleLayout != null)
                    {
                        ty += h1 + Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                        DrawLayout(ctx, subtitleLayout, SmallTitleFontFace, SmallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, tx, ty);
                        subtitleLayout.Dispose();
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt)
 {
     if (evnt.Button == 1 && new Gdk.Rectangle(0, 0, Allocation.Width, Allocation.Height).Contains((int)evnt.X, (int)evnt.Y))
     {
         WelcomePageSection.DispatchLink(LinkUrl);
         return(true);
     }
     return(base.OnButtonReleaseEvent(evnt));
 }
        protected void Update()
        {
            if (imageNormal != null)
            {
                image.Image = mouseOver ? imageHover : imageNormal;
            }
            var color = mouseOver ? HoverColor : Color;

            label.Markup = WelcomePageSection.FormatText(FontFamily, FontSize, FontWeight, color, Text);
        }
        void HandlePress(object sender, EventArgs args)
        {
            // If alternate UI is shown then a press activates the pin
            if (AllowPinning && mouseOver)
            {
                Pinned = !pinned;

                QueueDraw();
                PinClicked?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                WelcomePageSection.DispatchLink(actionUrl);
            }
        }
Esempio n. 5
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt)
 {
     if (evnt.Button == 1)
     {
         if (mouseOverStar && AllowPinning)
         {
             pinned = !pinned;
             QueueDraw();
             if (PinClicked != null)
             {
                 PinClicked(this, EventArgs.Empty);
             }
             return(true);
         }
         else if (mouseOver)
         {
             WelcomePageSection.DispatchLink(actionUrl);
             return(true);
         }
     }
     return(base.OnButtonReleaseEvent(evnt));
 }
 protected virtual void OnClicked()
 {
     WelcomePageSection.DispatchLink(actionLink);
 }
Esempio n. 7
0
 void PerformPress(object sender, EventArgs e)
 {
     WelcomePageSection.DispatchLink(LinkUrl);
 }
Esempio n. 8
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var ctx = Gdk.CairoHelper.Create(evnt.Window)) {
                if (mouseOver)
                {
                    if (BorderPadding <= 0)
                    {
                        ctx.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                        ctx.SetSourceColor(CairoExtensions.ParseColor(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBackgroundColor));
                        ctx.Fill();
                        ctx.MoveTo(Allocation.X, Allocation.Y + 0.5);
                        ctx.RelLineTo(Allocation.Width, 0);
                        ctx.MoveTo(Allocation.X, Allocation.Y + Allocation.Height - 0.5);
                        ctx.RelLineTo(Allocation.Width, 0);

                        if (DrawRightBorder)
                        {
                            ctx.MoveTo(Allocation.Right + 0.5, Allocation.Y + 0.5);
                            ctx.LineTo(Allocation.Right + 0.5, Allocation.Bottom - 0.5);
                        }
                        if (DrawLeftBorder)
                        {
                            ctx.MoveTo(Allocation.Left + 0.5, Allocation.Y + 0.5);
                            ctx.LineTo(Allocation.Left + 0.5, Allocation.Bottom - 0.5);
                        }

                        ctx.LineWidth = 1;
                        ctx.SetSourceColor(CairoExtensions.ParseColor(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBorderColor));
                        ctx.Stroke();
                    }
                    else
                    {
                        Gdk.Rectangle region = Allocation;
                        region.Inflate(-BorderPadding, -BorderPadding);

                        ctx.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
                        ctx.SetSourceColor(CairoExtensions.ParseColor(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBackgroundColor));
                        ctx.FillPreserve();

                        ctx.LineWidth = 1;
                        ctx.SetSourceColor(CairoExtensions.ParseColor(Styles.WelcomeScreen.Pad.Solutions.SolutionTile.HoverBorderColor));
                        ctx.Stroke();
                    }
                }

                // Draw the icon

                int x = Allocation.X + InternalPadding;
                int y = Allocation.Y + (Allocation.Height - icon.Height) / 2;
                Gdk.CairoHelper.SetSourcePixbuf(ctx, icon, x, y);
                ctx.Paint();

                if (AllowPinning && (mouseOver || pinned))
                {
                    Gdk.Pixbuf star;
                    if (pinned)
                    {
                        if (mouseOverStar)
                        {
                            star = starPinnedHover;
                        }
                        else
                        {
                            star = starPinned;
                        }
                    }
                    else
                    {
                        if (mouseOverStar)
                        {
                            star = starNormalHover;
                        }
                        else
                        {
                            star = starNormal;
                        }
                    }
                    x = x + icon.Width - star.Width + 3;
                    y = y + icon.Height - star.Height + 3;
                    Gdk.CairoHelper.SetSourcePixbuf(ctx, star, x, y);
                    ctx.Paint();
                    starRect = new Gdk.Rectangle(x, y, star.Width, star.Height);
                }

                // Draw the text

                int textWidth = Allocation.Width - LeftTextPadding - InternalPadding * 2;

                var          face        = Platform.IsMac ? Styles.WelcomeScreen.Pad.TitleFontFamilyMac : Styles.WelcomeScreen.Pad.TitleFontFamilyWindows;
                Pango.Layout titleLayout = new Pango.Layout(PangoContext);
                titleLayout.Width     = Pango.Units.FromPixels(textWidth);
                titleLayout.Ellipsize = Pango.EllipsizeMode.End;
                titleLayout.SetMarkup(WelcomePageSection.FormatText(face, Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleFontSize, false, Styles.WelcomeScreen.Pad.MediumTitleColor, title));

                Pango.Layout subtitleLayout = null;

                if (!string.IsNullOrEmpty(subtitle))
                {
                    subtitleLayout           = new Pango.Layout(PangoContext);
                    subtitleLayout.Width     = Pango.Units.FromPixels(textWidth);
                    subtitleLayout.Ellipsize = Pango.EllipsizeMode.Start;
                    subtitleLayout.SetMarkup(WelcomePageSection.FormatText(face, Styles.WelcomeScreen.Pad.Solutions.SolutionTile.PathFontSize, false, Styles.WelcomeScreen.Pad.SmallTitleColor, subtitle));
                }

                int height = 0;
                int w, h1, h2;
                titleLayout.GetPixelSize(out w, out h1);
                height += h1;

                if (subtitleLayout != null)
                {
                    height += Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                    subtitleLayout.GetPixelSize(out w, out h2);
                    height += h2;
                }

                int tx = Allocation.X + InternalPadding + LeftTextPadding;
                int ty = Allocation.Y + (Allocation.Height - height) / 2;
                ctx.MoveTo(tx, ty);
                Pango.CairoHelper.ShowLayout(ctx, titleLayout);

                if (subtitleLayout != null)
                {
                    ty += h1 + Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                    ctx.MoveTo(tx, ty);
                    Pango.CairoHelper.ShowLayout(ctx, subtitleLayout);
                }
            }
            return(true);
        }