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


C# Drawable.DrawRectangle方法代码示例

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


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

示例1: Draw

        public void Draw(Drawable draw, Gdk.Color back)
        {
            Gdk.GC gc = new Gdk.GC(draw);

            try {

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

                int xPoint = (width * Volume) / 100;
                int yTop = height * Volume / 100;

                List<Point> points = new List<Point>();
                points.Add(new Point(0,0));
                points.Add(new Point(xPoint, yTop));
                points.Add(new Point(xPoint, height));
                points.Add(new Point(0,height));
                points.Add(new Point(0,0));

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

                points.Clear();
                points.Add(new Point(0,0));
                points.Add(new Point(xPoint, yTop));
                points.Add(new Point(xPoint, 0));
                points.Add(new Point(0,0));
                gc.Foreground = new Gdk.Color(0,128,0);
                gc.Background = new Gdk.Color(0,128,0);
                draw.DrawPolygon(gc, true, points.ToArray());

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

            gc.Dispose();
        }
开发者ID:peter-gregory,项目名称:ClockRadio,代码行数:41,代码来源:GuiVolume.cs

示例2: Render

		protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			if (isDisposed)
				return;
			if (diffMode) {
				
				if (path.Equals (selctedPath)) {
					selectedLine = -1;
					selctedPath = null;
				}
				
				int w, maxy;
				window.GetSize (out w, out maxy);
				if (DrawLeft) {
					cell_area.Width += cell_area.X - leftSpace;
					cell_area.X = leftSpace;
				}
				var treeview = widget as FileTreeView;
				var p = treeview != null? treeview.CursorLocation : null;
				
				cell_area.Width -= RightPadding;
				
				window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height);
				
				Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
				Gdk.GC removedGC = new Gdk.GC (window);
				removedGC.Copy (normalGC);
				removedGC.RgbFgColor = baseRemoveColor.AddLight (-0.3);
				Gdk.GC addedGC = new Gdk.GC (window);
				addedGC.Copy (normalGC);
				addedGC.RgbFgColor = baseAddColor.AddLight (-0.3);
				Gdk.GC infoGC = new Gdk.GC (window);
				infoGC.Copy (normalGC);
				infoGC.RgbFgColor = widget.Style.Text (StateType.Normal).AddLight (0.2);
				
				Cairo.Context ctx = CairoHelper.Create (window);
				Gdk.Color bgColor = new Gdk.Color (0,0,0);
				
				
				// Rendering is done in two steps:
				// 1) Get a list of blocks to render
				// 2) render the blocks
				
				int y = cell_area.Y + 2;
				
				// cline keeps track of the current source code line (the one to jump to when double clicking)
				int cline = 1;
				bool inHeader = true;
				BlockInfo currentBlock = null;
				
				List<BlockInfo> blocks = new List<BlockInfo> ();
				
				for (int n=0; n<lines.Length; n++, y += lineHeight) {
					
					string line = lines [n];
					if (line.Length == 0) {
						currentBlock = null;
						y -= lineHeight;
						continue;
					}
					
					char tag = line [0];
	
					if (line.StartsWith ("---") || line.StartsWith ("+++")) {
						// Ignore this part of the header.
						currentBlock = null;
						y -= lineHeight;
						continue;
					}
					if (tag == '@') {
						int l = ParseCurrentLine (line);
						if (l != -1) cline = l - 1;
						inHeader = false;
					} else if (tag != '-' && !inHeader)
						cline++;
					
					BlockType type;
					bool hasBg = false;
					switch (tag) {
						case '-': type = BlockType.Removed; break;
						case '+': type = BlockType.Added; break;
						case '@': type = BlockType.Info; break;
						default: type = BlockType.Unchanged; break;
					}

					if (currentBlock == null || type != currentBlock.Type) {
						if (y > maxy)
							break;
					
						// Starting a new block. Mark section ends between a change block and a normal code block
						if (currentBlock != null && IsChangeBlock (currentBlock.Type) && !IsChangeBlock (type))
							currentBlock.SectionEnd = true;
						
						currentBlock = new BlockInfo () {
							YStart = y,
							FirstLine = n,
							Type = type,
							SourceLineStart = cline,
							SectionStart = (blocks.Count == 0 || !IsChangeBlock (blocks[blocks.Count - 1].Type)) && IsChangeBlock (type)
						};
//.........这里部分代码省略.........
开发者ID:nickname100,项目名称:monodevelop,代码行数:101,代码来源:CellRendererDiff.cs

示例3: Render

		protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			if (isDisposed)
				return;
			if (diffMode) {
				
				if (path.Equals (selctedPath)) {
					selectedLine = -1;
					selctedPath = null;
				}
				
				int w, maxy;
				window.GetSize (out w, out maxy);
				
				var treeview = widget as FileTreeView;
				var p = treeview != null? treeview.CursorLocation : null;
				
				int recty = cell_area.Y;
				int recth = cell_area.Height - 1;
				if (recty < 0) {
					recth += recty + 1;
					recty = -1;
				}
				if (recth > maxy + 2)
					recth = maxy + 2;
				
				window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth);

				Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
				Gdk.GC removedGC = new Gdk.GC (window);
				removedGC.Copy (normalGC);
				removedGC.RgbFgColor = new Color (255, 0, 0);
				Gdk.GC addedGC = new Gdk.GC (window);
				addedGC.Copy (normalGC);
				addedGC.RgbFgColor = new Color (0, 0, 255);
				Gdk.GC infoGC = new Gdk.GC (window);
				infoGC.Copy (normalGC);
				infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a);
				
				int y = cell_area.Y + 2;
				int cline = 1;
				bool inHeader = true;
				
				for (int n=0; n<lines.Length; n++, y += lineHeight) {
					
					string line = lines [n];
					if (line.Length == 0)
						continue;
					
					char tag = line [0];

					// Keep track of the real file line
					int thisLine = cline;
					if (tag == '@') {
						int l = ParseCurrentLine (line);
						if (l != -1) cline = thisLine = l;
						inHeader = false;
					} else if (tag != '-' && !inHeader)
						cline++;
					
					if (y + lineHeight < 0)
						continue;
					if (y > maxy)
						break;
					
					Gdk.GC gc;
					switch (tag) {
						case '-': gc = removedGC; break;
						case '+': gc = addedGC; break;
						case '@': gc = infoGC; break;
						default: gc = normalGC; break;
					}

					if (p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= y && p.Value.Y < y + lineHeight) {
						window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Prelight), true, cell_area.X, y, cell_area.Width - 1, lineHeight);
						selectedLine = thisLine;
						selctedPath = path;
					}
					
					layout.SetText (line);
					window.DrawLayout (gc, cell_area.X + 2, y, layout);
				}
				window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth);
				removedGC.Dispose ();
				addedGC.Dispose ();
				infoGC.Dispose ();
			} else {
				int y = cell_area.Y + (cell_area.Height - height)/2;
				window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:91,代码来源:CellRendererDiff.cs

示例4: Render

			protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
			{
				if (isDisposed)
					return;
				try {
					if (diffMode) {
						int w, maxy;
						window.GetSize (out w, out maxy);

						int recty = cell_area.Y;
						int recth = cell_area.Height - 1;
						if (recty < 0) {
							recth += recty + 1;
							recty = -1;
						}
						if (recth > maxy + 2)
							recth = maxy + 2;

						window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth);

						Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
						Gdk.GC removedGC = new Gdk.GC (window);
						removedGC.Copy (normalGC);
						removedGC.RgbFgColor = new Color (255, 0, 0);
						Gdk.GC addedGC = new Gdk.GC (window);
						addedGC.Copy (normalGC);
						addedGC.RgbFgColor = new Color (0, 0, 255);
						Gdk.GC infoGC = new Gdk.GC (window);
						infoGC.Copy (normalGC);
						infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a);

						int y = cell_area.Y + 2;

						for (int n = 0; n < lines.Length; n++,y += lineHeight) {
							if (y + lineHeight < 0)
								continue;
							if (y > maxy)
								break;
							string line = lines[n];
							if (line.Length == 0)
								continue;

							Gdk.GC gc;
							switch (line[0]) {
							case '-':
								gc = removedGC;
								break;
							case '+':
								gc = addedGC;
								break;
							case '@':
								gc = infoGC;
								break;
							default:
								gc = normalGC;
								break;
							}

							layout.SetText (line);
							window.DrawLayout (gc, cell_area.X + 2, y, layout);
						}
						window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth);
						removedGC.Dispose ();
						addedGC.Dispose ();
						infoGC.Dispose ();
					} else {
						int y = cell_area.Y + (cell_area.Height - height) / 2;
						window.DrawLayout (widget.Style.TextGC (GetState (flags)), cell_area.X, y, layout);
					}
				} catch (Exception e) {
					Console.WriteLine (e);
				}
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:73,代码来源:RefactoringPreviewDialog.cs

示例5: DrawBackground

		public bool DrawBackground (TextEditor editor, Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
		{
			drawBg = false;
			if (selectionStart > 0)
				return true;
			using (Gdk.GC gc = new Gdk.GC (win)) {
				gc.RgbFgColor = color;
				win.DrawRectangle (gc, true, startXPos, y, endXPos - startXPos, editor.LineHeight);
			}
			return true;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:11,代码来源:TextMarker.cs

示例6: Render

        /// <summary>
        /// This method is used to render a sprite viewport onto a
        /// drawable object, such as Gdk.Pixmap. This handles the
        /// translation of widget space into sprite space and also the
        /// appropriate clipping.
        /// </summary>
        public void Render(
			Drawable drawable,
			Rectangle region)
        {
            // Create the GC
            GC gc = new GC(drawable);

            // Figure out what parts of the rectangle we care about
            Rectangle ourselves = new Rectangle(x, y, width, height);

            if (!ourselves.IntersectsWith(region))
            {
                // No overlap, don't bother
                return;
            }

            // Get the intersection of ourselves and the update
            // region. This helps with keeping to a specific focus.
            ourselves.Intersect(region);

            // Clear everything
            gc.RgbFgColor = BackgroundColor;
            drawable.DrawRectangle(gc, true, ourselves);

            // Go through the sprites
            foreach (ISprite sprite in SpriteList)
            {
                sprite.Render(drawable, gc);
            }
        }
开发者ID:dmoonfire,项目名称:wordplay,代码行数:36,代码来源:SpriteViewport.cs


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