Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 643528

@User 643528
About
Posts
7
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Rotate Text - Find bounding rectangle
    U User 643528

    Actually what I needed is a bit more complicated. I first used MeasureString to create a rectangle for the text. Then I want to rotate that rectangle and find the largest "non-rotate" rectangle that rectangle will fit in. I don't care about the location of the largest rectangle, just the width and height. I did figure this out with a bunch of math. here is the routine if anyone is interested. Note that the rect that is passed into this routine is the rect created using MeasureString. private RectangleF FindBoundingRect(RectangleF rect, float angle) { // Do a quick short cut here if the text is not really rotated // but is instead horizontal or rotated. if (angle == 0 || angle == 180 || angle == 360) { return new RectangleF(0, 0, rect.Width, rect.Height); } else if (angle == 90 || angle == 270) { return new RectangleF(0, 0, rect.Height, rect.Width); } else if (angle > 360) { // Don't handle this case for now. return new RectangleF(0, 0, 0, 0); } // First transform the angle to radians. float radianAngle = angle * (float)(Math.PI / 180.0F); float radian90Degrees = 90 * (float)(Math.PI / 180.0F); // First find the rotated point 1. This is the bottom right point. The radius // for this point is the width. float x = (float)(rect.Width * Math.Cos(radianAngle)); float y = (float)(rect.Width * Math.Sin(radianAngle)); PointF p1 = new PointF(x, y); // Now find point 3 which is also easy. This is the top left point. The // radius for this point is the height. x = (float)(rect.Height * Math.Cos(radianAngle + radian90Degrees)); y = (float)(rect.Height * Math.Sin(radianAngle + radian90Degrees)); PointF p3 = new PointF(x, y); // Point 2, the top right point, is a bit trickier. First find the angle // from the bottom left up to the top left when the rect is not rotated. float radianAngleP2 = (float) Math.Atan(rect.Height / rect.Width); // Now find the length of the diagonal line between these two points. float radiusP2 = (float) Math.Sqrt((rect.Height * rect.Height) + (rect.Width * rect.Width)); // Now we can find the x,y of point 2 rotated by the specified angle. x = (float)(radiusP2 * Math.Cos(radianAngle + radianAngleP2)); y = (float)(radiusP2 * Math.Sin(radianAngle + radianAngleP2)); PointF p2 = new PointF(x, y); // Now based on the original angle we can figure out the width and height // of our returned rectagle. float width = 0; float height = 0; if (angle < 90) { width = p1.X + Math.Ab

    C# graphics tutorial question

  • Rotate Text - Find bounding rectangle
    U User 643528

    To rotate the text use the power of the Graphics class in .net. It has a RotateTransform() method. Here is one link that talks about how to use it. I'm sure you can find other tutorials on the web also. http://www.c-sharpcorner.com/Code/2004/April/Transformations06.asp

    C# graphics tutorial question

  • Rotate Text - Find bounding rectangle
    U User 643528

    I am rotating text via the Graphics.RotateTransformation technique. After drawing my text string I set the rotation transform back to normal. I then want to draw a "non-rotated" rectangle around the rotated text. Does anyone know how to calculate this rectangle (the largest non-rotated rectangle around the rotated text)??

    C# graphics tutorial question

  • Custom Control Initialization - first time drop on win form
    U User 643528

    I am writing a small custom win form control (i.e. UserControl). I would like to pop up a wizard the first time the user places the control on a windows form. I cannot figure out how to tell the first time a control is places??? I cannot seem to find any methods or properties in the designer class. Can anyone help here? Thanks!

    C# help tutorial question

  • Custom WebControl - Rendering Images
    U User 643528

    I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.

    C# html question

  • Reading in an XML File into a DataSet
    U User 643528

    I am trying to read an XML document into a .NET DataSet object. I used the XSD.EXE utility to generate a schema file for this XML document. This schema has re-ocurring elements that I would like to load as records into my DataSet. However, I only want to load certain child elements as fields into the DataSet record. Is there a way I can modify this schema file such that I can use the DataSet.ReadXml method to parse this XML file and create the proper table rows?? Thanks

    Database xml csharp database tools question

  • DataSet - reading in and XML Document
    U User 643528

    I am trying to read an XML document into a .NET DataSet object. I used the XSD.EXE utility to generate a schema file for this XML document. This schema has re-ocurring elements that I would like to load as records into my DataSet. However, I only want to load certain child elements as fields into the DataSet record. Is there a way I can modify this schema file such that I can use the DataSet.ReadXml method to parse this XML file and create the proper table rows?? Thanks

    XML / XSL xml csharp database tools question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups