private void InitializeVisualElements(IEnumerable <T> source) { VisualElements.Clear(); foreach (var element in source) { VisualElements.Add(element); } }
public VisualElementManagerMock(IEnumerable <Step> stepsToUseForInitialize) : this() { foreach (var step in stepsToUseForInitialize) { VisualElements.Add(new VisualElement(null) { ElementID = step.ElementID, WindowID = Guid.Parse("df575070-f243-4e6d-bc14-a5196294cedf"), }); } }
public void RebuildLayout() { if (LayoutChanges.Count == 1 && LayoutChanges[0] is PropertyChange pc && pc.Property == nameof(LeftHanded)) { if (VisualElements.Count > 0) { VisualElements.ForEach(e => e.FlipHandedness()); isLayoutDirty = false; LayoutChanges.Clear(); OnLayoutUpdated(); return; } } VisualElements.Clear(); for (int i = 0; i < NumberOfStrings; i++) { Strings[i].ClearLayoutData(); } _CachedBounds = RectangleM.Empty; if (StringSpacing is StringSpacingSimple) { (StringSpacing as StringSpacingSimple).CalculateAdjustedPositions(); } Measure nutCenter = Measure.Zero; Measure bridgeCenter = Measure.Zero; Measure[] nutStringPos = StringSpacing.GetStringPositions(FingerboardEnd.Nut, out nutCenter); Measure[] bridgeStringPos = StringSpacing.GetStringPositions(FingerboardEnd.Bridge, out bridgeCenter); LayoutStrings(nutStringPos, bridgeStringPos); CreateFingerboardEdges(); PlaceFrets(); FinishFingerboardShape(); var layoutBounds = GetLayoutBounds(); VisualElements.Add(new LayoutLine(new PointM(Measure.Zero, layoutBounds.Top), new PointM(Measure.Zero, layoutBounds.Bottom), VisualElementType.CenterLine)); if (LeftHanded) { VisualElements.ForEach(e => e.FlipHandedness()); } isLayoutDirty = false; LayoutChanges.Clear(); OnLayoutUpdated(); }
public void buildgraph() { SeriesCollection.Clear(); VisualElements.Clear(); SeriesCollection.Add( new StackedColumnSeries { Values = new ChartValues <double> { 4, 5, 6, 8 }, StackMode = StackMode.Values, // this is not necessary, values is the default stack mode DataLabels = true } ); SeriesCollection.Add( new StackedColumnSeries { Values = new ChartValues <double> { 2, 5, 6, 7 }, StackMode = StackMode.Values, DataLabels = true } ); //adding series updates and animates the chart SeriesCollection.Add(new StackedColumnSeries { Values = new ChartValues <double> { 6, 2, 7 }, StackMode = StackMode.Values }); //adding values also updates and animates SeriesCollection[2].Values.Add(4d); Labels = new[] { "Chrome", "Mozilla", "Opera", "IE" }; VisualElementTest vstest = new VisualElementTest(); countpos++; VisualElements.Add(vstest.visual); DataContext = this; }
private T AddVisualElement <T>(T elem) where T : VisualElement { VisualElements.Add(elem); elem.Layout = this; return(elem); }
private void FinishFingerboardShape() { var trebleSideEdge = VisualElements.OfType <FingerboardSideEdge>().First(e => e.Side == FingerboardSide.Treble); var bassSideEdge = VisualElements.OfType <FingerboardSideEdge>().First(e => e.Side == FingerboardSide.Bass); var trebleNutFret = VisualElements.OfType <FretLine>().First(f => f.IsNut && f.Strings.Contains(FirstString)); var bassNutFret = VisualElements.OfType <FretLine>().First(f => f.IsNut && f.Strings.Contains(LastString)); //create inward fingerboard edges from nut if (!Strings.AllEqual(s => s.StartingFret)) { foreach (var str in Strings) { if (str.Next != null && str.StartingFret != str.Next.StartingFret) { var nut1 = VisualElements.OfType <FretLine>().First(f => f.IsNut && f.Strings.Contains(str)); var nut2 = VisualElements.OfType <FretLine>().First(f => f.IsNut && f.Strings.Contains(str.Next)); AddVisualElement(new FingerboardEdge(nut1.Points.First(), nut2.Points.Last()) { IsSideEdge = true }); //var center = GetStringBoundaryLine(str, FingerboardSide.Bass) as StringCenter; //var p1 = center.GetRelativePoint(str.LayoutLine, str.LayoutLine.P1); //var p2 = center.GetRelativePoint(str.Next.LayoutLine, str.Next.LayoutLine.P1); //AddVisualElement(new FingerboardEdge(p1, p2) { IsSideEdge = true }); } } } var trebSideNutInter = PointM.Empty; if (trebleNutFret.Intersects(trebleSideEdge, out trebSideNutInter)) { trebleSideEdge.P1 = trebSideNutInter; } var bassSideNutInter = PointM.Empty; if (bassNutFret.Intersects(bassSideEdge, out bassSideNutInter)) { bassSideEdge.P1 = bassSideNutInter; } trebleSideEdge.RealEnd = trebleSideEdge.P2; bassSideEdge.RealEnd = bassSideEdge.P2; var trebleLastFret = VisualElements.OfType <FretLine>().First(f => f.FretIndex == FirstString.NumberOfFrets && f.Strings.Contains(FirstString)); var bassLastFret = VisualElements.OfType <FretLine>().First(f => f.FretIndex == LastString.NumberOfFrets && f.Strings.Contains(LastString)); PointM trebleEndPoint = trebleLastFret.Points.Last(); PointM bassEndPoint = bassLastFret.Points.First(); if (!Margins.LastFret.IsEmpty) { trebleEndPoint += trebleSideEdge.Direction * Margins.LastFret; bassEndPoint += bassSideEdge.Direction * Margins.LastFret; } //split physical from virtual fingerboard var virtualTrebleEdge = AddVisualElement(new LayoutLine(trebleEndPoint, trebleSideEdge.P2, VisualElementType.FingerboardContinuation)); var virtualBassEdge = AddVisualElement(new LayoutLine(bassEndPoint, bassSideEdge.P2, VisualElementType.FingerboardContinuation)); trebleSideEdge.P2 = virtualTrebleEdge.P1; bassSideEdge.P2 = virtualBassEdge.P1; if (NumberOfStrings > 1) { var bridgeLine = new LayoutPolyLine(Strings.Select(s => s.LayoutLine.P2), VisualElementType.BridgeLine); VisualElements.Add(bridgeLine); var bridgeTrebleInter = PointM.Empty; if (bridgeLine.Intersects(virtualTrebleEdge, out bridgeTrebleInter)) { virtualTrebleEdge.P2 = bridgeTrebleInter; } var bridgeBassInter = PointM.Empty; if (bridgeLine.Intersects(virtualBassEdge, out bridgeBassInter)) { virtualBassEdge.P2 = bridgeBassInter; } } if (trebleLastFret.Strings.Count() == NumberOfStrings && trebleLastFret.IsStraight && trebleLastFret.FretIndex == MaximumFret) { AddVisualElement(new FingerboardEdge(bassSideEdge.P2, trebleSideEdge.P2)); } else if (!Margins.LastFret.IsEmpty) { var fretLines = VisualElements.OfType <FretLine>(); var edgePoints = new List <PointM>(); for (int i = NumberOfStrings - 1; i >= 0; i--) { var strLastFret = fretLines.First(fl => fl.FretIndex == Strings[i].NumberOfFrets && fl.Strings.Contains(Strings[i])); var trebleSide = GetStringBoundaryLine(Strings[i], FingerboardSide.Treble); var bassSide = GetStringBoundaryLine(Strings[i], FingerboardSide.Bass); var pt1 = PointM.Empty; var pt2 = PointM.Empty; if (!strLastFret.Intersects(bassSide, out pt1)) { pt1 = strLastFret.Points.First(); } if (!strLastFret.Intersects(trebleSide, out pt2)) { pt2 = strLastFret.Points.Last(); } pt1 += bassSide.Direction * Margins.LastFret; pt2 += trebleSide.Direction * Margins.LastFret; edgePoints.Add(pt1); edgePoints.Add(pt2); } //edgePoints.RemoveAll(p => p.IsEmpty); edgePoints = edgePoints.Distinct().ToList(); var fretboardEdge = AddVisualElement(new FingerboardEdge(edgePoints)); //fretboardEdge.InterpolateSpline(); } var fingerboardEnds = VisualElements.OfType <FingerboardEdge>(); var trebleLine = FirstString.LayoutLine; foreach (var end in fingerboardEnds) { if (end.Intersects(trebleLine, out PointM inter, false)) { AddVisualElement(new LayoutLine(trebleLine.P1, inter, VisualElementType.FingerboardMargin)); break; } } if (LastString != FirstString) { var bassLine = LastString.LayoutLine; foreach (var end in fingerboardEnds) { if (end.Intersects(bassLine, out PointM inter, false)) { AddVisualElement(new LayoutLine(bassLine.P1, inter, VisualElementType.FingerboardMargin)); break; } } } }