示例#1
0
        protected void OnDrawVolumeExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Color back = Style.Background(StateType.Normal);
            Gdk.Color fore = Style.Foreground(StateType.Normal);

            Drawable draw = args.Event.Window;

            int width;
            int height;
            draw.GetSize(out width, out height);

            Gdk.GC gc = new Gdk.GC(draw);

            gc.Foreground = back;
            gc.Background = back;
            draw.DrawRectangle(gc, true, 0, 0, width, height);

            //Color lightSlateGray = new Color(119,136,153);

            //gc.Colormap.AllocColor(ref lightSlateGray, false, true);

            int outside = height * 8 / 10;
            int middle = height * 6 / 10;
            int inside = height * 4 / 10;

            int startOut = 24;
            int startMiddle = 30;
            int startInside = 36;

            int endOut = width - 24;
            int endMiddle = width - 30;
            int endInside = width - 36;

            gc.Foreground = fore;
            gc.Foreground = fore;
            gc.SetLineAttributes(outside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawLine(gc, startOut, height / 2, endOut, height / 2);

            gc.Foreground = back;
            gc.Background = back;
            gc.SetLineAttributes(middle, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawLine(gc, startMiddle, height / 2, endMiddle, height / 2);

            int endX = (endInside - startInside) * Percentage / 100 + startInside;
            gc.Foreground = fore;
            gc.Foreground = fore;
            gc.SetLineAttributes(inside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawLine(gc, startInside, height / 2, endX, height / 2);

            gc.Dispose();
        }
 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz)
 {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null))
     {
         return(res);
     }
     else
     {
         try {
             return(Gtk.IconTheme.Default.LoadIcon(name, sz, 0));
         }
         catch (System.Exception) {
             if ((name != "gtk-missing-image"))
             {
                 return(Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz));
             }
             else
             {
                 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
                 Gdk.GC     gc   = new Gdk.GC(pmap);
                 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
                 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
                 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
                 return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz));
             }
         }
     }
 }
示例#3
0
    public static void Draw(Gdk.GC gc, Window dest, int X0, int Y0, int X1, int Y1)
    {
        if (gc == null || dest == null)
        {
            return;
        }

        var w = Math.Abs(X1 - X0);
        var h = Math.Abs(Y1 - Y0);

        if (w > 2 && h > 2)
        {
            gc.RgbFgColor = SelectedColor;

            gc.SetLineAttributes(MarkerSize, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);

            if (Selection.EllipseMode)
            {
                DrawEllipse(gc, dest, X0, Y0, X1, Y1, w, h);
            }
            else
            {
                DrawBox(gc, dest, X0, Y0, X1, Y1, w, h);
            }
        }
    }
    protected void DrawBoxes()
    {
        if (!Paused)
        {
            return;
        }

        if (GtkSelection.Selection.Count() > 0)
        {
            var dest  = worldImage.GdkWindow;
            var gc    = new Gdk.GC(dest);
            var boxes = GtkSelection.Selection.BoundingBoxes();

            for (int i = 0; i < boxes.Count; i++)
            {
                if (i == GtkSelection.Selected - 1 || ShowColonies.Active)
                {
                    var box = boxes[i];

                    var w = Math.Abs(box.X1 - box.X0);
                    var h = Math.Abs(box.Y1 - box.Y0);

                    gc.RgbFgColor = i != GtkSelection.Selected - 1 ? GtkSelection.SelectedColor : Colonies[i].ArtificialLife.ColonyColor;
                    gc.SetLineAttributes(GtkSelection.MarkerSize, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);

                    GtkSelection.DrawBox(gc, dest, box.X0, box.Y0, box.X1, box.Y1, w, h, false);
                }
            }
        }
    }
示例#5
0
        void DrawingArea_ExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Rectangle area   = args.Event.Area;
            var       window = args.Event.Window;

            window.DrawRectangle(drawingArea.Style.WhiteGC, true, area);

            if (chipHistory.Count < 2)
            {
                return;
            }

            Gdk.GC gc_chips = new Gdk.GC(window);
            gc_chips.SetLineAttributes(2, LineStyle.Solid, CapStyle.Butt, JoinStyle.Bevel);

            Gdk.GC gc_red = new Gdk.GC(window);
            gc_red.RgbFgColor = new Color(255, 50, 50);

            Gdk.GC gc_blue = new Gdk.GC(window);
            gc_blue.RgbFgColor = new Color(128, 128, 255);

            int skip_count = chipHistory.Count - area.Width / 5;

            if (skip_count < 0)
            {
                skip_count = 0;
            }

            //Draw_Graph(area, window, 1, 2, false, estimateHistory.Skip(skip_count).Select(t => t.Item1), gc_red);
            Draw_Graph(area, window, 1, 2, false, estimateHistory.Skip(skip_count).Select(t => t.Item2), gc_blue);

            Draw_Graph(area, window, 5000, 60000, true, chipHistory.Skip(skip_count).Select(c => (double)c), gc_chips);

            Draw_Graph(area, window, 1, 2, false, correlationHistory.Skip(skip_count).Select(y => y + 1), gc_red);
        }
        protected override bool OnExposeEvent(Gdk.EventExpose ev)
        {
            int w, h;

            this.GdkWindow.GetSize(out w, out h);

            if (fill == BoxFill.Box)
            {
                this.GdkWindow.DrawRectangle(this.Style.WhiteGC, true, 0, 0, w, h);
                this.GdkWindow.DrawRectangle(this.Style.BlackGC, false, 0, 0, w - 1, h - 1);
            }
            else if (fill == BoxFill.HLine)
            {
                Gdk.GC gc = new Gdk.GC(this.GdkWindow);
                gc.SetDashes(0, new sbyte[] { 1, 1 }, 2);
                gc.SetLineAttributes(SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
                gc.Foreground = this.Style.Black;
                this.GdkWindow.DrawLine(gc, 0, h / 2, w, h / 2);
                gc.Foreground = this.Style.White;
                this.GdkWindow.DrawLine(gc, 1, h / 2, w, h / 2);
            }
            else
            {
                Gdk.GC gc = new Gdk.GC(this.GdkWindow);
                gc.SetDashes(0, new sbyte[] { 1, 1 }, 2);
                gc.SetLineAttributes(SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
                gc.Foreground = this.Style.Black;
                this.GdkWindow.DrawLine(gc, w / 2, 0, w / 2, h);
                gc.Foreground = this.Style.White;
                this.GdkWindow.DrawLine(gc, w / 2, 1, w / 2, h);
            }

            return(true);
        }
示例#7
0
        public Gdk.GC CreateGC(Gdk.Color foregroundColor)
        {
            var gc = new Gdk.GC(GdkWindow);
            gc.RgbFgColor = foregroundColor;
            gc.RgbBgColor = new Gdk.Color(255, 255, 255);
            gc.Background = new Gdk.Color(255, 255, 255);
            gc.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.Projecting, JoinStyle.Round);

            return gc;
        }
示例#8
0
        public Gdk.GC CreateGC(Gdk.Color foregroundColor)
        {
            var gc = new Gdk.GC(GdkWindow);

            gc.RgbFgColor = foregroundColor;
            gc.RgbBgColor = new Gdk.Color(255, 255, 255);
            gc.Background = new Gdk.Color(255, 255, 255);
            gc.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.Projecting, JoinStyle.Round);

            return(gc);
        }
示例#9
0
        protected virtual void OnDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            int width, height;
            this.DrawingArea.GdkWindow.GetSize(out width, out height);

            using(Gdk.GC g = new Gdk.GC(DrawingArea.GdkWindow))
            {
                g.SetLineAttributes(2, LineStyle.Solid, CapStyle.Round, JoinStyle.Miter);
                DrawingArea.GdkWindow.DrawRectangle(g, false, new Rectangle(0, 0, width, height));
            }
        }
示例#10
0
    void RealizeHanlder(object o, EventArgs sender)
    {
        white_gc = Style.WhiteGC;

        bkgr_gc = Style.BackgroundGC(StateType.Normal);

        selection_gc = new Gdk.GC(GdkWindow);
        selection_gc.Copy(Style.BackgroundGC(StateType.Normal));
        Gdk.Color fgcol = new Gdk.Color();
        fgcol.Pixel             = 0x000077ee;
        selection_gc.Foreground = fgcol;
        selection_gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.NotLast, JoinStyle.Round);
    }
示例#11
0
        private void DrawSelectionRect(Gtk.Widget widget, Gdk.Window window)
        {
            Gdk.GC gc = (widget.Style.WhiteGC);
            gc.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.Butt, JoinStyle.Miter);
            gc.Function = Function.Xor;
            _selectionRect.Normalize();

            RectangleD r = _selectionRect;
            PointD     p = View.DrawingToView(r.X, r.Y);

            window.DrawRectangle(gc, false, (int)p.X,
                                 (int)p.Y,
                                 (int)(r.Width * View.Scale),
                                 (int)(r.Height * View.Scale));
        }
示例#12
0
        private void DrawSelectionRect(Gtk.Widget widget, Gdk.Window window)
        {
            Gdk.GC gc = (widget.Style.WhiteGC);
            gc.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.Butt, JoinStyle.Miter);
            gc.Function = Function.Xor;
            _selectionRect.Normalize();

            Gdk.Point[] points = new Gdk.Point[4];
            points [0] = new Gdk.Point((int)_selectionRect.X, (int)_selectionRect.Y);
            points [1] = new Gdk.Point((int)_selectionRect.X2, (int)_selectionRect.Y);
            points [2] = new Gdk.Point((int)_selectionRect.X2, (int)_selectionRect.Y2);
            points [3] = new Gdk.Point((int)_selectionRect.X, (int)_selectionRect.Y2);

            window.DrawPolygon(gc, false, points);
        }
示例#13
0
        // From MonoDevelop:
        // https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Ide/gtk-gui/generated.cs
        private static Pixbuf CreateMissingImage(int size)
        {
            var pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, size, size);
            var gc   = new Gdk.GC(pmap);

            gc.RgbFgColor = new Gdk.Color(255, 255, 255);
            pmap.DrawRectangle(gc, true, 0, 0, size, size);
            gc.RgbFgColor = new Gdk.Color(0, 0, 0);
            pmap.DrawRectangle(gc, false, 0, 0, (size - 1), (size - 1));

            gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
            gc.RgbFgColor = new Gdk.Color(255, 0, 0);
            pmap.DrawLine(gc, (size / 4), (size / 4), ((size - 1) - (size / 4)), ((size - 1) - (size / 4)));
            pmap.DrawLine(gc, ((size - 1) - (size / 4)), (size / 4), (size / 4), ((size - 1) - (size / 4)));

            return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, size, size));
        }
示例#14
0
        // From MonoDevelop:
        // https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Ide/gtk-gui/generated.cs
        private static Pixbuf CreateMissingImage(int size)
        {
            var pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, size, size);
            var gc = new Gdk.GC (pmap);

            gc.RgbFgColor = new Gdk.Color (255, 255, 255);
            pmap.DrawRectangle (gc, true, 0, 0, size, size);
            gc.RgbFgColor = new Gdk.Color (0, 0, 0);
            pmap.DrawRectangle (gc, false, 0, 0, (size - 1), (size - 1));

            gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
            gc.RgbFgColor = new Gdk.Color (255, 0, 0);
            pmap.DrawLine (gc, (size / 4), (size / 4), ((size - 1) - (size / 4)), ((size - 1) - (size / 4)));
            pmap.DrawLine (gc, ((size - 1) - (size / 4)), (size / 4), (size / 4), ((size - 1) - (size / 4)));

            return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, size, size);
        }
示例#15
0
 void draw()
 {
     Gdk.GC gc = new Gdk.GC((Drawable)base.GdkWindow);
     gc.RgbFgColor = new Gdk.Color(255, 50, 50);
     gc.RgbBgColor = new Gdk.Color(0, 0, 0);
     gc.SetLineAttributes(3, LineStyle.OnOffDash,
                          CapStyle.Projecting, JoinStyle.Round);
     Gdk.Point[] pts = new Gdk.Point[8];
     pts [0] = new Gdk.Point(10, 50);
     pts [1] = new Gdk.Point(15, 70);
     pts [2] = new Gdk.Point(20, 80);
     pts [3] = new Gdk.Point(25, 70);
     pts [4] = new Gdk.Point(30, 80);
     pts [5] = new Gdk.Point(40, 90);
     pts [6] = new Gdk.Point(55, 85);
     pts [7] = new Gdk.Point(75, 65);
     base.GdkWindow.DrawLines(gc, pts);
 }
示例#16
0
 /// <summary>
 /// Loads the missing icon for a given size in pixels.
 /// </summary>
 /// <returns>The missing icon. This function uses a cache internally.</returns>
 /// <param name="sz">Size in pixels.</param>
 public static Gdk.Pixbuf LoadMissingIcon(int sz)
 {
     if (!missingIcons.ContainsKey(sz))
     {
         Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
         Gdk.GC     gc   = new Gdk.GC(pmap);
         gc.RgbFgColor = new Gdk.Color(255, 255, 255);
         pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
         gc.RgbFgColor = new Gdk.Color(0, 0, 0);
         pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
         gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
         gc.RgbFgColor = new Gdk.Color(255, 0, 0);
         pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
         pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
         missingIcons [sz] = Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
     }
     return((Gdk.Pixbuf)missingIcons [sz]);
 }
示例#17
0
        public override void FillStrokePolygon(Color fill, Color stroke, List <Point> points, bool dashed)
        {
            Gdk.Point[] pointArray = new Gdk.Point[points.Count];
            for (int i = 0; i < points.Count; ++i)
            {
                pointArray[i].X = (int)points[i].X;
                pointArray[i].Y = (int)points[i].Y;
            }

            Gdk.GC g = new Gdk.GC(window);
            g.RgbFgColor = GdkColor(fill);
            if (dashed)
            {
                g.SetLineAttributes(1, LineStyle.OnOffDash, CapStyle.NotLast, JoinStyle.Miter);
                g.SetDashes(0, new sbyte[] { 2 }, 1);
            }
            window.DrawPolygon(g, true, pointArray);
            g.RgbFgColor = GdkColor(stroke);
            window.DrawPolygon(g, false, pointArray);
        }
示例#18
0
        public static Pixbuf LoadIcon(Widget widget, string name, IconSize size)
        {
            var res = widget.RenderIcon(name, size, null);

            if (res != null)
            {
                return(res);
            }

            int sz;
            int sy;

            Icon.SizeLookup(size, out sz, out sy);
            try
            {
                return(IconTheme.Default.LoadIcon(name, sz, 0));
            }
            catch (Exception)
            {
                if (name != "gtk-missing-image")
                {
                    return(LoadIcon(widget, "gtk-missing-image", size));
                }

                var pmap = new Pixmap(Screen.Default.RootWindow, sz, sz);
                var gc   = new GC(pmap)
                {
                    RgbFgColor = new Color(255, 255, 255)
                };
                pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                gc.RgbFgColor = new Color(0, 0, 0);
                pmap.DrawRectangle(gc, false, 0, 0, sz - 1, sz - 1);
                gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                gc.RgbFgColor = new Color(255, 0, 0);
                pmap.DrawLine(gc, sz / 4, sz / 4, (sz - 1) - (sz / 4), (sz - 1) - (sz / 4));
                pmap.DrawLine(gc, (sz - 1) - (sz / 4), sz / 4, sz / 4, (sz - 1) - (sz / 4));
                return(Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz));
            }
        }
示例#19
0
            public void draw2D(Gdk.Drawable da)
            {
                if (SrcPos == null)
                {
                    return;
                }
                try
                {
                    int width, height;
                    da.GetSize(out width, out height);

                    double dx, dy;
                    dx     = 20;
                    dy     = 20;
                    width  = width - 2 * (int)dy;
                    height = height - 2 * (int)dx;

                    double maxX, minX, maxY, minY;
                    maxX = -999; maxY = -999;
                    minX = 999; minY = 999;
                    for (int i = 0; i < this.numDet; i++)
                    {
                        if (maxX < this.DetPos[i, 0])
                        {
                            maxX = this.DetPos[i, 0];
                        }
                        if (maxY < this.DetPos[i, 1])
                        {
                            maxY = this.DetPos[i, 1];
                        }
                        if (minX > this.DetPos[i, 0])
                        {
                            minX = this.DetPos[i, 0];
                        }
                        if (minY > this.DetPos[i, 1])
                        {
                            minY = this.DetPos[i, 1];
                        }
                    }


                    for (int i = 0; i < this.numSrc; i++)
                    {
                        if (maxX < this.SrcPos[i, 0])
                        {
                            maxX = this.SrcPos[i, 0];
                        }
                        if (maxY < this.SrcPos[i, 1])
                        {
                            maxY = this.SrcPos[i, 1];
                        }
                        if (minX > this.SrcPos[i, 0])
                        {
                            minX = this.SrcPos[i, 0];
                        }
                        if (minY > this.SrcPos[i, 1])
                        {
                            minY = this.SrcPos[i, 1];
                        }
                    }


                    ROIdrawPos = new double[ROIs.Count, 2];
                    for (int i = 0; i < ROIs.Count; i++)
                    {
                        ROIdrawPos[i, 0] = minX - .15 * (maxX - minX);
                        ROIdrawPos[i, 1] = minY - .25 * (i + 1) * (maxY - minY);
                    }
                    if (ROIs.Count > 0)
                    {
                        minY = minY - (ROIs.Count + 1) * .25 * (maxY - minY);
                        minX = minX - .15 * (maxX - minX);
                    }

                    double rangeX = maxX - minX;
                    double rangeY = maxY - minY;

                    Gdk.GC gc = new Gdk.GC(da);

                    gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    Rectangle rarea = new Rectangle();
                    rarea.Height = height + 2 * (int)dy;
                    rarea.Width  = width + 2 * (int)dx;
                    da.DrawRectangle(gc, true, rarea);

                    gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                    gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                    rarea         = new Rectangle();
                    rarea.Height  = height - 2 + 2 * (int)dx;;
                    rarea.Width   = width - 2 + 2 * (int)dx;;
                    rarea.X       = 1;
                    rarea.Y       = 1;

                    da.DrawRectangle(gc, true, rarea);

                    int sz = 10;

                    if (this.measlistAct == null)
                    {
                        this.measlistAct = new bool[this.ChannelMap.Length];
                        for (int i = 0; i < this.ChannelMap.Length; i++)
                        {
                            this.measlistAct[i] = false;
                        }
                        this.measlistAct[0] = true;
                    }


                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round);
                    for (int i = 0; i < this.numChannels; i++)
                    {
                        if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype))
                        {
                            if (this.measlistAct[i])
                            {
                                gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0);
                            }
                            else
                            {
                                gc.RgbFgColor = new Gdk.Color(230, 230, 230);
                            }
                            int si = this.ChannelMap[i].sourceindex;
                            int di = this.ChannelMap[i].detectorindex;

                            double x1 = (this.DetPos[di, 0] - minX) / rangeX * width;
                            double y1 = height - ((this.DetPos[di, 1] - minY) / rangeY * height) + dy;
                            double x2 = (this.SrcPos[si, 0] - minX) / rangeX * width;
                            double y2 = height - ((this.SrcPos[si, 1] - minY) / rangeY * height) + dy;
                            da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2);
                            //pts[cnt]=new Gdk.Point((int)x,(int)y);
                        }
                    }


                    gc.RgbFgColor = new Gdk.Color(0, 255, 0);
                    gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                    //  Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc];
                    for (int i = 0; i < this.numDet; i++)
                    {
                        double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2;
                        double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy;
                        da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                        //pts[cnt]=new Gdk.Point((int)x,(int)y);
                    }
                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    for (int i = 0; i < this.numDet; i++)
                    {
                        double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2;
                        double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy;

                        Gtk.Label lab = new Gtk.Label();
                        lab.Text = string.Format("D{0}", i + 1);
                        da.DrawLayout(gc, (int)x, (int)y, lab.Layout);
                    }


                    gc.RgbBgColor = new Gdk.Color(0, 255, 0);
                    gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                    gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                    for (int i = 0; i < this.numSrc; i++)
                    {
                        double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2;
                        double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy;
                        da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                    }

                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    for (int i = 0; i < this.numSrc; i++)
                    {
                        double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2;
                        double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy;

                        Gtk.Label lab = new Gtk.Label();
                        lab.Text = string.Format("S{0}", i + 1);
                        da.DrawLayout(gc, (int)x, (int)y, lab.Layout);
                    }

                    gc.RgbFgColor = new Gdk.Color(255, 0, 255);
                    for (int i = 0; i < ROIs.Count; i++)
                    {
                        double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2;
                        double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy;
                        da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                    }

                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    for (int i = 0; i < ROIs.Count; i++)
                    {
                        double    x   = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz;
                        double    y   = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy;
                        Gtk.Label lab = new Gtk.Label();
                        lab.Text = ROIs[i].name;
                        da.DrawLayout(gc, (int)(x), (int)y, lab.Layout);
                    }

                    Gtk.Label lab2 = new Gtk.Label();
                    lab2.Text = "L";
                    da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout);
                }
                catch { }

                return;
            }
示例#20
0
    //Gdk.GC pen_blanco;
    void event_execute_configureColors()
    {
        Gdk.Color rojo = new Gdk.Color(0xff,0,0);
        Gdk.Color azul  = new Gdk.Color(0,0,0xff);
        Gdk.Color negro = new Gdk.Color(0,0,0);
        Gdk.Color green = new Gdk.Color(0,0xff,0);
        Gdk.Color gris = new Gdk.Color(0x66,0x66,0x66);
        Gdk.Color beige = new Gdk.Color(0x99,0x99,0x99);
        Gdk.Color brown = new Gdk.Color(0xd6,0x88,0x33);
        Gdk.Color violet = new Gdk.Color(0xc4,0x20,0xf3);
        //Gdk.Color blanco = new Gdk.Color(0xff,0xff,0xff);

        Gdk.Colormap colormap = Gdk.Colormap.System;
        colormap.AllocColor (ref rojo, true, true);
        colormap.AllocColor (ref azul,true,true);
        colormap.AllocColor (ref negro,true,true);
        colormap.AllocColor (ref green,true,true);
        colormap.AllocColor (ref gris,true,true);
        colormap.AllocColor (ref beige,true,true);
        colormap.AllocColor (ref brown,true,true);
        colormap.AllocColor (ref violet,true,true);
        //colormap.AllocColor (ref blanco,true,true);

        //-- Configurar los contextos graficos (pinceles)
        pen_rojo = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_azul = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_rojo_discont = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_azul_discont = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        //pen_negro = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        //pen_blanco= new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_negro_discont = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_green_discont = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_gris = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_beige_discont = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_brown_bold = new Gdk.GC(event_execute_drawingarea.GdkWindow);
        pen_violet_bold = new Gdk.GC(event_execute_drawingarea.GdkWindow);

        pen_rojo.Foreground = rojo;
        pen_azul.Foreground = azul;

        pen_rojo_discont.Foreground = rojo;
        pen_azul_discont.Foreground = azul;
        pen_rojo_discont.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
        pen_azul_discont.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);

        pen_negro_discont.Foreground = negro;
        pen_negro_discont.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
        pen_green_discont.Foreground = green;
        pen_green_discont.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);

        pen_gris.Foreground = gris;

        pen_beige_discont.Foreground = beige;
        pen_beige_discont.SetLineAttributes(1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);

        pen_brown_bold.Foreground = brown;
        pen_brown_bold.SetLineAttributes(2, Gdk.LineStyle.Solid, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
        pen_violet_bold.Foreground = violet;
        pen_violet_bold.SetLineAttributes(2, Gdk.LineStyle.Solid, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
    }
        public override void Paint(Gdk.Drawable wnd, System.Drawing.Rectangle rect)
        {
            int one_width = (int) textArea.TextView.GetWidth ('w');

            using (Gdk.GC gc = new Gdk.GC (wnd)) {
            using (Pango.Layout ly = new Pango.Layout (TextArea.PangoContext)) {
                ly.FontDescription = FontContainer.DefaultFont;
                ly.Width = drawingPosition.Width;
                ly.Alignment = Pango.Alignment.Right;

                HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

                gc.RgbBgColor = new Gdk.Color (lineNumberPainterColor.BackgroundColor);
                gc.RgbFgColor = TextArea.Style.White;
                wnd.DrawRectangle (gc, true, drawingPosition);

                gc.RgbFgColor = new Gdk.Color (lineNumberPainterColor.Color);
                gc.SetLineAttributes (1, LineStyle.OnOffDash, CapStyle.NotLast, JoinStyle.Miter);
                wnd.DrawLine (gc, drawingPosition.X + drawingPosition.Width, drawingPosition.Y, drawingPosition.X + drawingPosition.Width, drawingPosition.Height);

                //FIXME: This doesnt allow different fonts and what not
                int fontHeight = TextArea.TextView.FontHeight;

                for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {
                    int ypos = drawingPosition.Y + fontHeight * y  - textArea.TextView.VisibleLineDrawingRemainder;

                    int curLine = y + textArea.TextView.FirstVisibleLine;
                    if (curLine < textArea.Document.TotalNumberOfLines) {
                        ly.SetText ((curLine + 1).ToString ());
                        wnd.DrawLayout (gc, drawingPosition.X + drawingPosition.Width - one_width, ypos, ly);
                    }
                }
            }}
        }
示例#22
0
        protected void OnDrawClockExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Color back = Style.Background(StateType.Normal);
            Gdk.Color fore = Style.Foreground(StateType.Normal);

            Drawable draw = args.Event.Window;

            int width;
            int height;
            draw.GetSize(out width, out height);

            Gdk.GC gc = new Gdk.GC(draw);
            gc.Foreground = back;
            gc.Background = back;

            Point start;
            Point stop;
            double xMax;
            double yMax;
            double angle = 0;

            int size = width < height ? width : height;
            size -= Spacing;
            Point center = new Point(width / 2, height / 2);
            Rectangle rect = new Rectangle((width - size) / 2, (height - size) / 2, size, size);

            if (clockFace != null && (clockFace.Width != width || clockFace.Height != height)) {
                clockFace.Dispose();
                clockFace = null;
            }

            if (clockFace == null) {

                draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0);

                draw.DrawRectangle(gc, true, 0, 0, width, height);

                gc.Foreground = fore;

                gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                draw.DrawArc(gc, false, rect.Left, rect.Top, size, size, 0, 360 * 64);
                gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);

                for (int index = 0; index < 60; index++, angle += Math.PI / 30.0) {
                    xMax = Math.Cos(angle) * size / 2;
                    yMax = Math.Sin(angle) * size / 2;
                    start = center;
                    stop = center;
                    if ((index % 5) == 0) {
                        int hour = ((index / 5) + 3) % 12;
                        if (hour == 0) hour = 12;

                        start.Offset((int)(xMax / 1.30), (int)(yMax / 1.30));

                        Pango.FontDescription font = Pango.FontDescription.FromString("Serif 10");
                        Pango.Layout layout = CreatePangoLayout(hour.ToString());
                        layout.FontDescription = font;
                        layout.Width = Pango.Units.FromPixels(100);

                        int textWidth;
                        int textHeight;
                        layout.GetPixelSize(out textWidth, out textHeight);

                        start.Offset(-textWidth / 2, -textHeight / 2);

                        draw.DrawLayoutWithColors(gc, start.X, start.Y, layout, fore, back);
                        layout.Dispose();

                        start = center;
                        gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                        start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05));
                        stop.Offset((int)xMax, (int)yMax);
                        draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y);
                        gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                    } else {
                        start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05));
                        stop.Offset((int)xMax, (int)yMax);
                        draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y);
                    }
                }
                clockFace = Pixbuf.FromDrawable(draw, draw.Colormap, 0, 0, 0, 0, width, height);

            } else {

                draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0);

            }

            gc.Foreground = fore;

            double startAngle = 1.5 * Math.PI;
            double secondAngle;
            double minuteAngle;
            double hourAngle;

            if (AnalogMovement) {

                double value = (CurrentTime.Second * 1000) + CurrentTime.Millisecond;
                double divisor = 60000.0;
                secondAngle = 2.0 * Math.PI * value / divisor + startAngle;

                value += (double) CurrentTime.Minute * divisor;
                divisor *= 60.0;
                minuteAngle = 2.0 * Math.PI * value / divisor + startAngle;

                value += (double) ((CurrentTime.Hour) % 12) * divisor;
                divisor *= 12.0;
                hourAngle = 2.0 * Math.PI * value / divisor + startAngle;

            } else {

                double value = CurrentTime.Second;
                double divisor = 60;
                secondAngle = 2.0 * Math.PI * value / divisor + startAngle;

                value = CurrentTime.Minute;
                divisor = 60;
                minuteAngle = 2.0 * Math.PI * value / divisor + startAngle;

                value = ((CurrentTime.Hour) % 12);
                divisor = 12;
                hourAngle = 2.0 * Math.PI * value / divisor + startAngle;

            }

            start = center;
            stop = center;
            xMax = Math.Cos(secondAngle) * size / 2;
            yMax = Math.Sin(secondAngle) * size / 2;
            stop.Offset((int) (xMax / 1.2), (int) (yMax / 1.2));
            draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y);

            stop = center;
            xMax = Math.Cos(minuteAngle) * size / 2;
            yMax = Math.Sin(minuteAngle) * size / 2;
            stop.Offset((int) (xMax / 1.4), (int) (yMax / 1.4));
            gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y);

            stop = center;
            xMax = Math.Cos(hourAngle) * size / 2;
            yMax = Math.Sin(hourAngle) * size / 2;
            stop.Offset((int) (xMax / 2.2), (int) (yMax / 2.2));
            gc.SetLineAttributes(8, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawLine(gc, start.X, start.Y , stop.X, stop.Y);

            gc.Dispose();
        }
示例#23
0
		protected override bool OnExposeEvent (Gdk.EventExpose ev)
		{
			int w, h;
			this.GdkWindow.GetSize (out w, out h);
			
			if (fill == BoxFill.Box) {
				this.GdkWindow.DrawRectangle (this.Style.WhiteGC, true, 0, 0, w, h);
				this.GdkWindow.DrawRectangle (this.Style.BlackGC, false, 0, 0, w-1, h-1);
			} else if (fill == BoxFill.HLine) {
				using (Gdk.GC gc = new Gdk.GC (this.GdkWindow)) {
					gc.SetDashes (0, new sbyte [] { 1, 1 }, 2);
					gc.SetLineAttributes (SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
					gc.Foreground = this.Style.Black;
					this.GdkWindow.DrawLine (gc, 0, h / 2, w, h / 2);
					gc.Foreground = this.Style.White;
					this.GdkWindow.DrawLine (gc, 1, h/2, w, h/2);
				}
			} else {
				using (Gdk.GC gc = new Gdk.GC (this.GdkWindow)) {
					gc.SetDashes (0, new sbyte [] { 1, 1 }, 2);
					gc.SetLineAttributes (SelectionHandleBox.selectionLineWidth, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
					gc.Foreground = this.Style.Black;
					this.GdkWindow.DrawLine (gc, w / 2, 0, w / 2, h);
					gc.Foreground = this.Style.White;
					this.GdkWindow.DrawLine (gc, w / 2, 1, w/2, h);
				}
			}
			
			return true;
		}
示例#24
0
文件: Misc.cs 项目: GNOME/longomatch
 /// <summary>
 /// Loads the missing icon for a given size in pixels.
 /// </summary>
 /// <returns>The missing icon. This function uses a cache internally.</returns>
 /// <param name="sz">Size in pixels.</param>
 public static Gdk.Pixbuf LoadMissingIcon(int sz)
 {
     if (!missingIcons.ContainsKey (sz)) {
         Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz);
         Gdk.GC gc = new Gdk.GC (pmap);
         gc.RgbFgColor = new Gdk.Color (255, 255, 255);
         pmap.DrawRectangle (gc, true, 0, 0, sz, sz);
         gc.RgbFgColor = new Gdk.Color (0, 0, 0);
         pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1));
         gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
         gc.RgbFgColor = new Gdk.Color (255, 0, 0);
         pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
         pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
         missingIcons [sz] = Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
     }
     return (Gdk.Pixbuf)missingIcons [sz];
 }
示例#25
0
            public void draw1020(Gdk.Drawable da)
            {
                if (!this.isregistered)
                {
                    draw(da);
                    return;
                }

                double headcirc = 0;

                double[,] lsrcpos = project1020(this.SrcPos3D, this.numSrc, out headcirc);
                double[,] ldetpos = project1020(this.DetPos3D, this.numDet, out headcirc);

                int width, height;

                da.GetSize(out width, out height);

                double dx, dy;

                dx     = 10;
                dy     = 10;
                width  = width - 20;
                height = height - 20;

                double maxX = headcirc * 1.2;
                double minX = -1 * headcirc * 1.2;
                double maxY = headcirc * 1.2;
                double minY = -1 * headcirc * 1.2;


                ROIdrawPos = new double[ROIs.Count, 2];
                for (int i = 0; i < ROIs.Count; i++)
                {
                    ROIdrawPos[i, 0] = minX - .1 * headcirc;
                    ROIdrawPos[i, 1] = minY - .2 * (i) * headcirc;
                }
                if (ROIs.Count > 0)
                {
                    minY = minY - (ROIs.Count) * .2 * headcirc;
                    minX = minX - .1 * headcirc;
                }

                double rangeX = maxX - minX;
                double rangeY = maxY - minY;

                Gdk.GC gc = new Gdk.GC(da);

                gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                Rectangle rarea = new Rectangle();

                rarea.Height = height + 20;
                rarea.Width  = width + 20;
                da.DrawRectangle(gc, true, rarea);

                gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                rarea         = new Rectangle();
                rarea.Height  = height + 18;
                rarea.Width   = width + 18;
                rarea.X       = 1;
                rarea.Y       = 1;

                da.DrawRectangle(gc, true, rarea);

                int sz = 10;

                if (this.measlistAct == null)
                {
                    this.measlistAct = new bool[this.ChannelMap.Length];
                    for (int i = 0; i < this.ChannelMap.Length; i++)
                    {
                        this.measlistAct[i] = false;
                    }
                    this.measlistAct[0] = true;
                }


                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round);
                for (int i = 0; i < this.numChannels; i++)
                {
                    if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype))
                    {
                        if (this.measlistAct[i])
                        {
                            gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0);
                        }
                        else
                        {
                            gc.RgbFgColor = new Gdk.Color(230, 230, 230);
                        }
                        int si = this.ChannelMap[i].sourceindex;
                        int di = this.ChannelMap[i].detectorindex;

                        double x1 = (ldetpos[di, 0] - minX) / rangeX * width + dx;
                        double y1 = (ldetpos[di, 1] - minY) / rangeY * height + dy;
                        double x2 = (lsrcpos[si, 0] - minX) / rangeX * width + dx;
                        double y2 = (lsrcpos[si, 1] - minY) / rangeY * height + dy;
                        da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2);
                        //pts[cnt]=new Gdk.Point((int)x,(int)y);
                    }
                }


                gc.RgbFgColor = new Gdk.Color(0, 255, 0);
                gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                //  Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc];
                for (int i = 0; i < this.numDet; i++)
                {
                    double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2;
                    double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2;
                    da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                    //pts[cnt]=new Gdk.Point((int)x,(int)y);
                }
                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                for (int i = 0; i < this.numDet; i++)
                {
                    double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2;
                    double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2;

                    Gtk.Label lab = new Gtk.Label();
                    lab.Text = string.Format("D{0}", i + 1);
                    da.DrawLayout(gc, (int)x, (int)y, lab.Layout);
                }


                gc.RgbBgColor = new Gdk.Color(0, 255, 0);
                gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
                for (int i = 0; i < this.numSrc; i++)
                {
                    double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2;
                    double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2;
                    da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                }


                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                for (int i = 0; i < this.numSrc; i++)
                {
                    double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2;
                    double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2;

                    Gtk.Label lab = new Gtk.Label();
                    lab.Text = string.Format("S{0}", i + 1);
                    da.DrawLayout(gc, (int)x, (int)y, lab.Layout);
                }

                gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                double xx = (0) / rangeX * width + dx;
                double yy = (0) / rangeY * height + dy;

                da.DrawArc(gc, false, (int)xx, (int)yy, (int)(width), (int)(height), 0, 360 * 64);



                gc.RgbFgColor = new Gdk.Color(255, 0, 255);
                for (int i = 0; i < ROIs.Count; i++)
                {
                    double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2;
                    double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy;
                    da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64);
                }

                gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                for (int i = 0; i < ROIs.Count; i++)
                {
                    double    x   = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz;
                    double    y   = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy;
                    Gtk.Label lab = new Gtk.Label();
                    lab.Text = ROIs[i].name;
                    da.DrawLayout(gc, (int)(x), (int)y, lab.Layout);
                }

                Gtk.Label lab2 = new Gtk.Label();
                lab2.Text = "R";
                da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout);
            }
示例#26
0
        protected virtual void DrawLastMove(Gdk.Window window)
        {
            if (lastMove == null)
                return;

            int i = -1, j = -1;
            string letters = "abcdefgh";
            string numbers = "87654321";

            int k = lastMove.Length - 2;
            while (k >= 0)
              {
                  i = letters.IndexOf (lastMove[k]);
                  j = numbers.IndexOf (lastMove[k + 1]);
                  if (i >= 0 && j >= 0)
                      break;
                  k--;
              }

            if (i == -1 || j == -1)
                return;

            Gdk.GC gc = Style.ForegroundGC (StateType.Normal);
            Gdk.GC tempGC = new Gdk.GC (window);
            tempGC.Copy (gc);
            tempGC.SetLineAttributes (2, LineStyle.OnOffDash,
                          CapStyle.Round, 0);

            if (side)
              {
                  i = 7 - i;
                  j = 7 - j;
              }

            int x = start_x + i * (space + size);
            int y = start_y + j * (space + size);

            window.DrawRectangle (tempGC, false, x, y, size,
                          size);
        }
示例#27
0
	protected void OnTableTabsExposeEvent (object o, ExposeEventArgs args) {
		
		Color fore = Style.Foreground(StateType.Normal);

		Drawable draw = args.Event.Window;
		Gdk.GC gc = new Gdk.GC(draw);

		try {
			Rectangle tabRect;
			switch (notebook.CurrentPage) {
				case 0: // WiFi
					tabRect = imageTabWiFi.Allocation;
					break;
				case 1: // Clock
					tabRect = imageTabClock.Allocation;
					break;
				case 2: // Radio
					tabRect = imageTabRadio.Allocation;
					break;
				case 3: // weather
					tabRect = imageTabWeather.Allocation;
					break;
				default:
					tabRect = imageTabIntercom.Allocation;
					break;
			}

			Rectangle rect = notebook.Allocation;
			rect.Inflate(4, 4);
			tabRect.Inflate(4, 4);

			List<Gdk.Point> points = new List<Gdk.Point>();
			points.Add(new Point(rect.Left, rect.Top));
			points.Add(new Point(rect.Right, rect.Top));
			points.Add(new Point(rect.Right, tabRect.Top));
			points.Add(new Point(tabRect.Right, tabRect.Top));
			points.Add(new Point(tabRect.Right, tabRect.Bottom));
			points.Add(new Point(rect.Right, tabRect.Bottom));
			points.Add(new Point(rect.Right, rect.Bottom));
			points.Add(new Point(rect.Left, rect.Bottom));
			points.Add(new Point(rect.Left, rect.Top));

			gc.Foreground = fore;
			gc.Background = fore;
			gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
			draw.DrawLines(gc, points.ToArray());

		} catch (Exception ex) {
			Console.WriteLine(ex.Source);
			Console.WriteLine(ex.StackTrace);
		}

		gc.Dispose();
	}
示例#28
0
	void RealizeHanlder (object o, EventArgs sender)
        {
                white_gc = Style.WhiteGC;

                bkgr_gc = Style.BackgroundGC (StateType.Normal);

                selection_gc = new Gdk.GC (GdkWindow);
                selection_gc.Copy (Style.BackgroundGC (StateType.Normal));
                Gdk.Color fgcol = new Gdk.Color ();
                fgcol.Pixel = 0x000077ee;
                selection_gc.Foreground = fgcol;
                selection_gc.SetLineAttributes (3, LineStyle.Solid, CapStyle.NotLast, JoinStyle.Round);
        }
示例#29
0
            public void draw(Gdk.Drawable da, string datasubtype, bool autoscale = false, double tMin = 0, bool manualscaleMin = false, double manualMin = -999999, bool manualscaleMax = false, double manualMax = 99999999)
            {
                try {
                    if (data == null)
                    {
                        return;
                    }

                    if (time.Count < 5)
                    {
                        return;
                    }

                    int width, height;
                    da.GetSize(out width, out height);

                    double maxY, minY;
                    minY = 99999; maxY = -99999;


                    int startIdx = 0;
                    for (int sIdx = 0; sIdx < this.time.Count; sIdx++)
                    {
                        if (this.time[sIdx] <= tMin)
                        {
                            startIdx = sIdx;
                        }
                    }

                    int skip = (int)Math.Max(1, Math.Floor((double)((this.time.Count - startIdx) / 1000)));


                    if (this.probe.measlistAct == null)
                    {
                        this.probe.measlistAct = new bool[this.probe.ChannelMap.Length];
                        for (int i = 0; i < this.probe.ChannelMap.Length; i++)
                        {
                            this.probe.measlistAct[i] = false;
                        }
                        this.probe.measlistAct[0] = true;
                    }



                    for (int i = 0; i < this.probe.ChannelMap.Length; i++)
                    {
                        for (int j = startIdx; j < this.data[i].Count; j++)
                        {
                            if (this.probe.ChannelMap[i].datasubtype.ToLower().Equals(datasubtype.ToLower()))
                            {
                                if (this.probe.measlistAct[i])
                                {
                                    double d = this.data[i][j]; // Only shown data will define the scale
                                    if (maxY < d)
                                    {
                                        maxY = d;
                                    }
                                    if (minY > d)
                                    {
                                        minY = d;
                                    }
                                }
                                else if (!autoscale)   // This will include all the data in defining the scale
                                {
                                    double d = this.data[i][j];
                                    if (maxY < d)
                                    {
                                        maxY = d;
                                    }
                                    if (minY > d)
                                    {
                                        minY = d;
                                    }
                                }
                            }
                        }
                    }

                    if (manualscaleMax)
                    {
                        maxY = manualMax;
                    }
                    if (manualscaleMin)
                    {
                        minY = manualMin;
                    }
                    double rangeY  = maxY - minY;
                    double rangeX  = this.time[this.time.Count - 1] - this.time[startIdx];
                    int    xoffset = 50;
                    int    yoffset = 1;

                    height = height - 31;
                    width  = width - 51;

                    Gdk.GC gc = new Gdk.GC(da);

                    gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    Rectangle rarea = new Rectangle();
                    rarea.X      = xoffset - 1;
                    rarea.Y      = yoffset - 1;
                    rarea.Height = height + 2;
                    rarea.Width  = width + 2;
                    da.DrawRectangle(gc, true, rarea);

                    gc.RgbBgColor = new Color(0, 0, 0);
                    gc.RgbFgColor = new Color(255, 255, 255);
                    rarea         = new Rectangle();
                    rarea.X       = xoffset;
                    rarea.Y       = yoffset;
                    rarea.Height  = height;
                    rarea.Width   = width;
                    da.DrawRectangle(gc, true, rarea);


                    gc.SetLineAttributes(2, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round);

                    // Draw stim events

                    for (int j = 0; j < stimulus.Count; j++)
                    {
                        gc.RgbFgColor = stimcolor[j];
                        Rectangle area = new Rectangle();


                        for (int k = 0; k < stimulus[j].onsets.Count; k++)
                        {
                            if (stimulus[j].amplitude[k] > 0 & stimulus[j].onsets[k] + stimulus[j].duration[k] >= this.time[startIdx])
                            {
                                area.Width = (int)(stimulus[j].duration[k] / rangeX * width);
                                if (area.Width == 0)
                                {
                                    area.Width = 1;
                                }
                                area.Height = height;
                                area.X      = (int)(xoffset + Math.Max((stimulus[j].onsets[k] - this.time[startIdx]), 0) / rangeX * width);
                                area.Y      = yoffset;
                                da.DrawRectangle(gc, true, area);
                            }
                            //da.DrawLine(gc,(int)x+xoffset,yoffset,(int)x+xoffset,(int)height+yoffset);
                        }
                    }



                    gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round);
                    for (int i = 0; i < this.probe.ChannelMap.Length; i++)
                    {
                        if (this.probe.measlistAct[i] & this.probe.ChannelMap[i].datasubtype.Equals(datasubtype))
                        {
                            gc.RgbFgColor = this.probe.colormap[i];
                            for (int j = 0; j < this.probe.ChannelMap.Length; j++)
                            {
                                if (this.probe.ChannelMap[i].sourceindex == this.probe.ChannelMap[j].sourceindex &
                                    this.probe.ChannelMap[i].detectorindex == this.probe.ChannelMap[j].detectorindex &
                                    this.probe.ChannelMap[j].datasubtype.Equals(this.probe.ChannelMap[0].datasubtype))
                                {
                                    gc.RgbFgColor = this.probe.colormap[j];
                                    break;
                                }
                            }

                            for (int j = startIdx + skip; j < Math.Min(this.data[i].Count, this.time.Count); j = j + skip)
                            {
                                double y2 = (this.data[i][j] - minY) / rangeY * height;
                                double y1 = (this.data[i][j - skip] - minY) / rangeY * height;

                                double x2 = (this.time[j] - this.time[startIdx]) / rangeX * width;
                                double x1 = (this.time[j - skip] - this.time[startIdx]) / rangeX * width;

                                da.DrawLine(gc, (int)x1 + xoffset, (int)(height - y1 + yoffset), (int)x2 + xoffset, (int)(height - y2 + yoffset));
                            }
                        }
                    }


                    if (stimulus.Count > 0)
                    {
                        // add legend to window
                        int w = 0;
                        int h = 0;

                        int maxw = 0;

                        for (int j = 0; j < stimulus.Count; j++)
                        {
                            Gtk.Label lab = new Gtk.Label();
                            gc.RgbFgColor = stimcolor[j];
                            lab.Text      = stimulus[j].name;
                            da.DrawLayout(gc, xoffset + 10, yoffset + j * 10 + 10, lab.Layout);
                            lab.Layout.GetPixelSize(out w, out h);
                            if (w > maxw)
                            {
                                maxw = w;
                            }
                        }
                        gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                        gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                        rarea         = new Rectangle();
                        rarea.X       = xoffset + 4;
                        rarea.Y       = yoffset + 4;
                        rarea.Height  = stimulus.Count * 10 + 12;
                        rarea.Width   = maxw + 12;
                        da.DrawRectangle(gc, true, rarea);

                        gc.RgbBgColor = new Gdk.Color(0, 0, 0);
                        gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                        rarea         = new Rectangle();
                        rarea.X       = xoffset + 5;
                        rarea.Y       = yoffset + 5;
                        rarea.Height  = stimulus.Count * 10 + 10;
                        rarea.Width   = maxw + 10;
                        da.DrawRectangle(gc, true, rarea);
                        for (int j = 0; j < stimulus.Count; j++)
                        {
                            Gtk.Label lab = new Gtk.Label();
                            gc.RgbFgColor = stimcolor[j];
                            lab.Text      = stimulus[j].name;
                            da.DrawLayout(gc, xoffset + 10, yoffset + j * 10 + 10, lab.Layout);
                        }
                    }

                    gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                    int numxlabels = 10;
                    int numylabels = 5;

                    // Add Xtick marks to the graph
                    double tstart, tend, dt;
                    tstart = this.time[startIdx];
                    tend   = this.time[this.time.Count - 1];
                    dt     = Math.Round((tend - tstart) / (1 + numxlabels));

                    if (dt < 1)
                    {
                        dt = 1;
                    }

                    for (double i = 0; i < rangeX; i += dt)
                    {
                        double    x   = i / rangeX * width;
                        Gtk.Label lab = new Gtk.Label();
                        lab.Text = String.Format("{0}", Math.Round((tstart + i) * 10) / 10);
                        da.DrawLayout(gc, (int)x + xoffset, (int)height + 2, lab.Layout);
                    }

                    double dy;
                    dy = rangeY / (1 + numylabels);

                    if (dy == 0.0)
                    {
                        dy = 1;
                    }

                    for (double i = 0; i < rangeY; i += dy)
                    {
                        double    y   = height - i / rangeY * height;
                        Gtk.Label lab = new Gtk.Label();
                        lab.Text = String.Format("{0}", Math.Round((i + minY) * 10) / 10);
                        da.DrawLayout(gc, 10, (int)y + yoffset, lab.Layout);
                    }
                }
                catch
                {
                    Console.WriteLine("Internal data draw failed");
                }
            }
 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null)) {
         return res;
     }
     else {
         try {
             return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
         }
         catch (System.Exception ) {
             if ((name != "gtk-missing-image")) {
                 return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz);
             }
             else {
                 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
                 Gdk.GC gc = new Gdk.GC(pmap);
                 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
                 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
                 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
                 return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
             }
         }
     }
 }
示例#31
0
    void prepareEncoderGraphs(bool eraseBars, bool eraseSignal)
    {
        LogB.Debug("prepareEncoderGraphs() start (should be on first thread: GTK)");

        if(eraseBars && encoder_capture_curves_bars_pixmap != null)
            UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea, encoder_capture_curves_bars_pixmap);

        if(eraseSignal && encoder_capture_signal_pixmap != null)
            UtilGtk.ErasePaint(encoder_capture_signal_drawingarea, encoder_capture_signal_pixmap);

        layout_encoder_capture_signal = new Pango.Layout (encoder_capture_signal_drawingarea.PangoContext);
        layout_encoder_capture_signal.FontDescription = Pango.FontDescription.FromString ("Courier 10");

        layout_encoder_capture_curves_bars = new Pango.Layout (encoder_capture_curves_bars_drawingarea.PangoContext);
        layout_encoder_capture_curves_bars.FontDescription = Pango.FontDescription.FromString ("Courier 10");

        layout_encoder_capture_curves_bars_text = new Pango.Layout (encoder_capture_curves_bars_drawingarea.PangoContext);
        layout_encoder_capture_curves_bars_text.FontDescription = Pango.FontDescription.FromString ("Courier 10");

        //defined as encoder_capture_curves_bars_drawingarea instead of encoder_capture_signal_drawingarea
        //because the 2nd is null if config.EncoderCaptureShowOnlyBars == TRUE
        pen_black_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_gray = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_red_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_red_light_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_green_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_blue_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_white_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_selected_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_red_light_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_red_dark_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_green_light_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_green_dark_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_blue_dark_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_blue_light_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);
        pen_yellow_encoder_capture = new Gdk.GC(encoder_capture_curves_bars_drawingarea.GdkWindow);

        Gdk.Colormap colormap = Gdk.Colormap.System;
        colormap.AllocColor (ref UtilGtk.BLACK,true,true);
        colormap.AllocColor (ref UtilGtk.GRAY,true,true);
        colormap.AllocColor (ref UtilGtk.RED_PLOTS,true,true);
        colormap.AllocColor (ref UtilGtk.RED_DARK,true,true);
        colormap.AllocColor (ref UtilGtk.RED_LIGHT,true,true);
        colormap.AllocColor (ref UtilGtk.GREEN_PLOTS,true,true);
        colormap.AllocColor (ref UtilGtk.GREEN_DARK,true,true);
        colormap.AllocColor (ref UtilGtk.GREEN_LIGHT,true,true);
        colormap.AllocColor (ref UtilGtk.BLUE_PLOTS,true,true);
        colormap.AllocColor (ref UtilGtk.BLUE_DARK,true,true);
        colormap.AllocColor (ref UtilGtk.BLUE_LIGHT,true,true);
        colormap.AllocColor (ref UtilGtk.YELLOW,true,true);
        colormap.AllocColor (ref UtilGtk.WHITE,true,true);
        colormap.AllocColor (ref UtilGtk.SELECTED,true,true);

        pen_black_encoder_capture.Foreground = UtilGtk.BLACK;
        pen_gray.Foreground = UtilGtk.GRAY;
        pen_red_encoder_capture.Foreground = UtilGtk.RED_PLOTS;
        pen_red_dark_encoder_capture.Foreground = UtilGtk.RED_DARK;
        pen_red_light_encoder_capture.Foreground = UtilGtk.RED_LIGHT;
        pen_green_encoder_capture.Foreground = UtilGtk.GREEN_PLOTS;
        pen_green_dark_encoder_capture.Foreground = UtilGtk.GREEN_DARK;
        pen_green_light_encoder_capture.Foreground = UtilGtk.GREEN_LIGHT;
        pen_blue_encoder_capture.Foreground = UtilGtk.BLUE_PLOTS;
        pen_blue_dark_encoder_capture.Foreground = UtilGtk.BLUE_DARK;
        pen_blue_light_encoder_capture.Foreground = UtilGtk.BLUE_LIGHT;
        pen_yellow_encoder_capture.Foreground = UtilGtk.YELLOW;
        pen_white_encoder_capture.Foreground = UtilGtk.WHITE;
        pen_selected_encoder_capture.Foreground = UtilGtk.SELECTED;

        pen_black_encoder_capture.SetLineAttributes (2, Gdk.LineStyle.Solid, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);
        pen_selected_encoder_capture.SetLineAttributes (2, Gdk.LineStyle.Solid, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Miter);

        LogB.Debug("prepareEncoderGraphs() end");
    }
示例#32
0
        protected void OnTableWeatherExposeEvent(object o, ExposeEventArgs args)
        {
            Color fore = Style.Foreground(StateType.Normal);

            Drawable draw = args.Event.Window;
            Gdk.GC gc = new Gdk.GC(draw);

            Rectangle rect;
            switch (SelectedForecast) {
                case 0:
                    rect = imageMorning1.Allocation;
                    break;
                case 1:
                    rect = imageDay1.Allocation;
                    break;
                case 2:
                    rect = imageMorning2.Allocation;
                    break;
                case 3:
                    rect = imageDay2.Allocation;
                    break;
                case 4:
                    rect = imageMorning3.Allocation;
                    break;
                case 5:
                    rect = imageDay3.Allocation;
                    break;
                case 6:
                    rect = imageMorning4.Allocation;
                    break;
                default:
                    rect = imageDay4.Allocation;
                    break;
            }

            gc.Foreground = fore;
            gc.Background = fore;
            gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
            draw.DrawRectangle(gc, false, rect);

            gc.Dispose();
        }
示例#33
0
        private void DrawMove(Gdk.Window window)
        {
            Gdk.GC gc = Style.ForegroundGC (StateType.Normal);

            if (info.stage == MoveStage.Start)
              {
                  int x = start_x +
                      info.start.x * (space + size);
                  int y = start_y +
                      info.start.y * (space + size);

                  window.DrawRectangle (gc, false, x, y,
                            size, size);
              }

            if (info.cursorVisible)
              {
                  Gdk.GC tempGC = new Gdk.GC (window);
                  tempGC.Copy (gc);
                  tempGC.SetLineAttributes (1,
                                LineStyle.
                                OnOffDash, 0, 0);

                  int x = start_x +
                      info.cursor.x * (space + size);
                  int y = start_y +
                      info.cursor.y * (space + size);

                  window.DrawRectangle (tempGC, false, x, y,
                            size, size);

              }

            return;
        }