private void boundsChange(Vector1D offsetX, Vector1D offsetY, Vector1D width, Vector1D height) { InnerBoundsChange(ref offsetX, ref offsetY, ref width, ref height); this.offset = new Vector2D(offsetX, offsetY); this.size = new Vector2D(width, height); }
public static void Build(string dot, string outputpath, bool open) { Vector2D pagesize; var nodes = Node.GetNodes(dot, out pagesize); var links = Link.GetLinks(dot, nodes); PDFDocument doc = new PDFDocument(); var page = doc.Pages.Add(new Page(pagesize)); var space = new Vector1D(0.15, UnitsOfMeasure.Centimeters); for (int i = 0; i < links.Length; i++) { var link = links[i]; var allTo = links.Where(x => x.To == link.To).ToList(); var allFrom = links.Where(x => x.From == link.From).ToList(); var p1 = new Vector2D(link.From.Center.X, link.From.GateRect.Bottom); var p3 = new Vector2D(link.To.Center.X, link.To.BoxRect.Top); p1.X += allFrom.IndexOf(link) * space - ((allFrom.Count - 1) * space) / 2; page.Objects.Add(new Connector(p1, p3 - p1, link.From.Center.X)); } for (int i = 0; i < nodes.Length; i++) page.Objects.AddRange(HandleNode(nodes[i])); doc.Create(outputpath, open); }
public void Vector1MulTest() { Vector1D a = new Vector1D(0.5); Vector1D b = new Vector1D(0.5); Assert.AreEqual(0.25, a * b); }
public static void Build(string dot, string outputpath, bool open) { Vector2D pagesize; var nodes = Node.GetNodes(dot, out pagesize); var links = Link.GetLinks(dot, nodes); PDFDocument doc = new PDFDocument(); var page = doc.Pages.Add(new Page(pagesize)); var space = new Vector1D(0.15, UnitsOfMeasure.Centimeters); for (int i = 0; i < links.Length; i++) { var link = links[i]; var allTo = links.Where(x => x.To == link.To).ToList(); var allFrom = links.Where(x => x.From == link.From).ToList(); var p1 = new Vector2D(link.From.Center.X, link.From.GateRect.Bottom); var p3 = new Vector2D(link.To.Center.X, link.To.BoxRect.Top); p1.X += allFrom.IndexOf(link) * space - ((allFrom.Count - 1) * space) / 2; page.Objects.Add(new Connector(p1, p3 - p1, link.From.Center.X)); } for (int i = 0; i < nodes.Length; i++) { page.Objects.AddRange(HandleNode(nodes[i])); } doc.Create(outputpath, open); }
protected override sealed void InnerBoundsChange(ref Vector1D offsetX, ref Vector1D offsetY, ref Vector1D width, ref Vector1D height) { if (height != this.Height) width = height * HEIGHT_TO_WIDTH; else if (width != this.Width) height = width * WIDTH_TO_HEIGHT; }
public void CurveFromTo(Vector1D x1, Vector1D y1, Vector1D x3, Vector1D y3) { cb.CurveFromTo( (float)x1.Value(UnitsOfMeasure.Points), (float)y1.Value(UnitsOfMeasure.Points), (float)x3.Value(UnitsOfMeasure.Points), (float)y3.Value(UnitsOfMeasure.Points)); }
public void Arc(Vector1D x1, Vector1D y1, Vector1D x2, Vector1D y2, float startAngle, float extentAngle) { cb.Arc( (float)x1.Value(UnitsOfMeasure.Points), (float)y1.Value(UnitsOfMeasure.Points), (float)x2.Value(UnitsOfMeasure.Points), (float)y2.Value(UnitsOfMeasure.Points), startAngle, extentAngle); }
public void CurveTo(Vector1D x2, Vector1D y2, Vector1D x3, Vector1D y3) { cb.CurveTo( (float)x2.Value(UnitsOfMeasure.Points), (float)y2.Value(UnitsOfMeasure.Points), (float)x3.Value(UnitsOfMeasure.Points), (float)y3.Value(UnitsOfMeasure.Points)); }
public void Vector1AddTest() { Vector1D expected = new Vector1D(1); Vector1D a = new Vector1D(0.5); Vector1D b = new Vector1D(0.5); Assert.AreEqual(expected.x, (a + b).x); }
public void Vector1SubTest() { Vector1D expected = new Vector1D(0); Vector1D a = new Vector1D(0.5); Vector1D b = new Vector1D(0.5); Assert.AreEqual(expected.x, (a - b).x); }
protected sealed override void InnerBoundsChange(ref Vector1D offsetX, ref Vector1D offsetY, ref Vector1D width, ref Vector1D height) { if (height != this.Height) { width = height * HEIGHT_TO_WIDTH; } else if (width != this.Width) { height = width * WIDTH_TO_HEIGHT; } }
public void MoveAbsolute(Vector1D zoom, Vector1D speed) { MoveAbsolute( new PTZVector() { panTilt = null, zoom = zoom }, speed != null ? new PTZSpeed() { zoom = speed } : null ); }
public void MoveContinuous(Vector2D panTilt, Vector1D zoom) { CurrentSession .ContinuousMove( profileToken, new PTZSpeed() { panTilt = panTilt, zoom = zoom }, null ) .ObserveOnCurrentDispatcher() .Subscribe( unit => { }, err => { //dbg.Error(err); SetErrorMessage(err.Message); } ); }
private FontInfo(string name, float size, FontStyle style, iTextSharp.text.Font iFont) { this.name = name; this.size = size; this.style = style; this.iFont = iFont; this.ascenderHeight = GetAscenderHeight(iFont); this.descenderHeight = GetDescenderHeight(iFont); this.baseHeight = GetBaseHeight(iFont); this.height = GetLineHeight(iFont); }
/// <summary> /// Initializes a new instance of the <see cref="StrokeObject"/> class. /// </summary> /// <param name="offset">The offset of the <see cref="StrokeObject" />.</param> /// <param name="size">The size of the <see cref="StrokeObject" />.</param> public StrokeObject(Vector2D offset, Vector2D size) : base(offset, size) { this.border = Color.Black; this.width = new Vector1D(1, UnitsOfMeasure.Points); }
public void GotoPreset() { string presetToken = null; Media.Profile profile = null; RunTest(() => { PTZConfigurationOptions options; profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsolute); PTZVector vector = new PTZVector(); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; if (Features.Contains(Feature.PTZAbsolutePanTilt) || Features.Contains(Feature.PTZRelativePanTilt)) { pantiltSpace = absoulteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) : options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0); vector.PanTilt = new Vector2D(); vector.PanTilt.space = pantiltSpace.URI; vector.PanTilt.x = pantiltSpace.XRange.Min; vector.PanTilt.y = pantiltSpace.YRange.Min; } if (Features.Contains(Feature.PTZAbsoluteZoom) || Features.Contains(Feature.PTZRelativeZoom)) { zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoulteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); string presetName = "Test"; presetToken = SetPreset(profile.token, presetName, null); //move to another position Vector2D oldPanTilt = vector.PanTilt; if (oldPanTilt != null) { vector.PanTilt = new Vector2D(); vector.PanTilt.space = oldPanTilt.space; vector.PanTilt.x = pantiltSpace.XRange.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } Vector1D oldZoom = vector.Zoom; if (oldZoom != null) { vector.Zoom = new Vector1D(); vector.Zoom.space = oldZoom.space; vector.Zoom.x = zoomSpace.XRange.Max; } if (absoulteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); GotoPreset(profile.token, presetToken, null); RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); PTZStatus status = GetPTZStatus(profile.token); vector.PanTilt = oldPanTilt; vector.Zoom = oldZoom; if (status.Position != null) { CheckPTZPosition(status.Position, vector, vector); } else { OpenVideo(); Assert(_operator.GetYesNoAnswer(string.Format("Is camera in position [{0}]?", PositionToString(vector))), "Camera is in wrong position", "Camera position check (manual)"); CloseVideo(); } RemovePreset(profile.token, presetToken); presetToken = null; }, () => { CloseVideo(); if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
bool AreTheSame(FindPTZPositionResult result1, FindPTZPositionResult result2) { bool equal = result1.Time == result2.Time && result1.RecordingToken == result2.RecordingToken && result1.TrackToken == result2.TrackToken; if (equal) { // ToDo : How to compare PTZ positions ? // (is it possible that they will be returned for different space ? ) bool positionsEqual = true; if (result1.Position != null && result2.Position != null) { Vector2D panTilt1 = result1.Position.PanTilt; Vector2D panTilt2 = result2.Position.PanTilt; if (panTilt1 != null && panTilt2 != null) { positionsEqual = panTilt1.space == panTilt2.space && panTilt1.x == panTilt2.x && panTilt1.y == panTilt2.y; } else { if (panTilt1 != null || panTilt2 != null) { positionsEqual = false; } } if (positionsEqual) { Vector1D zoom1 = result1.Position.Zoom; Vector1D zoom2 = result2.Position.Zoom; if (zoom1 != null && zoom2 != null) { positionsEqual = zoom1.space == zoom2.space && zoom1.x == zoom2.x; } else { if (zoom1 != null || zoom2 != null) { positionsEqual = false; } } } } else { if (result1.Position != null || result2.Position != null) { positionsEqual = false; } // else both null - OK } equal = positionsEqual; } return(equal); }
/// <summary> /// When implemented in a derived class, ensures that the offset and size values specified for an object are "acceptable". /// This method will be executed when changes are made to an objects size or offset, before the actual change is applied to the object. /// When this method exits the object is updated with the parameter values. /// </summary> /// <param name="offsetX">The new x-coordinate of the objects local offset.</param> /// <param name="offsetY">The new y-coordinate of the objects local offset.</param> /// <param name="width">The new width of the object.</param> /// <param name="height">The new height of the object.</param> protected virtual void InnerBoundsChange(ref Vector1D offsetX, ref Vector1D offsetY, ref Vector1D width, ref Vector1D height) { }
public Vector4D(Vector1D x, Vector1D y, Vector1D width, Vector1D height) { this.offset = new Vector2D(x, y); this.size = new Vector2D(width, height); }
public GateObject(Vector1D gateHeight) : base(Vector2D.Zero, new Vector2D(gateHeight, gateHeight)) { BorderWidth = new Vector1D(2, UnitsOfMeasure.Points); }
public OrGate(Vector1D gateHeight) : base(gateHeight) { }
public void Mark(Vector2D v, Vector1D radius) { Mark(v, radius, Color.Black); }
public void Vector1Length() { Vector1D a = new Vector1D(-1); Assert.AreEqual(1, a.Length()); }
public void Mark(Vector2D v, Vector1D radius, Color color) { cb.SetColorStroke(new iTextSharp.text.Color(color)); MoveTo(v.X - radius, v.Y); LineTo(v.X + radius, v.Y); cb.Stroke(); MoveTo(v.X, v.Y - radius); LineTo(v.X, v.Y + radius); cb.Stroke(); }
public void MoveTo(Vector1D x, Vector1D y) { cb.MoveTo( (float)x.Value(UnitsOfMeasure.Points), (float)y.Value(UnitsOfMeasure.Points)); }
public void Rectangle(Vector1D x, Vector1D y, Vector1D width, Vector1D height) { cb.Rectangle( (float)x.Value(UnitsOfMeasure.Points), (float)y.Value(UnitsOfMeasure.Points), (float)width.Value(UnitsOfMeasure.Points), (float)height.Value(UnitsOfMeasure.Points)); }
public Connector(Vector2D offset, Vector2D size, Vector1D centerX) : base(offset, size) { this.centerX = centerX; BorderColor = System.Drawing.Color.Black; }
public AndGate(Vector1D gateHeight) : base(gateHeight) { }
public void GotoPreset() { string presetToken = null; Profile profile = null; RunTest(() => { Assert(Features.ContainsFeature(Feature.PTZAbsoluteOrRelative), "No Absolute or Relative movement is supported", "Check that Absolute or Relative movement is supported"); PTZConfigurationOptions options; profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoluteMoveSupported = Features.Contains(Feature.PTZAbsolute); // pantilt movement is used if correcponding Pan/Tilt is supported bool panTilt = (absoluteMoveSupported && Features.ContainsFeature(Feature.PTZAbsolutePanTilt)) || (!absoluteMoveSupported && Features.ContainsFeature(Feature.PTZRelativePanTilt)); bool absoluteZoom = absoluteMoveSupported && Features.Contains(Feature.PTZAbsoluteZoom); bool relativeZoom = !absoluteMoveSupported && Features.Contains(Feature.PTZRelativeZoom); bool zoom = absoluteZoom || relativeZoom; PTZVector vector = new PTZVector(); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; if (panTilt) { pantiltSpace = absoluteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) : options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0); vector.PanTilt = new Vector2D(); vector.PanTilt.space = pantiltSpace.URI; vector.PanTilt.x = pantiltSpace.XRange.Min; vector.PanTilt.y = pantiltSpace.YRange.Min; } if (zoom) { zoomSpace = absoluteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); string presetName = "Test"; presetToken = SetPreset(profile.token, presetName, null); //move to another position Vector2D oldPanTilt = vector.PanTilt; if (oldPanTilt != null) { vector.PanTilt = new Vector2D(); vector.PanTilt.space = oldPanTilt.space; vector.PanTilt.x = pantiltSpace.XRange.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } Vector1D oldZoom = vector.Zoom; if (oldZoom != null) { vector.Zoom = new Vector1D(); vector.Zoom.space = oldZoom.space; vector.Zoom.x = zoomSpace.XRange.Max; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); GotoPreset(profile.token, presetToken, null); RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); PTZStatus status = GetPTZStatus(profile.token); vector.PanTilt = oldPanTilt; vector.Zoom = oldZoom; if (status.Position != null) { CheckPTZPosition(status.Position, vector, vector, pantiltSpace, zoomSpace); } RemovePreset(profile.token, presetToken); presetToken = null; }, () => { CloseVideo(); if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
public void Ellipse(Vector1D x, Vector1D y, Vector1D width, Vector1D height) { cb.Ellipse( (float)x.Value(UnitsOfMeasure.Points), (float)y.Value(UnitsOfMeasure.Points), (float)(x + width).Value(UnitsOfMeasure.Points), (float)(y + height).Value(UnitsOfMeasure.Points)); }
public Vector4D(Vector1D x, Vector1D y, Vector1D width,Vector1D height) { this.offset = new Vector2D(x, y); this.size = new Vector2D(width, height); }