コード例 #1
0
ファイル: ImlVisualEditor.cs プロジェクト: jpbruyere/CrowIDE
        void drawIcon(Context gr, Picture pic, Rectangle r)
        {
//			gr.SetSourceColor (Color.Black);
//			CairoHelpers.CairoRectangle (gr, r.Inflated (1), 2, 1.0);
            gr.SetSourceColor(Colors.White);
            CairoHelpers.CairoRectangle(gr, r.Inflated(1), 2);
            gr.Fill();
            gr.Operator = Operator.Clear;
            pic.Paint(gr, r);
            gr.Operator = Operator.Over;
        }
コード例 #2
0
ファイル: SnippingArea.cs プロジェクト: zzcandor/ailab
        private void Draw(Cairo.Context context)
        {
            CairoHelper.SetSourcePixbuf(context, this.screenshot, 0, 0);
            context.Paint();

            if (this.x0 >= 0 && this.y0 >= 0)
            {
                CairoHelpers.DrawInverseSelectionRectangles(
                    context,
                    this.inverseSelectionColor,
                    this.x0,
                    this.y0,
                    this.x1,
                    this.y1,
                    this.windowWidth,
                    this.windowHeight);
                CairoHelpers.DrawSelectionRectangle(
                    context,
                    SelectionRectangleDashesPattern,
                    this.accentColor,
                    this.x0,
                    this.y0,
                    this.x1,
                    this.y1);
                CairoHelpers.DrawSizeTooltip(
                    context,
                    this.tooltipBackgroundColor,
                    this.textColor,
                    this.x0,
                    this.y0,
                    this.x1,
                    this.y1,
                    SizeTooltipPaddingInPixels,
                    SizeTooltipMarginInPixels);
            }
            else if (this.croppingRectangle != null)
            {
                this.Crop(this.croppingRectangle.Value);
                this.croppingRectangle = null;
            }
            else
            {
                context.SetSourceRGBA(
                    this.inverseSelectionColor.R,
                    this.inverseSelectionColor.G,
                    this.inverseSelectionColor.B,
                    this.inverseSelectionColor.A);
                context.Rectangle(0, 0, this.windowWidth, this.windowHeight);
                context.Fill();
            }
        }
コード例 #3
0
        protected override void onDraw(Context gr)
        {
            gr.Save();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            Rectangle r      = ClientRectangle;
            double    radius = 0,
                      cx     = r.Width / 2.0 + r.X,
                      cy     = r.Height / 2.0 + r.Y;

            if (r.Width > r.Height)
            {
                radius = r.Height / 2.0;
            }
            else
            {
                radius = r.Width / 2.0;
            }

            double dx = Math.Sin(pi3) * radius;
            double dy = Math.Cos(pi3) * radius;

            gr.MoveTo(cx - radius, cy);
            gr.LineTo(cx - dy, cy - dx);
            gr.LineTo(cx + dy, cy - dx);
            gr.LineTo(cx + radius, cy);
            gr.LineTo(cx + dy, cy + dx);
            gr.LineTo(cx - dy, cy + dx);
            gr.ClosePath();

            gr.LineWidth = 1;
            Background.SetAsSource(gr);
            gr.FillPreserve();
            Foreground.SetAsSource(gr);
            gr.Stroke();

            if (child != null)
            {
                if (child.Visible)
                {
                    child.Paint(ref gr);
                }
            }
            gr.Restore();
        }
コード例 #4
0
ファイル: SnippingArea.cs プロジェクト: zzcandor/ailab
        private void Crop(Cairo.Rectangle rectangle)
        {
            var normalizedRectangle = CairoHelpers.NormalizeRectangle(rectangle);
            var croppedScreenshot   = new Pixbuf(
                this.screenshot,
                (int)normalizedRectangle.X,
                (int)normalizedRectangle.Y,
                (int)normalizedRectangle.Width,
                (int)normalizedRectangle.Height);

            if (croppedScreenshot == null)
            {
                return;
            }

            var snippingWindow = this.Parent as SnippingWindow;

            var imagePath = ScreenshotHelpers.SaveAndReturnPath(croppedScreenshot);

            if (!string.IsNullOrEmpty(imagePath))
            {
                if (SettingsFeature.Settings.CopyToClipboard)
                {
                    ScreenshotHelpers.CopyToClipboard(this, croppedScreenshot);
                }

                this.Close(snippingWindow);
                snippingWindow.UpdateInsightsImage(imagePath);
                snippingWindow.OpenInsights();
            }
            else
            {
                this.Close(snippingWindow);

                var md = new MessageDialog(snippingWindow.Toplevel as Gtk.Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, string.Empty);
                md.Text      = "Error ocurred during snip. Please try again.";
                md.Response += (o, args) =>
                {
                    md.Destroy();
                };

                md.Show();
            }
        }
コード例 #5
0
        protected override void onDraw(Cairo.Context gr)
        {
            if (datas == null)
            {
                return;
            }

            lock (mutex) {
                gr.SelectFontFace(Font.Name, Font.Slant, Font.Wheight);
                gr.SetFontSize(Font.Size);

                Crow.Rectangle scrBar = ClientRectangle;
                if (datas?.Count > visibleLines)
                {
                    scrBar.X    += ClientRectangle.Width - scrBarWidth;
                    scrBar.Width = scrBarWidth;
                }
                Crow.Rectangle r = ClientRectangle;
                r.Width -= scrBarWidth;

                int diffScroll  = lastScroll - scroll;
                int diffVisible = visibleLines - lastVisibleLines;

                int limInf = 0;
                int limSup = diffScroll + diffVisible;

                if (diffScroll < 0)
                {
                    limInf = lastVisibleLines + diffScroll;
                    limSup = visibleLines;
                }

                gr.Save();
                gr.ResetClip();

                gr.Rectangle(r.X, r.Y + limInf * fe.Height, r.Width, (limSup - limInf) * fe.Height);
                if (lastHoverIndex != HoverIndex)
                {
                    if (lastHoverIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (lastHoverIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                    if (HoverIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (HoverIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                }
                if (lastSelectedIndex != SelectedIndex)
                {
                    if (lastSelectedIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (lastSelectedIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                    if (selectedIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (SelectedIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                }
                if (datas?.Count > visibleLines && diffScroll != 0)
                {
                    gr.Rectangle(scrBar);
                }

                gr.ClipPreserve();
                gr.Operator = Operator.Clear;
                gr.Fill();
                gr.Operator = Operator.Over;

                base.onDraw(gr);

                Foreground.SetAsSource(gr);

                int i = limInf;
                while (i < limSup)
                {
                    if (i + Scroll >= Datas.Count)
                    {
                        break;
                    }
                    drawDataLine(gr, i + Scroll, r.X, r.Y + i * fe.Height, (double)r.Width, fe.Height);
                    i++;
                }
                int redrawnLines = limSup - limInf;
                System.Diagnostics.Debug.WriteLine("draw {0} lines from {1} to {2}", redrawnLines, limInf, limSup - 1);
                if (lastHoverIndex != HoverIndex)
                {
                    if (lastHoverIndex >= 0 && (redrawnLines == 0 || (lastHoverIndex < limInf + Scroll || lastHoverIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, lastHoverIndex, r.X, r.Y + (lastHoverIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                    if (HoverIndex >= 0 && (redrawnLines == 0 || (HoverIndex < limInf + Scroll || HoverIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, HoverIndex, r.X, r.Y + (HoverIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                }
                if (lastSelectedIndex != SelectedIndex)
                {
                    if (lastSelectedIndex >= 0 && (redrawnLines == 0 || (lastSelectedIndex < limInf + Scroll || lastSelectedIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, lastSelectedIndex, r.X, r.Y + (lastSelectedIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                    if (SelectedIndex >= 0 && (redrawnLines == 0 || (SelectedIndex < limInf + Scroll || SelectedIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, SelectedIndex, r.X, r.Y + (SelectedIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                }

                double x = ClientRectangle.X;
                gr.LineWidth = 1;
                for (i = 0; i < cols.Length; i++)
                {
                    x += (double)r.Width * cols [i];
                    gr.MoveTo(Math.Floor(x) + 0.5, 0);
                    gr.LineTo(Math.Floor(x) + 0.5, r.Height);
                }
                gr.Stroke();

                lastScroll        = Scroll;
                lastHoverIndex    = HoverIndex;
                lastSelectedIndex = SelectedIndex;
                lastVisibleLines  = visibleLines;

                if (Datas?.Count <= visibleLines)
                {
                    gr.Restore();
                    return;
                }
                if (mouseScrolling)
                {
                    new SolidColor(Crow.Color.Jet.AdjustAlpha(0.5)).SetAsSource(gr);
                }
                else
                {
                    new SolidColor(Crow.Color.LightGray.AdjustAlpha(0.5)).SetAsSource(gr);
                }
                CairoHelpers.CairoRectangle(gr, scrBar, 0.0);
                gr.Fill();
                new SolidColor(Crow.Color.BlueCrayola.AdjustAlpha(0.7)).SetAsSource(gr);
                scrBar.Y     += (int)((double)scrBar.Height * (double)Scroll / (double)Datas.Count);
                scrBar.Height = (int)((double)scrBar.Height * (double)visibleLines / (double)Datas.Count);
                CairoHelpers.CairoRectangle(gr, scrBar, 2.0);
                gr.Fill();
                gr.Restore();
            }
        }