ResetClip() public method

public ResetClip ( ) : void
return void
Esempio n. 1
1
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                if (Config.UseDimming)
                {
                    using (Region region = new Region(regionFillPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawLine(borderPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
Esempio n. 2
1
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
                borderDotPen2.DashOffset = 5 + (float)timer.Elapsed.TotalSeconds * 10;

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawPath(borderDotPen2, regionFillPath);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen2, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
Esempio n. 3
0
        protected override void PaintRestore(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled)
        {
            SmoothingMode sm = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.None;

            Size s = new Size(10, 10);
            Rectangle rm = GetSignRect(r, s);
            Region oldClip = g.Clip;

            LinearGradientColorTable buttonTable = isEnabled ? ct.Foreground : new LinearGradientColorTable(GetDisabledColor(ct.Foreground.Start), GetDisabledColor(ct.Foreground.End), ct.Foreground.GradientAngle);
            using (Brush fill = DisplayHelp.CreateBrush(rm, ct.Foreground))
            {
                Rectangle inner = new Rectangle(rm.X + 4, rm.Y + 2, 6, 4);
                g.SetClip(inner, CombineMode.Exclude);
                g.SetClip(new Rectangle(rm.X + 1, rm.Y + 5, 6, 4), CombineMode.Exclude);

                g.FillRectangle(fill, rm.X + 3, rm.Y, 8, 7);
                g.ResetClip();

                inner = new Rectangle(rm.X + 1, rm.Y + 5, 6, 4);
                g.SetClip(inner, CombineMode.Exclude);
                g.FillRectangle(fill, rm.X, rm.Y + 3, 8, 7);
                g.ResetClip();
            }
            if (oldClip != null)
            {
                g.Clip = oldClip;
                oldClip.Dispose();
            }
            g.SmoothingMode = sm;
        }
Esempio n. 4
0
        public static void DrawImage(Graphics g, Image image, ImageLayoutMode layoutMode, Rectangle rect)
        {
            // Graphics g = Graphics.FromHwnd(IntPtr.Zero);

            if (layoutMode == ImageLayoutMode.None)
            {
                Rectangle tempRect = new Rectangle(rect.X, rect.Y, image.Width, image.Height);
                g.SetClip(rect);
                g.DrawImage(image, tempRect);
                g.ResetClip();
            }
            else if (layoutMode == ImageLayoutMode.Stretch)
            {
                g.DrawImage(image, rect);
            }
            else if (layoutMode == ImageLayoutMode.FitToWidth)
            {
                g.SetClip(rect);
                Size newSize = new Size(rect.Width, rect.Width * image.Height / image.Width);
                g.DrawImage(image, new Rectangle(rect.Location, newSize));
                g.ResetClip();
            }
            else if (layoutMode == ImageLayoutMode.FitToHeight)
            {
                g.SetClip(rect);
                Size newSize = new Size(rect.Height * image.Width / image.Height, rect.Height);
                g.DrawImage(image, new Rectangle(rect.Location, newSize));
                g.ResetClip();
            }
        }
Esempio n. 5
0
        protected override void  Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            Bitmap    estrellaBmp  = MSDNVideo.Tienda.Properties.Resources.Estrella;
            Rectangle rectEstrella = new Rectangle(cellBounds.X, cellBounds.Y + 2, (int)(estrellaBmp.Width * (cellBounds.Height - 4) / estrellaBmp.Height), cellBounds.Height - 4);
            int       i;
            int       widthValue;

            if (value == null)
            {
                widthValue = 0;
            }
            else
            {
                widthValue = (int)((double)((decimal)value) * cellBounds.Width / 10d);
            }

            graphics.FillRectangle(Brushes.White, cellBounds);
            graphics.SetClip(new Rectangle(cellBounds.X, cellBounds.Y, widthValue, cellBounds.Height));
            for (i = 0; i <= (int)(widthValue / rectEstrella.Width); i++)
            {
                graphics.DrawImage(estrellaBmp, rectEstrella, new Rectangle(0, 0, estrellaBmp.Width, estrellaBmp.Height), GraphicsUnit.Pixel);
                rectEstrella.X += rectEstrella.Width;
            }

            graphics.ResetClip();

            string valor;

            valor = String.Format("{0:F1}", value);
            SizeF sizeText = graphics.MeasureString(valor, cellStyle.Font);

            graphics.DrawString(valor, cellStyle.Font, Brushes.Black, new Rectangle(cellBounds.X + (int)((cellBounds.Width - sizeText.Width) / 2), cellBounds.Y + (int)((cellBounds.Height - sizeText.Height) / 2), (int)(sizeText.Width) + 1, (int)(sizeText.Height) + 1));

            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, DataGridViewPaintParts.Border);
        }
        protected override void Draw(Graphics g)
        {
            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.ExcludeClip(region);
                    g.FillRectangle(shadowBrush, 0, 0, Width, Height);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }
            else
            {
                g.FillRectangle(shadowBrush, 0, 0, Width, Height);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
            }

            base.Draw(g);
        }
Esempio n. 7
0
 public static void DrawToLane(System.Drawing.Graphics g, IReadOnlyEditorLaneEnvironment env, NoteBase note)
 {
     // NOTE: お試し実装
     using (var sb = new SolidBrush(NoteGraphicsGenerator.GetColor(note.NoteType)))
         using (var pen = new Pen(Color.White))
         {
             g.Clip = new Region(env.LaneRect);
             var rect = note.GetRectangle(env);
             if (note.NoteType == NoteType.HoldRelay)
             {
                 g.DrawRectangle(pen, rect);
             }
             else
             {
                 g.FillRectangle(sb, rect);
             }
             DrawToLanePreviewNoteFrame(g, rect, note as PreviewNote);
             // 水平位置を1周分ずらしてもう一回描画
             rect.X -= (int)(MadcaEnv.LaneCount * env.LaneUnitWidth);
             if (note.NoteType == NoteType.HoldRelay)
             {
                 g.DrawRectangle(pen, rect);
             }
             else
             {
                 g.FillRectangle(sb, rect);
             }
             DrawToLanePreviewNoteFrame(g, rect, note as PreviewNote);
             g.ResetClip();
         }
 }
Esempio n. 8
0
		private void DrawPointerDown(Graphics g)
		{
			Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);
			Region region = new Region(path);
			g.Clip = region;

			if (ThumbState == 3 || !base.Enabled)
				ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
			else
				g.Clear(SystemColors.Control);

			g.ResetClip();
			region.Dispose();
			path.Dispose();
			Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLightLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
			points[0].Offset(0, -1);
			points[1].Offset(1, 0);
			points[2].Offset(1, 1);
			points[3].Offset(-1, 1);
			points[4].Offset(-1, 0);
			points[5] = points[0];
			pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDark, pointArray2);
		}
Esempio n. 9
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half;
                graphics.SetClip(cellBounds);
                var color = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor);

                graphics.FillRectangle(color, cellBounds);
                var args = new CellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
                graphics.Restore(state);
            }
Esempio n. 10
0
        protected override void Draw(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.HighQuality;

            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
            }

            base.Draw(g);
        }
Esempio n. 11
0
        /// <summary>
        /// Renders the key in the specified surface.
        /// </summary>
        /// <param name="g">The GDI+ surface to render on.</param>
        /// <param name="scrollCount">The number of times the direction has been scrolled within the timeout.</param>
        public void Render(Graphics g, int scrollCount)
        {
            var pressed = scrollCount > 0;
            var style = GlobalSettings.CurrentStyle.TryGetElementStyle<KeyStyle>(this.Id)
                            ?? GlobalSettings.CurrentStyle.DefaultKeyStyle;
            var defaultStyle = GlobalSettings.CurrentStyle.DefaultKeyStyle;
            var subStyle = pressed ? style?.Pressed ?? defaultStyle.Pressed : style?.Loose ?? defaultStyle.Loose;

            var text = pressed ? scrollCount.ToString() : this.Text;
            var txtSize = g.MeasureString(text, subStyle.Font);
            var txtPoint = new TPoint(
                this.TextPosition.X - (int)(txtSize.Width / 2),
                this.TextPosition.Y - (int)(txtSize.Height / 2));

            // Draw the background
            var backgroundBrush = this.GetBackgroundBrush(subStyle, pressed);
            g.FillPolygon(backgroundBrush, this.Boundaries.ConvertAll<Point>(x => x).ToArray());

            // Draw the text
            g.SetClip(this.GetBoundingBox());
            g.DrawString(text, subStyle.Font, new SolidBrush(subStyle.Text), (Point)txtPoint);
            g.ResetClip();

            // Draw the outline.
            if (subStyle.ShowOutline)
                g.DrawPolygon(new Pen(subStyle.Outline, 1), this.Boundaries.ConvertAll<Point>(x => x).ToArray());
        }
Esempio n. 12
0
        public override void Paint(Graphics g, TabStrip tabStrip)
        {
            base.Paint(g, tabStrip);

            TabColorScheme colorScheme = tabStrip.ColorScheme;
            Rectangle clientRect = tabStrip.DisplayRectangle;

            if (colorScheme.TabBackgroundImage != null)
                BarFunctions.PaintBackgroundImage(g, clientRect, colorScheme.TabBackgroundImage, eBackgroundImagePosition.Tile, 255);

            if (colorScheme.TabBackground != Color.Transparent && !colorScheme.TabBackground.IsEmpty)
            {
                if (colorScheme.TabBackground2.IsEmpty)
                {
                    if (!colorScheme.TabBackground.IsEmpty)
                    {
                        using (SolidBrush brush = new SolidBrush(colorScheme.TabBackground))
                            g.FillRectangle(brush, clientRect);
                    }
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(Color.White))
                        g.FillRectangle(brush, clientRect);
                    using (LinearGradientBrush brush = CreateTabGradientBrush(clientRect, colorScheme.TabBackground, colorScheme.TabBackground2, colorScheme.TabBackgroundGradientAngle))
                        g.FillRectangle(brush, clientRect);
                }
            }

            Rectangle selectedRect = Rectangle.Empty;
            if (tabStrip.SelectedTab != null)
                selectedRect = tabStrip.SelectedTab.DisplayRectangle;

            using(Region tabRegion = new Region(tabStrip.DisplayRectangle))
                DrawBackground(tabStrip, clientRect, g, colorScheme, tabRegion, tabStrip.TabAlignment, selectedRect);

            Rectangle systemBoxRect = tabStrip.GetSystemBoxRectangle();
            systemBoxRect.Inflate(-2, -2);
            for (int i = tabStrip.Tabs.Count - 1; i >= 0; i--)
            {
                TabItem tab = tabStrip.Tabs[i];

                if (!tab.Visible || tab == tabStrip.SelectedTab)
                    continue;
                if(!tab.DisplayRectangle.IntersectsWith(systemBoxRect) && tab.DisplayRectangle.IntersectsWith(clientRect))
                    PaintTab(g, tab, false, false);
            }

            if (tabStrip.SelectedTab != null && tabStrip.Tabs.Contains(tabStrip.SelectedTab))
            {
                if (!GetAdjustedRect(tabStrip.SelectedTab).IntersectsWith(systemBoxRect))
                    PaintTab(g, tabStrip.SelectedTab, false, false);
            }

            g.ResetClip();
            tabStrip.PaintTabSystemBox(g);
        }
Esempio n. 13
0
        protected override void PaintRestore(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled)
        {
            //SmoothingMode sm = g.SmoothingMode;
            //g.SmoothingMode = SmoothingMode.Default;
            
            Size s = new Size(12, 11);
            Rectangle rm = GetSignRect(r, s);
            Region oldClip = g.Clip;

            using (Brush fill = DisplayHelp.CreateBrush(rm, ct.Foreground))
            {
                using (Pen pen = new Pen(ct.DarkShade))
                {
                    using (GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(new Rectangle(rm.X + 5, rm.Y, 8, 8), 1))
                    {
                        Rectangle inner = new Rectangle(rm.X + 7, rm.Y + 4, 4, 2);
                        g.SetClip(inner, CombineMode.Exclude);
                        g.SetClip(new Rectangle(rm.X, rm.Y + 3, 8, 8), CombineMode.Exclude);
                        g.FillPath(fill, path);
                        g.DrawPath(pen, path);
                        g.ResetClip();
                        g.DrawRectangle(pen, inner);
                    }
                    using (GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(new Rectangle(rm.X, rm.Y + 3, 8, 8), 1))
                    {
                        Rectangle inner = new Rectangle(rm.X + 2, rm.Y + 7, 4, 2);
                        g.SetClip(inner, CombineMode.Exclude);
                        g.FillPath(fill, path);
                        g.DrawPath(pen, path);
                        g.ResetClip();
                        g.DrawRectangle(pen, inner);
                    }
                }
            }
            if (oldClip != null)
            {
                g.Clip = oldClip;
                oldClip.Dispose();
            }
            //g.SmoothingMode = sm;
        }
Esempio n. 14
0
        public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone)
        {
            using (Bitmap b = new Bitmap(mBackgroundImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);

            var path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddPie(bounds.X, bounds.Y, bounds.Width, bounds.Height, -90f, (float) (360 * hoverDone));
            graphics.SetClip(path);
            using (Bitmap b = new Bitmap(mImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);
            graphics.ResetClip();
        }
Esempio n. 15
0
		public override void Paint(Graphics g, TabStrip tabStrip)
		{
			base.Paint(g,tabStrip);

			TabColorScheme colorScheme=tabStrip.ColorScheme;
			Rectangle clientRect=tabStrip.DisplayRectangle;

            if (tabStrip.BackColor != Color.Transparent || colorScheme.TabBackground != Color.Transparent)
            {
                if (colorScheme.TabPanelBackground2.IsEmpty)
                {
                    if (!colorScheme.TabPanelBackground.IsEmpty)
                    {
                        using (SolidBrush brush = new SolidBrush(colorScheme.TabPanelBackground))
                            g.FillRectangle(brush, clientRect);
                    }
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(Color.White))
                        g.FillRectangle(brush, clientRect);
                    using (LinearGradientBrush brush = CreateTabGradientBrush(clientRect, colorScheme.TabPanelBackground, colorScheme.TabPanelBackground2, colorScheme.TabPanelBackgroundGradientAngle))
                        g.FillRectangle(brush, clientRect);
                }
            }

            Rectangle selectedRect = Rectangle.Empty;
            if (tabStrip.SelectedTab != null)
                selectedRect = tabStrip.SelectedTab.DisplayRectangle;
			DrawBackground(tabStrip, clientRect,g,colorScheme,new Region(tabStrip.DisplayRectangle),tabStrip.TabAlignment, selectedRect);

            tabStrip.ClipExcludeSystemBox(g);

			for(int i=tabStrip.Tabs.Count-1;i>=0;i--)
			{
				TabItem tab=tabStrip.Tabs[i];

				if(!tab.Visible || tab==tabStrip.SelectedTab || !tab.DisplayRectangle.IntersectsWith(clientRect))
					continue;
			
				PaintTab(g,tab,false,false);				
			}

			if(tabStrip.SelectedTab!=null && tabStrip.Tabs.Contains(tabStrip.SelectedTab))
			{
				PaintTab(g,tabStrip.SelectedTab,false,false);
			}

			g.ResetClip();
			tabStrip.PaintTabSystemBox(g);
		}
Esempio n. 16
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) ||
                    cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, shouldDisposeGraphics: false));
                }

                graphics.SetClip(cellBounds);
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
            }
Esempio n. 17
0
        /// <summary>
        /// 绘制续打区域
        /// </summary>
        /// <param name="g">图形绘制对象</param>
        /// <param name="ClipRectangle">剪切矩形</param>
        /// <param name="Position">续打位置</param>
        /// <param name="FillColor">填充色</param>
        protected void DrawJumpPrintArea(
            System.Drawing.Graphics g,
            System.Drawing.Rectangle ClipRectangle,
            int Position,
            System.Drawing.Color FillColor)
        {
            MultiPageTransform trans = (MultiPageTransform)this.myTransform;
            int pos = trans.UnTransformY(Position);

            if (pos >= 0)
            {
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                    0,
                    0,
                    this.ClientSize.Width,
                    pos);

                System.Drawing.Rectangle rect2 = ClipRectangle;
                if (ClipRectangle.IsEmpty)
                {
                    rect2 = rect;
                }
                else
                {
                    rect2 = System.Drawing.Rectangle.Intersect(rect, rect2);
                }
                if (!rect2.IsEmpty)
                {
                    g.ResetClip();
                    g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
                    g.ResetTransform();
                    using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(FillColor))
                    {
                        g.FillRectangle(b, rect2);
                    }
                    using (System.Drawing.Pen p =
                               new System.Drawing.Pen(System.Drawing.Color.Blue, 2))
                    {
                        g.DrawLine(
                            p,
                            0,
                            rect.Bottom - 1,
                            this.ClientSize.Width,
                            rect.Bottom - 1);
                    }
                }
            }
        }
Esempio n. 18
0
    public static void Paint(
        Graphics g,
        RectangleF area,
        float horizontalSpacing,
        float verticalSpacing,
        float penWidth) {
      //ControlPaint.DrawGrid(
      //    g,
      //    area,
      //    new Size(20, 20),
      //    Color.Wheat);

      //g.SmoothingMode = SmoothingMode.HighQuality;
      //g.CompositingQuality = CompositingQuality.HighQuality;
      //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
      g.SetClip(area);
      float sideLength = Math.Min(area.Width, area.Height);
      float horizSpacing = sideLength / horizontalSpacing;
      float vertSpacing = sideLength / verticalSpacing;

      Pen majorPen = new Pen(Color.DarkGray);
      majorPen.Width = penWidth;
      majorPen.DashStyle = DashStyle.Dot;

      float top = area.Top;  // The top y coord.
      float bottom = area.Bottom;  // The bottom y coord.
      float left = area.Left;  // The left y coord.
      float right = area.Right;  // The right y coord.
      PointF p1;  // The starting point for the grid line.
      PointF p2;  // The end point for the grid line.

      // Draw the horizontal lines, starting at the top.
      for (float i = top; i <= bottom; i += horizontalSpacing) {
        p1 = new PointF(left, i);
        p2 = new PointF(right, i);
        g.DrawLine(majorPen, p1, p2);
      }

      // Draw the major vertical lines, starting at the left edge.
      for (float i = left; i <= right; i += verticalSpacing) {
        p1 = new PointF(i, top);
        p2 = new PointF(i, bottom);
        g.DrawLine(majorPen, p1, p2);
      }
      g.ResetClip();
    }
        public static void DoGrid(this WidgetMidiList widget, FloatRect grid, Graphics g)
        {
            var gs = g.Save();
              using (g.Clip = new Region(grid))
              {
            using (var p0 = new Pen(Color.Black)) foreach (var i in widget.GetHLines(4))
              g.DrawLines(p0, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });

            using (var p1 = new Pen(Gray130)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2))))
              g.DrawLines(p1, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });

            using (var p2 = new Pen(White)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3))))
              g.DrawLines(p2, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });

            g.ResetClip();
              }
              g.Restore(gs);
        }
Esempio n. 20
0
        private void DrawSamples(Panel panel, Graphics g, float[] data, int dataCount, float minValue, float maxValue, int step = 1)
        {
            g.ResetClip();

            float dist = maxValue - minValue;
            float dx = (float) panel.ClientRectangle.Width / (float) dataCount;
            float x = 0.0f;

            Func<int, float> fGetData = (int index) => {
                return (1.0f - ((data[index] - minValue) / dist)) * panel.ClientRectangle.Height;
            };

            g.DrawRectangle(Pens.Black, panel.ClientRectangle);
            for (int i = step; i < dataCount; i += step) {
                g.DrawLine(Pens.Red, x, fGetData(i-step), x + dx, fGetData(i));
                x += dx * step;
            }
        }
Esempio n. 21
0
        public static void DrawHoldRegionToLane(System.Drawing.Graphics g, IReadOnlyEditorLaneEnvironment env, Hold hold)
        {
            using (var sb = new SolidBrush(Color.FromArgb(200, 200, 175, 90)))
                using (var path = hold.GetGraphicsPath(env))
                    using (var matToLeft = new Matrix())
                        using (var matToRight = new Matrix())
                            using (var matToReset = new Matrix())
                            {
                                var laneWidth = env.LaneUnitWidth * MadcaEnv.LaneCount;
                                g.Clip = new Region(env.LaneRect);
                                matToLeft.Translate(-laneWidth, 0);
                                matToRight.Translate(laneWidth, 0);
                                var leftTimes = 0;

                                try
                                {
                                    g.FillPath(sb, path);
                                }
                                catch (Exception) { }
                                while (path.GetBounds().Right > env.LaneRect.Right)
                                {
                                    path.Transform(matToLeft);
                                    try
                                    {
                                        g.FillPath(sb, path);
                                    }
                                    catch (Exception) { }
                                    leftTimes++;
                                }
                                matToReset.Translate(laneWidth * leftTimes, 0);
                                path.Transform(matToReset);

                                while (path.GetBounds().Left < env.LaneRect.Left)
                                {
                                    path.Transform(matToRight);
                                    try
                                    {
                                        g.FillPath(sb, path);
                                    }
                                    catch (Exception) { }
                                }
                                g.ResetClip();
                            }
        }
Esempio n. 22
0
        /// <summary>
        /// 绘制选中区域 Add by wwj 2012-04-17
        /// </summary>
        /// <param name="g"></param>
        /// <param name="clipRectangle"></param>
        /// <param name="leftTopPoint"></param>
        /// <param name="rightBottomPoint"></param>
        /// <param name="FillColor"></param>
        protected void DrawSelectAreaPrint(System.Drawing.Graphics g, System.Drawing.Rectangle clipRectangle,
                                           Point leftTopPoint, Point rightBottomPoint, System.Drawing.Color FillColor)
        {
            MultiPageTransform trans = (MultiPageTransform)this.myTransform;

            //由于leftTopPoint代表鼠标按下的Location, rightBottomPoint代表鼠标弹起的location
            //所以需要重新调整leftTopPoint与rightBottomPoint的位置
            Point tempPoint = leftTopPoint;

            if (leftTopPoint.Y > rightBottomPoint.Y)
            {
                leftTopPoint     = rightBottomPoint;
                rightBottomPoint = tempPoint;
            }
            tempPoint = rightBottomPoint;
            if (leftTopPoint.X > rightBottomPoint.X)
            {
                rightBottomPoint.X = leftTopPoint.X;
                leftTopPoint.X     = tempPoint.X;
            }

            leftTopPoint     = trans.UnTransformPoint(leftTopPoint);
            rightBottomPoint = trans.UnTransformPoint(rightBottomPoint);

            if (true)//表示整行选中
            {
                leftTopPoint.X     = 0;
                rightBottomPoint.X = this.ClientSize.Width;
            }

            if (leftTopPoint != Point.Empty && rightBottomPoint != Point.Empty)
            {
                Rectangle rect = new Rectangle(leftTopPoint.X, leftTopPoint.Y, rightBottomPoint.X - leftTopPoint.X, rightBottomPoint.Y - leftTopPoint.Y);
                g.ResetClip();
                g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
                g.ResetTransform();
                using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(FillColor))
                {
                    g.FillRectangle(b, rect);
                }
            }
        }
Esempio n. 23
0
        void PinPanelPaint(object sender, PaintEventArgs e)
        {
            if (FVisiblePins == null)
            {
                return;
            }

            FVisiblePins.Sort(delegate(TBasePin p1, TBasePin p2) { return((p1 as TBasePin).Order.CompareTo((p2 as TBasePin).Order)); });

            System.Drawing.Graphics g = e.Graphics;

            //mark current slice
            Brush     bgray = new System.Drawing.SolidBrush(Color.Gray);
            Rectangle r     = new Rectangle(0, 0, 0, 0);

            r.Location = new Point(FTargetPin * FPinWidth, (FTargetSlice + 1) * FSliceHeight);
            r.Width    = FPinWidth;
            r.Height   = FSliceHeight + 1;
            g.FillRectangle(bgray, r);

            //draw inputs
            Font  f      = new Font("Lucida Sans", 8);
            Brush bblack = new System.Drawing.SolidBrush(Color.Black);
            Pen   p      = new Pen(Color.Black);

            int idx = 0;

            foreach (TBasePin pin in FVisiblePins)
            {
                r.X      = idx * FPinWidth;
                r.Y      = 0;
                r.Width  = FPinWidth;
                r.Height = this.ClientRectangle.Height - 1;

                g.ResetClip();
                g.DrawRectangle(p, r);

                g.SetClip(r);
                pin.Draw(g, f, bblack, p, r);
                idx++;
            }
        }
Esempio n. 24
0
 public static Rectangle DrawIcons(Graphics gr, Rectangle aTextRect, CustomAppointment anAppointment, ImageList anAppIcons)
 {
     if ((anAppIcons != null) && (anAppointment.IconIndexes != null))
     {
         int length = anAppointment.IconIndexes.Length;
         int width = anAppIcons.ImageSize.Width;
         int num3 = aTextRect.Width / 3;
         if ((aTextRect.Width / 2) > width)
         {
             int x = (aTextRect.Right - 1) - width;
             int y = aTextRect.Y + 1;
             Region clip = gr.Clip;
             Region region2 = new Region(aTextRect);
             region2.Intersect(clip);
             gr.Clip = region2;
             for (int i = length - 1; i >= 0; i--)
             {
                 using (Image image = anAppIcons.Images[anAppointment.IconIndexes[i]])
                 {
                     Rectangle rect = new Rectangle(x, y, width, width);
                     DrawSingleIcon(gr, rect, image);
                 }
                 x -= width;
                 if (num3 >= (x - aTextRect.X))
                 {
                     aTextRect.Width -= width * (length - i);
                     return aTextRect;
                 }
             }
             gr.ResetClip();
             region2.Dispose();
             region2 = null;
             if (clip != null)
             {
                 gr.Clip = clip;
             }
             aTextRect.Width -= width * length;
         }
     }
     return aTextRect;
 }
 public static void DoNoteIds(this WidgetMidiList widget, FloatRect grid, Graphics g)
 {
     var gs = g.Save();
       using (g.Clip = new Region(grid))
       {
     foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2))))
     {
       var r2=new FloatRect(i.XO-16,grid.Top,32,24);
       g.FillEllipse(Brushes.Black,r2);
       g.DrawText((i.Index / 4).ToString(),Color.White,widget.Font,r2);
     }
     foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3))))
     {
       var r2=new FloatRect(i.XO-16,grid.Top+32,32,24);
       g.FillEllipse(Brushes.Black,r2);
       g.DrawText((i.Index / 64).ToString(),Color.White,widget.Font,r2);
     }
     g.ResetClip();
       }
       g.Restore(gs);
 }
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                using (Region region = new Region(regionFillPath))
                {
                    g.ExcludeClip(region);
                    g.FillRectangle(shadowBrush, 0, 0, Width, Height);
                    g.ResetClip();
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawLine(borderPen, points[0], points[points.Count - 1]);
                g.DrawRectangleProper(borderPen, currentArea);
            }
            else
            {
                g.FillRectangle(shadowBrush, 0, 0, Width, Height);
            }

            base.Draw(g);
        }
Esempio n. 27
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.SetClip(cellBounds);
#pragma warning disable 618
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);
                Handler.Callback.OnPaint(Handler.Widget, args);
#pragma warning restore 618
                graphics.ResetClip();
                graphics.Restore(state);
            }
Esempio n. 28
0
        private static void MergeBitmaps(Bitmap bitmapFore, Bitmap bitmapBack)
        {
            // Define output polygon and coverage rectangle
            var curvePoints = new Point[] {
                new Point(833, 278), new Point(1876, 525),
                new Point(1876, 837), new Point(833, 830)
            };
            var outRect = new Rectangle(833, 278, 1043, 559);

            // Create clipping region from points
            System.Drawing.Drawing2D.GraphicsPath clipPath = new System.Drawing.Drawing2D.GraphicsPath();
            clipPath.AddPolygon(curvePoints);

            try
            {
                Bitmap imgB = bitmapBack;
                Bitmap imgF = bitmapFore;
                Bitmap m    = new Bitmap(bitmapBack);
                System.Drawing.Graphics myGraphic = System.Drawing.Graphics.FromImage(m);

                myGraphic.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                myGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                myGraphic.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

                // Draw foreground image into clipping region
                myGraphic.SetClip(clipPath, System.Drawing.Drawing2D.CombineMode.Replace);
                myGraphic.DrawImage(imgF, outRect);
                myGraphic.ResetClip();

                myGraphic.Save();
                m.Save(@"test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 29
0
        protected override void PaintMaximize(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled)
        {
            Size s = new Size(11, 9);
            Rectangle rm = GetSignRect(r, s);
            Region oldClip = g.Clip;

            using (Brush fill = DisplayHelp.CreateBrush(rm, ct.Foreground))
            {
                using (Pen pen = new Pen(ct.DarkShade))
                {
                    Rectangle inner = new Rectangle(rm.X + 3, rm.Y + 3, ct.DarkShade.IsEmpty ? 5 : 4, ct.DarkShade.IsEmpty ? 3 : 2);
                    g.SetClip(inner, CombineMode.Exclude);
                    DisplayHelp.DrawRoundedRectangle(g, pen, fill, rm.X, rm.Y, rm.Width, rm.Height, 1);
                    g.ResetClip();
                    g.DrawRectangle(pen, inner);
                }
            }

            if (oldClip != null)
            {
                g.Clip = oldClip;
                oldClip.Dispose();
            }
        }
        private void PaintAccountGlyph(Graphics g, Rectangle bounds, Account account)
        {
            Bitmap image = account.Type == AccountTypes.Regular ? _iconStandard : _iconApps;
            int tileWidth = _userFrame.Width;
            int tileHeight = (int)(((float)tileWidth / (float)image.Width) * image.Height);
            RectangleF clipRect = new RectangleF(bounds.X + 14, bounds.Y + 13, _userFrame.Width - 30, _userFrame.Height - 30);

            g.SetClip(clipRect);
            g.DrawImage(image, bounds.X, bounds.Y + 10, tileWidth, tileHeight);
            g.ResetClip();

            g.DrawImage(_userFrame, new Rectangle(bounds.X, bounds.Y, _userFrame.Width, _userFrame.Height));

            Point addressPoint = new Point(bounds.X + _userFrame.Width, bounds.Y);
            Rectangle addressRect = new Rectangle(addressPoint.X, addressPoint.Y, bounds.Width - _userFrame.Width, bounds.Height);
            Rectangle textExtent = _rendererListSmall.GetTextExtent(g, addressRect, account.FullAddress, TextFormatFlags.Left);
            int center = (_userFrame.Height - textExtent.Height) / 2;

            if (account.Default) {
                Rectangle defaultExtent = _rendererListSmall.GetTextExtent(g, addressRect, Locale.Current.JumpList.DefaultAccount, TextFormatFlags.Left);

                center -= (defaultExtent.Height / 2) + 4; // 4 is the additional padding we're adding
            }

            addressRect.Offset(0, center);

            _rendererListSmall.DrawText(g, addressRect, account.FullAddress, false, TextFormatFlags.Left);

            if (account.Default) {
                addressRect.Offset(0, textExtent.Height + 4);

                _rendererListSmall.DrawText(g, addressRect, Locale.Current.JumpList.DefaultAccount, true, TextFormatFlags.Left);
            }
        }
        /// <summary>
        /// Render all the <see cref="GraphPane"/> objects in the <see cref="PaneList"/> to the
        /// specified graphics device.
        /// </summary>
        /// <remarks>This method should be part of the Paint() update process.  Calling this routine
        /// will redraw all
        /// features of all the <see cref="GraphPane"/> items.  No preparation is required other than
        /// instantiated <see cref="GraphPane"/> objects that have been added to the list with the
        /// <see cref="Add"/> method.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        public override void Draw( Graphics g )
        {
            // Draw the pane border & background fill, the title, and the GraphObj objects that lie at
            // ZOrder.GBehindAll
            base.Draw( g );

            if ( _rect.Width <= 1 || _rect.Height <= 1 )
                return;

            float scaleFactor = CalcScaleFactor();

            // Clip everything to the rect
            g.SetClip( _rect );

            // For the MasterPane, All GraphItems go behind the GraphPanes, except those that
            // are explicity declared as ZOrder.AInFront
            _graphObjList.Draw( g, this, scaleFactor, ZOrder.G_BehindChartFill );
            _graphObjList.Draw( g, this, scaleFactor, ZOrder.E_BehindCurves );
            _graphObjList.Draw( g, this, scaleFactor, ZOrder.D_BehindAxis );
            _graphObjList.Draw( g, this, scaleFactor, ZOrder.C_BehindChartBorder );

            // Reset the clipping
            g.ResetClip();

            foreach ( GraphPane pane in _paneList )
                pane.Draw( g );

            // Clip everything to the rect
            g.SetClip( _rect );

            _graphObjList.Draw( g, this, scaleFactor, ZOrder.B_BehindLegend );

            // Recalculate the legend rect, just in case it has not yet been done
            // innerRect is the area for the GraphPane's
            RectangleF innerRect = CalcClientRect( g, scaleFactor );
            _legend.CalcRect( g, this, scaleFactor, ref innerRect );
            //this.legend.SetLocation( this,

            _legend.Draw( g, this, scaleFactor );

            _graphObjList.Draw( g, this, scaleFactor, ZOrder.A_InFront );

            // Reset the clipping
            g.ResetClip();
        }
Esempio n. 32
0
		private void DrawVisibleBarItems(Graphics g)
		{			
	//		int requiredHeight = 0;
			Bar bar = m_pBars[m_ActiveBarIndex];

			if(bar.Items.Count > 0){            
				g.SetClip(bar.BarClientRect);

				for(int i=bar.FirstVisibleIndex;i<bar.Items.Count;i++){
					Item item = bar.Items[i];
					Point mPt = this.PointToClient(Control.MousePosition);
					bool hot  = item.Bounds.Contains(mPt) && bar.ItemFullyVisible(item) && !this.UpScrollBtnRect.Contains(mPt)&& !this.DownScrollBtnRect.Contains(mPt);				    
					DrawItem(g,item,bar,hot,Control.MouseButtons == MouseButtons.Left);

	//				requiredHeight += item.Bounds.Height;				
				}

				g.ResetClip();
			}
		}
Esempio n. 33
0
    /// <summary>
    /// Paints the background and the empty page.
    /// </summary>
    internal void PaintBackground(Graphics gfx)
    {
      // Draw sharp paper borders and shadow.
      gfx.SmoothingMode = SmoothingMode.None;
      //gfx.SetCompositingMode(CompositingModeSourceOver); // CompositingModeSourceCopy
      //gfx.SetCompositingQuality(CompositingQualityHighQuality);

      gfx.TranslateTransform(-this.posOffset.X, -this.posOffset.Y);

      // Draw outer area. Use clipping to prevent flickering of page interior.
      gfx.SetClip(new Rectangle(virtualPage.X, virtualPage.Y, virtualPage.Width + 3, virtualPage.Height + 3), CombineMode.Exclude);
      gfx.SetClip(new Rectangle(virtualPage.X + virtualPage.Width + 1, virtualPage.Y, 2, 2), CombineMode.Union);
      gfx.SetClip(new Rectangle(virtualPage.X, virtualPage.Y + virtualPage.Height + 1, 2, 2), CombineMode.Union);
      gfx.Clear(this.desktopColor);

#if DRAW_X
      gfx.DrawLine(Pens.Blue, 0, 0, virtualCanvas.Width, virtualCanvas.Height);
      gfx.DrawLine(Pens.Blue, virtualCanvas.Width, 0, 0, virtualCanvas.Height);
#endif
      gfx.ResetClip();

#if !DRAW_BMP
      // Fill page interior.
      SolidBrush brushPaper = new SolidBrush(this.pageColor);
      gfx.FillRectangle(brushPaper, virtualPage.X + 1, virtualPage.Y + 1, virtualPage.Width - 1, virtualPage.Height - 1);
#endif

      //// draw non printable area
      //if (m_ShowNonPrintableArea)
      //{
      //SolidBrush brushNPA(+DESKTOP::QuerySysColor((SYSCLR_3DLIGHT)) | 0xFF000000);
      //
      //gfx.FillRectangle(&brushNPA, virtualPage.X, virtualPage.Y, virtualPage.Width, rcPrintableArea.Y - virtualPage.Y);
      //gfx.FillRectangle(&brushNPA, virtualPage.X, virtualPage.Y, rcPrintableArea.X - virtualPage.X, virtualPage.Height);
      //gfx.FillRectangle(&brushNPA, rcPrintableArea.X + rcPrintableArea.Width,
      //virtualPage.Y, virtualPage.X + virtualPage.Width - (rcPrintableArea.X + rcPrintableArea.Width), virtualPage.Height);
      //gfx.FillRectangle(&brushNPA, virtualPage.X, rcPrintableArea.Y + rcPrintableArea.Height,
      //virtualPage.Width, virtualPage.Y + virtualPage.Height - (rcPrintableArea.Y + rcPrintableArea.Height));
      //}
      //this.DrawDash(gfx, virtualPage);

      // Draw page border and shadow.
      Pen penPaperBorder = SystemPens.WindowText;
      Brush brushShadow = SystemBrushes.ControlDarkDark;
      gfx.DrawRectangle(penPaperBorder, virtualPage);
      gfx.FillRectangle(brushShadow, virtualPage.X + virtualPage.Width + 1, virtualPage.Y + 2, 2, virtualPage.Height + 1);
      gfx.FillRectangle(brushShadow, virtualPage.X + 2, virtualPage.Y + virtualPage.Height + 1, virtualPage.Width + 1, 2);
    }
Esempio n. 34
0
 protected virtual void DrawExtra(Graphics g, Rectangle r)
 {
     if (hscrollBar.Visible && vscrollBar.Visible)
     {
         g.ResetClip();
         g.FillRectangle(SystemBrushes.Control, r.Width-vscrollBar.Width-borderWid, r.Height-hscrollBar.Height-borderWid, vscrollBar.Width, hscrollBar.Height);
     }
 }
Esempio n. 35
0
        /// <summary>
        /// Draws a Toolstrip split-button
        /// </summary>
        /// <param name="Item">The Toolstrip split-button</param>
        /// <param name="Link">The Graphics object to handle</param>
        /// <param name="Parent">The parent Toolstrip</param>
        public void IDrawToolstripSplitButton(ToolStripSplitButton Item, Graphics Link, ToolStrip Parent)
        {
            if (Item.Selected || Item.DropDownButtonPressed || Item.ButtonPressed)
            {
                Rectangle Area = new Rectangle(
                                        new Point(0, 0),
                                        new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1)
                                        );

                Blend BackBlend = GetBlend(Item, ButtonType.SplitButton);
                Color[] NormalRender = new Color[] { _sBtnManager.HoverBackgroundTop, _sBtnManager.HoverBackgroundBottom };
                Color[] Render = GetButtonBackColor(Item, ButtonType.SplitButton);

                using (GraphicsPath Path = CreateDrawingPath(Area, _sBtnManager.Curve))
                {
                    Link.SetClip(Path);

                    if (!Item.DropDownButtonPressed)
                    {
                        PaintBackground(
                                        Link,
                                        Area,
                                        NormalRender[0],
                                        NormalRender[1],
                                        _sBtnManager.BackgroundAngle,
                                        BackBlend
                                        );
                    }
                    else
                    {
                        PaintBackground(
                                        Link,
                                        Area,
                                        Render[0],
                                        Render[1]
                                        );
                    }

                    if (Item.ButtonPressed)
                    {
                        Rectangle ButtonArea = new Rectangle(
                                                    new Point(0, 0),
                                                    new Size(Item.ButtonBounds.Width, Item.ButtonBounds.Height - 1)
                                                    );

                        PaintBackground(
                                        Link,
                                        ButtonArea,
                                        Render[0],
                                        Render[1],
                                        _sBtnManager.BackgroundAngle,
                                        _sBtnManager.BackgroundBlend
                                        );
                    }

                    Link.ResetClip();

                    Link.SmoothingMode = SmoothingMode.AntiAlias;

                    using (GraphicsPath OBPath = CreateDrawingPath(Area, _sBtnManager.Curve))
                    {
                        Color TopColor = (Item.DropDownButtonPressed ? _mnuManager.MenustripButtonBorder : _sBtnManager.BorderTop);
                        Color BottomColor = (Item.DropDownButtonPressed ? _mnuManager.MenustripButtonBorder : _sBtnManager.BorderBottom);

                        PaintBorder(
                                    Link,
                                    OBPath,
                                    Area,
                                    TopColor,
                                    BottomColor,
                                    _sBtnManager.BorderAngle,
                                    _sBtnManager.BorderBlend
                                    );

                        OBPath.Dispose();
                    }

                    if (!Item.DropDownButtonPressed)
                    {
                        Area.Inflate(-1, -1);

                        using (GraphicsPath IBPath = CreateDrawingPath(Area, _sBtnManager.Curve))
                        {
                            using (SolidBrush InnerBorder = new SolidBrush(_sBtnManager.InnerBorder))
                            {
                                PaintBorder(
                                            Link,
                                            IBPath,
                                            InnerBorder
                                            );

                                Link.DrawRectangle(
                                                new Pen(_sBtnManager.InnerBorder),
                                                new Rectangle(
                                                            Item.ButtonBounds.Width,
                                                            1,
                                                            2,
                                                            Item.ButtonBounds.Height - 3
                                                            )
                                                    );

                                InnerBorder.Dispose();
                            }
                        }

                        using (LinearGradientBrush SplitLine = new LinearGradientBrush(
                                                                            new Rectangle(0, 0, 1, Item.Height),
                                                                            _sBtnManager.BorderTop,
                                                                            _sBtnManager.BorderBottom,
                                                                            _sBtnManager.BackgroundAngle
                                                                            ))
                        {
                            if (_sBtnManager.BackgroundBlend != null)
                            {
                                SplitLine.Blend = _sBtnManager.BackgroundBlend;
                            }

                            Link.DrawLine(
                                        new Pen(SplitLine),
                                        Item.ButtonBounds.Width + 1,
                                        0,
                                        Item.ButtonBounds.Width + 1,
                                        Item.Height - 1
                                        );

                            SplitLine.Dispose();
                        }
                    }

                    Link.SmoothingMode = SmoothingMode.Default;
                }
            }

            Int32 ArrowSize = 5;

            if (
                (_sBtnManager.ArrowDisplay == ArrowDisplay.Always) ||
                (_sBtnManager.ArrowDisplay == ArrowDisplay.Hover && Item.Selected)
                )
            {
                using (GraphicsPath TrianglePath = CreateTrianglePath(
                                                new Rectangle(
                                                        Item.DropDownButtonBounds.Left + (ArrowSize / 2) - 1,
                                                        (Item.DropDownButtonBounds.Height / 2) - (ArrowSize / 2) - 3,
                                                        ArrowSize * 2,
                                                        ArrowSize * 2
                                                        ),
                                                ArrowSize,
                                                ArrowDirection.Down
                                                ))
                {
                    Link.FillPath(new SolidBrush(_sBtnManager.ArrowColor), TrianglePath);

                    TrianglePath.Dispose();
                }

            }
        }
Esempio n. 36
0
        private static void DrawHoldStep(System.Drawing.Graphics g, IReadOnlyPreviewDisplayEnvironment env, NoteBase begin, NoteBase end)
        {
            using (var clipPath = new GraphicsPath())
            {
                clipPath.AddEllipse(env.Circle);
                g.Clip = new Region(clipPath);
            }

            var step = 5;
            // 円の中央が0
            var rbegin  = (1 - ((begin.Timing - env.TimingOffset) / env.TimingLength).BarRatio) * env.Radius;
            var rend    = (1 - ((end.Timing - env.TimingOffset) / env.TimingLength).BarRatio) * env.Radius;
            var dr      = rbegin - rend;
            var dlleft  = end.Lane.RawLane - begin.Lane.RawLane;
            var dlright = (end.Lane.RawLane + end.NoteSize.Size) - (begin.Lane.RawLane + begin.NoteSize.Size);
            var psLeft  = new List <Point>();
            var psRight = new List <Point>();

            var curR = rbegin - step;

            while (true)
            {
                if (curR <= 0 || curR <= rend)
                {
                    break;
                }

                if (dlleft != 0 || curR <= step)
                {
                    var radLeft = MyMath.DegToRad(CalcCsDeg((float)(begin.Lane.RawLane * 6 + (rbegin - curR) / dr * dlleft * 6)));
                    psLeft.Add(new Point((int)(env.CenterPoint.X + curR * Math.Cos(radLeft)), (int)(env.CenterPoint.Y + curR * Math.Sin(radLeft))));
                }
                if (dlright != 0 || curR <= step)
                {
                    var radRight = MyMath.DegToRad(CalcCsDeg((float)((begin.Lane.RawLane + begin.NoteSize.Size) * 6 + (rbegin - curR) / dr * dlright * 6)));
                    psRight.Add(new Point((int)(env.CenterPoint.X + curR * Math.Cos(radRight)), (int)(env.CenterPoint.Y + curR * Math.Sin(radRight))));
                }
                curR -= step;
            }

            var path = new GraphicsPath();

            if (psLeft.Any())
            {
                path.AddLines(psLeft.ToArray());
            }
            if (rend > 0)
            {
                path.AddArc(
                    (float)(env.CenterPoint.X - rend),
                    (float)(env.CenterPoint.Y - rend),
                    (float)(2 * rend),
                    (float)(2 * rend),
                    CalcCsDeg(end.Lane.NormalizedLane * 6),
                    CalcCsDegSize(end.NoteSize.Size * 6));
            }
            if (psRight.Any())
            {
                path.AddLines(psRight.Reverse <Point>().ToArray());
            }
            if (rbegin > 0)
            {
                path.AddArc(
                    (float)(env.CenterPoint.X - rbegin),
                    (float)(env.CenterPoint.Y - rbegin),
                    (float)(2 * rbegin),
                    (float)(2 * rbegin),
                    CalcCsDeg((begin.Lane.NormalizedLane + begin.NoteSize.Size) * 6),
                    CalcCsDegSize(-begin.NoteSize.Size * 6));
            }

            // 色は決め打ちではなく,名前つけて一か所にまとめた方がいいかもね
            using (var sb = new SolidBrush(Color.FromArgb(200, 200, 175, 90)))
            {
                try
                {
                    g.FillPath(sb, path);
                }
                catch (Exception) { }
            }
            path.Dispose();
            g.ResetClip();
        }
Esempio n. 37
0
        private void DrawColumnHeaders(Graphics gr)
        {
            PerformanceAnalyzer.Start("DrawColumnHeaders");
            ReorderColumnState reorder = Input as ReorderColumnState;
            int x = 0;
            TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false);
            gr.TranslateTransform(-OffsetX, 0);
            foreach (TreeColumn c in Columns)
            {
                if (c.IsVisible)
                {
                    if (x >= OffsetX && x - OffsetX < this.Bounds.Width)// skip invisible columns
                    {
                        Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1);
                        gr.SetClip(rect);
                        bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c));
                        c.Draw(gr, rect, ColumnFont, pressed, _hotColumn == c);
                        gr.ResetClip();

                        if (reorder != null && reorder.DropColumn == c)
                            TreeColumn.DrawDropMark(gr, rect);
                    }
                    x += c.Width;
                }
            }

            if (reorder != null)
            {
                if (reorder.DropColumn == null)
                    TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight));
                gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X +  + reorder.DragOffset, reorder.Location.Y));
            }
            PerformanceAnalyzer.Finish("DrawColumnHeaders");
        }
Esempio n. 38
0
        private RectangleF DrawBar(Graphics g, Color back, Color fore, RectangleF rect, float startSeg, float segWidth, string text, bool visible)
        {
            var subRect = GetSubrect(rect, startSeg, segWidth);
            subRect.Height = barHeight;

            if (subRect.Contains(markerPos) && visible && showMarker && markerPos.Y < ClientRectangle.Height - pipRadius*6)
            {
                back = Color.LightYellow;
                fore = Color.Black;
                Cursor = Cursors.Hand;
            }

            if (visible)
            {
                using(var brush = new SolidBrush(back))
                    g.FillRectangle(brush, subRect.X, subRect.Y, subRect.Width, subRect.Height);

                using(var pen = new Pen(Brushes.Black, barBorder))
                    g.DrawRectangle(pen, subRect.X, subRect.Y, subRect.Width, subRect.Height);

                var p = new Pen(Color.FromArgb(230, 230, 230), 1);

                g.DrawLine(p, new PointF(subRect.Left, subRect.Bottom), new PointF(subRect.Left, rect.Bottom - pipRadius * 6));
                g.DrawLine(p, new PointF(subRect.Right, subRect.Bottom), new PointF(subRect.Right, rect.Bottom - pipRadius * 6));

                p.Dispose();
            }

            var stringSize = g.MeasureString(text, barFont);

            float left = subRect.X + barPadding;

            if(left < barPadding)
                left = Math.Min(barPadding, Math.Max(subRect.X + subRect.Width - barPadding * 2 - stringSize.Width, left));

            var textRect = new RectangleF(left, subRect.Y + barPadding,
                                           subRect.Width - barPadding*2, subRect.Height - barPadding);

            textRect.Height = Math.Min(textRect.Height, rect.Height - pipRadius * 6);

            if (visible)
            {
                g.Clip = new Region(textRect);
                using (var brush = new SolidBrush(fore))
                    g.DrawString(text, barFont, brush, textRect.X, textRect.Y);
                g.ResetClip();
            }

            var ret = rect;
            ret.X = subRect.X;
            ret.Y = subRect.Y + subRect.Height;
            ret.Width = subRect.Width;
            ret.Height = rect.Height - subRect.Height;

            return ret;
        }
Esempio n. 39
0
        /// <summary>
        /// 打印指定页面
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">绘图操作对象</param>
        /// <param name="MainClipRect">主剪切矩形</param>
        /// <param name="PrintHead">是否打印页眉</param>
        /// <param name="PrintTail">是否打印页脚</param>
        public virtual void DrawPage(
            PrintPage myPage,
            System.Drawing.Graphics g,
            System.Drawing.Rectangle MainClipRect,
            bool UseMargin)
        {
            int LeftMargin   = 0;
            int TopMargin    = 0;
            int RightMargin  = 0;
            int BottomMargin = 0;

            if (UseMargin)
            {
                LeftMargin   = myPages.LeftMargin;
                TopMargin    = myPages.TopMargin;
                RightMargin  = myPages.RightMargin;
                BottomMargin = myPages.BottomMargin;
            }

            this.OnBeforeDrawPage(myPage, g);

            g.PageUnit = myDocument.DocumentGraphicsUnit;
            System.Drawing.Rectangle ClipRect = System.Drawing.Rectangle.Empty;
            if (this.bolDrawHead)
            {
                if (myPages.HeadHeight > 0)
                {
                    g.ResetTransform();
                    g.ResetClip();

                    ClipRect = new System.Drawing.Rectangle(0, 0, myPage.Width, myPages.HeadHeight);
                    g.TranslateTransform(LeftMargin, TopMargin);

                    g.SetClip(new System.Drawing.Rectangle(
                                  ClipRect.Left,
                                  ClipRect.Top,
                                  ClipRect.Width + 1,
                                  ClipRect.Height + 1));

                    myDocument.DrawHead(g, ClipRect);
                    //DesignPaintEventArgs e = new DesignPaintEventArgs(g, ClipRect);
                    //myDocument.RefreshView(e);
                }
                g.ResetClip();
                g.ResetTransform();
            }

            ClipRect = new System.Drawing.Rectangle(
                0,
                myPages.Top,
                myPage.Width,
                myPages.Height);

            if (!MainClipRect.IsEmpty)
            {
                ClipRect = System.Drawing.Rectangle.Intersect(ClipRect, MainClipRect);
            }
            if (!ClipRect.IsEmpty)
            {
                g.TranslateTransform(
                    LeftMargin,
                    TopMargin - myPage.Top + myPages.HeadHeight);

                //System.Drawing.Drawing2D.GraphicsPath clipPath = new System.Drawing.Drawing2D.GraphicsPath();
                //clipPath.AddRectangle( ClipRect );
                //g.SetClip( clipPath );

                //g.TranslateTransform( myPages.LeftMargin , myPages.TopMargin - myPage.Top + myPages.HeadHeight );

                System.Drawing.RectangleF rect = DrawerUtil.FixClipBounds(
                    g,
                    ClipRect.Left,
                    ClipRect.Top,
                    ClipRect.Width,
                    ClipRect.Height);

                rect.Offset(-4, -4);
                //rect.Offset(-4, -100);
                rect.Width  = rect.Width + 8;
                rect.Height = rect.Height + 8;
                g.SetClip(rect);

//				System.Drawing.RectangleF rect2 = g.ClipBounds ;
//				if( rect.Top < rect2.Top )
//				{
//					float dy = rect2.Top - rect.Top ;
//					rect.Y = rect.Y - dy * 2 ;
//					rect.Height = rect.Height + dy * 4 ;
//				}
//				g.SetClip( rect );

                myDocument.DrawDocument(g, ClipRect);
                //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                //myDocument.RefreshView( e );
            }

            if (this.bolDrawFooter)
            {
                if (myPages.FooterHeight > 0)
                {
                    g.ResetClip();
                    g.ResetTransform();

                    ClipRect = new System.Drawing.Rectangle(
                        0,
                        myPages.DocumentHeight - myPages.FooterHeight,
                        myPage.Width,
                        myPages.FooterHeight);

                    int dy = 0;
                    if (UseMargin)
                    {
                        dy = myPages.PaperHeight - myPages.BottomMargin - myPages.DocumentHeight;
                    }
                    else
                    {
                        dy = myPages.PaperHeight - myPages.BottomMargin - myPages.DocumentHeight - myPages.TopMargin;
                    }
                    g.TranslateTransform(
                        LeftMargin,
                        dy);

                    g.SetClip(new System.Drawing.Rectangle(
                                  ClipRect.Left,
                                  ClipRect.Top,
                                  ClipRect.Width + 1,
                                  ClipRect.Height + 1));

                    myDocument.DrawFooter(g, ClipRect);
                    //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                    //myDocument.RefreshView( e );
                }
            } //if( this.bolDrawFooter )
        }     //public void DrawPage()
Esempio n. 40
0
        /// <summary>
        /// 绘制续打区域
        /// </summary>
        /// <param name="g">图形绘制对象</param>
        /// <param name="ClipRectangle">剪切矩形</param>
        /// <param name="Position">续打位置</param>
        /// <param name="FillColor">填充色</param>
        protected void DrawJumpPrintArea(
            System.Drawing.Graphics g,
            System.Drawing.Rectangle ClipRectangle,
            JumpPrintInfo Position,
            System.Drawing.Color FillColor)
        {
            if (Position == null || Position.Page == null || Position.Enabled == false)
            {
                return;
            }

            MultiPageTransform trans = ( MultiPageTransform )this.myTransform;

            int pos = -1;

            foreach (SimpleRectangleTransform item in trans)
            {
                if (item.ContentStyle == PageContentPartyStyle.Body &&
                    item.PageObject == Position.Page)
                {
                    pos = item.UnTransformPoint(0, Position.Position + ( int )item.DescRectF.Top).Y;
                }
            }
            if (pos < 0)
            {
                return;
            }
            //int pos = trans.UnTransformY( Position );

            if (pos >= 0)
            {
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                    0,
                    0,
                    this.ClientSize.Width,
                    pos);

                System.Drawing.Rectangle rect2 = ClipRectangle;
                if (ClipRectangle.IsEmpty)
                {
                    rect2 = rect;
                }
                else
                {
                    rect2 = System.Drawing.Rectangle.Intersect(rect, rect2);
                }
                if (!rect2.IsEmpty)
                {
                    g.ResetClip();
                    g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
                    g.ResetTransform();
                    using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(FillColor))
                    {
                        g.FillRectangle(b, rect2);
                    }
                    using (System.Drawing.Pen p =
                               new System.Drawing.Pen(System.Drawing.Color.Blue, 2))
                    {
                        g.DrawLine(
                            p,
                            0,
                            rect.Bottom - 1,
                            this.ClientSize.Width,
                            rect.Bottom - 1);
                    }
                }
            }
        }
Esempio n. 41
0
        private void RenderSection(int depth, Graphics g, RectangleF rect, Section section, bool visible, float lastVisibleHeight)
        {
            float start = 0.0f;

            float[] minwidths = new float[section.subsections.Count];
            float[] widths = new float[section.subsections.Count];
            float maxwidth = 0.0f;
            float totalwidth = 0.0f;
            for (int i = 0; i < section.subsections.Count; i++)
            {
                // initial widths are minwidth, used to 'proportionally' size sections.
                // all that matters here is the relative proportions and that it's >= minwidth,
                // it gets sized up or down to fit later.
                minwidths[i] = MinSectionSize(g, section.subsections[i]);
                widths[i] = minwidths[i];

                maxwidth = Math.Max(maxwidth, minwidths[i]);
                totalwidth += widths[i];
            }

            float scale = rect.Width / totalwidth;

            // if we have space free, scale everything up the same
            if (totalwidth < rect.Width)
            {
                for (int i = 0; i < section.subsections.Count; i++)
                    widths[i] *= scale;
            }
            else
            {
                // scale everything down to fit (this will reduce some below minwidth)
                for (int i = 0; i < section.subsections.Count; i++)
                    widths[i] *= scale;

                // search for sections that are > their min width, and skim off the top.
                for (int i = 0; i < section.subsections.Count; i++)
                {
                    // found a section that's too small
                    if (widths[i] < minwidths[i])
                    {
                        // we try and skim an equal amount off every section, so the scaling
                        // is nice and uniform rather than left-focussed
                        float missing = minwidths[i] - widths[i];
                        float share = missing / (float)(section.subsections.Count - 1);

                        bool slack = false;

                        // keep going trying to find some slack and skimming it off
                        int iters = 0;
                        do
                        {
                            slack = false;
                            iters++;
                            if (iters == 10) break;
                            for (int j = 0; j < section.subsections.Count; )
                            {
                                // ignore current section
                                if (i == j)
                                {
                                    j++;
                                    continue;
                                }

                                // if this section has free space
                                if (widths[j] > minwidths[j])
                                {
                                    float avail = widths[j] - minwidths[j];

                                    // skim off up as much as is available, up to the share per section
                                    float delta = Math.Max(0.1f, Math.Min(avail, share));
                                    widths[i] += delta;
                                    widths[j] -= delta;
                                    missing -= delta;

                                    // if we didn't skim off our share, recalculate how much we'll need to
                                    // skim off each, and start again
                                    if (avail < share)
                                    {
                                        share = missing / (float)(section.subsections.Count - 1);
                                        j = 0;
                                        continue;
                                    }

                                    slack = true;
                                }

                                j++;
                            }
                            // keep going while there are sections with slack, and we need to make some up.
                            // ie. if we find all our missing space then we can finish, but also if we haven't
                            // found enough but there's nothing to give, we also give up.
                        } while (slack && missing > 0.0f);
                    }
                }
            }

            for (int i = 0; i < section.subsections.Count; i++)
                widths[i] /= rect.Width;

            var clipRect = rect;
            clipRect.Height -= pipRadius * 6;

            for (int i = 0; i < section.subsections.Count; i++)
            {
                var s = section.subsections[i];
                if (s.Name.Length > 0)
                {
                    var col = depth % 2 == 0 ? lightBack : darkBack;
                    var textcol = Color.Black;

                    if (s.color.A > 0)
                    {
                        col = s.color;
                        textcol = s.textcolor;
                    }

                    g.Clip = new Region(clipRect);
                    var childRect = DrawBar(g, col, textcol, rect, start, widths[i], (s.Expanded ? "- " : "+ ") + s.Name, visible);
                    g.ResetClip();

                    RenderSection(depth + 1, g, childRect, s, visible && s.Expanded, visible ? childRect.Top : lastVisibleHeight);

                    var backRect = GetSubrect(childRect, 0.0f, 1.0f);
                    backRect.Y += barBorder / 2;
                    backRect.Height = barHeight;

                    LinearGradientBrush brush = new LinearGradientBrush(new PointF(0, backRect.Y),
                                                                        new PointF(0, backRect.Y + backRect.Height + 1),
                                                                        Color.FromArgb(255, darkBack), Color.FromArgb(0, darkBack));

                    if (visible && s.Expanded && (s.subsections == null || s.subsections.Count == 0))
                    {
                        g.Clip = new Region(clipRect);
                        g.FillRectangle(brush, backRect);
                        g.ResetClip();
                    }

                    brush.Dispose();

                    s.lastRect = childRect;
                    s.lastRect.Y = rect.Y;
                    s.lastRect.Height = childRect.Y - rect.Y;

                    if (!visible) s.lastRect.Height = 0;
                }
                else
                {
                    var backRect = GetSubrect(rect, start, widths[i]);
                    backRect.Y += barBorder/2;
                    backRect.Height = barHeight;

                    LinearGradientBrush brush = new LinearGradientBrush(new PointF(0, backRect.Y),
                                                                        new PointF(0, backRect.Y + backRect.Height + 1),
                                                                        Color.FromArgb(255, darkBack), Color.FromArgb(0, darkBack));

                    if (visible)
                    {
                        g.Clip = new Region(clipRect);
                        g.FillRectangle(brush, backRect);
                        g.ResetClip();
                    }

                    brush.Dispose();

                    int highlight = -1;

                    var highlightBarRect = rect;
                    highlightBarRect.Y = highlightBarRect.Bottom - pipRadius * 4;
                    highlightBarRect.Height = pipRadius * 2;

                    if(s.draws != null)
                    {
                        for (int d = 0; d < s.draws.Count; d++)
                        {
                            if (m_History != null)
                            {
                                foreach (var u in m_History)
                                {
                                    if (u.eventID == s.draws[d].eventID)
                                    {
                                        var barcol = Color.Black;

                                        int type = 2;

                                        DrawPip(g, barcol, highlightBarRect, type, d, s.draws.Count, start, widths[i], "");
                                    }
                                }
                            }
                            else if (m_HighlightUsage != null)
                            {
                                foreach (var u in m_HighlightUsage)
                                {
                                    if ((u.eventID == s.draws[d].eventID) ||
                                        (u.eventID < s.draws[d].eventID && s.draws[d].events.Length > 0 && u.eventID >= s.draws[d].events[0].eventID))
                                    {
                                        var barcol = Color.Black;

                                        int type = 2;

                                        if (u.usage == ResourceUsage.Barrier)
                                            type = 6;

                                        DrawPip(g, barcol, highlightBarRect, type, d, s.draws.Count, start, widths[i], "");
                                    }
                                }
                            }

                            s.lastUsage[d] = false;
                            s.lastVisible[d] = visible;
                        }

                        for (int d = 0; d < s.draws.Count; d++)
                        {
                            if (m_History != null)
                            {
                                foreach (var u in m_History)
                                {
                                    if (u.eventID == s.draws[d].eventID)
                                    {
                                        if (u.EventPassed())
                                        {
                                            DrawPip(g, Color.Lime, highlightBarRect, 1, d, s.draws.Count, start, widths[i], "");
                                            MarkWrite(s.draws[d].eventID);
                                        }
                                        else
                                        {
                                            DrawPip(g, Color.Crimson, highlightBarRect, 1, d, s.draws.Count, start, widths[i], "");
                                            MarkRead(s.draws[d].eventID);
                                        }

                                        s.lastUsage[d] = true;
                                    }
                                }
                            }
                            else if (m_HighlightUsage != null)
                            {
                                foreach (var u in m_HighlightUsage)
                                {
                                    if ((u.eventID == s.draws[d].eventID) ||
                                        (u.eventID < s.draws[d].eventID && s.draws[d].events.Length > 0 && u.eventID >= s.draws[d].events[0].eventID))
                                    {
                                        // read/write
                                        if (
                                            ((int)u.usage >= (int)ResourceUsage.VS_RWResource &&
                                             (int)u.usage <= (int)ResourceUsage.CS_RWResource) ||
                                            u.usage == ResourceUsage.GenMips ||
                                            u.usage == ResourceUsage.Copy ||
                                            u.usage == ResourceUsage.Resolve)
                                        {
                                            DrawPip(g, Color.Orchid, highlightBarRect, 3, d, s.draws.Count, start, widths[i], "");
                                            DrawPip(g, Color.Lime, highlightBarRect, 4, d, s.draws.Count, start, widths[i], "");
                                            MarkWrite(s.draws[d].eventID);
                                        }
                                        // write
                                        else if (u.usage == ResourceUsage.SO ||
                                                 u.usage == ResourceUsage.DepthStencilTarget ||
                                                 u.usage == ResourceUsage.ColourTarget ||
                                                 u.usage == ResourceUsage.CopyDst ||
                                                 u.usage == ResourceUsage.ResolveDst)
                                        {
                                            DrawPip(g, Color.Orchid, highlightBarRect, 1, d, s.draws.Count, start, widths[i], "");
                                            MarkWrite(s.draws[d].eventID);
                                        }
                                        // clear
                                        else if (u.usage == ResourceUsage.Clear)
                                        {
                                            DrawPip(g, Color.Silver, highlightBarRect, 1, d, s.draws.Count, start, widths[i], "");
                                            MarkWrite(s.draws[d].eventID);
                                        }
                                        // barrier
                                        else if (u.usage == ResourceUsage.Barrier)
                                        {
                                            DrawPip(g, Color.Tomato, highlightBarRect, 5, d, s.draws.Count, start, widths[i], "");
                                            MarkWrite(s.draws[d].eventID);
                                        }
                                        // read
                                        else
                                        {
                                            DrawPip(g, Color.Lime, highlightBarRect, 1, d, s.draws.Count, start, widths[i], "");
                                            MarkRead(s.draws[d].eventID);
                                        }

                                        s.lastUsage[d] = true;
                                    }
                                }
                            }
                        }

                        for (int d = 0; d < s.draws.Count; d++)
                        {
                            if (s.draws[d].eventID == m_Core.CurEvent)
                                highlight = d;

                            if (visible)
                            {
                                g.Clip = new Region(clipRect);

                                if (s.draws[d].eventID != m_Core.CurEvent)
                                    s.lastPoss[d] = DrawPip(g, Color.Blue, rect, 0, d, s.draws.Count, start, widths[i], s.draws[d].name);

                                g.ResetClip();
                            }
                            else
                            {
                                s.lastPoss[d] = DrawPip(g, Color.Blue, rect, 999, d, s.draws.Count, start, widths[i], s.draws[d].name);
                            }
                        }
                    }

                    if (highlight >= 0)
                    {
                        var subRect = GetSubrect(rect, start, widths[i]);
                        subRect.X += pipRadius;
                        subRect.Y += pipPaddingY;
                        subRect.Width -= pipRadius * 2;
                        subRect.Height = pipRadius * 2;

                        float delta = (float)(highlight + 1) / (float)(s.draws.Count + 1);

                        m_CurrentMarker = new PointF(subRect.X + delta * Math.Max(0, subRect.Width), lastVisibleHeight);
                    }

                    if (highlight >= 0 && visible && s.draws != null)
                    {
                        g.Clip = new Region(clipRect);

                        s.lastPoss[highlight] = DrawPip(g, Color.LightGreen, rect, 0, highlight, s.draws.Count, start, widths[i], s.draws[highlight].name);

                        g.ResetClip();
                    }

                    s.lastRect = backRect;

                    if (!visible) s.lastRect.Height = 0;
                }

                start += widths[i];
            }
        }
Esempio n. 42
0
        /// <summary>
        /// Override OnPaint method
        /// </summary>
        /// <param name="e">paint event argument</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;

            int hh = (int)Math.Round(Height / 2f);

            GraphicsToolkit.FillTriangle(g, 8, new Point(10, hh), GraphicsToolkit.TriangleDirection.Left,
                                         viewScroll > 0 ? SystemPens.WindowText : SystemPens.GrayText);

            int max = this.maxWidth - this.ClientRectangle.Width + rightPadding + 10;

            GraphicsToolkit.FillTriangle(g, 8, new Point(20, hh), GraphicsToolkit.TriangleDirection.Right,
                                         viewScroll < max ? SystemPens.WindowText : SystemPens.GrayText);

            var controlStyle = this.grid.ControlStyle;

            var borderPen        = this.resourceManager.GetPen(controlStyle[ControlAppearanceColors.SheetTabBorder]);
            var defaultTextBrush = this.resourceManager.GetBrush(this.ForeColor);

            Rectangle rect = new Rectangle(leftPadding, 0, ClientRectangle.Width - 4, ClientRectangle.Height - 2);

            #region Border
            if (this.BorderStyle != SheetTabBorderStyle.NoBorder)
            {
                switch (this.Position)
                {
                default:
                case SheetTabControlPosition.Top:
                    g.DrawLine(borderPen, 0, rect.Bottom - 1,
                               ClientRectangle.Right, rect.Bottom - 1);
                    break;

                case SheetTabControlPosition.Bottom:
                    g.DrawLine(borderPen, 0, rect.Top, ClientRectangle.Right, rect.Top);
                    break;
                }
            }
            #endregion

            g.SetClip(new Rectangle(ClientRectangle.Left + leftPadding, ClientRectangle.Top,
                                    ClientRectangle.Width - leftPadding - rightPadding, ClientRectangle.Height));

            g.TranslateTransform(-this.viewScroll, 0);

            using (var sf = new StringFormat(StringFormat.GenericTypographic)
            {
                Alignment = StringAlignment.Center,
                LineAlignment = StringAlignment.Center,
            })
            {
                int textTopPadding = (this.ClientRectangle.Height - this.Font.Height) / 2;

                #region Unselected items

                for (int i = 0; i < tabs.Count; i++)
                {
                    var tab = this.tabs[i];
                    rect = tab.Bounds;

                    if (i != selectedIndex)
                    {
                        if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0)
                        {
                            using (var bb = new SolidBrush(tab.BackgroundColor))
                            {
                                g.FillRectangle(bb, rect);
                            }
                        }

                        if (!tab.ForegroundColor.IsEmpty && tab.ForegroundColor.A > 0)
                        {
                            using (var fb = new SolidBrush(tab.ForegroundColor))
                            {
                                g.DrawString(tab.Title, this.Font, fb, rect, sf);
                            }
                        }
                        else
                        {
                            g.DrawString(tab.Title, this.Font, defaultTextBrush, rect, sf);
                        }

                        if (i > 0)
                        {
                            g.DrawLine(SystemPens.ControlDark, rect.Left, rect.Top + 4, rect.Left, rect.Bottom - 4);
                        }
                    }

                    if (rect.Left > maxWidth)
                    {
                        break;
                    }
                }

                #endregion

                #region Selected item

                if (this.selectedIndex >= 0 && this.selectedIndex < this.tabs.Count)
                {
                    var tab = this.tabs[this.selectedIndex];
                    rect = tab.Bounds;

                    if (rect.Right > this.viewScroll ||
                        rect.Left < this.maxWidth - this.viewScroll)
                    {
                        int x = rect.Left, x2 = rect.Right, y = 0, y2 = 0;

                        if (this.BorderStyle != SheetTabBorderStyle.NoBorder)
                        {
                            if (this.BorderStyle == SheetTabBorderStyle.SplitRouned)
                            {
                                x++; x2--;
                            }

                            switch (this.Position)
                            {
                            default:
                            case SheetTabControlPosition.Top:
                                y = rect.Top; y2 = rect.Bottom;

                                if (this.BorderStyle == SheetTabBorderStyle.SplitRouned)
                                {
                                    y++; y2--;
                                }

                                break;

                            case SheetTabControlPosition.Bottom:
                                y = rect.Bottom - 1; y2 = rect.Top;

                                if (this.BorderStyle == SheetTabBorderStyle.SplitRouned)
                                {
                                    y--; y2++;
                                }

                                break;
                            }

                            // left and right
                            g.DrawLine(borderPen, rect.Left, y, rect.Left, y2);
                            g.DrawLine(borderPen, rect.Right, y, rect.Right, y2);
                        }

                        Brush selectedBackBrush = this.resourceManager.GetBrush(controlStyle[ControlAppearanceColors.SheetTabSelected]);
                        Brush selectedTextBrush = this.resourceManager.GetBrush(controlStyle[ControlAppearanceColors.SheetTabText]);

                        // top or bottom
                        switch (this.Position)
                        {
                        default:
                        case SheetTabControlPosition.Top:
                            var bgrectTop = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 1, rect.Height - 1);

                            if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0)
                            {
                                using (var bb = new SolidBrush(tab.BackgroundColor))
                                {
                                    g.FillRectangle(bb, bgrectTop);
                                }
                            }
                            else
                            {
                                g.FillRectangle(selectedBackBrush, bgrectTop);
                            }

                            if (this.BorderStyle != SheetTabBorderStyle.NoBorder)
                            {
                                g.DrawLine(borderPen, x, rect.Top, x2, rect.Top);
                            }
                            break;

                        case SheetTabControlPosition.Bottom:

                            var bgrectBottom = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 1, rect.Height - 1);

                            if (!tab.BackgroundColor.IsEmpty && tab.BackgroundColor.A > 0)
                            {
                                using (var bb = new SolidBrush(tab.BackgroundColor))
                                {
                                    g.FillRectangle(bb, bgrectBottom);
                                }
                            }
                            else
                            {
                                g.FillRectangle(selectedBackBrush, bgrectBottom);
                            }

                            if (this.BorderStyle != SheetTabBorderStyle.NoBorder)
                            {
                                g.DrawLine(borderPen, x, rect.Bottom - 1, x2, rect.Bottom - 1);
                            }
                            break;
                        }

                        if (this.BorderStyle != SheetTabBorderStyle.NoBorder && Shadow)
                        {
                            g.DrawLine(borderPen, rect.Right + 1, rect.Top + 2, rect.Right + 1, rect.Bottom - 1);
                        }

                        if (!tab.ForegroundColor.IsEmpty && tab.ForegroundColor.A > 0)
                        {
                            using (var fb = new SolidBrush(tab.ForegroundColor))
                            {
                                g.DrawString(tab.Title, this.Font, fb, rect, sf);
                            }
                        }
                        else
                        {
                            g.DrawString(tab.Title, this.Font, selectedTextBrush, rect, sf);
                        }
                    }
                }

                #endregion                 // Selected item
            }

            g.ResetClip();
            g.ResetTransform();

            if (this.NewButtonVisible)
            {
                g.DrawImage(addButtonHover ? newButtonImage : newButtonDisableImage,
                            new Rectangle(this.ClientRectangle.Width - 28, (this.ClientRectangle.Height - 16) / 2, 16, 16));
            }

            for (int i = 4; i < this.ClientRectangle.Height - 4; i += 4)
            {
                g.FillRectangle(SystemBrushes.ControlDark, new Rectangle(this.ClientRectangle.Right - 5, i, 2, 2));
            }

            if (this.movingHoverIndex >= 0 && this.movingHoverIndex <= this.tabs.Count &&
                this.movingHoverIndex != this.movingStartIndex)
            {
                Rectangle itemRect = GetItemBounds(this.movingHoverIndex >= this.tabs.Count ?
                                                   this.tabs.Count - 1 : this.movingHoverIndex);

                GraphicsToolkit.FillTriangle(g, 8, new Point(
                                                 (this.movingHoverIndex >= this.tabs.Count ? itemRect.Right : itemRect.Left) - this.viewScroll,
                                                 itemRect.Top + 4), GraphicsToolkit.TriangleDirection.Up);
            }

            base.OnPaint(e);
        }
Esempio n. 43
0
        private void DrawLines(Graphics gr, TreeNodeAdv node, Rectangle rowRect)
        {
            if (UseColumns && Columns.Count > 0)
                gr.SetClip(new Rectangle(0, rowRect.Y, Columns[0].Width, rowRect.Bottom));

            TreeNodeAdv curNode = node;
            while (curNode != _root && curNode != null)
            {
                int level = curNode.Level;
                int x = (level - 1) * _indent + NodePlusMinus.ImageSize / 2 + LeftMargin;
                int width = NodePlusMinus.Width - NodePlusMinus.ImageSize / 2;
                int y = rowRect.Y;
                int y2 = y + rowRect.Height;

                if (curNode == node)
                {
                    int midy = y + rowRect.Height / 2;
                    gr.DrawLine(_linePen, x, midy, x + width, midy);
                    if (curNode.NextNode == null)
                        y2 = y + rowRect.Height / 2;
                }

                if (node.Row == 0)
                    y = rowRect.Height / 2;
                if (curNode.NextNode != null || curNode == node)
                    gr.DrawLine(_linePen, x, y, x, y2);

                curNode = curNode.Parent;
            }

            gr.ResetClip();
        }
Esempio n. 44
0
        /// <summary>
        /// Draws a Toolstrip button
        /// </summary>
        /// <param name="Item">The Toolstrip button</param>
        /// <param name="Link">The Graphics object to handle</param>
        /// <param name="Parent">The parent Toolstrip</param>
        public void IDrawToolstripButton(ToolStripButton Item, Graphics Link, ToolStrip Parent)
        {
            Rectangle Area = new Rectangle(
                                new Point(0, 0),
                                new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1)
                            );

            Blend BackBlend = GetBlend(Item, ButtonType.NormalButton);
            Color[] Render = GetButtonBackColor(Item, ButtonType.NormalButton);

            using (GraphicsPath Path = CreateDrawingPath(Area, _btnManager.Curve))
            {
                Link.SetClip(Path);

                PaintBackground(
                            Link,
                            Area,
                            Render[0],
                            Render[1],
                            _btnManager.BackgroundAngle,
                            BackBlend
                            );

                Link.ResetClip();

                Link.SmoothingMode = SmoothingMode.AntiAlias;

                using (GraphicsPath OBPath = CreateDrawingPath(Area, _btnManager.Curve))
                {
                    PaintBorder(
                                Link,
                                OBPath,
                                Area,
                                _btnManager.BorderTop,
                                _btnManager.BorderBottom,
                                _btnManager.BorderAngle,
                                _btnManager.BorderBlend
                                );

                    OBPath.Dispose();
                }

                Area.Inflate(-1, -1);

                using (GraphicsPath IBPath = CreateDrawingPath(Area, _btnManager.Curve))
                {
                    using (SolidBrush InnerBorder = new SolidBrush(_btnManager.InnerBorder))
                    {
                        PaintBorder(
                                    Link,
                                    IBPath,
                                    InnerBorder
                                    );

                        InnerBorder.Dispose();
                    }
                }

                Link.SmoothingMode = SmoothingMode.Default;
            }
        }