public static void DrawBorder(ChartRenderer renderer, ExtRect rect, GfxBorderStyle borderStyle) { int rL = rect.Left; int rT = rect.Top; int rR = rect.Right; int rB = rect.Bottom; switch (borderStyle) { case GfxBorderStyle.Single: DrawSingleRect(renderer, rL, rT, rect.GetWidth(), rect.GetHeight(), DefaultPenWidth); break; case GfxBorderStyle.Double: DrawDoubleRect(renderer, rL, rT, rect.GetWidth(), rect.GetHeight(), DefaultStreak, DefaultPenWidth); break; case GfxBorderStyle.Triple: DrawTripleRect(renderer, rL, rT, rect.GetWidth(), rect.GetHeight(), DefaultStreak, DefaultPenWidth); break; case GfxBorderStyle.Sunken3D: case GfxBorderStyle.Raised3D: Draw3D(renderer, rL, rT, rR, rB, borderStyle, DefaultPenWidth); break; case GfxBorderStyle.SingleSquareCuts: DrawSingleSquareCuts(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultPenWidth); break; case GfxBorderStyle.DoubleSquareCuts: DrawDoubleSquareCuts(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultStreak, DefaultPenWidth); break; case GfxBorderStyle.SingleRoundCuts: DrawSingleRoundCuts(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultPenWidth); break; case GfxBorderStyle.DoubleRoundCuts: DrawDoubleRoundCuts(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultStreak, DefaultPenWidth); break; case GfxBorderStyle.SingleBevels: DrawSingleBevels(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultPenWidth); break; case GfxBorderStyle.DoubleBevels: DrawDoubleBevels(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultStreak, DefaultPenWidth); break; case GfxBorderStyle.CrossCorners: DrawCrossCorners(renderer, rL, rT, rR, rB, DefaultAngleOffset, DefaultPenWidth); break; } }
public override void UpdateView() { ExtRect cr = fChart.GetClientRect(); int height = Math.Min(cr.GetHeight() - (PADDING_Y << 1), RADIUS); int width = (int)GetChordLength(height, (float)(SEGMENT_ANGLE * (Math.PI / 180.0f))); fDestRect = ExtRect.CreateBounds(cr.Left + PADDING_X, cr.Top + Math.Max(PADDING_Y, (cr.GetHeight() - height) >> 1), width, height); }
public static ExtRect NormalizeFormRect(ExtRect winRect) { // Travis CI does not have access to UI and tests aren't performed. #if !CI_MODE //------------------------------------------------------------------ // 2016-09-30 Ruslan Garipov <*****@*****.**> // Restrict position and size of the main window. // FIXME: DPI-aware code still required here. //------------------------------------------------------------------ Screen screen = Screen.FromRectangle(Rt2Rt(winRect)); if (screen != null) { Rectangle workArea = screen.WorkingArea; int width = winRect.GetWidth(); int height = winRect.GetHeight(); // Besides disallowing to the main window to have its right // and bottom borders overhanged entire virtual workspace, // combined from all available monitors, this code also // does not allow to have this window "between" two // monitors. This may be UNWANTED BEHAVIOR. winRect.Left = Math.Max(workArea.Left, Math.Min(workArea.Right - width, winRect.Left)); winRect.Top = Math.Max(workArea.Top, Math.Min(workArea.Bottom - height, winRect.Top)); winRect.Right = winRect.Left + width - 1; winRect.Bottom = winRect.Top + height - 1; } #endif return(winRect); }
public override void UpdateView() { ExtRect cr = fChart.GetClientRect(); if (fGrowOver) { int height = cr.GetHeight() - (PADDING_Y << 1); fDestRect = new Rectangle(cr.Right - (PADDING_X + Width), cr.Top + PADDING_Y, Width, height); } else { int height = Math.Min(cr.GetHeight() - (PADDING_Y << 1), Height); fDestRect = new Rectangle(cr.Right - (PADDING_X + Width), cr.Top + Math.Max(PADDING_Y, (cr.GetHeight() - height) >> 1), Width, height); } }
public IImage CreateImage(Stream stream, int thumbWidth, int thumbHeight, ExtRect cutoutArea) { if (stream == null) { throw new ArgumentNullException("stream"); } using (Bitmap bmp = new Bitmap(stream)) { bool cutoutIsEmpty = cutoutArea.IsEmpty(); int imgWidth = (cutoutIsEmpty) ? bmp.Width : cutoutArea.GetWidth(); int imgHeight = (cutoutIsEmpty) ? bmp.Height : cutoutArea.GetHeight(); if (thumbWidth > 0 && thumbHeight > 0) { float ratio = SysUtils.ZoomToFit(imgWidth, imgHeight, thumbWidth, thumbHeight); imgWidth = (int)(imgWidth * ratio); imgHeight = (int)(imgHeight * ratio); } Bitmap newImage = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb); using (Graphics graphic = Graphics.FromImage(newImage)) { graphic.InterpolationMode = InterpolationMode.HighQualityBicubic; graphic.SmoothingMode = SmoothingMode.HighQuality; graphic.PixelOffsetMode = PixelOffsetMode.HighQuality; graphic.CompositingQuality = CompositingQuality.HighQuality; if (cutoutIsEmpty) { graphic.DrawImage(bmp, 0, 0, imgWidth, imgHeight); } else { Rectangle destRect = new Rectangle(0, 0, imgWidth, imgHeight); //Rectangle srcRect = cutoutArea.ToRectangle(); graphic.DrawImage(bmp, destRect, cutoutArea.Left, cutoutArea.Top, cutoutArea.GetWidth(), cutoutArea.GetHeight(), GraphicsUnit.Pixel); } } return(new ImageHandler(newImage)); } }
public IImage CreateImage(Stream stream, int thumbWidth, int thumbHeight, ExtRect cutoutArea) { if (stream == null) { throw new ArgumentNullException("stream"); } using (Bitmap bmp = new Bitmap(stream)) { bool cutoutIsEmpty = cutoutArea.IsEmpty(); int imgWidth = (cutoutIsEmpty) ? bmp.Width : cutoutArea.GetWidth(); int imgHeight = (cutoutIsEmpty) ? bmp.Height : cutoutArea.GetHeight(); if (thumbWidth > 0 && thumbHeight > 0) { float ratio = GfxHelper.ZoomToFit(imgWidth, imgHeight, thumbWidth, thumbHeight); imgWidth = (int)(imgWidth * ratio); imgHeight = (int)(imgHeight * ratio); } Bitmap newImage = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb); using (Graphics graphic = new Graphics(newImage)) { graphic.AntiAlias = true; graphic.ImageInterpolation = ImageInterpolation.High; graphic.PixelOffsetMode = PixelOffsetMode.Half; if (cutoutIsEmpty) { graphic.DrawImage(bmp, 0, 0, imgWidth, imgHeight); } else { RectangleF sourRect = new RectangleF(cutoutArea.Left, cutoutArea.Top, cutoutArea.GetWidth(), cutoutArea.GetHeight()); RectangleF destRect = new RectangleF(0, 0, imgWidth, imgHeight); graphic.DrawImage(bmp, sourRect, destRect); } } return(new ImageHandler(newImage)); } }
public void Test_ExtRect() { ExtRect rt = ExtRect.Create(0, 0, 9, 9); Assert.AreEqual(0, rt.Left); Assert.AreEqual(0, rt.Top); Assert.AreEqual(9, rt.Right); Assert.AreEqual(9, rt.Bottom); Assert.AreEqual(10, rt.GetHeight()); Assert.AreEqual(10, rt.GetWidth()); rt = ExtRect.CreateBounds(0, 0, 10, 10); Assert.AreEqual(0, rt.Left); Assert.AreEqual(0, rt.Top); Assert.AreEqual(9, rt.Right); Assert.AreEqual(9, rt.Bottom); Assert.AreEqual(10, rt.GetHeight()); Assert.AreEqual(10, rt.GetWidth()); Assert.AreEqual("{X=0,Y=0,Width=10,Height=10}", rt.ToString()); Assert.IsTrue(rt.Contains(5, 5)); rt.Inflate(3, -2); Assert.AreEqual("{X=3,Y=-2,Width=4,Height=14}", rt.ToString()); rt.Offset(2, 5); Assert.AreEqual("{X=5,Y=3,Width=4,Height=14}", rt.ToString()); rt = rt.GetOffset(10, 10); Assert.AreEqual("{X=15,Y=13,Width=4,Height=14}", rt.ToString()); Assert.IsTrue(rt.IntersectsWith(ExtRect.Create(16, 14, 20, 20))); rt = ExtRect.CreateEmpty(); Assert.IsTrue(rt.IsEmpty()); Assert.IsFalse(rt.Contains(5, 5)); }
public void CalcBounds(int lines, ChartRenderer renderer) { try { InitInfo(lines); DefineExpands(); int maxwid = 0; for (int k = 0; k < lines; k++) { int wt = renderer.GetTextWidth(Lines[k], fModel.DrawFont); if (maxwid < wt) { maxwid = wt; } } int pad2side = (fModel.NodePadding * 2); fWidth = pad2side + maxwid; fHeight = pad2side + renderer.GetTextHeight(fModel.DrawFont) * lines; if (fPortrait != null) { ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1); portRt.Inflate(3, 3); int rtW = portRt.GetWidth(); int rtH = portRt.GetHeight(); int imgW = fPortrait.Width; int imgH = fPortrait.Height; float ratio = SysUtils.ZoomToFit(imgW, imgH, rtW, rtH); imgW = (int)Math.Round(imgW * ratio); imgH = (int)Math.Round(imgH * ratio); PortraitArea = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH); fPortraitWidth = imgW; fWidth += imgW; } } catch (Exception ex) { Logger.LogWrite("TreeChartPerson.CalcBounds(): " + ex.Message); } }
public static void RestoreFormRect(Form form, ExtRect rt, Eto.Forms.WindowState winState) { // check for new and empty struct if (form == null || rt.IsEmpty()) { return; } if (winState != Eto.Forms.WindowState.Minimized) { form.Location = new Point(rt.Left, rt.Top); form.Width = rt.GetWidth(); form.Height = rt.GetHeight(); form.WindowState = winState; } else { form.WindowState = Eto.Forms.WindowState.Maximized; } }
public static void RestoreFormRect(Form form, ExtRect rt, FormWindowState winState) { // check for new and empty struct if (form == null || rt.IsEmpty()) { return; } if (winState != FormWindowState.Minimized) { form.Left = rt.Left; form.Top = rt.Top; form.Width = rt.GetWidth(); form.Height = rt.GetHeight(); form.WindowState = winState; } else { form.WindowState = FormWindowState.Maximized; } }
public static Rectangle Rt2Rt(ExtRect ert) { return(new Rectangle(ert.Left, ert.Top, ert.GetWidth(), ert.GetHeight())); }
private void SetMultimediaLink(GEDCOMMultimediaLink value) { fMultimediaLink = value; if (fMultimediaLink == null || fMultimediaLink.Value == null) { return; } GEDCOMMultimediaRecord mmRec = (GEDCOMMultimediaRecord)fMultimediaLink.Value; IImage img = fBase.Context.LoadMediaImage(mmRec.FileReferences[0], false); if (img == null) { return; } imageView1.OpenImage(((ImageHandler)img).Handle); if (fMultimediaLink.IsPrimaryCutout) { ExtRect rt = fMultimediaLink.CutoutPosition.Value; imageView1.SelectionRegion = new RectangleF(rt.Left, rt.Top, rt.GetWidth(), rt.GetHeight()); } }
public void CalcBounds(int lines, ChartRenderer renderer) { try { TreeChartOptions options = fModel.Options; InitInfo(lines); DefineExpands(); int bh = renderer.GetTextHeight(fModel.BoldFont); int th = renderer.GetTextHeight(fModel.DrawFont); int maxwid = 0; int height = 0; for (int k = 0; k < lines; k++) { IFont font; if (options.BoldNames && k < NameLines) { height += bh; font = fModel.BoldFont; } else { height += th; font = fModel.DrawFont; } int wt = renderer.GetTextWidth(Lines[k], font); if (maxwid < wt) { maxwid = wt; } } int pad2side = (fModel.NodePadding * 2); fWidth = pad2side + maxwid; fHeight = pad2side + height; if (fPortrait != null) { ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1); portRt.Inflate(-3, -3); int rtW = portRt.GetWidth(); int rtH = portRt.GetHeight(); int imgW = fPortrait.Width; int imgH = fPortrait.Height; float ratio = GfxHelper.ZoomToFit(imgW, imgH, rtW, rtH); imgW = (int)Math.Round(imgW * ratio); imgH = (int)Math.Round(imgH * ratio); PortraitArea = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH); fPortraitWidth = imgW; fWidth += imgW; } } catch (Exception ex) { Logger.WriteError("TreeChartPerson.CalcBounds()", ex); } }