public virtual Size GetBorderOffset() { if (this.element.cachedBorderOffset == LayoutUtils.InvalidSize) { SizeF borderSize = SizeF.Empty; IBoxElement parentBox = this.Parent as IBoxElement; if ((parentBox != null) && (this.Parent.Visibility != ElementVisibility.Collapsed)) { borderSize = parentBox.Offset; } if (this.element is IBoxElement) { return(borderSize.ToSize()); } //Fix if (this.element is FillPrimitive) { return(borderSize.ToSize()); } SizeF childBorderSize = this.GetMaxChildBorderOffset(); if (childBorderSize != SizeF.Empty) { borderSize = SizeF.Add(borderSize, childBorderSize); } this.element.cachedBorderOffset = borderSize.ToSize(); } return(this.element.cachedBorderOffset); }
protected override SizeF MeasureOverride(SizeF availableSize) { base.MeasureOverride(availableSize); SizeF empty = SizeF.Empty; return(SizeF.Add(this.Direction == ArrowDirection.Left || this.Direction == ArrowDirection.Right ? (SizeF)TelerikDpiHelper.ScaleSize(ArrowPrimitive.MinHorizontalSize, this.DpiScaleFactor) : (SizeF)TelerikDpiHelper.ScaleSize(ArrowPrimitive.MinVerticalSize, this.DpiScaleFactor), (SizeF)this.Padding.Size)); }
protected SizeF MeasureButtonChildren(SizeF availableSize) { SizeF sizeF1 = SizeF.Empty; if (this.AutoSize) { for (int index = 0; index < this.Children.Count; ++index) { RadElement child = this.Children[index]; if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent || child.FitToSizeMode == RadFitToSizeMode.FitToParentPadding) { child.Measure(SizeF.Subtract(SizeF.Subtract(availableSize, (SizeF)this.Padding.Size), (SizeF)this.BorderThickness.Size)); } else { child.Measure(availableSize); } SizeF sz1 = child.DesiredSize; if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent) { sz1 = SizeF.Add(sz1, (SizeF)this.Padding.Size); } if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent || child.FitToSizeMode == RadFitToSizeMode.FitToParentPadding) { SizeF sizeF2 = SizeF.Add(sz1, (SizeF)this.BorderThickness.Size); float width = sizeF2.Width; float height = sizeF2.Height; if (this.ElementTree.RootElement.MaxSize.Width > 0 && (double)sizeF2.Width > (double)this.ElementTree.Control.MaximumSize.Width) { width = (float)this.ElementTree.Control.MaximumSize.Width; } if (this.MaxSize.Width > 0 && (double)sizeF2.Width > (double)this.MaxSize.Width) { width = (float)this.MaxSize.Width; } if (this.ElementTree.RootElement.MaxSize.Height > 0 && (double)sizeF2.Height > (double)this.ElementTree.Control.MaximumSize.Height) { height = (float)this.ElementTree.Control.MaximumSize.Height; } if (this.MaxSize.Height > 0 && (double)sizeF2.Height > (double)this.MaxSize.Height) { height = (float)this.MaxSize.Height; } sz1 = new SizeF(width, height); } sizeF1.Width = Math.Min(availableSize.Width, Math.Max(sizeF1.Width, sz1.Width)); sizeF1.Height = Math.Min(availableSize.Height, Math.Max(sizeF1.Height, sz1.Height)); } } else { for (int index = 0; index < this.Children.Count; ++index) { this.Children[index].Measure(availableSize); } sizeF1 = (SizeF)this.Size; } return(sizeF1); }
public override void Move(int dx, int dy) { base.Move(dx, dy); var solidFigure = TargetFigure as SolidFigure; if (solidFigure != null) { solidFigure.Size = SizeF.Add(solidFigure.Size, new SizeF(dx * 2, dy * 2)); } }
public void ArithmeticTest(float width, float height) { SizeF s1 = new SizeF(width, height); SizeF s2 = new SizeF(height, width); SizeF addExpected = new SizeF(width + height, width + height); SizeF subExpected = new SizeF(width - height, height - width); Assert.Equal(addExpected, s1 + s2); Assert.Equal(addExpected, SizeF.Add(s1, s2)); Assert.Equal(subExpected, s1 - s2); Assert.Equal(subExpected, SizeF.Subtract(s1, s2)); }
protected override SizeF MeasureOverride(SizeF availableSize) { SizeF sizeF = SizeF.Empty; if (this.AutoSize) { for (int index = 0; index < this.Children.Count; ++index) { RadElement child = this.Children[index]; if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent || child.FitToSizeMode == RadFitToSizeMode.FitToParentPadding) { child.Measure(SizeF.Subtract(SizeF.Subtract(availableSize, (SizeF)this.Padding.Size), (SizeF)this.BorderThickness.Size)); } else { child.Measure(availableSize); } SizeF sz1 = child.DesiredSize; if (!this.BypassLayoutPolicies) { if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent) { sz1 = SizeF.Add(sz1, (SizeF)this.Padding.Size); } if (child.FitToSizeMode == RadFitToSizeMode.FitToParentContent || child.FitToSizeMode == RadFitToSizeMode.FitToParentPadding) { sz1 = SizeF.Add(sz1, (SizeF)this.BorderThickness.Size); } } sizeF.Width = Math.Min(availableSize.Width, Math.Max(sizeF.Width, sz1.Width)); sizeF.Height = Math.Min(availableSize.Height, Math.Max(sizeF.Height, sz1.Height)); } } else { for (int index = 0; index < this.Children.Count; ++index) { this.Children[index].Measure(availableSize); } sizeF = (SizeF)this.Size; } return(sizeF); }
public virtual Size GetBorderSize() { if (this.element.cachedBorderSize == LayoutUtils.InvalidSize) { SizeF borderSize = SizeF.Empty; IBoxElement elementBox = this.element as IBoxElement; if ((elementBox != null) && (this.element.Visibility != ElementVisibility.Collapsed)) { borderSize = elementBox.BorderSize; } SizeF childBorderSize = GetMaxChildBorder(); if (childBorderSize != SizeF.Empty) { borderSize = SizeF.Add(borderSize, childBorderSize); } this.element.cachedBorderSize = borderSize.ToSize(); } return(this.element.cachedBorderSize); }
public void AddTest() { Assert.AreEqual(sz11_99, SizeF.Add(sz11_0, new SizeF(0.0F, 9.9F)), "ADD#1"); Assert.AreEqual(sz11_99, SizeF.Add(new SizeF(0.0F, 0.0F), new SizeF(1.1F, 9.9F)), "ADD#2"); }
public override SizeF Measure(Graphics g) { return(SizeF.Add(g.MeasureString(Node.Data.Name, BoldFont), new SizeF(4, 4))); }
private SizeF GetMessageSize(Graphics gr, string message) { return(SizeF.Add(gr.MeasureString(message, Font, 250), new SizeF(10, 10))); }
public IBoundingBox DetermineBoundingBox(IBoundingBox trackerBoundingBox, List <IBoundingBox> detectorBoundingBoxes, Image <Gray, byte> frame, out bool reinitializeTracker, bool prevValid, out bool currValid) { IBoundingBox output = null; reinitializeTracker = false; currValid = false; /* [Zdenek] If neither the tracker nor the detector output a bounding box, * the object is declared as not visible */ if (trackerBoundingBox == null && detectorBoundingBoxes == null) { return(null); } // calculate relative similarities for all bounding boxes Dictionary <IBoundingBox, float> relativeSimilarities = new Dictionary <IBoundingBox, float>(); // -> tracker if (trackerBoundingBox != null) { frame.ROI = Rectangle.Round(trackerBoundingBox.GetRectangle()); Size patchSize = _objectModel.PatchSize; Image <Gray, byte> trackerPatch = frame.Resize(patchSize.Width, patchSize.Height, INTER.CV_INTER_LINEAR); relativeSimilarities.Add(trackerBoundingBox, _objectModel.RelativeSimilarity(trackerPatch)); frame.ROI = Rectangle.Empty; } // -> detector if (detectorBoundingBoxes != null) { for (int i = 0; i < detectorBoundingBoxes.Count; i++) { IBoundingBox bb = detectorBoundingBoxes[i]; relativeSimilarities.Add(bb, CurrentState.RelativeSimilarities[bb]); } } // if tracker is defined if (trackerBoundingBox != null) { output = trackerBoundingBox; if (detectorBoundingBoxes != null) { float bigOverlap = 0.8f; // get detector bounding boxes // that are far from tracker // and are more confident then the tracker List <IBoundingBox> bbs = new List <IBoundingBox>(); foreach (IBoundingBox bb in detectorBoundingBoxes) { if (bb.GetOverlap(trackerBoundingBox) < bigOverlap && relativeSimilarities[bb] > relativeSimilarities[trackerBoundingBox]) { bbs.Add(bb); } } // if there is only only one such bounding box, // reinitialize the tracker if (bbs.Count == 1) { output = bbs[0]; reinitializeTracker = true; currValid = false; } // otherwise calculate weighted average with close detections else { int trackerRepeat = 1; PointF center = trackerBoundingBox.Center.Multiply(trackerRepeat, trackerRepeat); SizeF size = trackerBoundingBox.Size.Multiply(trackerRepeat, trackerRepeat); // consider detector bounding boxes that are close to the tracker int bbCount = trackerRepeat; foreach (IBoundingBox bb in detectorBoundingBoxes) { if (bb.GetOverlap(trackerBoundingBox) >= bigOverlap) { center = center.Add(bb.Center); size = size.Add(bb.Size); bbCount++; } } output = trackerBoundingBox.CreateInstance( center.Divide(bbCount, bbCount), size.Divide(bbCount, bbCount) ); } } } // if tracker is not defined else { if (detectorBoundingBoxes != null) { List <IBoundingBox> suppressedBbs = Service.NonMaximalBoundingBoxSuppress(detectorBoundingBoxes); // if there is a single detection, reinitialize the tracker if (suppressedBbs.Count == 1) { output = suppressedBbs[0]; reinitializeTracker = true; currValid = false; } } } if (output != null) { if (prevValid == true) { currValid = true; } else { Image <Gray, byte> outputPatch = frame.GetPatch(output.Center, Size.Round(output.Size)) .Resize(_objectModel.PatchSize.Width, _objectModel.PatchSize.Height, INTER.CV_INTER_LINEAR); float pnn, nnn; float conservativeSimilarity = _objectModel.ConservativeSimilarity(outputPatch, out pnn, out nnn); if (pnn > 0.8f && conservativeSimilarity >= ConsSimValidThreshold) { currValid = true; } } } return(output); }
protected override SizeF MeasureContentCore(SizeF availableSize, SizeF desiredSize) { if (this.Data == null || this.IsDesignMode) { return(SizeF.Empty); } float num1 = 0.0f; float num2 = 0.0f; if (this.Data.Owner.ShowCheckBoxes) { switch (this.Data.Owner.CheckBoxesPosition) { case CheckBoxesPosition.Left: case CheckBoxesPosition.Right: num1 = this.ToggleElement.DesiredSize.Width; break; default: num2 = this.ToggleElement.DesiredSize.Height; break; } } desiredSize.Width += num1; desiredSize.Height += num2; RadListViewElement owner = this.Data.Owner; if (owner == null) { return(desiredSize); } bool arbitraryItemWidth = owner.AllowArbitraryItemWidth; bool arbitraryItemHeight = owner.AllowArbitraryItemHeight; CardListViewElement viewElement = owner.ViewElement as CardListViewElement; SizeF itemSize = (SizeF)owner.ItemSize; if (viewElement.CardTemplate.ContainerElement.LayoutTree.Root != null) { if (arbitraryItemWidth) { itemSize.Width = viewElement.CardTemplate.ContainerElement.LayoutTree.Root.Bounds.Width; } if (arbitraryItemHeight) { itemSize.Height = viewElement.CardTemplate.ContainerElement.LayoutTree.Root.Bounds.Height; } } desiredSize = itemSize; if (!arbitraryItemHeight && !arbitraryItemWidth) { this.layoutContainer.Measure(desiredSize); this.UpdateScrollbars(desiredSize); } else if (arbitraryItemHeight && !arbitraryItemWidth) { desiredSize.Width = itemSize.Width + num1; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { this.layoutContainer.Measure((SizeF) new Size(1, 1)); desiredSize.Height = this.layoutContainer.LayoutTree.Root.Bounds.Height; this.layoutContainer.Measure(desiredSize); } if (this.HorizontalScrollBar.Visibility != ElementVisibility.Collapsed) { desiredSize.Height += (float)this.HorizontalScrollBar.MinSize.Height; } this.UpdateScrollbars(desiredSize); this.VerticalScrollBar.Visibility = ElementVisibility.Collapsed; desiredSize.Height += num2; if (this.Data.Size.Height > 0) { desiredSize.Height = (float)this.Data.Size.Height; } } else if (!arbitraryItemHeight && arbitraryItemWidth) { desiredSize.Height = itemSize.Height + num2; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { desiredSize.Width = this.layoutContainer.LayoutTree.Root.Bounds.Width + (this.VerticalScrollBar.Visibility != ElementVisibility.Collapsed ? (float)this.VerticalScrollBar.MinSize.Width : 0.0f); this.layoutContainer.Measure(desiredSize); } this.UpdateScrollbars(desiredSize); this.HorizontalScrollBar.Visibility = ElementVisibility.Collapsed; if (this.VerticalScrollBar.Visibility != ElementVisibility.Collapsed) { desiredSize.Width += (float)this.VerticalScrollBar.MinSize.Width; } desiredSize.Width += num1; if (this.Data.Size.Width > 0) { desiredSize.Width = (float)this.Data.Size.Width; } } else { this.VerticalScrollBar.Visibility = ElementVisibility.Collapsed; this.HorizontalScrollBar.Visibility = ElementVisibility.Collapsed; this.layoutContainer.Measure(desiredSize); if (this.HasItemCollapsedGroups(viewElement) && this.layoutContainer.LayoutTree.Root != null) { desiredSize = this.layoutContainer.LayoutTree.Root.Bounds.Size; } this.layoutContainer.Measure(desiredSize); desiredSize.Width += num1; desiredSize.Height += num2; if (this.Data.Size.Width > 0) { desiredSize.Width = (float)this.Data.Size.Width; } if (this.Data.Size.Height > 0) { desiredSize.Height = (float)this.Data.Size.Height; } } Padding padding = Padding.Add(this.GetBorderThickness(true), this.Padding); desiredSize = SizeF.Add(desiredSize, new SizeF((float)padding.Horizontal, (float)padding.Vertical)); this.Data.ActualSize = desiredSize.ToSize(); return(desiredSize); }