Esempio n. 1
0
        public void Paint(Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            if (_fillToPrevPlotItem && null != prevItemData)
            {
                PaintFillToPrevPlotItem(g, layer, pdata, prevItemData);
            }

            if (_fillToNextPlotItem && null != nextItemData)
            {
                // ensure that brush and pen are cached
                if (null != _fillBrush)
                {
                    _fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));
                }

                PlotRangeList rangeList    = pdata.RangeList;
                int           rangelistlen = rangeList.Count;

                if (rangelistlen > 0)
                {
                    // we have to ignore the missing points here, thus all ranges can be plotted
                    // as one range, i.e. continuously
                    // for this, we create the totalRange, which contains all ranges
                    var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                    _cachedPaintOneRange(g, pdata, totalRange, layer, nextItemData);
                }
            }
        }
Esempio n. 2
0
        public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea)
        {
            innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // Padding
            var outerArea = innerArea;

            outerArea.Inflate(_shadowLength, _shadowLength);

            brush.SetEnvironment(outerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
            g.FillRectangle(brush, (RectangleF)outerArea);

            var twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255));
            var oA     = (RectangleF)outerArea;
            var iA     = (RectangleF)innerArea;

            g.FillPolygon(twhite, new PointF[] {
                new PointF(oA.Left, oA.Top),                                      // upper left point
                new PointF(oA.Right, oA.Top),                                     // go to the right
                new PointF(iA.Right, iA.Top),                                     // go 45 deg left down in the upper right corner
                new PointF(iA.Left, iA.Top),                                      // upper left corner of the inner rectangle
                new PointF(iA.Left, iA.Bottom),                                   // lower left corner of the inner rectangle
                new PointF(oA.Left, oA.Bottom)                                    // lower left corner
            });

            var tblack = new SolidBrush(Color.FromArgb(128, 0, 0, 0));

            g.FillPolygon(tblack, new PointF[] {
                new PointF(oA.Right, oA.Bottom),
                new PointF(oA.Right, oA.Top),
                new PointF(iA.Right, iA.Top),
                new PointF(iA.Right, iA.Bottom),                                    // upper left corner of the inner rectangle
                new PointF(iA.Left, iA.Bottom),                                     // lower left corner of the inner rectangle
                new PointF(oA.Left, oA.Bottom)                                      // lower left corner
            });
        }
Esempio n. 3
0
 public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea)
 {
     if (brush != null)
     {
         brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
         g.FillRectangle(brush, (RectangleF)innerArea);
     }
 }
Esempio n. 4
0
        public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            if (_connectionStyle is LineConnectionStyles.NoConnection)
            {
                return;
            }

            PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates;

            if (_independentOnShiftingGroupStyles)
            {
                _cachedLogicalShiftX = _cachedLogicalShiftY = 0;
            }

            if (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)
            {
                plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }

            // ensure that brush and pen are cached
            if (null != _framePen)
            {
                _framePen.Cached = true;
            }

            if (null != _fillBrush)
            {
                _fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));
            }

            _fillDirection = layer.UpdateCSPlaneID(_fillDirection);

            var gp = new GraphicsPath();

            PlotRangeList rangeList = pdata.RangeList;

            if (_ignoreMissingDataPoints)
            {
                // in case we ignore the missing points, all ranges can be plotted
                // as one range, i.e. continuously
                // for this, we create the totalRange, which contains all ranges
                IPlotRange totalRange = new PlotRangeCompound(rangeList);
                _connectionStyle.FillOneRange(gp, pdata, totalRange, layer, _fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }
            else // we not ignore missing points, so plot all ranges separately
            {
                for (int i = 0; i < rangeList.Count; i++)
                {
                    _connectionStyle.FillOneRange(gp, pdata, rangeList[i], layer, _fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
                }
            }

            g.FillPath(_fillBrush, gp);

            g.DrawPath(_framePen, gp);
        }
Esempio n. 5
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            grfx.DrawRectangle(new Pen(e.ForeColor), rectColor);

            string text       = string.Empty;
            object objAtIndex = e.Index >= 0 ? Items[e.Index] : SelectedItem;

            if (objAtIndex is Color)
            {
                Color itemColor = (Color)objAtIndex;
                grfx.FillRectangle(new SolidBrush(itemColor), rectColor);
                if (itemColor.IsNamedColor)
                {
                    text = itemColor.Name;
                }
                else if (ColorDictionary.IsBaseColorNamed(itemColor))
                {
                    int transparency = ((255 - itemColor.A) * 100) / 255;
                    text = "T" + transparency.ToString() + ColorDictionary.GetBaseColorName(itemColor);
                }
                else
                {
                    text = "Custom Color";
                }
            }
            else if (objAtIndex is BrushX)
            {
                BrushX itemBrush = (BrushX)objAtIndex;
                itemBrush.SetEnvironment(rectColor, BrushX.GetEffectiveMaximumResolution(grfx));
                grfx.FillRectangle(itemBrush, rectColor);
                text = "Custom Brush";
            }

            grfx.DrawString(text, Font, new SolidBrush(e.ForeColor), rectText);
        }
Esempio n. 6
0
        public void UpdatePreview(BrushX brush)
        {
            if (null == _previewPanel || null == brush)
            {
                return;
            }

            int height = (int)_previewPanel.ActualHeight;
            int width  = (int)_previewPanel.ActualWidth;

            if (height <= 0)
            {
                height = 64;
            }
            if (width <= 0)
            {
                width = 64;
            }

            if (null == _previewBitmap)
            {
                _previewBitmap       = new GdiToWpfBitmap(width, height);
                _previewPanel.Source = _previewBitmap.WpfBitmap;
            }

            if (width != _previewBitmap.GdiRectangle.Width || height != _previewBitmap.GdiRectangle.Height)
            {
                _previewBitmap.Resize(width, height);
                _previewPanel.Source = _previewBitmap.WpfBitmap;
            }

            using (var grfx = _previewBitmap.BeginGdiPainting())
            {
                var fullRect = _previewBitmap.GdiRectangle;

                grfx.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                grfx.FillRectangle(System.Drawing.Brushes.Transparent, fullRect);
                grfx.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                var r2 = fullRect;
                r2.Inflate(-r2.Width / 4, -r2.Height / 4);
                //grfx.FillRectangle(System.Drawing.Brushes.Black, r2);

                brush.SetEnvironment(fullRect, BrushX.GetEffectiveMaximumResolution(grfx));
                grfx.FillRectangle(brush, fullRect);

                _previewBitmap.EndGdiPainting();
            }
        }
Esempio n. 7
0
 public RectangleF PaintSymbol(Graphics g, RectangleF bounds)
 {
     bounds.Inflate(0, -bounds.Height / 4);
     if (null != _fillBrush)
     {
         _fillBrush.SetEnvironment(bounds, BrushX.GetEffectiveMaximumResolution(g, 1));
         g.FillRectangle(_fillBrush, bounds);
     }
     if (null != _framePen)
     {
         _framePen.SetEnvironment(bounds, BrushX.GetEffectiveMaximumResolution(g, 1));
         g.DrawRectangle(_framePen, bounds.X, bounds.Y, bounds.Width, bounds.Height);
     }
     return(bounds);
 }
Esempio n. 8
0
        public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea)
        {
            BrushX shadowBrush = null;

            if (object.ReferenceEquals(brush, _brush))
            {
                if (null == _cachedShadowBrush)
                {
                    _cachedShadowBrush = GetShadowBrush(brush);
                    _cachedShadowBrush.ParentObject = this;
                }
                shadowBrush = _cachedShadowBrush;
            }
            else
            {
                shadowBrush = GetShadowBrush(brush);
            }

            innerArea.Inflate(_shadowLength / 2, _shadowLength / 2);

            // please note: m_Bounds is already extended to the shadow

            // first the shadow
            shadowBrush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));

            // shortCuts to floats
            var   iArea        = (RectangleF)innerArea;
            float shadowLength = (float)_shadowLength;

            g.TranslateTransform(shadowLength, shadowLength);
            g.FillRectangle(shadowBrush, iArea);
            g.TranslateTransform(-shadowLength, -shadowLength);

            brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
            g.FillRectangle(brush, iArea);
            g.DrawRectangle(Pens.Black, iArea.Left, iArea.Top, iArea.Width, iArea.Height);
        }
Esempio n. 9
0
		public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea)
		{
			if (brush != null)
			{
				brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
				g.FillRectangle(brush, (RectangleF)innerArea);
			}
		}
Esempio n. 10
0
		public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea)
		{
			innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // Padding
			var outerArea = innerArea;
			outerArea.Inflate(_shadowLength, _shadowLength);

			brush.SetEnvironment(outerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
			g.FillRectangle(brush, (RectangleF)outerArea);

			SolidBrush twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255));
			RectangleF oA = (RectangleF)outerArea;
			RectangleF iA = (RectangleF)innerArea;
			g.FillPolygon(twhite, new PointF[] {
																											new PointF(oA.Left,oA.Top), // upper left point
                                                      new PointF(oA.Right,oA.Top), // go to the right
                                                      new PointF(iA.Right,iA.Top), // go 45 deg left down in the upper right corner
                                                      new PointF(iA.Left,iA.Top), // upper left corner of the inner rectangle
                                                      new PointF(iA.Left,iA.Bottom), // lower left corner of the inner rectangle
                                                      new PointF(oA.Left,oA.Bottom) // lower left corner
      });

			SolidBrush tblack = new SolidBrush(Color.FromArgb(128, 0, 0, 0));
			g.FillPolygon(tblack, new PointF[] {
																											new PointF(oA.Right,oA.Bottom),
																											new PointF(oA.Right,oA.Top),
																											new PointF(iA.Right,iA.Top),
																											new PointF(iA.Right,iA.Bottom), // upper left corner of the inner rectangle
                                                      new PointF(iA.Left,iA.Bottom), // lower left corner of the inner rectangle
                                                      new PointF(oA.Left,oA.Bottom) // lower left corner
      });
		}
Esempio n. 11
0
		public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea)
		{
			BrushX shadowBrush = null;
			if (object.ReferenceEquals(brush, _brush))
			{
				if (null == _cachedShadowBrush)
				{
					_cachedShadowBrush = GetShadowBrush(brush);
					_cachedShadowBrush.ParentObject = this;
				}
				shadowBrush = _cachedShadowBrush;
			}
			else
			{
				shadowBrush = GetShadowBrush(brush);
			}

			innerArea.Inflate(_shadowLength / 2, _shadowLength / 2);

			// please note: m_Bounds is already extended to the shadow

			// first the shadow
			shadowBrush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));

			// shortCuts to floats
			RectangleF iArea = (RectangleF)innerArea; float shadowLength = (float)_shadowLength;
			g.TranslateTransform(shadowLength, shadowLength);
			g.FillRectangle(shadowBrush, iArea);
			g.TranslateTransform(-shadowLength, -shadowLength);

			brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1));
			g.FillRectangle(brush, iArea);
			g.DrawRectangle(Pens.Black, iArea.Left, iArea.Top, iArea.Width, iArea.Height);
		}