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


C# Control.CreateGraphics方法代码示例

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


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

示例1: VisibleSurface

 public VisibleSurface(Control surface)
     : base(surface.Width, surface.Height)
 {
     base.DC = surface.CreateGraphics();
     base.Buffer = new Backbuffer(this);
     this.RedrawDirtyRectangleOnly = true;
 }
开发者ID:Isthimius,项目名称:Gondwana,代码行数:7,代码来源:VisibleSurface.cs

示例2: GetImage

    public static Image GetImage(Control c_)
    {
      Graphics g = null;
      Image ret = null;
      try
      {
        if (c_ is Form)
          c_.BringToFront();
        else
          c_.FindForm().BringToFront();

        Application.DoEvents();

        g = c_.CreateGraphics();
        ret = new Bitmap(c_.ClientRectangle.Width, c_.ClientRectangle.Height, g);
        Graphics g2 = Graphics.FromImage(ret);
        IntPtr dc1 = g.GetHdc();
        IntPtr dc2 = g2.GetHdc();
        BitBlt(dc2, 0, 0, c_.ClientRectangle.Width, c_.ClientRectangle.Height, dc1, 0, 0, 13369376);
        g.ReleaseHdc(dc1);
        g2.ReleaseHdc(dc2);
      }
      finally
      {
        if (g != null)
          g.Dispose();
      }

      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:Util.cs

示例3: GetCompactPath

 public static string GetCompactPath(this FileSystemInfo info, int newWidth, Font drawFont)
 {
     using (Control ctrl = new Control())
        {
     Graphics g = ctrl.CreateGraphics();
     string longPath = info.FullName;
     int width = g.MeasureString(longPath, drawFont).ToSize().Width;
     if (width <= newWidth)
      return longPath;
     int aveCharWidth = width / longPath.Length;
     int charCount = newWidth / aveCharWidth;
     StringBuilder builder = new StringBuilder();
     builder.Append(longPath);
     builder.EnsureCapacity(charCount);
     while (g.MeasureString(builder.ToString(), drawFont).Width > newWidth)
     {
      if (!NativeMethods.PathCompactPathEx(builder, longPath,
       (uint)charCount--, 0))
      {
       return string.Empty;
      }
     }
     return builder.ToString();
        }
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:25,代码来源:IO.cs

示例4: XmlSerialize

 public void XmlSerialize(XmlWriter writer, Control detailView)
 {
     writer.WriteStartElement("DetailView");
     int dpiX = 0x60;
     int dpiY = 0x60;
     if (true)
     {
         Graphics graphics = detailView.CreateGraphics();
         dpiX = (int) graphics.DpiX;
         dpiY = (int) graphics.DpiY;
         graphics.Dispose();
         graphics = null;
     }
     writer.WriteAttributeString("DpiX", Convert.ToString(dpiX));
     writer.WriteAttributeString("DpiY", Convert.ToString(dpiY));
     this.SerializeDetailViewProperties(writer, detailView);
     IList propertyValue = (IList) ReflectionHelper.GetPropertyValue(detailView, "Items");
     foreach (object obj2 in propertyValue)
     {
         writer.WriteStartElement("Item");
         Type type = obj2.GetType();
         if (type.Assembly.ManifestModule.Name.ToLower().StartsWith("resco.detailview"))
         {
             writer.WriteAttributeString("Type", type.FullName);
         }
         else
         {
             writer.WriteAttributeString("Type", type.AssemblyQualifiedName);
         }
         this.SerializeProperties(writer, obj2);
         writer.WriteEndElement();
     }
 }
开发者ID:north0808,项目名称:haina,代码行数:33,代码来源:DVXmlSerializer.cs

示例5: CalculateGraphicsProportion

 /// <summary>
 /// Returns relation between current graphics resolution and default DpiY (96.0).
 /// Can be used when arranging controls and resizing forms.
 /// </summary>
 /// <param name="control"></param>
 /// <returns></returns>
 public static float CalculateGraphicsProportion(Control control)
 {
     Graphics graphics = control.CreateGraphics();
     float proportion = (float)(graphics.DpiY / 96.0);
     graphics.Dispose();
     return proportion;
 }
开发者ID:CisBetter,项目名称:ags,代码行数:13,代码来源:Utilities.cs

示例6: IsClientRectangleVisible

        /// <summary>
        /// Returns true if any part of the client based rectangle is visible.
        /// </summary>
        /// <param name="control">Control to check.</param>
        /// <param name="rectangleToCheck">Client based rectangle to check.</param>
        public static bool IsClientRectangleVisible( Control control, Rectangle rectangleToCheck )
        {
            if( !control.IsHandleCreated )
            {
                return false;
            }

            Utility.Win32.Common.RECT rcClip, rcClient = new Utility.Win32.Common.RECT( rectangleToCheck );

            using( Graphics grfx = control.CreateGraphics() )
            {
                IntPtr hdc = IntPtr.Zero;

                try
                {
                    hdc = grfx.GetHdc();

                    RegionValue result = (RegionValue) Gdi.GetClipBox( hdc, out rcClip );

                    return result != RegionValue.NULLREGION;
                }
                finally
                {
                    if( hdc != IntPtr.Zero )
                    {
                        grfx.ReleaseHdc( hdc );
                    }
                }
            }
        }
开发者ID:CecleCW,项目名称:ProductMan,代码行数:35,代码来源:ControlUtils.cs

示例7: GetTextWidth

 /// <summary>
 /// This method provides the width of a given text, with the given font
 /// 
 /// </summary>
 /// <param name="text"></param>
 /// <param name="size"></param>
 /// <returns>Text width</returns>
 protected int GetTextWidth(string text, Control control)
 {
     float textwidth=0;
     Graphics g = control.CreateGraphics();
     textwidth = (int)g.MeasureString(text, control.Font).Width;
     g.Dispose();
     return (int)Math.Ceiling(textwidth);
 }
开发者ID:ymai,项目名称:DotNet_UtilityCodeAsset,代码行数:15,代码来源:AutoFillPanel.cs

示例8: GenerateBackground

        public void GenerateBackground(Control control)
        {
            Graphics g = control.CreateGraphics();
            Size size = control.ClientSize;

            GenerateBackground(g, size);

            g.Dispose();
        }
开发者ID:khadoran,项目名称:reanimator,代码行数:9,代码来源:HGLWindowBackground.cs

示例9: TextGeometry

        public TextGeometry(Control control)
        {
            this.control = control;
            g = control.CreateGraphics();
            stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

            charWidth = MeasureString("_");
            lineHeight = Font.Height;
        }
开发者ID:chrisforbes,项目名称:corfu,代码行数:9,代码来源:TextGeometry.cs

示例10: Graphics

        /// <summary>
        /// Instantiates a new <see cref="Graphics"/> object with the specified
        /// <paramref name="control"/>.
        /// </summary>
        /// <param name="control">The desired value of
        /// <see cref="Control"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="control"/>
        /// is <c>null</c>.</exception>
        public Graphics(Control control)
        {
            if (ReferenceEquals(control, null))
            {
                throw new ArgumentNullException(nameof(control));
            }

            Control = control;
            native = Control.CreateGraphics();
        }
开发者ID:njonsson,项目名称:PasswordTextBox-Control,代码行数:18,代码来源:Graphics.cs

示例11: LoadDeviceScaling

 private static void LoadDeviceScaling()
 {
     using (var control = new Control())
     {
         using (var graphics = control.CreateGraphics())
         {
             _deviceScaleX = 96.0 / graphics.DpiX;
             _deviceScaleY = 96.0 / graphics.DpiY;
         }
     }
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:11,代码来源:WpfHelper.cs

示例12: ObjectNet

        public ObjectNet(string name, ObjectSequence inObj, ObjectSequence outObj, Control _ControlHandle)
        {
            netName = name;
            inputObject = inObj;
            inputObject.UpdatePosition += new ObjectSequence.ObjectPosistionMove(inputObject_UpdatePosition);

            outputObject = outObj;
            outputObject.UpdatePosition += new ObjectSequence.ObjectPosistionMove(outputObject_UpdatePosition);

            canvas = _ControlHandle.CreateGraphics();
        }
开发者ID:farisais,项目名称:sigsence-apps-core,代码行数:11,代码来源:ObjectNet.cs

示例13: AnimateGradient

 public AnimateGradient(Control control, Color color1, Color color2, float gradientAngle, Control label)
 {
     _timer.Interval = 100;
     _timer.Tick += _timer_Tick;
     _control = control;
     _clientRectangle = control.ClientRectangle;
     _graphics = control.CreateGraphics();
     _angle = gradientAngle;
     _color1 = color1;
     _color2 = color2;
     _label = label;
 }
开发者ID:DeadDreamer,项目名称:enslaver2000,代码行数:12,代码来源:AnimateGradient.cs

示例14: CaptureScreen

 public Bitmap CaptureScreen(Control con, int fromX, int fromY)
 {
     Size size = con.Size;
     Graphics g = con.CreateGraphics();
     Bitmap image = new Bitmap(size.Width - fromX, size.Height - fromY, g);
     Graphics graphics2 = Graphics.FromImage(image);
     IntPtr hdc = g.GetHdc();
     IntPtr hdcDest = graphics2.GetHdc();
     BitBlt(hdcDest, 0, 0, con.ClientRectangle.Width - fromX, con.ClientRectangle.Height - fromY, hdc, fromX, fromY, 0xcc0020);
     g.ReleaseHdc(hdc);
     graphics2.ReleaseHdc(hdcDest);
     return image;
 }
开发者ID:lexzh,项目名称:Myproject,代码行数:13,代码来源:PrintOption.cs

示例15: smethod_0

		// Token: 0x060025F9 RID: 9721
		// RVA: 0x000E3B88 File Offset: 0x000E1D88
		internal static float smethod_0(Control control_0, bool bool_0)
		{
			if (!bool_0 && Class611.float_0 > 0f)
			{
				return Class611.float_0;
			}
			float result;
			using (Graphics graphics = control_0.CreateGraphics())
			{
				result = (Class611.float_0 = graphics.DpiX);
			}
			return result;
		}
开发者ID:newchild,项目名称:Project-DayZero,代码行数:15,代码来源:Class611.cs


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