示例#1
0
        // custom painting for the Style column
        // Paints the custom selection background for selected rows.
        void HandleCellPaint(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex < 0 || Columns[e.ColumnIndex].Name != "Style")
            {
                e.Handled = false;
            }
            else
            {
                e.PaintBackground(e.ClipBounds, (e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected);

                Debug.Assert(e.RowIndex >= 0 && e.RowIndex <= items.Count, "Invalid RowIndex in HandleCellPaint");
                Item x = items[e.RowIndex];

                int m = (e.CellBounds.Top + e.CellBounds.Bottom) / 2;

                if (x is Function1DItem)
                {
                    var f   = (Function1DItem)x;
                    Pen pen = new Pen(new SolidBrush(f.Color), 4);
                    pen.DashStyle = f.LineStyle;
                    e.Graphics.DrawLine(pen, new Point(e.CellBounds.Left + 1, m), new Point(e.CellBounds.Right - 2, m));
                }
                else if (x is DataItem)
                {
                    var d   = (DataItem)x;
                    Pen pen = new Pen(new SolidBrush(d.Color), 4);
                    pen.DashStyle = d.LineStyle;
                    e.Graphics.DrawLine(pen, new Point(e.CellBounds.Left + 1, m), new Point(e.CellBounds.Right - 2, m));
                }
                else if (x is Function2DItem)
                {
                    var f = (Function2DItem)x;
                    GradientPainter.FillRectangle(e.Graphics, f.Gradient,
                                                  new Rectangle(e.CellBounds.Left + 1, e.CellBounds.Top + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3),
                                                  GradientPainter.Direction.Left);
                }
                else
                {
                    e.PaintContent(e.ClipBounds);
                }


                e.Handled = true;
            }
        }
        protected void TaskSummary(MovieClip clip, int w, int h)
        {
            clip.Graphics.FillRectangle(m_backBrush, 0, 0, w, h);
            clip.Graphics.DrawRectangle(Pens.SlateGray, 0, 0, w - 1, h - 1);

            // ID Zone
            MovieClip idLabel = clip.CreateSubMovieClip(0, 0, w / 12, h);

            AlignedString(idLabel, "T1", Brushes.White, StringAlignment.Center);
            MovieClip editNav = clip.CreateSubMovieClip(w / 12, 0, w / 12, h);
            MovieClip edit    = editNav.CreateSubMovieClip(0, 0, w / 24, h);
            MovieClip nav     = editNav.CreateSubMovieClip(w / 24, 0, w / 24, h);

            //edit.Graphics.DrawRectangle( Pens.Sienna, 0, 0, edit.Width-1, edit.Height-1 );
            //nav.Graphics.DrawRectangle( Pens.Sienna, 0, 0, nav.Width-1, nav.Height-1 );

            int eb_h = (int)(h * .45);
            int eb_w = (int)(h * .45);

            GradientPainter.Fill3DSphere(edit, Color.Green, Color.White, edit.Width / 2 - eb_w / 2, edit.Height / 2 - eb_h / 2, eb_w, eb_h);
            edit.CenteredString("33", Brushes.White);
            edit.Graphics.DrawEllipse(Pens.DarkGreen, edit.Width / 2 - eb_w / 2, edit.Height / 2 - eb_h / 2, eb_w, eb_h);

            GradientPainter.Fill3DSphere(nav, Color.Blue, Color.White, nav.Width / 2 - eb_w / 2, nav.Height / 2 - eb_h / 2, eb_w, eb_h);
            nav.CenteredString("15", Brushes.White);
            nav.Graphics.DrawEllipse(Pens.DarkGreen, nav.Width / 2 - eb_w / 2, nav.Height / 2 - eb_h / 2, eb_w, eb_h);

            // TAG CLOUD
            MovieClip tagCloud = clip.CreateSubMovieClip(w / 6, 0, w / 2, h);

            //tagCloud.LeftString( "lock(3) DB(2)", Brushes.White );
            AlignedString(tagCloud, "AUTOTAGS:", Brushes.LightGray, StringAlignment.Near, 7);
            AlignedString(tagCloud, "Lock(3), Oracle(2)", Brushes.White, StringAlignment.Center);

            MovieClip sessions = clip.CreateSubMovieClip(2 * w / 3, 0, w / 3, h);

            AlignedString(sessions, "SESSIONS:", Brushes.LightGray, StringAlignment.Near, 7);
            DrawSessionGraph(sessions, sessions.Width, sessions.Height);
        }