public void SetLineOutOfRange() { Page page = new Page(); PageLine line = new PageLine(); page.SetLine(16, line); }
private bool Seek(int charIndex, int lineIndex) { CurrentLine = Math.Clamp(lineIndex, 0, _page.LineCount); if (CurrentLine != lineIndex) { return(false); } PageLine line = _page[lineIndex]; int columnIndex = 0; bool found = false; while (columnIndex <= line.TokenCount && !found) { if (line[columnIndex].Start >= charIndex) { found = true; } columnIndex++; } if (found) { CurrentLine = lineIndex; CurrentColumn = columnIndex; } return(found); }
public void Indexer() { PageLine line = new PageLine(); line[0] = 0x44; line[15] = 0x66; Assert.AreEqual <byte>(0x44, line[0]); Assert.AreEqual <byte>(0x66, line[15]); Assert.AreEqual <byte>(0x00, line[1]); }
private void ProcessPage(Xwt.Drawing.Context g, IEnumerable p) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; Xwt.Drawing.Color bcolorleft = XwtColor.SystemColorToXwtColor(pl.SI.BColorLeft); DrawLine(bcolorleft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2) ); continue; } Xwt.Rectangle rect = new Xwt.Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImage(i, g, rect); continue; } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, g, rect); } if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } if (pi is PageRectangle) { //DrawBackground(g, rect, pi.SI); } DrawBorder(pi, g, rect); } }
public void ToStringInvalidFormat() { try { PageLine line = new PageLine(); Console.WriteLine(line.ToString("X")); } catch (FormatException ex) { Console.WriteLine(ex.Message); throw ex; } }
public void GetLine() { Page page = new Page(); page[250] = 0x33; PageLine line = page.GetLine(15); for (int i = 0; i < PageLine.Size; i++) { Assert.AreEqual <byte>((byte)((i == 10) ? 0x33 : 0), line[i]); } }
public void ToByteArray() { PageLine line = new PageLine(); line[0] = 0x44; line[15] = 0x66; byte[] array = line; Assert.AreEqual(PageLine.Size, array.Length); Assert.AreEqual <byte>(0x44, array[0]); Assert.AreEqual <byte>(0, array[1]); Assert.AreEqual <byte>(0x66, array[15]); }
public void SetLine() { Page page = new Page(); PageLine line = new PageLine(); line[0] = 0x22; line[15] = 0xAA; page.SetLine(0, line); page.SetLine(15, line); Assert.AreEqual <byte>(0x22, page[0]); Assert.AreEqual <byte>(0xAA, page[15]); Assert.AreEqual <byte>(0x22, page[240]); Assert.AreEqual <byte>(0xAA, page[255]); }
public void AppendNewLine(PageLine newLine) { selectedIndex++; Observable.FromEventPattern(newLine.del, "Click").Select(i => i.Sender).Subscribe(sl => { var lineToDelete = (sl as Button).Tag as UIElement; if (lineToDelete is PageLine) { ///TODO: still buggy... //foreach (var l in (lineToDelete as PageLine).GetDependentLineIndices()) { // this.allLines.Children.RemoveAt(l); //} } this.allLines.Children.Remove(lineToDelete); }); newLine.NewUIResult.Subscribe(i => { var smartGrid = new GridSplitter.SmartGrid(); smartGrid.Add(i); this.allLines.Children.Add(smartGrid); newLine.AddDependentLineIndex(selectedIndex); selectedIndex++; }); Observable.FromEventPattern(newLine.input, "PreviewKeyDown").Subscribe(i => { var sender = ((i.Sender as TextBox).Tag as PageLine); var e = (i.EventArgs as KeyEventArgs); if (e.Key == Key.Enter && (Keyboard.IsKeyDown(Key.RightShift) || Keyboard.IsKeyDown(Key.LeftShift))) { var result = CSharp.AppendCSharp(newLine.input.Text, newLine.LineNumber); newLine.SetResult(result); AppendNewLine(new PageLine()); e.Handled = true; } else if (e.Key == Key.Enter && (Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl))) { var result = sender.Result; if (result == "") { result = sender.GetText(); } CSharp.CSharpAssign(result, sender.LineNumber); AppendNewLine(new PageLine()); e.Handled = true; } }); this.allLines.Children.Add(newLine); setFocus(); }
// render all the objects in a page (or any composite object private void ProcessPage(StringBuilder sb, IEnumerable p, Rectangle offset) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, sb, new Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H))); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, PixelsX(pl.SI.BWidthLeft), sb, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2)); continue; } Rectangle rect = new Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImageBackground(i, pi.SI, sb, rect); } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, sb, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, sb, rect); } else if (pi is PageRectangle) { this.DrawRectangle(pi as PageRectangle, sb, rect); } DrawBorder(pi, sb, rect); } }
public void ToFormattedString() { PageLine line = new PageLine(); for (int i = 0; i < PageLine.Size; i++) { line[i] = (byte)(0x30 + i); } Console.WriteLine(line.ToString()); Console.WriteLine(); Console.WriteLine(line.ToString("G")); Console.WriteLine(); Console.WriteLine(line.ToString("H")); Console.WriteLine(); Console.WriteLine(line.ToString("C")); Console.WriteLine(); }
private void Open_Click_1(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); var success = ofd.ShowDialog().Value; if (success) { var xml = XElement.Load(ofd.FileName); resetContent(); foreach (var line in xml.Elements("Line")) { var newLine = PageLine.FromXml(line); this.AppendNewLine(newLine); if (newLine.Type == LineType.Eval) { var result = CSharp.AppendCSharp(newLine.input.Text, newLine.LineNumber); newLine.SetResult(result); } } } }
// render all the objects in a page (or any composite object private void ProcessPage(System.Drawing.Graphics g, IEnumerable p) { // TODO: (Peter) Support can grow and can shrink foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll), PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll)); continue; } RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), PixelsX(pi.W), PixelsY(pi.H)); if ((pi is PagePolygon) || (pi is PageCurve)) { // intentionally empty; polygon's rectangles aren't calculated } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImageBackground(i, pi.SI, g, rect); } if (pi is PageText) { // TODO: enable can shrink, can grow // 2005 spec file, page 9, in the text box has // CanGrow and CanShrink PageText pt = pi as PageText; DrawString(pt, g, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } else if (pi is PageRectangle) { this.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; FillPolygon(ppo, g, rect); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension); } DrawBorder(pi, g, rect); } // TO: convert System.Drawing.Graphics to Xwt.Drawing.Context and draw it to this.g Bitmap bm = new Bitmap(600, 600); g.DrawImage(bm, 600, 600); System.IO.MemoryStream s = new System.IO.MemoryStream(); gImg.Save(s, System.Drawing.Imaging.ImageFormat.Png); gImg.Save("test.png", System.Drawing.Imaging.ImageFormat.Png); // Xwt.Drawing.Image img = Xwt.Drawing.Image.FromStream(s); Xwt.Drawing.Image img = Xwt.Drawing.Image.FromFile("test.png"); xwtContext.DrawImage(img, new Xwt.Rectangle(0, 0, 600, 600), new Xwt.Rectangle(0, 0, 600, 600)); //Xwt.Drawing.TextLayout layout = new Xwt.Drawing.TextLayout(xwtContext); //layout.Font = xwtContext.Font; //layout.Text = "Test"; //xwtContext.DrawTextLayout(layout, 2, 4); }
public void IndexerOutOfRange() { PageLine line = new PageLine(); line[16] = 0x44; }
// render all the objects in a page (or any composite object private void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList) { // TODO: (Peter) Support can grow and can shrink foreach (PageItem pi in p) { //if (pi is PageTextHtml) //{ // PageTextHtml is actually a composite object (just like a page) // if (SelectTool && bHitList) // { // RectangleF hr = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), // PixelsX(pi.W), PixelsY(pi.H)); // _HitList.Add(new HitListEntry(hr, pi)); // } // ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList); // continue; //} if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll), PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll)); continue; } RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), PixelsX(pi.W), PixelsY(pi.H)); // Maintain the hit list //if (bHitList) //{ // if (SelectTool) // { // we need all PageText and PageImage items that have been displayed // if (pi is PageText || pi is PageImage) // { // _HitList.Add(new HitListEntry(rect, pi)); // } // } // // Only care about items with links and tips // else if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null) // { // HitListEntry hle; // if (pi is PagePolygon) // hle = new HitListEntry(pi as PagePolygon, _left - _hScroll, _top - _vScroll, this); // else // hle = new HitListEntry(rect, pi); // _HitList.Add(hle); // } //} if ((pi is PagePolygon) || (pi is PageCurve)) { // intentionally empty; polygon's rectangles aren't calculated } else if (!rect.IntersectsWith(clipRect)) { continue; } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImageBackground(i, pi.SI, g, rect); } if (pi is PageText) { // TODO: enable can shrink, can grow // 2005 spec file, page 9, in the text box has // CanGrow and CanShrink PageText pt = pi as PageText; DrawString(pt, g, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } else if (pi is PageRectangle) { this.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; FillPolygon(ppo, g, rect); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension); } DrawBorder(pi, g, rect); } }
private void ProcessPage(Cairo.Context g, IEnumerable p) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine( pl.SI.BColorLeft.ToCairoColor(), pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2) ); continue; } // RectangleF rect = new RectangleF(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); Cairo.Rectangle rect = new Cairo.Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImage(i, g, rect); continue; } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, g, rect); } if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } if (pi is PageRectangle) { //DrawBackground(g, rect, pi.SI); } // else if (pi is PageEllipse) // { // PageEllipse pe = pi as PageEllipse; // DrawEllipse(pe, g, rect); // } // else if (pi is PagePie) // { // PagePie pp = pi as PagePie; // DrawPie(pp, g, rect); // } // else if (pi is PagePolygon) // { // PagePolygon ppo = pi as PagePolygon; // FillPolygon(ppo, g, rect); // } // else if (pi is PageCurve) // { // PageCurve pc = pi as PageCurve; // DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, // g, pc.Points, pc.Offset, pc.Tension); // } // DrawBorder(pi, g, rect); } }
private void resetContent() { this.allLines.Children.Clear(); this.selectedIndex = 0; PageLine.ResetLineCounter(); }
public ProtocolReadPageRx(byte header, Mode regim) : base(header, 0x5A, regim, new CheckSumXOR7FManager()) { Line = new PageLine(); }
/// <summary> /// Renders all the objects in a Page or composite object. /// </summary> private static void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList, CanvasProperties cp, ref PageItemManager cpim) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) if (cpim.SelectToolEnabled && bHitList) { RectangleF hr = new RectangleF( Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pi.Y + cp.Scroll.X - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pi.W, cp.Dpi.X), Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y)); cpim.HitList.Add(new HitListEntry(hr, pi)); } ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList, cp, ref cpim); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; CanvasPainter.DrawLine( pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, Measurement.PixelsFromPoints(pl.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pl.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pl.X2 + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pl.Y2 + cp.Top - cp.Scroll.Y, cp.Dpi.Y)); continue; } RectangleF rect = new RectangleF( Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pi.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pi.W, cp.Dpi.X), Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y)); // Maintain the hit list if (bHitList) { if (cpim.SelectToolEnabled) { // we need all PageText and PageImage items that have been displayed if (pi is PageText || pi is PageImage) { cpim.HitList.Add(new HitListEntry(rect, pi)); } } // Only care about items with links and tips else if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null) { HitListEntry hle; if (pi is PagePolygon) { hle = new HitListEntry(pi as PagePolygon, cp.Left - cp.Scroll.X, cp.Top - cp.Scroll.Y, ((Canvas)cp.Parent)); } else { hle = new HitListEntry(rect, pi); } cpim.HitList.Add(hle); } } if ((pi is PagePolygon) || (pi is PageCurve)) { // intentionally empty; polygon's rectangles aren't calculated } else if (!rect.IntersectsWith(clipRect)) { continue; } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; CanvasPainter.DrawImageBackground(i, pi.SI, g, rect); } if (pi is PageText) { PageText pt = pi as PageText; CanvasPainter.DrawString(pt, g, rect, cp, cpim); } else if (pi is PageImage) { PageImage i = pi as PageImage; CanvasPainter.DrawImage(i, g, rect, cp, cpim); } else if (pi is PageRectangle) { CanvasPainter.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; CanvasPainter.DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; CanvasPainter.DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; CanvasPainter.FillPolygon(ppo, g, rect, cp); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; CanvasPainter.DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension, cp); } CanvasPainter.DrawBorder(pi, g, rect); } }
// render all the objects in a page (or any composite object private void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll), PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll)); continue; } RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), PixelsX(pi.W), PixelsY(pi.H)); // Maintain the hit list if (bHitList) { // Only care about items with links and tips if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null) { _HitList.Add(new HitListEntry(rect, pi)); } } if (!rect.IntersectsWith(clipRect)) { continue; } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImage(i, g, rect); } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, g, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } else if (pi is PageRectangle) { this.DrawBackground(g, rect, pi.SI); } DrawBorder(pi, g, rect); } }
public ProtocolWritePageTx(byte header, Mode regim) : base(header, 0x55, regim, new CheckSumXOR7FManager()) { Line = new PageLine(); }
public void GetLineOutOfRange() { Page page = new Page(); PageLine line = page.GetLine(16); }
// render all the objects in a page (or any composite object private void ProcessPage(System.Drawing.Graphics g, IEnumerable p) { // TODO: (Peter) Support can grow and can shrink foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll), PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll)); continue; } RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), PixelsX(pi.W), PixelsY(pi.H)); if ((pi is PagePolygon) || (pi is PageCurve)) { // intentionally empty; polygon's rectangles aren't calculated } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImageBackground(i, pi.SI, g, rect); } if (pi is PageText) { // TODO: enable can shrink, can grow // 2005 spec file, page 9, in the text box has // CanGrow and CanShrink PageText pt = pi as PageText; DrawString(pt, g, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } else if (pi is PageRectangle) { this.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; FillPolygon(ppo, g, rect); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension); } DrawBorder(pi, g, rect); } // TO: convert System.Drawing.Graphics to Xwt.Drawing.Context and draw it to this.g Bitmap bm = new Bitmap(gImg.Width, gImg.Height); g.DrawImage(bm, gImg.Width, gImg.Height); // Xwt.Drawing.Image.FromStream does not work. It crashes with both wpf and gtk // As a work around save the image to a temporary file and load it into xwt using the // FromFile method. System.IO.MemoryStream s = new System.IO.MemoryStream(); gImg.Save(s, System.Drawing.Imaging.ImageFormat.Png); string fileName = System.IO.Path.GetTempFileName(); gImg.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); // Xwt.Drawing.Image img = Xwt.Drawing.Image.FromStream(s); Xwt.Drawing.Image img = Xwt.Drawing.Image.FromFile(fileName); xwtContext.DrawImage(img, new Xwt.Rectangle(0, 0, gImg.Width, gImg.Height), new Xwt.Rectangle(0, 0, gImg.Width, gImg.Height)); img.Dispose(); System.IO.File.Delete(fileName); }