Esempio n. 1
0
            public void CreateImage(
                DxfRasterImage rasterImage,
                WW.Math.Point2D imageCorner1,
                WW.Math.Point2D imageCorner2,
                Vector4D transformedOrigin,
                Vector4D transformedXAxis,
                Vector4D transformedYAxis,
                DrawContext.Wireframe drawContext)
            {
                IBitmap bitmap = rasterImage.ImageDef.Bitmap;

                if (!bitmap.IsValid)
                {
                    return;
                }
                imageCorner1 += DxfRasterImage.PixelOffset;
                imageCorner2 -= DxfRasterImage.PixelOffset;
                double width  = (double)bitmap.Width;
                double height = (double)bitmap.Height;

                imageCorner1.X = IntervalD.GetRestrictedValue(imageCorner1.X, 0.0, width - 1.0);
                imageCorner1.Y = IntervalD.GetRestrictedValue(imageCorner1.Y, 0.0, height - 1.0);
                imageCorner2.X = IntervalD.GetRestrictedValue(imageCorner2.X, 0.0, width - 1.0);
                imageCorner2.Y = IntervalD.GetRestrictedValue(imageCorner2.Y, 0.0, height - 1.0);
                bool   flag    = imageCorner1.X != 0.0 || imageCorner1.Y != 0.0 || imageCorner2.X != width - 1.0 || imageCorner2.Y != height - 1.0;
                IntPtr hbitmap = bitmap.Image.GetHbitmap();

                try
                {
                    BitmapSource source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    if (flag)
                    {
                        source = (BitmapSource) new CroppedBitmap(source, new Int32Rect((int)imageCorner1.X, (int)imageCorner1.Y, (int)(imageCorner2.X - imageCorner1.X), (int)(imageCorner2.Y - imageCorner1.Y)));
                    }
                    WW.Math.Point2D   point2D1          = this.matrix4D_0.TransformToPoint2D(transformedOrigin);
                    WW.Math.Point2D   point2D2          = this.matrix4D_0.TransformToPoint2D(transformedXAxis);
                    WW.Math.Point2D   point2D3          = this.matrix4D_0.TransformToPoint2D(transformedYAxis);
                    Vector2D          vector2D1         = point2D2 - point2D1;
                    Vector2D          vector2D2         = point2D3 - point2D1;
                    TransformedBitmap transformedBitmap = new TransformedBitmap();
                    transformedBitmap.BeginInit();
                    transformedBitmap.Source    = source;
                    transformedBitmap.Transform = (Transform) new MatrixTransform(new Matrix(1.0, 0.0, 0.0, 1.0, 0.0, point2D1.Y) * new Matrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0) * new Matrix(1.0, 0.0, 0.0, 1.0, 0.0, -point2D1.Y) * new Matrix(vector2D1.X, vector2D2.X, vector2D1.Y, vector2D2.Y, 0.0, 0.0));
                    transformedBitmap.EndInit();
                    Image image = new Image();
                    image.BeginInit();
                    image.Source          = (ImageSource)transformedBitmap;
                    image.RenderTransform = (Transform) new TranslateTransform(point2D1.X, point2D1.Y);
                    image.Stretch         = Stretch.None;
                    image.EndInit();
                    this.visualCollection_0.Add((Visual)image);
                }
                finally
                {
                    Class975.DeleteObject(hbitmap);
                }
            }
Esempio n. 2
0
        public override bool Equals(object other)
        {
            IntervalD intervalD = other as IntervalD;

            if (intervalD == null || this.double_0 != intervalD.double_0 || (this.bool_0 != intervalD.bool_0 || this.double_1 != intervalD.double_1))
            {
                return(false);
            }
            return(this.bool_1 == intervalD.bool_1);
        }
Esempio n. 3
0
            public void CreateImage(
                DxfRasterImage rasterImage,
                WW.Math.Point2D imageCorner1,
                WW.Math.Point2D imageCorner2,
                Vector4D transformedOrigin,
                Vector4D transformedXAxis,
                Vector4D transformedYAxis,
                DrawContext.Wireframe drawContext)
            {
                IBitmap bitmap = rasterImage.ImageDef == null ? (IBitmap)null : rasterImage.ImageDef.Bitmap;

                if (bitmap == null || !bitmap.IsValid)
                {
                    return;
                }
                imageCorner1 += DxfRasterImage.PixelOffset;
                imageCorner2 -= DxfRasterImage.PixelOffset;
                double width  = (double)bitmap.Width;
                double height = (double)bitmap.Height;

                imageCorner1.X = IntervalD.GetRestrictedValue(imageCorner1.X, 0.0, width - 1.0);
                imageCorner1.Y = IntervalD.GetRestrictedValue(imageCorner1.Y, 0.0, height - 1.0);
                imageCorner2.X = IntervalD.GetRestrictedValue(imageCorner2.X, 0.0, width - 1.0);
                imageCorner2.Y = IntervalD.GetRestrictedValue(imageCorner2.Y, 0.0, height - 1.0);
                bool   flag    = imageCorner1.X != 0.0 || imageCorner1.Y != 0.0 || imageCorner2.X != width - 1.0 || imageCorner2.Y != height - 1.0;
                IntPtr hbitmap = bitmap.Image.GetHbitmap();

                try
                {
                    BitmapSource source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    if (flag)
                    {
                        source = (BitmapSource) new CroppedBitmap(source, new Int32Rect((int)imageCorner1.X, (int)imageCorner1.Y, (int)(imageCorner2.X - imageCorner1.X), (int)(imageCorner2.Y - imageCorner1.Y)));
                    }
                    WW.Math.Point2D point2D1  = this.matrix4D_0.TransformToPoint2D(transformedOrigin);
                    WW.Math.Point2D point2D2  = this.matrix4D_0.TransformToPoint2D(transformedXAxis);
                    WW.Math.Point2D point2D3  = this.matrix4D_0.TransformToPoint2D(transformedYAxis);
                    Vector2D        vector2D1 = point2D2 - point2D1;
                    Vector2D        vector2D2 = point2D3 - point2D1;
                    Image           image     = new Image();
                    image.BeginInit();
                    image.Source          = (ImageSource)source;
                    image.RenderTransform = (Transform) new MatrixTransform(new Matrix(1.0, 0.0, 0.0, -1.0, 0.0, source.Height) * new Matrix(vector2D1.X, vector2D1.Y, vector2D2.X, vector2D2.Y, point2D1.X, point2D1.Y));
                    image.Stretch         = Stretch.None;
                    image.Tag             = this.objectTaggerDelegate_0((DxfEntity)rasterImage, (DrawContext)drawContext);
                    image.EndInit();
                    this.linkedListNodeRef_0.Insert((Interface37) new Class747((FrameworkElement)image));
                }
                finally
                {
                    Class975.DeleteObject(hbitmap);
                }
            }
Esempio n. 4
0
 public bool Overlaps(IntervalD other, double precision)
 {
     if ((!this.bool_0 || !other.bool_1 ? (this.double_0 < other.double_1 - precision ? 1 : 0) : (this.double_0 < other.double_1 + precision ? 1 : 0)) == 0)
     {
         return(false);
     }
     if (this.bool_1 && other.bool_0)
     {
         return(this.double_1 > other.double_0 - precision);
     }
     return(this.double_1 > other.double_0 + precision);
 }
Esempio n. 5
0
 public bool Overlaps(IntervalD other)
 {
     if ((!this.bool_0 || !other.bool_1 ? (this.double_0 < other.double_1 ? 1 : 0) : (this.double_0 <= other.double_1 ? 1 : 0)) == 0)
     {
         return(false);
     }
     if (this.bool_1 && other.bool_0)
     {
         return(this.double_1 >= other.double_0);
     }
     return(this.double_1 > other.double_0);
 }