using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace testgrid ... { public partial class TriangleTile : Form1 ...{ const int iSide = 50; MenuItem miChecked; public TriangleTile() ...{ Menu = new MainMenu(); Menu.MenuItems.Add("&Wrap-Mode"); foreach (WrapMode wm in Enum.GetValues(typeof(WrapMode))) ...{ MenuItem mi = new MenuItem(); mi.Text = wm.ToString(); mi.Click += new EventHandler(mi_Click); Menu.MenuItems[0].MenuItems.Add(mi); } miChecked = Menu.MenuItems[0].MenuItems[0]; miChecked.Checked = true; InitializeComponent(); } void mi_Click(object sender, EventArgs e) ...{ // throw new Exception("The method or operation is not implemented."); miChecked.Checked = false; miChecked = (MenuItem)sender; miChecked.Checked = true; Invalidate(); } protected override void DoPage(Graphics g, Color clr, int cx, int cy) ...{ //base.DoPage(g, clr, cx, cy); Point[] apt =...{ new Point(0, 0), new Point(iSide, 0), new Point(0, iSide) }; PathGradientBrush pgbrush = new PathGradientBrush(apt, (WrapMode)miChecked.Index); g.FillRectangle(pgbrush, 0, 0, cx, cy); } }} using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Printing; namespace testgrid ... { public partial class Form1 : Form ...{ public Form1() ...{ InitializeComponent(); } private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) ...{ } private void Form1_Load(object sender, EventArgs e) ...{ } private void dataGridView1_KeyDown(object sender, KeyEventArgs e) ...{ MessageBox.Show(e.ToString()); e.Handled = true; } protected override void OnPaint(PaintEventArgs e) ...{ //Graphics g = e.Graphics; //Pen pen = new Pen(ForeColor); //g.SmoothingMode = SmoothingMode.None; //g.PixelOffsetMode = PixelOffsetMode.Default; //g.DrawLine(pen, 2, 2, 180, 100); DoPage(e.Graphics, ForeColor, ClientSize.Width, ClientSize.Height); } protected override void OnClick(EventArgs e) ...{ PrintDocument prndoc = new PrintDocument(); prndoc.DocumentName = Text; prndoc.PrintPage += new PrintPageEventHandler(prndoc_PrintPage); } void prndoc_PrintPage(object sender, PrintPageEventArgs e) ...{ Graphics g = e.Graphics; SizeF sizef = g.VisibleClipBounds.Size; DoPage(g, Color.Black, (int)sizef.Width, (int)sizef.Height); } protected virtual void DoPage(Graphics g, Color clr, int cx, int cy) ...{ Pen pen=new Pen(clr); g.DrawLine(pen,0,0,cx-1,cy-1); g.DrawLine(pen, cx - 1, 0, 0, cy - 1); } public void Form1_SizeChanged(object sender, EventArgs e) ...{ this.Refresh(); } }}