private ListDisplay <MethodMetricsReport> CreateChangedMethods() { var methodChanges = new ListDisplay <MethodMetricsReport>("Changed Methods since last build"); methodChanges.AddAll(ViewModel.ChangedMethods); return(methodChanges); }
public static void Highlight <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, Color color) where TFont : IFont <TGlyph> { foreach (var display in self.Displays) { display.Highlight(color); } }
// Use this for initialization void Awake() { listDisplay = ListDisplay.vocabulary; toggleListBtn = GetPanel().transform.Find("ToggleListBtn").gameObject; listToggledToLbl = GetPanel().transform.Find("ListToggledToLbl").gameObject; welshSkillsList = GetPanel().transform.Find("ScrollWindow").Find("WelshSkillsList"); }
private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { var listDisplay = new ListDisplay(); listDisplay.ItemClicked += i => ViewModel.JumpToMethod(i as MethodMetricsReport); listDisplay.DataContext = CreateChangedMethods(); listDisplay.Show(); }
private void btnSubmit_Click(object sender, EventArgs e) { var ld = new ListDisplay(); ld.Show(); ld.LoadingListBox(); }
public static PointF?PointForIndex <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, MathListIndex index) where TFont : IFont <TGlyph> { if (index is null) { return(null); } PointF?position; if (index.AtomIndex == self.Range.End) { // Special case the edge of the range position = new PointF(self.Width, 0); } else if (self.Range.Contains(index.AtomIndex) && self.SubDisplayForIndex(index) is IDisplay <TFont, TGlyph> display) { switch (index.SubIndexType) { case MathListSubIndexType.Nucleus: var nucleusPosition = index.AtomIndex + index.SubIndex.AtomIndex; position = display.PointForIndex(context, MathListIndex.Level0Index(nucleusPosition)); break; case MathListSubIndexType.None: position = display.PointForIndex(context, index); break; default: // Recurse position = display.PointForIndex(context, index.SubIndex); break; } } else { // Outside the range return(null); } if (position is PointF found) { // Convert bounds from our coordinate system before returning found.X += self.Position.X; found.Y += self.Position.Y; return(found); } else { // We didn't find the position return(null); } }
public void ToggleList() { if (listDisplay == ListDisplay.vocabulary) { listDisplay = ListDisplay.grammar; toggleListBtn.GetComponent <Text>().text = "Vocabulary"; listToggledToLbl.GetComponent <Text>().text = "Grammar"; DisplayWelshGrammarList(); } else { listDisplay = ListDisplay.vocabulary; toggleListBtn.GetComponent <Text>().text = "Grammar"; listToggledToLbl.GetComponent <Text>().text = "Vocabulary"; DisplayWelshVocabList(); } }
public static IDisplay <TFont, TGlyph> SubDisplayForIndex <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, MathListIndex index) where TFont : IFont <TGlyph> { // Inside the range if (index.SubIndexType is MathListSubIndexType.Superscript || index.SubIndexType is MathListSubIndexType.Subscript) { foreach (var display in self.Displays) { if (display is ListDisplay <TFont, TGlyph> list && index.AtomIndex == list.IndexInParent && // This is the right character for the sub/superscript, check that it's type matches the index ((list.LinePosition is Enumerations.LinePosition.Subscript && index.SubIndexType is MathListSubIndexType.Subscript) || (list.LinePosition is Enumerations.LinePosition.Superscript && index.SubIndexType is MathListSubIndexType.Superscript))) { return(list); } else { } }
public static void HighlightCharacterAt <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, MathListIndex index, Color color) where TFont : IFont <TGlyph> { if (index is null) { return; } if (self.Range.Contains(index.AtomIndex) && self.SubDisplayForIndex(index) is IDisplay <TFont, TGlyph> display) { if (index.SubIndexType is MathListSubIndexType.BetweenBaseAndScripts || index.SubIndexType is MathListSubIndexType.None) { display.HighlightCharacterAt(index, color); } else { // Recurse display.HighlightCharacterAt(index.SubIndex, color); } } }
public static MathListIndex?IndexForPoint <TFont, TGlyph> (this ListDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, PointF point) where TFont : IFont <TGlyph> { // The origin of for the subelements of a MathList is the current position, // so translate the current point to our origin. var translatedPoint = new PointF(point.X - self.Position.X, point.Y - self.Position.Y); IDisplay <TFont, TGlyph>?closest = null; var xbounds = new List <IDisplay <TFont, TGlyph> >(); float minDistance = float.MaxValue; foreach (var display in self.Displays) { var bounds = display.DisplayBounds(); var rect = new RectangleF(display.Position, bounds.Size); var maxBoundsX = rect.Right; if (rect.X - PixelDelta <= translatedPoint.X && translatedPoint.X <= maxBoundsX + PixelDelta) { xbounds.Add(display); } var distance = DistanceFromPointToRect(translatedPoint, rect); if (distance < minDistance) { closest = display; minDistance = distance; } } IDisplay <TFont, TGlyph>?displayWithPoint; switch (xbounds.Count) { case 0: if (translatedPoint.X <= -PixelDelta) { // All the way to the left return(self.Range.Location < 0 ? null : MathListIndex.Level0Index(self.Range.Location)); } else if (translatedPoint.X >= self.Width + PixelDelta) { // if closest is a script if (closest is ListDisplay <TFont, TGlyph> ld && ld.LinePosition != LinePosition.Regular) { // then we try to find its parent var parent = self.Displays.FirstOrDefault(d => d.HasScript && d.Range.Contains(ld.IndexInParent)); if (parent != null) { return(MathListIndex.Level0Index(parent.Range.End)); } } // All the way to the right return (self.Range.End < 0 ? null : self.Displays.Count == 1 && self.Displays[0] is TextLineDisplay <TFont, TGlyph> { Atoms : var atoms } && atoms.Count == 1 && atoms[0] is Atom.Atoms.Placeholder ? MathListIndex.Level0Index(self.Range.Location) : MathListIndex.Level0Index(self.Range.End)); }
private ListDisplay<MethodMetricsReport> CreateChangedMethods() { var methodChanges = new ListDisplay<MethodMetricsReport>("Changed Methods since last build"); methodChanges.AddAll(ViewModel.ChangedMethods); return methodChanges; }
public void SetListDisplayParent(ListDisplay p) { this.listDisplayParent = p; }
// Update is called once per frame void Update() { objectList = objectSpawner.GetList(); dL.updateArr(ListDisplay.pointArr(objectList)); dL.setupPositions(); }
public static PointF?PointForIndex <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, MathListIndex index) where TFont : IFont <TGlyph> { if (index is null) { return(null); } PointF?position = null; var nonScripted = self.Displays .Where(d => !(d is ListDisplay <TFont, TGlyph> ld && ld.LinePosition != Enumerations.LinePosition.Regular)) .ToArray(); if (index.SubIndexType == MathListSubIndexType.None && nonScripted.Length > 0 && nonScripted.All(d => d.Range.End <= index.AtomIndex)) { position = new PointF(self.Width, 0); } else { if (index.AtomIndex == self.Range.End) { // Special case the edge of the range position = new PointF(self.Width, 0); } else if (self.Range.Contains(index.AtomIndex) && self.SubDisplayForIndex(index) is IDisplay <TFont, TGlyph> display) { switch (index.SubIndexType) { case MathListSubIndexType.BetweenBaseAndScripts: var nucleusPosition = index.AtomIndex + index.SubIndex.AtomIndex; position = display.PointForIndex(context, MathListIndex.Level0Index(nucleusPosition)); break; case MathListSubIndexType.None: if (!display.HasScript) { position = display.PointForIndex(context, index); } else { var mainPosition = display.PointForIndex(context, index); position = self.Displays.SingleOrDefault(d => d is ListDisplay <TFont, TGlyph> ld && ld.IndexInParent == index.AtomIndex - 1) is IDisplay <TFont, TGlyph> scripted && mainPosition != null ? new PointF(mainPosition.Value.X + scripted.Width, 0) : mainPosition; } break; default: // Recurse position = display.PointForIndex(context, index.SubIndex); break; } } else { // Outside the range return(null); } } if (position is PointF found) { // Convert bounds from our coordinate system before returning found.X += self.Position.X; found.Y += self.Position.Y; return(found); } else { // We didn't find the position return(null); } }
public static MathListIndex IndexForPoint <TFont, TGlyph>(this ListDisplay <TFont, TGlyph> self, TypesettingContext <TFont, TGlyph> context, PointF point) where TFont : IFont <TGlyph> { // The origin of for the subelements of a MathList is the current position, so translate the current point to our origin. var translatedPoint = new PointF(point.X - self.Position.X, point.Y - self.Position.Y); IDisplay <TFont, TGlyph> closest = null; var xbounds = new List <IDisplay <TFont, TGlyph> >(); float minDistance = float.MaxValue; foreach (var display in self.Displays) { var bounds = display.DisplayBounds; var rect = new RectangleF(display.Position, bounds.Size); var maxBoundsX = rect.Right; if (rect.X - PixelDelta <= translatedPoint.X && translatedPoint.X <= maxBoundsX + PixelDelta) { xbounds.Add(display); } var distance = DistanceFromPointToRect(translatedPoint, rect); if (distance < minDistance) { closest = display; minDistance = distance; } } IDisplay <TFont, TGlyph> displayWithPoint; switch (xbounds.Count) { case 0: if (translatedPoint.X <= -PixelDelta) { // All the way to the left return(self.Range.Location < 0 ? null : MathListIndex.Level0Index(self.Range.Location)); } else if (translatedPoint.X >= self.Width + PixelDelta) { // if closest is a script if (closest != null && closest is ListDisplay <TFont, TGlyph> ld && ld.LinePosition != Enumerations.LinePosition.Regular) { // then we try to find its parent var parent = self.Displays.FirstOrDefault(d => d.HasScript && d.Range.Contains(ld.IndexInParent)); if (parent != null) { return(MathListIndex.Level0Index(parent.Range.End)); } } // All the way to the right return(self.Range.End < 0 ? null : MathListIndex.Level0Index(self.Range.End)); } else { // It is within the ListDisplay but not within the X bounds of any sublist. Use the closest in that case. displayWithPoint = closest; } break; case 1: displayWithPoint = xbounds[0]; var rect = new RectangleF(displayWithPoint.Position, displayWithPoint.DisplayBounds.Size); if (translatedPoint.X >= self.Width - PixelDelta) { //The point is close to the end. Only use the selected X bounds if the Y is within range. if (translatedPoint.Y <= rect.YMin() - PixelDelta) { //The point is less than the Y including the delta. Move the cursor to the end rather than in this atom. return(MathListIndex.Level0Index(self.Range.End)); } } break; default: //Use the closest since there are more than 2 sublists which have this X position. displayWithPoint = closest; break; } if (displayWithPoint is null) { return(null); } var index = displayWithPoint.IndexForPoint(context, translatedPoint); if (displayWithPoint is ListDisplay <TFont, TGlyph> closestLine) { if (closestLine.LinePosition is Enumerations.LinePosition.Regular) { throw Arg($"{nameof(ListDisplay<TFont, TGlyph>)} {nameof(ListDisplay<TFont, TGlyph>.LinePosition)} {nameof(Enumerations.LinePosition.Regular)} " + $"inside an {nameof(ListDisplay<TFont, TGlyph>)} - shouldn't happen", nameof(self)); } // This is a subscript or a superscript, return the right type of subindex var indexType = closestLine.LinePosition is Enumerations.LinePosition.Subscript ? MathListSubIndexType.Subscript : MathListSubIndexType.Superscript; // The index of the atom this denotes. if (closestLine.IndexInParent is int.MinValue) { throw Arg($"Index was not set for a {indexType} in the {nameof(ListDisplay<TFont, TGlyph>)}.", nameof(self)); } return(MathListIndex.IndexAtLocation(closestLine.IndexInParent, indexType, index)); } else if (displayWithPoint.HasScript) { //The display list has a subscript or a superscript. If the index is at the end of the atom, then we need to put it before the sub/super script rather than after. if (index?.AtomIndex == displayWithPoint.Range.End) { return(MathListIndex.IndexAtLocation(index.AtomIndex - 1, MathListSubIndexType.BetweenBaseAndScripts, MathListIndex.Level0Index(1))); } } return(index); }
public AddTask(ListDisplay ld) { _ld = ld; }