void UpdatePath() { if (_borderShape == null) { return; } var strokeThickness = _borderPath?.StrokeThickness ?? 0; var width = ActualWidth; var height = ActualHeight; if (width <= 0 || height <= 0) { return; } var pathSize = new Graphics.Rectangle(0, 0, width + strokeThickness, height + strokeThickness); var shapePath = _borderShape.PathForBounds(pathSize); var geometry = shapePath.AsPathGeometry(); if (_borderPath != null) { _borderPath.Data = geometry; _borderPath.RenderTransform = new TranslateTransform() { X = -(strokeThickness / 2), Y = -(strokeThickness / 2) }; } }
protected override WSize ArrangeOverride(global::Windows.Foundation.Size finalSize) { var myRect = new WRect(0, 0, finalSize.Width, finalSize.Height); if (Control != null) { Control.Arrange(myRect); } var mauiContext = Element?.Handler?.MauiContext; if (Element is not IVisualTreeElement vte || mauiContext == null) { return(finalSize); } var mauiRect = new Graphics.Rectangle(0, 0, finalSize.Width, finalSize.Height); foreach (var child in vte.GetVisualChildren()) { if (child is Maui.IElement childElement && childElement.Handler is IPlatformViewHandler nvh) { nvh.PlatformArrangeHandler(mauiRect); } } return(finalSize); }
PathF IShape.PathForBounds(Graphics.Rectangle bounds) { var path = new PathF(); AppendPath(path); return(path); }
public override void OnBoundsChanged(Graphics.Rectangle oldRect) { base.OnBoundsChanged(oldRect); if (Width > 0 && Height > 0) { UpdatePath(); } }
public void BuildBitmap001() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(2, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); IDjvuPage page = document.Pages[0]; Graphics.Rectangle rect = new Graphics.Rectangle(100, 0, 100, 100); var bitmap = page.BuildBitmap(rect, 1, 1, null); Assert.NotNull(bitmap); } }
public void GetBitmapList002() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(1, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; var rect = new Graphics.Rectangle(0, 0, 0, 0); var image = page.GetBitmapList(rect, 1, 1, null); Assert.NotNull(image); } }
public void GetPixelMap001() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(10, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; Graphics.Rectangle rect = new Graphics.Rectangle(); var image = page.GetPixelMap(rect, 1, 2.2, null); VerifyPixelMap(image); } }
public void GetTextForLocation002() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(10, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; Graphics.Rectangle rect = new Graphics.Rectangle(page.Width / 2, 0, page.Width / 2, page.Height); var result = page.GetTextForLocation(rect); Assert.NotNull(result); Assert.IsType <string>(result); } }
public void GetPixelMap003() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(3, out pageCount)) { int count = 0; try { Util.VerifyDjvuDocument(pageCount, document); foreach (DjvuPage page in document.Pages) { if (count > 0) { break; } var jb2img = page.ForegroundJB2Image; Assert.NotNull(jb2img); Graphics.Rectangle rect = new Graphics.Rectangle(0, 0, page.Width, page.Height); Graphics.PixelMap map = new Graphics.PixelMap(); Graphics.IPixelMap result = null; result = page.GetPixelMap(rect, 1, 2.2, map); VerifyPixelMap(result); Graphics.Rectangle rect12 = new Graphics.Rectangle(0, 0, page.Width / 12, page.Height / 12); Graphics.PixelMap map2 = new Graphics.PixelMap(); result = null; result = page.GetPixelMap(rect12, 12, 2.2, map2); VerifyPixelMap(result); count++; } } catch (Exception err) { Util.FailOnException(err, "Error on DjvuPage.GetPixelMap call cycle count {0}", count); } } }
private Window2DTest() : base(800, 600, "TriEngine2D Test") { Services.Provide(new InputManager(this), new AudioManager()); _controlManager = new ControlManager(); ResourceManager.LoadSong("unknown1", "menu1.ogg"); ResourceManager.LoadSong("call", "menu2.ogg"); ResourceManager.LoadSong("pirates", "menu3.ogg").IsLooped = true; ResourceManager.LoadSound("test", "test1.wav"); ResourceManager.LoadSound("test2", "test2.wav"); //Services.Audio.LoadSong("unknown2", "menu4.ogg"); _font = ResourceManager.LoadFont("Anon", "Anonymous.ttf", 32); _control = new Label { Rectangle = new Rectangle(100, 100, 250, 250), Color = Color.Green, Alignment = QFontAlignment.Left, Text = "Test" }; ((Label)_control).SetFont(_font); _control.Clicked += ControlClicked; _controlManager.AddControl(_control); _text = new TextObject("Hello, World!", _font, new Point <int>(100, 50), QFontAlignment.Left); _label = new Label(); _label.SetFont(_font); _label.Position = new Point <int>(250, 300); _label.Text = "Foo Bar Baz"; _label.Alignment = QFontAlignment.Right; _controlManager.AddControl(_label); _link = new LinkLabel(); _link.SetFont(_font); _link.Position = new Point <int>(300, 500); _link.Text = "Go to google"; _link.Alignment = QFontAlignment.Centre; _link.Url = "http://www.google.com/"; _controlManager.AddControl(_link); _triangle = new Triangle(new Point <int>(100, 25), new Point <int>(50, 100), new Point <int>(150, 100)); _rectangle = new Graphics.Rectangle(new Rectangle(200, 100, 100, 200)); }
public void GetBgPixmap_Theory(int subsample) { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(2, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; Graphics.Rectangle rect = new Graphics.Rectangle(0, 0, page.Width / subsample, page.Height / subsample); Graphics.PixelMap map = new Graphics.PixelMap(); var result = page.GetBgPixmap(rect, subsample, 2.2, map); Assert.NotNull(result); Assert.IsType <Graphics.PixelMap>(result); Assert.Equal <int>(3, result.BytesPerPixel); Assert.Equal <int>(0, result.BlueOffset); Assert.Equal <int>(1, result.GreenOffset); Assert.Equal <int>(2, result.RedOffset); } }
public void GetBgPixmap001() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(1, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; Graphics.Rectangle rect = new Graphics.Rectangle(0, 0, 1000, 1500); Graphics.PixelMap map = new Graphics.PixelMap(); var result = page.GetBgPixmap(rect, 1, 2.2, map); Assert.NotNull(result); Assert.IsType <Graphics.PixelMap>(result); Assert.Equal <int>(3, result.BytesPerPixel); Assert.Equal <int>(0, result.BlueOffset); Assert.Equal <int>(1, result.GreenOffset); Assert.Equal <int>(2, result.RedOffset); } }
public void GetBitmapList001() { int pageCount = 0; using (DjvuDocument document = Util.GetTestDocument(1, out pageCount)) { Util.VerifyDjvuDocument(pageCount, document); var page = document.FirstPage; DjvuNet.Graphics.Rectangle rect = new Graphics.Rectangle(0, 0, page.Width / 12, page.Height / 12); // By setting subsample 1, align 0 one gets AccessViolationException // subsample 0, align 0 - 10 gives ArgumentException // subsample 12, align 0 gives NullReferenceException // subsample 1 - 12, align 1, components list 1 - 5 or null is OK var image = page.GetBitmapList(rect, 1, 1, null); //new List<int>(new int[] { 1, 2, 3, 4, 5 })); Assert.NotNull(image); var image2 = page.GetBitmapList(rect, 1, 1, new List <int>(new int[] { 1, 2, 3, 4, 5 })); Assert.NotNull(image2); } }
void UpdateClip() { if (Child == null) { return; } var clipGeometry = Clip; if (clipGeometry == null) { return; } double width = Child.ActualWidth; double height = Child.ActualHeight; if (height <= 0 && width <= 0) { return; } var visual = ElementCompositionPreview.GetElementVisual(Child); var compositor = visual.Compositor; var pathSize = new Graphics.Rectangle(0, 0, width, height); var clipPath = clipGeometry.PathForBounds(pathSize); var device = CanvasDevice.GetSharedDevice(); var geometry = clipPath.AsPath(device); var path = new CompositionPath(geometry); var pathGeometry = compositor.CreatePathGeometry(path); var geometricClip = compositor.CreateGeometricClip(pathGeometry); visual.Clip = geometricClip; }
/// <summary> /// Orients the rectangle for the proper page location /// </summary> /// <param name="rectangle"></param> /// <param name="pageHeight"></param> /// <returns></returns> public static Rectangle OrientRectangle(this Graphics.Rectangle rectangle, int pageHeight) { return(new Rectangle(rectangle.Right, pageHeight - rectangle.Bottom - rectangle.Height, rectangle.Width, rectangle.Height)); }
public override void PlatformArrange(Graphics.Rectangle frame) { base.PlatformArrange(frame); }
public static (int left, int top, int right, int bottom) ToPixels(this Context context, Graphics.Rectangle rectangle) { return ( (int)context.ToPixels(rectangle.Left), (int)context.ToPixels(rectangle.Top), (int)context.ToPixels(rectangle.Right), (int)context.ToPixels(rectangle.Bottom) ); }