MultiplyTransform() public method

public MultiplyTransform ( Matrix matrix ) : void
matrix Matrix
return void
Example #1
0
 protected override void DrawDisabled(Graphics g, ArrowDirection direction)
 {
     g.DrawEllipse(_disabledPen, _circleRect);
     if (direction == ArrowDirection.Right)
         g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 23, 0));
     g.DrawPath(_disabledArrowPen, _arrowPath);
 }
Example #2
0
		/// <summary>
		/// Transforms the graphics context is such a way, that the object can be drawn in local coordinates.
		/// </summary>
		/// <param name="g">Graphics context (should be saved beforehand).</param>
		protected override void TransformGraphics(Graphics g)
		{
			g.MultiplyTransform(_transformation);
		}
Example #3
0
    public virtual void Paint(Graphics g)
    {
      GraphicsState savedgstate = g.Save();
      //g.TranslateTransform(m_LayerPosition.X,m_LayerPosition.Y);
      //g.RotateTransform(m_LayerAngle);

      g.MultiplyTransform(_cachedForwardMatrix);

      RectangleF layerBounds = new RectangleF(_cachedLayerPosition, _cachedLayerSize);

      _gridPlanes.Paint(g, this);

      _axisStyles.Paint(g, this);

      if (ClipDataToFrame==LayerDataClipping.StrictToCS)
      {
        g.Clip = CoordinateSystem.GetRegion();
      }
      foreach (IGPlotItem pi in _plotItems)
      {
        pi.Paint(g, this);
      }
      if (ClipDataToFrame==LayerDataClipping.StrictToCS)
      {
        g.ResetClip();
      }

      _graphObjects.DrawObjects(g, 1, this);

      _legends.DrawObjects(g, 1, this);

      g.Restore(savedgstate);
    }
Example #4
0
 /// <summary>
 /// This switches the graphics context from printable area coordinates to layer coordinates.
 /// </summary>
 /// <param name="g">The graphics state to change.</param>
 public void GraphToLayerCoordinates(Graphics g)
 {
   g.MultiplyTransform(_cachedForwardMatrix);
 }
Example #5
0
        private void DrawListsToGraphics(ref Graphics g)
        {
            if (mGfxBuff == null) return;
            mCurPen.Width = -1;
            {
                g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                g.PageUnit = GraphicsUnit.Inch;
                g.ResetTransform();
                g.MultiplyTransform(mMtxWCS);
                //Draw the axis indicator and axis lines
                foreach (clsDisplayList p in mWcsDisplayLists)
                {
                    if (p.Rapid)
                    {
                        mWCSPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
                        mWCSPen.DashPattern = mAxisDashStyle;
                    }
                    else
                    {
                        mWCSPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    }
                    mWCSPen.Color = p.Color;
                    g.DrawLines(mWCSPen, p.Points);
                }
                g.ResetTransform();

                //Now draw the toolpath
                mRapidDashStyle[0] = 0.05f / mScaleToReal;
                mRapidDashStyle[1] = 0.05f / mScaleToReal;
                g.MultiplyTransform(mMtxDraw);
                foreach (clsDisplayList p in mDisplayLists)
                {
                    if (!p.InView)
                    {
                        continue;
                    }
                    if (p.Rapid)
                    {
                        mCurPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
                        mCurPen.DashPattern = mRapidDashStyle;
                    }
                    else
                    {
                        mCurPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    }
                    mCurPen.Color = p.Color;
                    LineFixUp(ref p.Points);
                    g.DrawLines(mCurPen, p.Points);
                }
            }
        }
Example #6
0
        protected virtual void PlotLabels(Graphics g, float labelspacing)
        {
            if (!OKToRender())
                return;
            int ypos = Height - ProtectedBottomPadding; //y2Pxl(0.0);

            float ylabelspacing = GetTickSpacingEstimate(MinY, MaxY);

            SizeF size = g.MeasureString("0", LabelFont);
            while (size.Height > (ConvertYToPixel(0) - ConvertYToPixel(ylabelspacing)))
            {
                ylabelspacing = ylabelspacing*2;
            }

            if (labelspacing == 0 || ylabelspacing == 0)
                return;
            double xval = FindMin(MinX, labelspacing);
            float yval = FindMin(MinY, ylabelspacing);

            double oldxval = xval;
            float oldyval = yval;

            // draw the x grid labels
            xval = oldxval;

            StringFormat format = new StringFormat
                                      {
                                          Alignment = StringAlignment.Center,
                                          LineAlignment = StringAlignment.Center
                                      };
            using (Brush labelBrush = new SolidBrush(LabelColor))
            {
                using (Brush titleBrush = new SolidBrush(TitleColor))
                {
                    using (Brush axesLabelBrush = new SolidBrush(AxesLabelColor))
                    {
                        int xpos;
                        string cstr;
                        SizeF strsize;
                        if (_showTickLabels)
                        {
                            float tMax = MaxX;
                            while (xval <= tMax)
                            {
                                double displayXVal = xval + XAxisOffset;
                                xpos = (int) ConvertXToPixel(xval);
                                if (displayXVal == (int) displayXVal)
                                    cstr = string.Format("{0}", (int) displayXVal);
                                else
                                {
                                    if (labelspacing < 0.06 || xval < .01)
                                        cstr = string.Format("{0:F3}", displayXVal);
                                    else if (labelspacing < 0.6 || xval < .1)
                                        cstr = string.Format("{0:F2}", displayXVal);
                                    else
                                        cstr = string.Format("{0:F1}", displayXVal);
                                }
                                if (cstr.EndsWith("000000000")) cstr = cstr.Substring(0, cstr.Length - 9) + "G";
                                if (cstr.EndsWith("000000")) cstr = cstr.Substring(0, cstr.Length - 6) + "M";
                                if (cstr.EndsWith("000")) cstr = cstr.Substring(0, cstr.Length - 3) + "K";

                                strsize = g.MeasureString(cstr, LabelFont);
                                if (!_hideXLabels)
                                {
                                    g.DrawString(cstr, LabelFont, labelBrush,
                                                 new Rectangle(xpos - (int) strsize.Width/2 - 2,
                                                               Height - ProtectedBottomPadding + 1,
                                                               (int) strsize.Width + 4, (int) strsize.Height), format);
                                }
                                xval = xval + labelspacing;
                            }
                        }
                        else if (XAxisLabels.Count > 0 && _hideXLabels == false)
                        {
                            int minimumXPos = int.MinValue;
                            float sin = (float) Math.Sin(Math.PI*Math.Abs(_xAxisLabelRotation)/180);
                            foreach (AxisLabel label in XAxisLabels)
                            {
                                xpos = (int) ConvertXToPixel(label.Position);
                                int ytry = Height - ProtectedBottomPadding + 1;
                                strsize = g.MeasureString(label.Value, LabelFont);
                                Matrix saveCoordFrame1 = g.Transform.Clone();
                                int xtry;
                                int xkeepout;
                                if (_xAxisLabelRotation != 0)
                                {
                                    xtry = xpos - 2 - (int) strsize.Width;
                                    ytry = Height - ProtectedBottomPadding - 1;
                                    xkeepout = (int) (strsize.Height/sin) + 1;

                                    Matrix m1 = new Matrix();
                                    m1.RotateAt(_xAxisLabelRotation, new PointF(xpos, Height - ProtectedBottomPadding));
                                    g.MultiplyTransform(m1);

                                    if (xpos > minimumXPos)
                                    {
                                        g.DrawString(label.Value, LabelFont, labelBrush,
                                                     new Rectangle(xtry, ytry, (int) (strsize.Width + 1),
                                                                   (int) (strsize.Height + 1)), format);
                                        minimumXPos = xpos + xkeepout;
                                    }
                                }
                                else
                                {
                                    xkeepout = (int) (strsize.Width/2 + 2);
                                    xtry = xpos - (int) strsize.Width/2 - 2;
                                    if (xtry > minimumXPos)
                                    {
                                        g.DrawString(label.Value, LabelFont, labelBrush,
                                                     new Rectangle(xtry, Height - ProtectedBottomPadding + 1,
                                                                   (int) strsize.Width + 4, (int) strsize.Height),
                                                     format);
                                        minimumXPos = xpos + xkeepout;
                                    }
                                }
                                g.Transform = saveCoordFrame1;
                            }
                        }

                        // the x axis label;
                        if (!_hideXLabels)
                        {
                            g.DrawString(XLabel, AxesLabelFont, axesLabelBrush,
                                         new Rectangle(ProtectedLeftPadding, Height - ProtectedBottomPadding + 2,
                                                       Width - ProtectedLeftPadding - ProtectedRightPadding, ProtectedBottomPadding), format);
                        }

                        // draw the title
                        g.DrawString(Title, TitleFont, titleBrush,
                                     new Rectangle(ProtectedLeftPadding, 0, Width - ProtectedLeftPadding - ProtectedRightPadding, ProtectedTopPadding),
                                     format);

                        // draw the y grid labels
                        format.Alignment = StringAlignment.Far;
                        float maxwidth = 0;
                        ypos = (int) ConvertYToPixel(MaxY) - 10;
                        cstr = _yUnits;
                        strsize = g.MeasureString(cstr, LabelFont);
                        format.Alignment = StringAlignment.Far;
                        g.DrawString(cstr, LabelFont, labelBrush,
                                     new Rectangle(0, ypos - (int) strsize.Height/2 - 1, ProtectedLeftPadding - 2,
                                                   (int) strsize.Height + 2), format);
                        format.Alignment = StringAlignment.Near;
                        g.DrawString(cstr, LabelFont, labelBrush,
                                     new Rectangle(Width - ProtectedRightPadding + 2, ypos - (int) strsize.Height/2 - 1,
                                                   ProtectedRightPadding - 2, (int) strsize.Height + 2), format);
                        yval = oldyval;
                        while (yval < MaxY)
                        {
                            ypos = (int) ConvertYToPixel(yval);
                            if (yval == (int) yval)
                                cstr = string.Format("{0}", (int) yval);
                            else
                            {
                                if (ylabelspacing < 0.06)
                                    cstr = string.Format("{0:F3}", yval);
                                else if (ylabelspacing < .6)
                                    cstr = string.Format("{0:F2}", yval);
                                else
                                    cstr = string.Format("{0:F1}", yval);
                            }
                            if (cstr.EndsWith("000000")) cstr = cstr.Substring(0, cstr.Length - 6) + "M";
                            if (cstr.EndsWith("000")) cstr = cstr.Substring(0, cstr.Length - 3) + "K";
                            strsize = g.MeasureString(cstr, LabelFont);
                            if (strsize.Width > maxwidth) maxwidth = strsize.Width;
                            //Y scale
                            format.Alignment = StringAlignment.Far;
                            int top = ypos - (int) strsize.Height/2 - 1;
                            if (top < 0) top = 0;
                            g.DrawString(cstr, LabelFont, labelBrush,
                                         new Rectangle(0, top, ProtectedLeftPadding - 2, (int) strsize.Height + 2), format);
                            format.Alignment = StringAlignment.Near;
                            if (_drawRightYAxisLabels)
                                g.DrawString(cstr, LabelFont, labelBrush,
                                             new Rectangle(Width - ProtectedRightPadding + 2, top, ProtectedRightPadding - 2,
                                                           (int) strsize.Height + 2), format);
                            yval += ylabelspacing;
                        }

                        // the y axis label;
                        format.Alignment = StringAlignment.Center;
                        format.LineAlignment = StringAlignment.Center;
                        Matrix saveCoordFrame = g.Transform.Clone();
                        Matrix m = new Matrix();
                        m.Rotate(-90F);
                        g.MultiplyTransform(m);
                        g.TranslateTransform(
                            (ProtectedLeftPadding - 20 - maxwidth)*saveCoordFrame.Elements[0],
                            (Height - ProtectedBottomPadding)*saveCoordFrame.Elements[3],
                            MatrixOrder.Append);
                        g.DrawString(YLabel, AxesLabelFont, axesLabelBrush,
                                     new Rectangle(0, 0, Height - ProtectedBottomPadding - ProtectedTopPadding, 20), format);
                        g.Transform = saveCoordFrame;
                    }
                }
            }
        }
Example #7
0
 protected override void DrawPressed(Graphics g, ArrowDirection direction)
 {
     g.FillEllipse(_pressedBrush,
         new RectangleF(_circleRect.X - 0.5f, _circleRect.Y - 0.5f, _circleRect.Width + 1,
             _circleRect.Height + 1));
     if (direction == ArrowDirection.Right)
         g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 23, 0));
     g.DrawPath(_hoverArrowPen, _arrowPath);
 }
		/// <summary>
		/// Draws the temporary line(s) from the first point to the mouse.
		/// </summary>
		/// <param name="g"></param>
		public override void AfterPaint(Graphics g)
		{
			if (_currentPoint >= 1)
			{
				if (null != _grac.ActiveLayer)
				{
					g.MultiplyTransform(_cachedActiveLayerTransformationGdi);
					//					g.TranslateTransform((float)_grac.ActiveLayer.Position.X, (float)_grac.ActiveLayer.Position.Y);
					//				g.RotateTransform((float)-_grac.ActiveLayer.Rotation);
					var currLayerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(_positionCurrentMouseInRootLayerCoordinates);
					DrawRectangleFromLTRB(g, _Points[0].LayerCoordinates, currLayerCoord);
				}
				else
				{
					DrawRectangleFromLTRB(g, _Points[0].RootLayerCoordinates, _positionCurrentMouseInRootLayerCoordinates);
				}
			}
		}
Example #9
0
		/// <summary>
		/// Paints the axis style labels.
		/// </summary>
		/// <param name="g">Graphics environment.</param>
		/// <param name="coordSyst">The coordinate system. Used to get the path along the axis.</param>
		/// <param name="scale">Scale.</param>
		/// <param name="tickSpacing">If not <c>null</c>, this parameter provides a custom tick spacing that is used instead of the default tick spacing of the scale.</param>
		/// <param name="styleInfo">Information about begin of axis, end of axis.</param>
		/// <param name="outerDistance">Distance between axis and labels.</param>
		/// <param name="useMinorTicks">If true, minor ticks are shown.</param>
		public virtual void Paint(Graphics g, G2DCoordinateSystem coordSyst, Scale scale, TickSpacing tickSpacing, CSAxisInformation styleInfo, double outerDistance, bool useMinorTicks)
		{
			_cachedAxisStyleInfo = styleInfo;
			CSLineID styleID = styleInfo.Identifier;
			Scale raxis = scale;
			TickSpacing ticking = tickSpacing;

			_enclosingPath.Reset();
			_enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
			GraphicsPath helperPath = new GraphicsPath();
			Matrix math = new Matrix();

			Logical3D r0 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisOrg);
			Logical3D r1 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisEnd);

			PointD2D outVector;
			Logical3D outer;
			var dist_x = outerDistance; // Distance from axis tick point to label
			var dist_y = outerDistance; // y distance from axis tick point to label

			// dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks

			// next statement is necessary to have a consistent string length both
			// on 0 degree rotated text and rotated text
			// without this statement, the text is fitted to the pixel grid, which
			// leads to "steps" during scaling
			g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

			double[] relpositions;
			AltaxoVariant[] ticks;
			if (useMinorTicks)
			{
				relpositions = ticking.GetMinorTicksNormal(raxis);
				ticks = ticking.GetMinorTicksAsVariant();
			}
			else
			{
				relpositions = ticking.GetMajorTicksNormal(raxis);
				ticks = ticking.GetMajorTicksAsVariant();
			}

			if (!_suppressedLabels.IsEmpty)
			{
				List<AltaxoVariant> filteredTicks = new List<AltaxoVariant>();
				List<double> filteredRelPositions = new List<double>();

				for (int i = 0; i < ticks.Length; i++)
				{
					if (_suppressedLabels.ByValues.Contains(ticks[i]))
						continue;
					if (_suppressedLabels.ByNumbers.Contains(i))
						continue;
					if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length))
						continue;

					filteredTicks.Add(ticks[i]);
					filteredRelPositions.Add(relpositions[i]);
				}
				ticks = filteredTicks.ToArray();
				relpositions = filteredRelPositions.ToArray();
			}

			IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks);

			double emSize = _font.Size;
			CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide;
			for (int i = 0; i < ticks.Length; i++)
			{
				double r = relpositions[i];

				if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000))
					continue;

				outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide);
				PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out outVector);
				PointD2D tickend = tickorg + outVector * outerDistance;

				PointD2D msize = labels[i].Size;
				PointD2D morg = tickend;

				if (_automaticRotationShift)
				{
					double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
					double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
					morg = morg + outVector * shift;
				}
				else
				{
					morg = morg.WithXPlus(outVector.X * _font.Size / 3);
				}

				RectangleD2D mrect = new RectangleD2D(morg, msize);
				if (_automaticRotationShift)
					AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
				else
					AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);

				math.Reset();
				math.Translate((float)morg.X, (float)morg.Y);
				if (this._rotation != 0)
				{
					math.Rotate((float)-this._rotation);
				}
				math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));

				System.Drawing.Drawing2D.GraphicsState gs = g.Save();
				g.MultiplyTransform(math);

				if (this._backgroundStyle != null)
					_backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize));

				_brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1));
				labels[i].Draw(g, _brush, new PointF(0, 0));
				g.Restore(gs); // Restore the graphics state

				helperPath.Reset();
				helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize));
				helperPath.Transform(math);

				_enclosingPath.AddPath(helperPath, true);
			}
		}
Example #10
0
    private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected
    public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks)
    {
      _cachedStyleID = styleInfo.Identifier;
      CSLineID styleID = styleInfo.Identifier;
      Scale raxis = styleID.ParallelAxisNumber==0 ? layer.XAxis : layer.YAxis;

      _enclosingPath.Reset();
      _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
      GraphicsPath helperPath = new GraphicsPath();
      Matrix math = new Matrix();

      Logical3D r0 = _cachedStyleID.Begin;
      Logical3D r1 = _cachedStyleID.End;

      SizeF layerSize = layer.Size;
      PointF outVector;
      Logical3D outer;
      float outerDistance = null==axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide);
      float dist_x = outerDistance; // Distance from axis tick point to label
      float dist_y = outerDistance; // y distance from axis tick point to label

      // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks

      // next statement is necessary to have a consistent string length both
      // on 0 degree rotated text and rotated text
      // without this statement, the text is fitted to the pixel grid, which
      // leads to "steps" during scaling
      g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

      double[] relpositions;
      AltaxoVariant[] ticks;
      if(useMinorTicks)
      {
        relpositions = raxis.GetMinorTicksNormal();
        ticks = raxis.GetMinorTicksAsVariant();
      }
      else
      {
        relpositions = raxis.GetMajorTicksNormal();
        ticks = raxis.GetMajorTicksAsVariant();
      }
      
      IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g,_font,_stringFormat,ticks);

      float emSize = _font.SizeInPoints;
      for(int i=0;i<ticks.Length;i++)
      {
        double r = relpositions[i];

        outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide);
        PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
        PointF tickend = tickorg;
        tickend.X += outVector.X * outerDistance;
        tickend.Y += outVector.Y * outerDistance;
       

        SizeF msize = labels[i].Size;
        PointF morg = tickend;

        if (_automaticRotationShift)
        {
          double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
          double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
          morg.X += (float)(outVector.X * shift);
          morg.Y += (float)(outVector.Y * shift);
        }
        else
        {
          morg.X += (float)(outVector.X * _font.SizeInPoints/3);
        }

       
        RectangleF mrect = new RectangleF(morg,msize);
        if(_automaticRotationShift)
          AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
        else
          AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);

        math.Reset();
        math.Translate((float)morg.X, (float)morg.Y);
        if (this._rotation != 0)
        {
          math.Rotate((float)-this._rotation);
        }
        math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));


        System.Drawing.Drawing2D.GraphicsState gs = g.Save();
        g.MultiplyTransform(math);

        if(this._backgroundStyle!=null)
          _backgroundStyle.Draw(g,new RectangleF(PointF.Empty,msize));

        _brush.Rectangle = new RectangleF(PointF.Empty, msize);      
        labels[i].Draw(g,_brush,new PointF(0,0));
        g.Restore(gs); // Restore the graphics state

        helperPath.Reset();
        helperPath.AddRectangle(new RectangleF(PointF.Empty, msize));
        helperPath.Transform(math);

        _enclosingPath.AddPath(helperPath,true);

       
      }
    

    }
Example #11
0
 /// <summary>
 /// Fulfill the IAlteration contract. Applies the matrix alteration
 /// to the Graphics object of the sprite.
 /// Bug: 
 /// </summary>
 /// <param name="p_g">
 /// A <see cref="Graphics"/> on which the sprite is being drawn
 /// </param>
 /// <param name="p_point">
 /// A <see cref="Point"/> indicating where the sprite will be drawn
 /// </param>
 /// <param name="p_bitmap">
 /// A <see cref="Bitmap"/> of the sprite
 /// </param>
 public void ApplyAlteration(Graphics p_g, Point p_point, ref Bitmap p_bitmap)
 {
     //p_g.Transform = matrix;
     p_g.MultiplyTransform(matrix);
 }
Example #12
0
        private static PointF DrawLineArrowInternal(Graphics gfx, Pen pen, Brush brush, float x, float y, float angle, ArrowStyle style)
        {
            PointF pt;
            var rt = new Matrix();
            rt.RotateAt(angle, new PointF(x, y));
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            switch (style.ArrowType)
            {
                default:
                case ArrowType.None:
                    {
                        pt = new PointF(x, y);
                    }
                    break;
                case ArrowType.Rectangle:
                    {
                        var pts = new PointF[] { new PointF(x - (float)sx, y) };
                        rt.TransformPoints(pts);
                        pt = pts[0];
                        var rect = new Rect2(x - sx, y - ry, sx, sy);
                        var gs = gfx.Save();
                        gfx.MultiplyTransform(rt);
                        DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                        gfx.Restore(gs);
                    }
                    break;
                case ArrowType.Ellipse:
                    {
                        var pts = new PointF[] { new PointF(x - (float)sx, y) };
                        rt.TransformPoints(pts);
                        pt = pts[0];
                        var gs = gfx.Save();
                        gfx.MultiplyTransform(rt);
                        var rect = new Rect2(x - sx, y - ry, sx, sy);
                        DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                        gfx.Restore(gs);
                    }
                    break;
                case ArrowType.Arrow:
                    {
                        var pts = new PointF[]
                        {
                            new PointF(x, y),
                            new PointF(x - (float)sx, y + (float)sy),
                            new PointF(x, y),
                            new PointF(x - (float)sx, y - (float)sy),
                            new PointF(x, y)
                        };
                        rt.TransformPoints(pts);
                        pt = pts[0];
                        var p11 = pts[1];
                        var p21 = pts[2];
                        var p12 = pts[3];
                        var p22 = pts[4];
                        DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
                        DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
                    }
                    break;
            }

            return pt;
        }
Example #13
0
        private void drawInputImage(Graphics g, int width, int height)
        {
            using (var brush = new SolidBrush(Color.Black))
            {
                if (inputBGImage != null)
                    g.DrawImage(inputBGImage, 0, 0);

                g.Transform = currentM;
                g.MultiplyTransform(transM, MatrixOrder.Append);
                g.InterpolationMode = InterpolationMode.High;
                g.DrawString(inputWord, inputStringFontDialog.Font, brush, 0, 0);
                g.ResetTransform();
            }
        }
 public void SetupGraphics(Graphics g, string detail)
 {
     scale = (double)(this.Height - 2 * padding_top) / Table.Height;
     g.SmoothingMode = SmoothingMode.AntiAlias;
     g.TranslateTransform((this.Width / 2) - (int)((scale * Table.Width) / 2), this.Height - padding_top);
     g.DrawString(detail, this.Font, Brushes.Black, 0, 10);
     g.MultiplyTransform(flip_vertically);
 }
Example #15
0
            protected override void DrawDisabled(Graphics g, ArrowDirection direction)
            {
                g.FillPath(_disabledUpperBackgroundBrush, _upperBackgroundPath);
                g.FillPath(_disabledLowerBackgroundBrush, _lowerBackgroundPath);
                g.FillPath(_disabledUpperBrush, _upperBackgroundPath);
                g.FillPath(_disabledLowerBrush, _lowerBackgroundPath);

                if (direction == ArrowDirection.Right)
                    g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 24f, 0));
                g.DrawPath(_disabledArrowPen, _arrowPath);
            }
Example #16
0
            protected override void DrawPressed(Graphics g, ArrowDirection direction)
            {
                g.FillPath(_pressedBackgrounBrush, _lowerBackgroundPath);
                g.FillPath(_pressedUpperBackgroundBrush, _upperBackgroundPath);
                g.FillEllipse(_pressedLowerBackgroundBrush, _backgroundRect);

                if (direction == ArrowDirection.Right)
                    g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 24f, 0));
                g.DrawPath(_normalArrowPen, _arrowPath);
            }
Example #17
0
        /// <summary>
        /// Apply the flip
        /// </summary>
        /// <param name="p_g">Graphic object</param>
        /// <param name="p_point">Location where to draw object</param>
        /// <param name="p_bitmap">Reference to bitmap to draw on</param>
        public void ApplyAlteration(Graphics p_g, Point p_point, ref Bitmap p_bitmap)
        {
            p_g.TranslateTransform((float)(p_point.X), (float)(p_point.Y));

            Matrix m = new Matrix(1,0,0,1,0,0);

            switch(flipType)
            {
            case Animation.Flip.FlipType.Horizontal:
                m = new Matrix(-1,0,0,1,0,0);
                break;
            case Animation.Flip.FlipType.Vertical:
                m = new Matrix(1,0,0,-1,0,0);
                break;
            case Animation.Flip.FlipType.Both:
                m = new Matrix(-1,0,0,-1,0,0);
                break;
            default:
                m = new Matrix(1,0,0,1,0,0);
                break;
            }

            // Rotate desired degrees
            p_g.MultiplyTransform(m);

            // Move the origin back to where it belongs while it is rotated
            p_g.TranslateTransform((float)(p_point.X) * -1, (float)(p_point.Y) * -1);
        }