Using a wide pen, how do I draw a series of line segments with rounded corners
The LineJoin property of the Pen class allows you to specify how two lines should be joined. The following code segment produces the picture below. private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Pen redPen = new Pen(Color.Red, 20); int startX = 20; int startY = 60; int width = this.ClientSize.Width / 17; int height = this.ClientSize.Height / 2; foreach(LineJoin LJ in new LineJoin[] { LineJoin.Bevel, LineJoin.Miter, LineJoin.Round}) { redPen.LineJoin = LJ; Point[] points = {new Point(startX, startY), new Point(startX + width, startY + height), new Point(startX + 2 * width, startY), new Point(startX + 3 * width, startY + height), new Point(startX + 4 * width, startY)}; e.Graphics.DrawLines(redPen, points); e.Graphics.DrawString( LJ.ToString(), new Font(‘Arial Black’, 13), new SolidBrush(Color.Blue), startX – 5, startY – 50); startX += 4 * width + 40; } }
How do I use hatched and gradient brush types
The Brushes Sample shows you how to use four different brushes in several shapes. Below is a code snippet showing how to use hatched and gradient brushes. Rectangle rect = new Rectangle(35, 190, 100, 100); LinearGradientBrush brush2 = new LinearGradientBrush(rect, Color.DarkOrange, Color.Aquamarine, LinearGradientMode.ForwardDiagonal); g.FillEllipse(brush2, 35, 190, 100, 100); HatchBrush brush1 = new HatchBrush(HatchStyle.DiagonalCross, Color.DarkOrange, Color.Aquamarine); g.FillEllipse(brush1, 35, 190, 100, 100);
Is it possible to call macros as part of a Visual Studio.NET command line build (or from a batch file)
Yes. You just use the following syntax: devenv.exe {Solution Name} /command {Macro name} Example: devenv.exe ‘myproject.sln’ /command ‘Macros.Syncfusion.Utils.FormatProjectAndClose’ Dev studio will start up, load the solution, run the macro and then terminate. Be sure to check that devenv.exe is available from your command line. Normally, you just have to run VSVARS32.bat to ensure this if you do not already have this in your path.
How can I make a Panel or Label semi-transparent on a Windows Form
You can make a panel or label transparent by specifying the alpha value for the Background color. panel.BackColor = Color.FromArgb(65, 204, 212, 230); In the designer you have to enter these values manually in the edit box. Don’t select the color using the ColorPicker.
How to make my Component add itself to the contained Form’s IContainer list?
You do this inorder to ensure that your component gets disposed along with the contained Form (logical parent). All Form derived classes come with an IContainer field into which many of the .Net components like ImageList and Timer add themselves to. The Form will dispose the contents of this IContainer from within its Dispose. Scenario 1 In order for your Component to get added to this IContainer list, all you have to do is provide a constructor that takes IContainer as the one and only argument. The design-time will discover this constructor automatically and use it to initialize your component. You should then add yourself to the IContainer in the constructor implementation. Note that for this to work your Component should not have a custom TypeConverter that can convert your type to an InstanceDescriptor. Example: public class MyComponent : Component { public MyComponent() { } public MyComponent(IContainer container) { container.Add(this); } } Scenario 2 Your components might have more constructors besides the default constructor and you might have a custom TypeConverter that provides an InstanceDescriptor to let your designer use a non-default constructor for initializing your component in code. In this case, the above approach will not work because you do not have an IContainer-argument only constructor. You now have to recreate what the design-time did for you. You have to provide a custom IDesignerSerializationProvider to do so. The attached ContainerInsertingSerializationProvider class can be used to get the above effect.