当前位置: 首页>>代码示例>>C#>>正文


C# Gdk.DrawPolygon方法代码示例

本文整理汇总了C#中Gdk.DrawPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.DrawPolygon方法的具体用法?C# Gdk.DrawPolygon怎么用?C# Gdk.DrawPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdk的用法示例。


在下文中一共展示了Gdk.DrawPolygon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawSlider

        /// <summary>
        /// Draws the slider arrows on both sides of the control.
        /// </summary>
        /// <param name="position">position value of the slider, lowest being at the bottom.  The range
        /// is between 0 and the controls height-9.  The values will be adjusted if too large/small</param>
        /// <param name="Unconditional">If Unconditional is true, the slider is drawn, otherwise some logic 
        /// is performed to determine is drawing is really neccessary.</param>
        private void DrawSlider(Gdk.Window g,int position, bool Unconditional)
        {
            if ( position < 0 ) position = 0;
            if ( position > this.Allocation.Height - 9 ) position = this.Allocation.Height - 9;

            if ( m_iMarker_Start_Y == position && !Unconditional )	//	If the marker position hasn't changed
                return;												//	since the last time it was drawn and we don't HAVE to redraw
            //	then exit procedure

            m_iMarker_Start_Y = position;	//	Update the controls marker position

            this.ClearSlider(g);		//	Remove old slider

            Gdk.GC gcfill  = new Gdk.GC( g );
            //	Same gray color Photoshop uses
            gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms(Color.FromArgb(116,114,106));

            Gdk.GC gcborder  = new Gdk.GC( g );
            gcfill.RgbFgColor = GraphUtil.gdkColorFromWinForms( Color.White );
            //	Same gray color Photoshop uses
            //Console.WriteLine( "position="+position );

            Gdk.Point[] arrow = new Gdk.Point[7];				//	 GGG
            arrow[0] = new Gdk.Point(1,position);			//	G   G
            arrow[1] = new Gdk.Point(3,position);			//	G    G
            arrow[2] = new Gdk.Point(7,position + 4);		//	G     G
            arrow[3] = new Gdk.Point(3,position + 8);		//	G      G
            arrow[4] = new Gdk.Point(1,position + 8);		//	G     G
            arrow[5] = new Gdk.Point(0,position + 7);		//	G    G
            arrow[6] = new Gdk.Point(0,position + 1);		//	G   G
            //	 GGG
            g.DrawPolygon( gcfill  , true , arrow );//	Fill left arrow with white
            g.DrawPolygon( gcborder, false, arrow );//	Draw left arrow border with gray

            //	    GGG
            arrow[0] = new Gdk.Point(this.Allocation.Width - 2,position);		//	   G   G
            arrow[1] = new Gdk.Point(this.Allocation.Width - 4,position);		//	  G    G
            arrow[2] = new Gdk.Point(this.Allocation.Width - 8,position + 4);	//	 G     G
            arrow[3] = new Gdk.Point(this.Allocation.Width - 4,position + 8);	//	G      G
            arrow[4] = new Gdk.Point(this.Allocation.Width - 2,position + 8);	//	 G     G
            arrow[5] = new Gdk.Point(this.Allocation.Width - 1,position + 7);	//	  G    G
            arrow[6] = new Gdk.Point(this.Allocation.Width - 1,position + 1);	//	   G   G
            //	    GGG

            g.DrawPolygon(gcfill  , true , arrow );	//	Fill right arrow with white
            g.DrawPolygon(gcborder, false, arrow );	//	Draw right arrow border with gray
        }
开发者ID:tizianomanni,项目名称:holly-gtk-widgets,代码行数:54,代码来源:VerticalColorSlider.cs

示例2: DrawArrow

            /* This will draw an arrow from the source point to the destination.
             * The caller has to resolve the centers of the source and destination squares
             * and pass them to this.
             * Instead of drawing the arrow to the center of the destination (which can
             * overlap with the piece at the destination), the arrow will be drawn in
             * such a way that only a limited portion of it will be inside the square.
             * The horizontal lines of the arrow needs to be perpendicular to the direction
             * of the arrow. To compute the points which are equidistant and at a distance 'alpha'
             * from a given point (x,y), the following formula is used:
             * (x + sin * alpha, y - cos * alpha) and (x - sin * alpha, y + cos * alpha)
             * The sin and cos are the values for the slope of the arrow.
             * GetPerpendicularCoords is used to get these values.
             * Another formula is used to find a point on the arrow at a distance 'dist' from a
             * point (x, y) in the reverse direction. This is used in drawing the edge of the arrow.
             * The formula used is:
             * (x - dist * cos, y - dist * sin)
             */
            public static void DrawArrow(Gdk.Drawable map,
						      Gdk.GC gc, int x1,
						      int y1, int x2, int y2,
						      int size, bool filled)
            {
                double len =
                    Math.Sqrt ((y2 - y1) * (y2 - y1) +
                           (x2 - x1) * (x2 - x1));
                double sin = (y2 - y1) / len;
                double cos = (x2 - x1) / len;

                int alpha = size / 4;

                double line_portion = 0.75 * size / 2;
                // the tip now touches the end of the square.
                // computing it like this takes care of the direction
                // from which the arrow is coming!
                Gdk.Point tip = new Gdk.Point ((int) Math.
                                   Round (x2 -
                                      line_portion
                                      * cos),
                                   (int) Math.
                                   Round (y2 -
                                      line_portion
                                      * sin));
                x2 = tip.X;
                y2 = tip.Y;

                Gdk.Point[]a = new Gdk.Point[2];
                GetPerpendicularCoords (x1, y1, sin, cos,
                            alpha, out a[0],
                            out a[1]);

                // This is the point where the arrow will start.
                // We need to draw a rectangle from the above point to this.
                // And the a triangle to the final dest.
                double factor = 1.5;
                Gdk.Point p =
                    new Gdk.Point ((int) Math.
                               Round (x2 -
                                  factor * alpha *
                                  cos),
                               (int) Math.Round (y2 -
                                     factor
                                     *
                                     alpha
                                     *
                                     sin));

                Gdk.Point[]b = new Gdk.Point[2];
                GetPerpendicularCoords (p.X, p.Y, sin, cos,
                            alpha, out b[0],
                            out b[1]);
                Gdk.Point c, d;
                GetPerpendicularCoords (p.X, p.Y, sin, cos,
                            3 * alpha, out c,
                            out d);

                Gdk.Point[]points = new Gdk.Point[]
                {
                a[0], a[1],
                        b[1], d, tip, c, b[0], a[0]};
                map.DrawPolygon (gc, filled, points);
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:81,代码来源:ViewerBoard.cs

示例3: drawScaled

        public void drawScaled(Gdk.Window win, int ox, int oy, int szx, int szy, Gdk.Color terr)
        {
            /* This function allows drawing the territory at a
             * predefined x,y coordinate, which requires we
             * translate the entirety of the polygon to begin at
             * that coordinate, an O(3n) operation (could be O(2n))
            */
               	Gdk.GC field = new Gdk.GC(win);
               	field.RgbFgColor = terr;

               	int minx = borders[0].X , miny = borders[0].Y, maxx = 0, maxy = 0, x = 0 , y = 0;
               	Point[] translated_borders = new Point[borders.Length];

               	/* Determine bounds */
               	for(int i=0; i<borders.Length; i++)
               	{
               		if (minx > borders[i].X) minx = borders[i].X;
               		if (miny > borders[i].Y) miny = borders[i].Y;

               		if (borders[i].X > maxx) maxx = borders[i].X;
               		if (borders[i].Y > maxy) maxy = borders[i].Y;
               		//System.Console.WriteLine("(x,y)=("+borders[i].X+","+borders[i].Y+")");
               	}

               	/* Translate */
               	int tx = minx-ox, ty = miny-oy;

               	maxx = maxy = 0;
               	for(int i=0; i<borders.Length; i++)
               	{
               		x = borders[i].X-tx;
               		y = borders[i].Y-ty;

               		if (x > maxx) maxx = x;
               		if (y > maxy) maxy = y;

               		translated_borders[i] = new Point(x,y);
               	}

               	/* Scale uniformly */
               	double scaleX = (double)(szx)/maxx;
               	double scaleY = (double)(szy)/maxy;

               	if (scaleX > scaleY)
               		scaleX = scaleY;
            else
            scaleY = scaleX;

               	for(int i=0; i<borders.Length; i++)
               	{
               		x = (int)(translated_borders[i].X*scaleX);
               		y = (int)(translated_borders[i].Y*scaleY);

               		translated_borders[i] = new Point(x,y);

               	}

            /* Draw */
            win.DrawPolygon(field, true, translated_borders);
        }
开发者ID:jcjones,项目名称:Gpremacy,代码行数:60,代码来源:MapTerritory.cs

示例4: DrawSelectionRect

        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);
        }
开发者ID:CoEST,项目名称:TraceLab,代码行数:14,代码来源:PixButtonHandle.cs


注:本文中的Gdk.DrawPolygon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。