ResetTransform() public method

public ResetTransform ( ) : void
return void
コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            bool linkBroken = this.ReferenceBroken;

            Color bgColorBright = Color.White;
            if (this.dragHover) bgColorBright = bgColorBright.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
            else if (this.multiple) bgColorBright = Color.Bisque;
            else if (linkBroken) bgColorBright = Color.FromArgb(255, 128, 128);

            bool darkBg = false;
            Rectangle rectImage = new Rectangle(this.rectPanel.X + 2, this.rectPanel.Y + 2, this.rectPanel.Width - 4, this.rectPanel.Height - 4);
            if (this.prevImage == null)
            {
                if (this.ReadOnly || !this.Enabled)
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, bgColorBright)), rectImage);
                else
                    e.Graphics.FillRectangle(new SolidBrush(bgColorBright), rectImage);
            }
            else
            {
                Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
                Color darkChecker = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);

                if (this.dragHover)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                }
                else if (this.multiple)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                }
                else if (linkBroken)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                }

                e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);

                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(rectImage.X, rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, rectImage);

                darkBg = this.prevImageLum > 0.5f;
                if (this.ReadOnly || !this.Enabled)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, SystemColors.Control)), rectImage);
                    darkBg = (this.prevImageLum + SystemColors.Control.GetLuminance()) * 0.5f < 0.5f;
                }
            }

            StringFormat format = StringFormat.GenericDefault;
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming = StringTrimming.EllipsisPath;
            SizeF textSize = e.Graphics.MeasureString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SizeF(this.rectPanel.Width, this.rectPanel.Height),
                format);

            Rectangle rectText;
            if (this.prevImage == null)
                rectText = this.rectPanel;
            else
                rectText = new Rectangle(
                    this.rectPanel.X, this.rectPanel.Bottom - (int)textSize.Height - 2, this.rectPanel.Width, (int)textSize.Height);

            if (this.prevImage != null)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(192, bgColorBright)),
                    rectText.X + rectText.Width / 2 - textSize.Width / 2 - 1,
                    rectText.Y + rectText.Height / 2 - textSize.Height / 2 - 2,
                    textSize.Width + 1,
                    textSize.Height + 2);
            }
            e.Graphics.DrawString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SolidBrush(this.Enabled ? SystemColors.ControlText : SystemColors.GrayText),
                rectText,
                format);

            ControlRenderer.DrawBorder(e.Graphics,
                this.rectPanel,
                BorderStyle.ContentBox,
                (this.ReadOnly || !this.Enabled) ? BorderState.Disabled : BorderState.Normal);

            ButtonState buttonStateSet = ButtonState.Disabled;
            if(!this.ReadOnly && this.Enabled)
            {
                if (this.buttonSetPressed) buttonStateSet = ButtonState.Pressed;
                else if (this.buttonSetHovered) buttonStateSet = ButtonState.Hot;
                else buttonStateSet = ButtonState.Normal;
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButtonSet,
                buttonStateSet,
                null,
                iconSet);

            ButtonState buttonStateReset = ButtonState.Disabled;
            if (!this.ReadOnly && this.Enabled && this.ReferenceName != null)
            {
                if (this.buttonResetPressed)		buttonStateReset = ButtonState.Pressed;
                else if (this.buttonResetHovered)	buttonStateReset = ButtonState.Hot;
                else								buttonStateReset = ButtonState.Normal;
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButtonReset,
                buttonStateReset,
                null,
                iconReset);

            ButtonState buttonStateShow = ButtonState.Disabled;
            if (this.Enabled && this.ReferenceName != null)
            {
                if (this.buttonShowPressed)							buttonStateShow = ButtonState.Pressed;
                else if (this.buttonShowHovered || this.Focused)	buttonStateShow = ButtonState.Hot;
                else												buttonStateShow = ButtonState.Normal;
            }
            ControlRenderer.DrawButton(
                e.Graphics,
                this.rectButtonShow,
                buttonStateShow,
                null,
                iconShow);
        }
コード例 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rectPreview = this.ClientRectangle;
            Rectangle rectImage = new Rectangle(rectPreview.X + 1, rectPreview.Y + 1, rectPreview.Width - 2, rectPreview.Height - 2);
            Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
            Color darkChecker = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);
            e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);
            if (this.prevImage != null)
            {
                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(rectImage.X, rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, rectImage);
            }

            ControlRenderer.DrawBorder(e.Graphics,
                rectPreview,
                BorderStyle.Simple,
                !this.Enabled ? BorderState.Disabled : BorderState.Normal);
        }
コード例 #3
0
        private bool RebarMessageCaptured(ref Message m)
        {
            // Make sure the menu bar obeys the Explorer setting.
            // Was this really so hard, Microsoft?
            if(m.Msg == RB.SETBANDINFO) {
                REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO));
                if((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) {
                    if(MenuHasFocus || MenuBarShown) {
                        pInfo.fStyle &= ~RBBS.HIDDEN;
                    }
                    else {
                        pInfo.fStyle |= RBBS.HIDDEN;
                    }
                    Marshal.StructureToPtr(pInfo, m.LParam, false);
                }
                return false;
            }

            if(m.Msg == WM.ERASEBKGND && (Config.Skin.UseRebarBGColor || Config.Skin.UseRebarImage)) {
                bool fFilled = false;
                using(Graphics graphics = Graphics.FromHdc(m.WParam)) {
                    RECT rect;
                    PInvoke.GetWindowRect(Handle, out rect);
                    Rectangle rectRebar = new Rectangle(0, 0, rect.Width, rect.Height);

                    // Fill the Rebar background color
                    if(Config.Skin.UseRebarBGColor) {
                        using(SolidBrush brush = new SolidBrush(Config.Skin.RebarColor)) {
                            graphics.FillRectangle(brush, rectRebar);
                            fFilled = true;
                        }
                    }
                    else if(Config.Skin.RebarStretchMode == StretchMode.Real) {
                        rebarController.DefWndProc(ref m);
                    }

                    // Draw the Rebar image
                    if(VisualStyleRenderer.IsSupported && Config.Skin.UseRebarImage && Config.Skin.RebarImageFile.Length > 0) {
                        if(bmpRebar == null) {
                            CreateRebarImage();
                        }
                        if(bmpRebar != null) {
                            List<Rectangle> rectTargets = new List<Rectangle>();
                            if(Config.Skin.RebarImageSeperateBars) {
                                int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero);
                                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                RECT rectBand = new RECT();
                                RECT rectMargin = new RECT();
                                for(int i = 0; i < bandCount; i++) {
                                    if(PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) {
                                        continue;
                                    }
                                    PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin);
                                    rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left;
                                    rectBand.top -= rectMargin.top;
                                    rectBand.right += rectMargin.right;
                                    rectBand.bottom += rectMargin.bottom;
                                    rectTargets.Add(rectBand.ToRectangle());
                                }
                            }
                            else {
                                rectTargets.Add(rectRebar);
                            }

                            foreach(Rectangle destRect in rectTargets) {
                                switch(Config.Skin.RebarStretchMode) {
                                    case StretchMode.Real:
                                        Rectangle rectDest2 = new Rectangle(new Point(0, 0), destRect.Size);
                                        Rectangle rectBmp = new Rectangle(new Point(0, 0), bmpRebar.Size);
                                        rectBmp.Intersect(rectDest2);
                                        rectDest2.Intersect(rectBmp);
                                        rectDest2.Offset(destRect.Location);
                                        graphics.DrawImage(bmpRebar, rectDest2, rectBmp, GraphicsUnit.Pixel);
                                        break;

                                    case StretchMode.Tile:
                                        textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar);
                                        textureBrushRebar.TranslateTransform(destRect.X, destRect.Y);
                                        graphics.FillRectangle(textureBrushRebar, destRect);
                                        textureBrushRebar.ResetTransform();
                                        break;

                                    default: // Full
                                        // todo: make this a function
                                        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                        Padding margin = Config.Skin.RebarSizeMargin;
                                        int left = margin.Left;
                                        int top = margin.Top;
                                        int right = margin.Right;
                                        int bottom = margin.Bottom;
                                        int vertical = margin.Vertical;
                                        int horizontal = margin.Horizontal;
                                        int width = bmpRebar.Width;
                                        int height = bmpRebar.Height;
                                        Rectangle[] dstRects = new Rectangle[] {
                                            new Rectangle(destRect.X, destRect.Y, left, top),
                                            new Rectangle(destRect.X + left, destRect.Y, destRect.Width - horizontal, top),
                                            new Rectangle(destRect.Right - right, destRect.Y, right, top),
                                            new Rectangle(destRect.X, destRect.Y + top, left, destRect.Height - vertical),
                                            new Rectangle(destRect.X + left, destRect.Y + top, destRect.Width - horizontal, destRect.Height - vertical),
                                            new Rectangle(destRect.Right - right, destRect.Y + top, right, destRect.Height - vertical),
                                            new Rectangle(destRect.X, destRect.Bottom - bottom, left, bottom),
                                            new Rectangle(destRect.X + left, destRect.Bottom - bottom, destRect.Width - horizontal, bottom),
                                            new Rectangle(destRect.Right - right, destRect.Bottom - bottom, right, bottom)
                                        };
                                        Rectangle[] srcRects = new Rectangle[] {
                                            new Rectangle(0, 0, left, top),
                                            new Rectangle(left, 0, width - horizontal, top),
                                            new Rectangle(width - right, 0, right, top),
                                            new Rectangle(0, top, left, height - vertical),
                                            new Rectangle(left, top, width - horizontal, height - vertical),
                                            new Rectangle(width - right, top, right, height - vertical),
                                            new Rectangle(0, height - bottom, left, bottom),
                                            new Rectangle(left, height - bottom, width - horizontal, bottom),
                                            new Rectangle(width - right, height - bottom, right, bottom),
                                        };
                                        for(int i = 0; i < 9; i++) {
                                            graphics.DrawImage(bmpRebar, dstRects[i], srcRects[i], GraphicsUnit.Pixel);
                                        }
                                        break;
                                }
                            }
                            fFilled = true;
                        }
                    }
                }
                if(fFilled) {
                    m.Result = (IntPtr)1;
                    return true;
                }
            }
            return false;
        }
コード例 #4
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint(e);
			
			Rectangle rectPreview = this.ClientRectangle;
			Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
			Color darkChecker = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);
			e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), this.rectImage);
			if (this.prevImage != null)
			{
				TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
				bgImageBrush.ResetTransform();
				bgImageBrush.TranslateTransform(this.rectImage.X, this.rectImage.Y);
				e.Graphics.FillRectangle(bgImageBrush, this.rectImage);
			}

			if (this.prevSoundInst != null)
			{
				e.Graphics.DrawImage(this.prevImageLum > 0.5f ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack, 
					this.rectPrevSound.X, 
					this.rectPrevSound.Y);
			}
			else
			{
				e.Graphics.DrawImageAlpha(this.prevImageLum > 0.5f ? EditorBaseResCache.IconSpeakerWhite : EditorBaseResCache.IconSpeakerBlack, 
					0.5f,
					this.rectPrevSound.X, 
					this.rectPrevSound.Y);
			}

			ControlRenderer.DrawBorder(e.Graphics, 
				rectPreview, 
				BorderStyle.Simple, 
				!this.Enabled ? BorderState.Disabled : BorderState.Normal);
		}
コード例 #5
0
ファイル: Polyline.cs プロジェクト: EdgarEDT/myitoppsp
        /// <summary>
        /// ��·
        /// </summary>
        /// <param name="g"></param>
        /// <param name="time"></param>
        private void Draw2(Graphics g, int time)
        {
            if (base.DrawVisible) {
                Matrix matrix1 = base.Transform.Matrix.Clone();

                GraphicsContainer container1 = g.BeginContainer();

                g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);

                ClipAndMask.ClipPath.Clip(g, time, this);
                bool flag1 = base.Visible;
                if (!base.Visible) {
                    g.SetClip(Rectangle.Empty);
                }
                float single1 = this.StrokeOpacity;
                if (this.svgAnimAttributes.ContainsKey("fill-opacity")) {
                    single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
                }
                ISvgBrush brush1 = this.GraphBrush;
                using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone()) {
                    path1.Transform(base.GraphTransform.Matrix);
                    if (!base.ShowBound) {

                        float width1 = Width * GraphTransform.Matrix.Elements[0];
                        Stroke stroke = Stroke.GetStroke(this);
                        Color color1 = Color.FromArgb(75, 75, 75);
                        if (stroke.StrokeColor.ToArgb()!=Color.Black.ToArgb()) color1 = stroke.StrokeColor;
                        using (Pen p = new Pen(Color.FromArgb((int)(single1 * 255), color1))) {
                            p.Width = width1;
                            g.DrawPath(p, path1);
                        }
                        if (LineType == "3") {
                            using (Pen p = new Pen(Color.Yellow)) {
                                if (width1 > 30)
                                    p.Width = 2;
                                else
                                    p.Width = 1;
                                //p.DashPattern = new float[] { 10, 10 };
                                g.DrawPath(p, path1);
                            }
                        } else {
                            //using (Pen p = new Pen(Color.Yellow)) {
                            //    if (width1 > 30)
                            //        p.Width = 2;
                            //    else
                            //        p.Width = 1;
                            //    g.DrawPath(p, path1);
                            //}
                        }
                        if (LineType == "4") {

                            using (Pen p =  new Pen(Color.FromArgb((int)(single1*255),color1))) {
                                p.Width = width1;
                                float f22 = width1 / 4f;
                                ImageAttributes imageAttributes = new ImageAttributes();
                                ColorMatrix cmatrix1 = new ColorMatrix();
                                cmatrix1.Matrix00 = 1f;
                                cmatrix1.Matrix11 = 1f;
                                cmatrix1.Matrix22 = 1f;
                                cmatrix1.Matrix33 = single1;//͸����
                                cmatrix1.Matrix44 = 1f;
                                //����͸����
                                imageAttributes.SetColorMatrix(cmatrix1, ColorMatrixFlag.Default, ColorAdjustType.Default);
                                if (BackgroundImage == null) BackgroundImageFile = "road.png";
                                TextureBrush tbush = new TextureBrush(BackgroundImage,new Rectangle(0,0,BackgroundImage.Width,BackgroundImage.Height),imageAttributes);
                                tbush.WrapMode = WrapMode.Tile;
                                for (int i = 0; i < path1.PointCount - 1;i++ ) {
                                    float k = (path1.PathPoints[i+1].Y - path1.PathPoints[i].Y) / (path1.PathPoints[i+1].X - path1.PathPoints[i].X);

                                    float y1 = path1.PathPoints[i].Y - path1.PathPoints[i+1].Y;
                                    float y2 = path1.PathPoints[i].X - path1.PathPoints[i+1].X;
                                    float k2 = (float)Math.Abs(k);
                                    float angle = (float)Math.Atan(k2) * 180 / (float)Math.PI;
                                    if (k < 0) {  angle = 360-angle; }

                                    PointF[] pts = new PointF[] { new PointF(path1.PathPoints[i].X, path1.PathPoints[i].Y - 26) };
                                    Matrix matrix11 = new Matrix();
                                    matrix11.RotateAt(angle, path1.PathPoints[i]);
                                    matrix11.Translate(path1.PathPoints[i].X, path1.PathPoints[i].Y);
                                    matrix11.Scale(width1 / 50, width1 / 50);
                                    //tbush.ScaleTransform(width1 / 50, width1 / 50, MatrixOrder.Append);
                                    //tbush.RotateTransform(angle, MatrixOrder.Append);
                                    //tbush.TranslateTransform(path1.PathPoints[i].X, path1.PathPoints[i].Y , MatrixOrder.Append);
                                    tbush.Transform = matrix11;

                                    p.Brush = tbush.Clone() as TextureBrush;
                                    p.Alignment = PenAlignment.Center;

                                    g.DrawLine(p, path1.PathPoints[i], path1.PathPoints[i + 1]);
                                    tbush.ResetTransform();
                                }
                            }
                            if (BackgroundImageFile == "road.png") {
                                using (Pen p = new Pen(Color.Yellow)) {
                                    if (width1 > 30)
                                        p.Width = 2;
                                    else
                                        p.Width = 1;
                                    g.DrawPath(p, path1);
                                }
                            }
                        }

                    } else {
                        g.DrawPath(new Pen(base.BoundColor), path1);
                    }
                    this.DrawConnect(g);
                }
                matrix1.Dispose();
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
コード例 #6
0
ファイル: TextureBrushTest.cs プロジェクト: nlhepler/mono
		public void ResetTransform ()
		{
			TextureBrush t = new TextureBrush (image);
			t.RotateTransform (90);
			Assert.IsFalse (t.Transform.IsIdentity, "Transform.IsIdentity");
			t.ResetTransform ();
			Assert.IsTrue (t.Transform.IsIdentity, "Reset.IsIdentity");
		}
コード例 #7
0
        public static bool PolyKaleidoscope(ref Bitmap bmp, int nPoly, bool mirrorLeft,
                                                double radius, Color bkColor)
        {
            if ((nPoly < 4) | (nPoly > 20)) return false;

            if (bmp.PixelFormat != PixelFormat.Format24bppRgb)
                return false;

            int w = bmp.Width;
            int h = bmp.Height;

            double r = Math.Min(w, h) / 2d;

            double centerAngle = Math.PI * 2d / (double)nPoly;

            double cx = (double)w / 2d;
            double cy = (double)h / 2d;

            if (mirrorLeft)
                Mirror(ref bmp, cx, cy, 270d, bkColor);
            else
                Mirror(ref bmp, cx, cy, 90d, bkColor);

            double p1x = cx - radius * Math.Tan(centerAngle / 2d) - 1d;
            double p1y = cy - radius;

            double p2x = cx + radius * Math.Tan(centerAngle / 2d) + 1d;
            double p2y = p1y;

            PointF[] pts = { new PointF((float)cx, (float)cy),
                            new PointF((float)p1x, (float)p1y),
                            new PointF((float)p2x, (float)p2y)
                          };

            GraphicsPath pt = new GraphicsPath();
            pt.AddPolygon(pts);

            double degAngle = centerAngle * 180d / Math.PI;
            PointF centerP = new PointF((float)cx, (float)cy);

            GraphicsPath rotPt;
            Matrix mt = new Matrix();
            TextureBrush tb = new TextureBrush(bmp);

            Bitmap tmp = new Bitmap(w, h, bmp.PixelFormat);
            Graphics g = Graphics.FromImage(tmp);
            g.Clear(bkColor);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            for (int i = 0; i < nPoly; i++)
            {
                mt.Reset();
                mt.RotateAt((float)degAngle * i, centerP);

                rotPt = pt.Clone() as GraphicsPath;
                rotPt.Transform(mt);

                tb.ResetTransform();
                tb.Transform = mt;

                g.FillPath(tb, rotPt);
                rotPt.Dispose();
            }

            CallDispose(g, tb, mt, pt, bmp);

            bmp = tmp;
            return true;
        }