/// <summary>Updates the rectangles used by the control</summary> protected override void UpdateRectangles() { // Get the bounding box first base.UpdateRectangles(); // Update text rect textRect = boundingBox; // First inflate by border to compute render rects textRect.Inflate(-border, -border); // Update the render rectangles elementRects[0] = textRect; elementRects[1] = new System.Drawing.Rectangle(boundingBox.Left, boundingBox.Top, (textRect.Left - boundingBox.Left), (textRect.Top - boundingBox.Top)); elementRects[2] = new System.Drawing.Rectangle(textRect.Left, boundingBox.Top, textRect.Width, (textRect.Top - boundingBox.Top)); elementRects[3] = new System.Drawing.Rectangle(textRect.Right, boundingBox.Top, (boundingBox.Right - textRect.Right), (textRect.Top - boundingBox.Top)); elementRects[4] = new System.Drawing.Rectangle(boundingBox.Left, textRect.Top, (textRect.Left - boundingBox.Left), textRect.Height); elementRects[5] = new System.Drawing.Rectangle(textRect.Right, textRect.Top, (boundingBox.Right - textRect.Right), textRect.Height); elementRects[6] = new System.Drawing.Rectangle(boundingBox.Left, textRect.Bottom, (textRect.Left - boundingBox.Left), (boundingBox.Bottom - textRect.Bottom)); elementRects[7] = new System.Drawing.Rectangle(textRect.Left, textRect.Bottom, textRect.Width, (boundingBox.Bottom - textRect.Bottom)); elementRects[8] = new System.Drawing.Rectangle(textRect.Right, textRect.Bottom, (boundingBox.Right - textRect.Right), (boundingBox.Bottom - textRect.Bottom)); // Inflate further by spacing textRect.Inflate(-spacing, -spacing); // Make the underlying rich text box the same size textData.Size = textRect.Size; }
public override System.Drawing.Bitmap Render(System.Drawing.Graphics g, System.Drawing.Bitmap b, params int[] options) { System.Drawing.Color bc = DrawingBackColor; System.Drawing.Color fc = DrawingForeColor; System.Drawing.Rectangle r = System.Drawing.Rectangle.Empty; System.Drawing.Size o = InnerSize; bool vm = (AccountType)options[0] == AccountType.VendingMachine; System.Drawing.Size sz = vm ? new System.Drawing.Size(o.Width - 1, o.Width * 2 / 3) : new System.Drawing.Size(o.Height * 2 / 3, o.Height - 1); int w = (vm ? (o.Height - o.Width / 3) : (o.Width - o.Height / 3)) / options[3]; for (int i = 0; i < (options[2] > options[3] ? options[3] : options[2]); i++) { r = vm ? new System.Drawing.Rectangle(0, i * w, sz.Width, sz.Height) : new System.Drawing.Rectangle(i * w, 0, sz.Width, sz.Height); g.FillEllipse(new System.Drawing.SolidBrush(bc), r); g.DrawEllipse(new System.Drawing.Pen(new System.Drawing.SolidBrush(fc)), r); } if (!r.IsEmpty) { string s = options[1].ToString(); if (vm) { r.Inflate(s.Length > 1 ? -3 : -11, -2); } else { r.Inflate(s.Length > 1 ? 4 : -4, -8); } System.Drawing.Font fnt = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold); g.DrawString(s, fnt, new System.Drawing.SolidBrush(fc), r); } return(b); }
private void btnLogIn_Paint(object sender, PaintEventArgs e) { try { //LOGIN ROUNDED BUTTON System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = btnLogIn.ClientRectangle; newRectangle.Inflate(18, 18); e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); newRectangle.Inflate(-1, -1); buttonPath.AddEllipse(newRectangle); btnLogIn.Region = new System.Drawing.Region(buttonPath); } catch (Exception ex) { MessageBox.Show(ex.Message, "User Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected override void OnPaintBackground(ElementPaintEventArgs e) { var bounds = new System.Drawing.Rectangle( e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1 ); for (int i = 1; i <= BorderWidth; i++) { double offset = (double)i / BorderWidth; var color = InterpolateBorderColor(offset); using (var pen = new System.Drawing.Pen(color, 1)) { e.Graphics.DrawRectangle( pen, bounds ); } bounds.Inflate(-1, -1); } }
protected override void Layout() { base.Layout(); int n = 3; System.Drawing.Rectangle rec0 = GH_Convert.ToRectangle(Bounds); rec0.Height += 22 * n; System.Drawing.Rectangle rec1 = rec0; rec1.Y = rec1.Bottom - (22 * n); // position of button (-ve is upwards) rec1.Height = 22; // height of button rec1.Inflate(-2, -2); System.Drawing.Rectangle rec2 = rec0; rec2.Y = rec2.Bottom - 22 * (n - 1); rec2.Height = 22; rec2.Inflate(-2, -2); System.Drawing.Rectangle rec3 = rec0; rec3.Y = rec3.Bottom - 22 * (n - 2); rec3.Height = 22; rec3.Inflate(-2, -2); Bounds = rec0; Button1Bounds = rec1; Button2Bounds = rec2; Button3Bounds = rec3; }
/// <summary>Update the rectangles for the list box control</summary> protected override void UpdateRectangles() { // Get bounding box base.UpdateRectangles(); // Calculate the size of the selection rectangle selectionRect = boundingBox; selectionRect.Width -= scrollWidth; selectionRect.Inflate(-border, -border); textRect = selectionRect; textRect.Inflate(-margin, 0); // Update the scroll bars rects too scrollbarControl.SetLocation(boundingBox.Right - scrollWidth, boundingBox.Top); scrollbarControl.SetSize(scrollWidth, height); FontNode fNode = DialogResourceManager.GetGlobalInstance().GetFontNode((int)(elementList[0] as Element).FontIndex); if ((fNode != null) && (fNode.Height > 0)) { scrollbarControl.PageSize = (int)(textRect.Height / fNode.Height); // The selected item may have been scrolled off the page. // Ensure that it is in page again. scrollbarControl.ShowItem(selectedIndex); } }
public static void Draw3DButton(System.Drawing.Graphics g, System.Drawing.Rectangle rect, bool isPressed) { // background WFRect bgRect = rect; //bgRect.Inflate(-1, -1); bgRect.Offset(1, 1); g.FillRectangle(isPressed ? RGBrushes.Black : RGBrushes.White, bgRect); // outter frame g.DrawLine(System.Drawing.Pens.Black, rect.X + 1, rect.Y, rect.Right - 1, rect.Y); g.DrawLine(System.Drawing.Pens.Black, rect.X + 1, rect.Bottom, rect.Right - 1, rect.Bottom); g.DrawLine(System.Drawing.Pens.Black, rect.X, rect.Y + 1, rect.X, rect.Bottom - 1); g.DrawLine(System.Drawing.Pens.Black, rect.Right, rect.Y + 1, rect.Right, rect.Bottom - 1); // content WFRect bodyRect = rect; bodyRect.Inflate(-1, -1); bodyRect.Offset(1, 1); g.FillRectangle(System.Drawing.Brushes.LightGray, bodyRect); // shadow g.DrawLines(isPressed ? RGPens.White : System.Drawing.Pens.DimGray, new System.Drawing.Point[] { new System.Drawing.Point(rect.Left + 1, rect.Bottom - 1), new System.Drawing.Point(rect.Right - 1, rect.Bottom - 1), new System.Drawing.Point(rect.Right - 1, rect.Top + 1), }); }
private System.Drawing.Rectangle GetObjectInvalidationArea() { System.Drawing.Rectangle result = GripsProvider.GetInvalidationRectangle(); result = System.Drawing.Rectangle.Union(result, _objectHost.HostViewer.WorkspaceToControl(_obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point)); result.Inflate(VObject.InvalidationMargin); return(result); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { // if (this.Type != ButtonType.None) // { // if (this.Parent != null) // e.Graphics.DrawRectangle(new System.Drawing.Pen(this.Parent.BackColor),this.Location.X,this.Location.Y,this.Width,this.Height); // e.Graphics.DrawImage(this.Image,this.Location.X,this.Location.Y,this.Width,this.Height); // return; // } base.OnPaint(e); if (m_enumGradientSource != Button.GradientSource.None) { System.Drawing.Graphics g = e.Graphics; System.Drawing.Rectangle clientRect = this.ClientRectangle; clientRect.Inflate(-1, -1); System.Drawing.Brush backgroundBrush; switch (m_enumGradientSource) { case Button.GradientSource.Color: backgroundBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height), this.m_clrGradientStart, this.m_clrGradientEnd, this.m_2dMode); g.FillRectangle(backgroundBrush, clientRect); g.DrawString(this.Text, this.Font, new System.Drawing.SolidBrush(this.ForeColor), clientRect, m_s_strfFormat); break; case Button.GradientSource.Image: if (this.BackgroundImage != null) { backgroundBrush = new System.Drawing.TextureBrush(this.BackgroundImage); g.FillRectangle(backgroundBrush, clientRect); g.DrawString(this.Text, this.Font, new System.Drawing.SolidBrush(this.ForeColor), clientRect, m_s_strfFormat); } break; } } }
public bool NotifyMouseMove(System.Windows.Forms.MouseEventArgs e) { if (e == null) { throw new System.ArgumentNullException("e"); } if (_multiSelect && _selecting) { if (this.IsCurrentLayerInaccessible) { System.Drawing.Rectangle invalidateRect = this.SelectionRectangle; _selecting = false; _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidateRect)); } else { System.Drawing.Rectangle invalidateRect = this.SelectionRectangle; _selectionCurPoint = new System.Drawing.Point(e.X, e.Y); invalidateRect = System.Drawing.Rectangle.Union(invalidateRect, this.SelectionRectangle); invalidateRect.Inflate(VObject.InvalidationMargin); _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidateRect)); } } return(true); }
private void InvalidateVObject(Layer layer, IVObject obj) { if (_hostViewer != null) { System.Drawing.Rectangle invalidationRect = _hostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point); invalidationRect.Inflate(VObject.InvalidationMargin); _hostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect, layer)); } }
public override System.Drawing.Bitmap Render(System.Drawing.Graphics g, System.Drawing.Bitmap b, params int[] options) { System.Drawing.Color bc = DrawingBackColor; System.Drawing.Color fc = DrawingForeColor; System.Drawing.Rectangle r = new System.Drawing.Rectangle() { Height = b.Height, Width = b.Width }; r.Inflate(-1, -1); g.Clear(System.Drawing.Color.White); g.FillEllipse(new System.Drawing.SolidBrush(bc), r); g.DrawEllipse(new System.Drawing.Pen(fc), r); string s = options[0].ToString(); r.Inflate(s.Length > 1 ? 4 : -4, -2); System.Drawing.Font fnt = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold); g.DrawString(s, fnt, new System.Drawing.SolidBrush(fc), r); b.MakeTransparent(System.Drawing.Color.White); return(b); }
protected void InvalidateObject(IVObject obj) { if (obj == null) { throw new System.ArgumentNullException("obj"); } System.Drawing.Rectangle areaToInvalidate = _objectHost.HostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point); areaToInvalidate.Inflate(VObject.InvalidationMargin); _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(areaToInvalidate, _objectHost.CurrentLayer)); }
public System.Drawing.Rectangle GetInvalidationRectangle() { System.Drawing.Rectangle result = System.Drawing.Rectangle.Empty; if (_controlPointsProvider != null) { result = _hostControl.WorkspaceToControl(_controlPointsProvider.GetControlPointsBounds(), Aurigma.GraphicsMill.Unit.Point); result.Inflate(_controlPointsProvider.MaxControlPointRadius, _controlPointsProvider.MaxControlPointRadius); } return(result); }
protected override System.Drawing.Rectangle GetInvalidationRectangle() { System.Drawing.Rectangle result = VObjectsUtils.GetBoundingRectangle((System.Drawing.Point[])_points.ToArray(typeof(System.Drawing.Point))); if (base.Pen != null) { int inflateValue = (int)System.Math.Ceiling(base.Pen.Width * base.VObjectHost.HostViewer.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point)); result.Inflate(inflateValue, inflateValue); } return(result); }
public override System.Drawing.Bitmap Render(System.Drawing.Graphics g, System.Drawing.Bitmap b, params int[] options) { System.Drawing.Color bc = DrawingBackColor; System.Drawing.Rectangle r = new System.Drawing.Rectangle() { Height = b.Height, Width = b.Width }; r.Inflate(-6, -6); g.Clear(bc.IsEmpty ? System.Drawing.Color.Transparent : bc); g.DrawImage(ResourceLoadHelper.GetImage(ResourceLoadHelper.GetImageName((DrinkType)options[0])), r); return(b); }
protected override void Layout() { base.Layout(); System.Drawing.Rectangle rec0 = GH_Convert.ToRectangle(Bounds); rec0.Height += 22; System.Drawing.Rectangle rec1 = rec0; rec1.Y = rec1.Bottom - 22; rec1.Height = 22; rec1.Inflate(-2, -2); Bounds = rec0; ButtonBounds = rec1; }
protected override System.Drawing.Rectangle GetInvalidationRectangle() { System.Drawing.Rectangle result = System.Drawing.Rectangle.Empty; if (_points.Count > 0) { System.Drawing.Point[] points = GetViewportPoints(_points.Count + 1); points[points.Length - 1] = _viewportMousePosition; result = VObjectsUtils.GetBoundingRectangle(points); int inflateValue = (int)System.Math.Ceiling(System.Math.Max(1.0f, 2 * base.Pen.Width * base.VObjectHost.HostViewer.Zoom)); result.Inflate(inflateValue, inflateValue); } return(result); }
public override System.Drawing.Bitmap Render(System.Drawing.Graphics g, System.Drawing.Bitmap b, params int[] options) { System.Drawing.Color bc = DrawingBackColor; System.Drawing.Color fc = DrawingForeColor; System.Drawing.Rectangle r = new System.Drawing.Rectangle() { Height = b.Height, Width = b.Width }; r.Inflate(-1, -1); g.Clear(System.Drawing.Color.White); g.FillRectangle(new System.Drawing.SolidBrush(bc), r); g.DrawRectangle(new System.Drawing.Pen(fc), r); b.MakeTransparent(System.Drawing.Color.White); return(b); }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); System.Drawing.Rectangle DayView = new System.Drawing.Rectangle(ClientRectangle.Location, ClientRectangle.Size); DayView.Y = 20; DayView.Height -= 20; DayView.Inflate(-1, -1); m_DayView.Location = DayView.Location; m_DayView.Size = DayView.Size; Invalidate(); }
public void DrawHotTrackRange(Graphics g, Metrics m, DrawInfo di) { if (di.HotTrackRange == null) { return; } var htr = di.HotTrackRange.Value; int x1 = htr.X1; int x2 = htr.X2; int y1 = htr.Y1; int y2 = htr.Y2; Rectangle rect = new Rectangle(x1, y1, GetSourceBarWidth(x1, x2), y2 - y1); rect.Inflate(1, 1); g.DrawRectangle(res.HotTrackRangePen, rect); g.FillRectangle(res.HotTrackRangeBrush, rect); }
/// <inheritdoc/> public override void DoTakeScreenshot(Issue issue) { // Get element and the window var element = (FrameworkElement)issue.Control; var host = (FrameworkElement)issue.Host; System.Drawing.Rectangle windowRect; Point point; if (host is Window) { var window = (Window)host; point = new Point(window.Left, window.Top); windowRect = new System.Drawing.Rectangle((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height); } else { point = host.PointToScreen(new Point(0, 0)); windowRect = new System.Drawing.Rectangle((int)point.X, (int)point.Y, (int)host.ActualWidth, (int)host.ActualHeight); } // Get screenshot bitmap System.Drawing.Bitmap screenshot = new System.Drawing.Bitmap(windowRect.Width, windowRect.Height); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(screenshot)) { // Take the screenshot graphics.CopyFromScreen(windowRect.Left, windowRect.Top, 0, 0, screenshot.Size); // Draw highlight if needed if (HighlightIssues) { var location = host.PointToScreen(new Point(0, 0)); var dx = (int)(location.X - point.X); var dy = (int)(location.Y - point.Y); System.Drawing.Rectangle highlightRect = new System.Drawing.Rectangle(issue.HightlightRect.Left + dx, issue.HightlightRect.Top + dy, issue.HightlightRect.Width, issue.HightlightRect.Height); highlightRect.Inflate(HighlightMargin, HighlightMargin); graphics.DrawRectangle(new System.Drawing.Pen(GetHighlightColor(issue.IssueType), HighlightWidth), highlightRect); graphics.Flush(); } } // Assign the screenshot to the issue issue.Screenshot = screenshot; }
protected override System.Drawing.Rectangle GetInvalidationRectangle() { System.Drawing.Rectangle result = System.Drawing.Rectangle.Empty; if (_dragging) { System.Drawing.RectangleF rect = GetWorkspaceRectangle(); if (base.Pen != null) { rect.Inflate(base.Pen.Width * 2, base.Pen.Width * 2); } result = base.VObjectHost.HostViewer.WorkspaceToControl(rect, Aurigma.GraphicsMill.Unit.Point); result.Inflate(VObject.InvalidationMargin.Width, VObject.InvalidationMargin.Width); } return(result); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (FlatStyle == FlatStyle.Popup && !mouse_over) { e.Graphics.DrawRectangle(new System.Drawing.Pen(BackColor, 2), ClientRectangle); } if (FlatStyle == FlatStyle.Popup && mouse_down) { e.Graphics.DrawRectangle(new System.Drawing.Pen(BackColor, 2), ClientRectangle); System.Drawing.Rectangle rc = ClientRectangle; rc.Inflate(-1, -1); FreeCL.RTL.DrawHelper.Frame3D(e.Graphics, rc, System.Drawing.SystemColors.ControlDark, System.Drawing.SystemColors.ControlLightLight, 1); } }
public virtual bool NotifyMouseUp(System.Windows.Forms.MouseEventArgs e) { if (e == null) { throw new System.ArgumentNullException("e"); } if (e.Button == System.Windows.Forms.MouseButtons.Left && _areaOriginDefined) { System.Drawing.RectangleF destinationRect; if (_areaDefined) { destinationRect = VObjectsUtils.GetBoundingRectangle(_cornerPoints); } else { destinationRect = new System.Drawing.RectangleF(_cornerPoints[0], System.Drawing.SizeF.Empty); } System.Drawing.Rectangle invalidationRect = System.Drawing.Rectangle.Empty; IVObject obj = CreateObject(destinationRect); if (obj != null) { _objectHost.CurrentLayer.VObjects.Add(obj); invalidationRect = _objectHost.HostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point); } if (_areaDefined) { System.Drawing.Rectangle tmp = _objectHost.HostViewer.WorkspaceToControl(destinationRect, Aurigma.GraphicsMill.Unit.Point); tmp.Inflate((int)_borderPen.Width * 2, (int)_borderPen.Width * 2); invalidationRect = System.Drawing.Rectangle.Union(invalidationRect, tmp); _areaDefined = false; } _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect, _objectHost.CurrentLayer)); _objectHost.CurrentDesigner = _objectHost.DefaultDesigner; } return(true); }
protected override void Layout() { base.Layout(); int numCapsules = 7; int capsuleHeight = 22; System.Drawing.Rectangle rec0 = GH_Convert.ToRectangle(Bounds); rec0.Height += 22 * numCapsules; CapsuleBounds = new List <System.Drawing.Rectangle>(); for (int i = 0; i < numCapsules; i++) { System.Drawing.Rectangle rec = rec0; rec.Y = rec.Bottom - 22 * (numCapsules - i); rec.Height = capsuleHeight; rec.Inflate(0, -2); CapsuleBounds.Add(rec); } Bounds = rec0; }
public bool NotifyMouseUp(System.Windows.Forms.MouseEventArgs e) { if (e == null) { throw new System.ArgumentNullException("e"); } if (this.IsCurrentLayerInaccessible) { return(true); } if (_multiSelect && e.Button == System.Windows.Forms.MouseButtons.Left && _selecting) { _selecting = false; System.Drawing.Rectangle invalidateRect = this.SelectionRectangle; invalidateRect.Inflate(VObject.InvalidationMargin); _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidateRect)); ProcessSelectionRectangle(); } return(true); }
private void timer_Tick(object sender, EventArgs e) { Image <Bgr, Byte> currentFrame = capture.QueryFrame().ToImage <Bgr, Byte>(); Image <Bgr, Byte> anotherFrame = capture.QueryFrame().ToImage <Bgr, Byte>(); Image <Gray, Byte> GrayImage = new Image <Gray, Byte>(currentFrame.Bitmap); CvInvoke.CvtColor(currentFrame, GrayImage, Emgu.CV.CvEnum.ColorConversion.Bgr2Gray); imgInput = anotherFrame; if (currentFrame != null) { System.Drawing.Rectangle[] detectedfaces = head.DetectMultiScale(GrayImage, 1.1, 5, new System.Drawing.Size(50, 50), new System.Drawing.Size(200, 200)); foreach (var faces in detectedfaces) { face = faces; body = faces; body.Inflate(face.Width * 3, face.Height * 4); trackface.measureface(faces, currentFrame, humanheightcm); } BitmapSource bs = ToBitmapSource(currentFrame); TrackingVideo.Source = bs; } }
public override bool NotifyMouseMove(System.Windows.Forms.MouseEventArgs e) { if (_dragging) { System.Drawing.PointF[] points = new System.Drawing.PointF[3]; points[0] = _point0; points[1] = _point1; _point1 = base.VObjectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point); points[2] = _point1; System.Drawing.RectangleF workspaceChangedRect = VObjectsUtils.GetBoundingRectangle(points); if (base.Pen != null) { workspaceChangedRect.Inflate(base.Pen.Width * 2, base.Pen.Width * 2); } System.Drawing.Rectangle invalidationRect = base.VObjectHost.HostViewer.WorkspaceToControl(workspaceChangedRect, Aurigma.GraphicsMill.Unit.Point); invalidationRect.Inflate(VObject.InvalidationMargin); base.VObjectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect)); } return(base.NotifyMouseMove(e)); }
public override void Render(DrawArgs drawArgs) { try { lock (this) { //override colors for visibility switch (World.Settings.WFSNameColors) { case WFSNameColors.Black: m_renderColor = System.Drawing.Color.Black.ToArgb(); break; case WFSNameColors.White: m_renderColor = System.Drawing.Color.White.ToArgb(); break; case WFSNameColors.Gray: m_renderColor = System.Drawing.Color.DarkGray.ToArgb(); break; case WFSNameColors.Default: m_renderColor = m_defaultColor; break; } if (World.Settings.WFSNameSizeMultiplier != m_fontScaling) { m_fontScaling = World.Settings.WFSNameSizeMultiplier; // scale font size based on settings FontDescription scaledDescription = m_fontDescription; scaledDescription.Height = (int)(m_fontDescription.Height * m_fontScaling); m_drawingFont = drawArgs.CreateFont(scaledDescription); } Vector3 cameraPosition = drawArgs.WorldCamera.Position; if (m_placeNames == null) { return; } // Black outline for light text, white outline for dark text int outlineColor = unchecked ((int)0x80ffffff); int brightness = (m_renderColor & 0xff) + ((m_renderColor >> 8) & 0xff) + ((m_renderColor >> 16) & 0xff); if (brightness > 255 * 3 / 2) { outlineColor = unchecked ((int)0x80000000); } if (m_sprite != null) { m_sprite.Begin(SpriteFlags.AlphaBlend); } int count = 0; Vector3 referenceCenter = new Vector3( (float)drawArgs.WorldCamera.ReferenceCenter.X, (float)drawArgs.WorldCamera.ReferenceCenter.Y, (float)drawArgs.WorldCamera.ReferenceCenter.Z); for (int index = 0; index < m_placeNames.Length; index++) { Vector3 v = m_placeNames[index].cartesianPoint; float distanceSquared = Vector3.LengthSq(v - cameraPosition); if (distanceSquared > m_maximumDistanceSq) { continue; } if (distanceSquared < m_minimumDistanceSq) { continue; } if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v)) { continue; } Vector3 pv = drawArgs.WorldCamera.Project(v - referenceCenter); // Render text only string label = m_placeNames[index].Name; /* * if(m_sprite != null && 1==0) * { * m_sprite.Draw(m_iconTexture, * m_spriteSize, * new Vector3(m_spriteSize.Width/2,m_spriteSize.Height/2,0), * new Vector3(pv.X, pv.Y, 0), * System.Drawing.Color.White); * pv.X += m_spriteSize.Width/2 + 4; * } */ System.Drawing.Rectangle rect = m_drawingFont.MeasureString(null, label, m_textFormat, m_renderColor); pv.Y -= rect.Height / 2; if (m_sprite == null) { // Center horizontally pv.X -= rect.Width / 2; } rect.Inflate(3, 1); int x = (int)Math.Round(pv.X); int y = (int)Math.Round(pv.Y); rect.Offset(x, y); if (World.Settings.WFSOutlineText) { m_drawingFont.DrawText(null, label, x - 1, y - 1, outlineColor); m_drawingFont.DrawText(null, label, x - 1, y + 1, outlineColor); m_drawingFont.DrawText(null, label, x + 1, y - 1, outlineColor); m_drawingFont.DrawText(null, label, x + 1, y + 1, outlineColor); } m_drawingFont.DrawText(null, label, x, y, m_renderColor); count++; if (count > 30) { break; } } if (m_sprite != null) { m_sprite.End(); } } } catch (Exception caught) { Log.Write(caught); } }
/// <summary>Update the rectangles for the list box control</summary> protected override void UpdateRectangles() { // Get bounding box base.UpdateRectangles(); // Calculate the size of the selection rectangle selectionRect = boundingBox; selectionRect.Width -= scrollWidth; selectionRect.Inflate(-border, -border); textRect = selectionRect; textRect.Inflate(-margin, 0); // Update the scroll bars rects too scrollbarControl.SetLocation(boundingBox.Right - scrollWidth, boundingBox.Top); scrollbarControl.SetSize(scrollWidth, height); FontNode fNode = DialogResourceManager.GetGlobalInstance().GetFontNode((int)(elementList[0] as Element).FontIndex); if ((fNode != null) && (fNode.Height > 0)) { scrollbarControl.PageSize = (int)(textRect.Height / fNode.Height); // The selected item may have been scrolled off the page. // Ensure that it is in page again. scrollbarControl.ShowItem(selectedIndex); } }
/// <summary>Updates the rectangles used by the control</summary> protected override void UpdateRectangles() { // Get the bounding box first base.UpdateRectangles (); // Update text rect textRect = boundingBox; // First inflate by border to compute render rects textRect.Inflate(-border, -border); // Update the render rectangles elementRects[0] = textRect; elementRects[1] = new System.Drawing.Rectangle(boundingBox.Left, boundingBox.Top, (textRect.Left - boundingBox.Left), (textRect.Top - boundingBox.Top)); elementRects[2] = new System.Drawing.Rectangle(textRect.Left, boundingBox.Top, textRect.Width, (textRect.Top - boundingBox.Top)); elementRects[3] = new System.Drawing.Rectangle(textRect.Right, boundingBox.Top, (boundingBox.Right - textRect.Right), (textRect.Top - boundingBox.Top)); elementRects[4] = new System.Drawing.Rectangle(boundingBox.Left, textRect.Top, (textRect.Left - boundingBox.Left), textRect.Height); elementRects[5] = new System.Drawing.Rectangle(textRect.Right, textRect.Top, (boundingBox.Right - textRect.Right), textRect.Height); elementRects[6] = new System.Drawing.Rectangle(boundingBox.Left, textRect.Bottom, (textRect.Left - boundingBox.Left), (boundingBox.Bottom - textRect.Bottom)); elementRects[7] = new System.Drawing.Rectangle(textRect.Left, textRect.Bottom, textRect.Width, (boundingBox.Bottom - textRect.Bottom)); elementRects[8] = new System.Drawing.Rectangle(textRect.Right, textRect.Bottom, (boundingBox.Right - textRect.Right), (boundingBox.Bottom - textRect.Bottom)); // Inflate further by spacing textRect.Inflate(-spacing, -spacing); // Make the underlying rich text box the same size textData.Size = textRect.Size; }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); System.Drawing.Rectangle DayView = new System.Drawing.Rectangle(ClientRectangle.Location, ClientRectangle.Size); DayView.Y = 20; DayView.Height -= 20; DayView.Inflate(-1, -1); m_DayView.Location = DayView.Location; m_DayView.Size = DayView.Size; Invalidate(); }
/// <summary> /// Add a <see cref="System.Drawing.Bitmap"/> thumbnail to the page. /// </summary> /// <param name="thumbnail">The <see cref="System.Drawing.Bitmap"/> /// thumbnail.</param> /// <param name="time">The <see cref="TimeSpan">time</see> the thumbnail was /// captured.</param> /// <param name="fileNum">The file number /// (>0 for multi-file <see cref="AVFileSet"/>s).</param> /// <param name="fileStartTime">The file start time.</param> /// <param name="highlight">if set to <c>true</c> highlight thumbnail border.</param> /// <returns> /// <c>true</c> if the page is now full. /// </returns> public bool Add(System.Drawing.Bitmap thumbnail, TimeSpan time, int fileNum, TimeSpan fileStartTime, bool highlight) { int x = _tgrid.Layout.Margin + _tgrid.Layout.Border + _currentCol * (_tgrid.ThumbWidth + _tgrid.Layout.Margin + 2*_tgrid.Layout.Border); int y = _tgrid.Layout.Height + _tgrid.Layout.Border - (_tgrid.NRows - _currentRow) * (_tgrid.ThumbHeight + _tgrid.Layout.Margin + 2*_tgrid.Layout.Border); using (System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes ()) { att.SetWrapMode (System.Drawing.Drawing2D.WrapMode.TileFlipXY); System.Drawing.Rectangle thumbRect = new System.Drawing.Rectangle (x, y, _tgrid.ThumbWidth, _tgrid.ThumbHeight); System.Drawing.Rectangle borderRect = thumbRect; _graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; _graphics.DrawImage (thumbnail, thumbRect, 0, 0, _tgrid.ThumbWidth, _tgrid.ThumbHeight, System.Drawing.GraphicsUnit.Pixel, att); thumbRect.Inflate (-_tgrid.Layout.Margin, -_tgrid.Layout.Margin); if (_tgrid.Layout.Border > 0) { borderRect.X -= _tgrid.Layout.Border; borderRect.Y -= _tgrid.Layout.Border; borderRect.Width += _tgrid.Layout.Border; borderRect.Height += _tgrid.Layout.Border; //borderRect.Width = borderRect.Width + 1; //borderRect.Height = borderRect.Height + 1; if (highlight) { _graphics.DrawRectangle (_borderHilightPen, borderRect); borderRect.Inflate (1, 1); _graphics.DrawRectangle (_borderHilightPen, borderRect); } else _graphics.DrawRectangle (_borderPen, borderRect); //borderRect.Offset (-1, -1); //_graphics.DrawRectangle (System.Drawing.Pens.Red, borderRect); //borderRect.Offset (2, 2); //_graphics.DrawRectangle (System.Drawing.Pens.Green, borderRect); } TimeSpan relativeTime = time - fileStartTime; string timeString; string timeFormat = @"h\:mm\:ss"; if (time.Milliseconds > 0) { if (_creator.TNSettings.AlwaysShowMilliseconds || (_pageNum > 0 && fileNum > 0)) timeFormat = @"h\:mm\:ss\.ffff"; else if (time.Milliseconds >= 500) time += _oneSecond; } timeString = time.ToString (timeFormat); // Multi-part files if (fileNum > 0) { //Detail pages if (_pageNum > 0) { timeFormat = @"h\:mm\:ss"; if (relativeTime.Milliseconds > 0) timeFormat = @"h\:mm\:ss\.ffff"; timeString += String.Format (" (#{0} {1})", fileNum, relativeTime.ToString (timeFormat)); } else { if (highlight) { timeString += String.Format (" #{0}", fileNum); } } } System.Drawing.RectangleF thumbRectF = (System.Drawing.RectangleF) thumbRect; _graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; #if false //_graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; //_graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; _graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; _graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; _graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; #endif if (_creator.TNSettings.LabelPosition != ThumbnailSettings.LabelPositions.None) { _graphics.DrawString (timeString, _font, _brushBlack, thumbRectF, _thumbFormat); thumbRectF.Offset (-1, -1); _graphics.DrawString (timeString, _font, _brushWhite, thumbRectF, _thumbFormat); } } _currentCol++; if (_currentCol >= _tgrid.NColumns) { _currentCol = 0; _currentRow++; } return _currentRow >= _tgrid.NRows; }