public Color GetColor(Junction junction, RevisionGraphDrawStyleEnum revisionGraphDrawStyle) { // Non relatives or non-highlighted in empty color switch (revisionGraphDrawStyle) { case RevisionGraphDrawStyleEnum.DrawNonRelativesGray when !junction.IsRelative: case RevisionGraphDrawStyleEnum.HighlightSelected when !junction.IsHighlighted: { return(NonRelativeColor); } } if (!AppSettings.MulticolorBranches) { return(AppSettings.GraphColor); } // See if this junction's colour has already been calculated if (junction.ColorIndex > -1 && junction.ColorIndex < PresetGraphColors.Count) { return(PresetGraphColors[junction.ColorIndex]); } var colorIndex = FindDistinctColour(junction); junction.ColorIndex = colorIndex; return(PresetGraphColors[colorIndex]); }
public void UpdateJunctionColors(IReadOnlyList <Junction> junctions, RevisionGraphDrawStyleEnum revisionGraphDrawStyle) { _junctionColors.Clear(); // Select one or two colours to use when rendering this junction if (junctions.Count == 0) { _junctionColors.Add(Color.Black); return; } for (var i = 0; i < 2 && i < junctions.Count; i++) { var color = _junctionColorProvider.GetColor(junctions[i], revisionGraphDrawStyle); _junctionColors.Add(color); } }
private bool DrawItem(Graphics wa, Graph.ILaneRow row) { if (row == null || row.NodeLane == -1) { return false; } // Clip to the area we're drawing in, but draw 1 pixel past so // that the top/bottom of the line segment's anti-aliasing isn't // visible in the final rendering. int top = wa.RenderingOrigin.Y + _rowHeight / 2; var laneRect = new Rectangle(0, top, Width, _rowHeight); Region oldClip = wa.Clip; var newClip = new Region(laneRect); newClip.Intersect(oldClip); wa.Clip = newClip; wa.Clear(Color.Transparent); //Getting RevisionGraphDrawStyle results in call to AppSettings. This is not very cheap, cache. revisionGraphDrawStyleCache = RevisionGraphDrawStyle; //for (int r = 0; r < 2; r++) for (int lane = 0; lane < row.Count; lane++) { int mid = wa.RenderingOrigin.X + (int)((lane + 0.5) * _laneWidth); for (int item = 0; item < row.LaneInfoCount(lane); item++) { Graph.LaneInfo laneInfo = row[lane, item]; bool highLight = (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && laneInfo.Junctions.Any(j => j.IsRelative)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && laneInfo.Junctions.Any(j => j.HighLight)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); List<Color> curColors = GetJunctionColors(laneInfo.Junctions); // Create the brush for drawing the line Brush brushLineColor = null; Pen brushLineColorPen = null; try { bool drawBorder = highLight && AppSettings.BranchBorders; //hide border for "non-relatives" if (curColors.Count == 1 || !AppSettings.StripedBranchChange) { if (curColors[0] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[0]); } else if (curColors.Count > 1 && curColors[1] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[1]); } else { drawBorder = false; brushLineColor = new SolidBrush(_nonRelativeColor); } } else { Color lastRealColor = curColors.LastOrDefault(c => c != _nonRelativeColor); if (lastRealColor.IsEmpty) { brushLineColor = new SolidBrush(_nonRelativeColor); drawBorder = false; } else { brushLineColor = new HatchBrush(HatchStyle.DarkDownwardDiagonal, curColors[0], lastRealColor); } } for (int i = drawBorder ? 0 : 2; i < 3; i++) { Pen penLine = null; if (i == 0) { penLine = _whiteBorderPen; } else if (i == 1) { penLine = _blackBorderPen; } else { if (brushLineColorPen == null) brushLineColorPen = new Pen(brushLineColor, _laneLineWidth); penLine = brushLineColorPen; } if (laneInfo.ConnectLane == lane) { wa.DrawLine ( penLine, new Point(mid, top - 1), new Point(mid, top + _rowHeight + 2) ); } else { wa.DrawBezier ( penLine, new Point(mid, top - 1), new Point(mid, top + _rowHeight + 2), new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top - 1), new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top + _rowHeight + 2) ); } } } finally { if (brushLineColorPen != null) ((IDisposable)brushLineColorPen).Dispose(); if (brushLineColor != null) ((IDisposable)brushLineColor).Dispose(); } } } // Reset the clip region wa.Clip = oldClip; { // Draw node var nodeRect = new Rectangle ( wa.RenderingOrigin.X + (_laneWidth - _nodeDimension) / 2 + row.NodeLane * _laneWidth, wa.RenderingOrigin.Y + (_rowHeight - _nodeDimension) / 2, _nodeDimension, _nodeDimension ); Brush nodeBrush; List<Color> nodeColors = GetJunctionColors(row.Node.Ancestors); bool highlight = (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && row.Node.Ancestors.Any(j => j.IsRelative)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && row.Node.Ancestors.Any(j => j.HighLight)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); bool drawBorder = AppSettings.BranchBorders && highlight; if (nodeColors.Count == 1) { nodeBrush = new SolidBrush(highlight ? nodeColors[0] : _nonRelativeColor); if (nodeColors[0] == _nonRelativeColor) drawBorder = false; } else { nodeBrush = new LinearGradientBrush(nodeRect, nodeColors[0], nodeColors[1], LinearGradientMode.Horizontal); if (nodeColors.All(c => c == _nonRelativeColor)) drawBorder = false; } if (_filterMode == FilterType.Highlight && row.Node.IsFiltered) { Rectangle highlightRect = nodeRect; highlightRect.Inflate(2, 3); wa.FillRectangle(Brushes.Yellow, highlightRect); wa.DrawRectangle(Pens.Black, highlightRect); } if (row.Node.Data == null) { wa.FillEllipse(Brushes.White, nodeRect); using (var pen = new Pen(Color.Red, 2)) { wa.DrawEllipse(pen, nodeRect); } } else if (row.Node.IsActive) { wa.FillRectangle(nodeBrush, nodeRect); nodeRect.Inflate(1, 1); using (var pen = new Pen(Color.Black, 3)) wa.DrawRectangle(pen, nodeRect); } else if (row.Node.IsSpecial) { wa.FillRectangle(nodeBrush, nodeRect); if (drawBorder) { wa.DrawRectangle(Pens.Black, nodeRect); } } else { wa.FillEllipse(nodeBrush, nodeRect); if (drawBorder) { wa.DrawEllipse(Pens.Black, nodeRect); } } } return true; }
private bool DrawItem(Graphics wa, Graph.ILaneRow row) { if (row == null || row.NodeLane == -1) { return(false); } // Clip to the area we're drawing in, but draw 1 pixel past so // that the top/bottom of the line segment's anti-aliasing isn't // visible in the final rendering. int top = wa.RenderingOrigin.Y + (_rowHeight / 2); var laneRect = new Rectangle(0, top, Width, _rowHeight); Region oldClip = wa.Clip; var newClip = new Region(laneRect); newClip.Intersect(oldClip); wa.Clip = newClip; wa.Clear(Color.Transparent); // Getting RevisionGraphDrawStyle results in call to AppSettings. This is not very cheap, cache. _revisionGraphDrawStyleCache = RevisionGraphDrawStyle; ////for (int r = 0; r < 2; r++) for (int lane = 0; lane < row.Count; lane++) { int mid = wa.RenderingOrigin.X + (int)((lane + 0.5) * _laneWidth); for (int item = 0; item < row.LaneInfoCount(lane); item++) { Graph.LaneInfo laneInfo = row[lane, item]; bool highLight = (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && laneInfo.Junctions.Any(j => j.IsRelative)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && laneInfo.Junctions.Any(j => j.HighLight)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); List <Color> curColors = GetJunctionColors(laneInfo.Junctions); // Create the brush for drawing the line Brush brushLineColor = null; Pen brushLineColorPen = null; try { bool drawBorder = highLight && AppSettings.BranchBorders; // hide border for "non-relatives" if (curColors.Count == 1 || !AppSettings.StripedBranchChange) { if (curColors[0] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[0]); } else if (curColors.Count > 1 && curColors[1] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[1]); } else { drawBorder = false; brushLineColor = new SolidBrush(_nonRelativeColor); } } else { Color lastRealColor = curColors.LastOrDefault(c => c != _nonRelativeColor); if (lastRealColor.IsEmpty) { brushLineColor = new SolidBrush(_nonRelativeColor); drawBorder = false; } else { brushLineColor = new HatchBrush(HatchStyle.DarkDownwardDiagonal, curColors[0], lastRealColor); } } // Precalculate line endpoints bool singleLane = laneInfo.ConnectLane == lane; int x0 = mid; int y0 = top - 1; int x1 = singleLane ? x0 : mid + ((laneInfo.ConnectLane - lane) * _laneWidth); int y1 = top + _rowHeight; Point p0 = new Point(x0, y0); Point p1 = new Point(x1, y1); // Precalculate curve control points when needed Point c0, c1; if (singleLane) { c0 = c1 = Point.Empty; } else { // Controls the curvature of cross-lane lines (0 = straight line, 1 = 90 degree turns) const float severity = 0.5f; c0 = new Point(x0, (int)((y0 * (1.0f - severity)) + (y1 * severity))); c1 = new Point(x1, (int)((y1 * (1.0f - severity)) + (y0 * severity))); } for (int i = drawBorder ? 0 : 2; i < 3; i++) { Pen penLine; switch (i) { case 0: penLine = _whiteBorderPen; break; case 1: penLine = _blackBorderPen; break; default: if (brushLineColorPen == null) { brushLineColorPen = new Pen(brushLineColor, _laneLineWidth); } penLine = brushLineColorPen; break; } if (singleLane) { wa.DrawLine(penLine, p0, p1); } else { wa.DrawBezier(penLine, p0, c0, c1, p1); } } } finally { brushLineColorPen?.Dispose(); ((IDisposable)brushLineColor)?.Dispose(); } } } // Reset the clip region wa.Clip = oldClip; { // Draw node var nodeRect = new Rectangle( wa.RenderingOrigin.X + ((_laneWidth - _nodeDimension) / 2) + (row.NodeLane * _laneWidth), wa.RenderingOrigin.Y + ((_rowHeight - _nodeDimension) / 2), _nodeDimension, _nodeDimension); Brush nodeBrush; List <Color> nodeColors = GetJunctionColors(row.Node.Ancestors); bool highlight = (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && row.Node.Ancestors.Any(j => j.IsRelative)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && row.Node.Ancestors.Any(j => j.HighLight)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); bool drawBorder = AppSettings.BranchBorders && highlight; if (nodeColors.Count == 1) { nodeBrush = new SolidBrush(highlight ? nodeColors[0] : _nonRelativeColor); if (nodeColors[0] == _nonRelativeColor) { drawBorder = false; } } else { nodeBrush = new LinearGradientBrush(nodeRect, nodeColors[0], nodeColors[1], LinearGradientMode.Horizontal); if (nodeColors.All(c => c == _nonRelativeColor)) { drawBorder = false; } } if (_filterMode == FilterType.Highlight && row.Node.IsFiltered) { Rectangle highlightRect = nodeRect; highlightRect.Inflate(2, 3); wa.FillRectangle(Brushes.Yellow, highlightRect); wa.DrawRectangle(Pens.Black, highlightRect); } if (row.Node.Data == null) { wa.FillEllipse(Brushes.White, nodeRect); using (var pen = new Pen(Color.Red, 2)) { wa.DrawEllipse(pen, nodeRect); } } else if (row.Node.IsActive) { wa.FillRectangle(nodeBrush, nodeRect); nodeRect.Inflate(1, 1); using (var pen = new Pen(Color.Black, 3)) { wa.DrawRectangle(pen, nodeRect); } } else if (row.Node.IsSpecial) { wa.FillRectangle(nodeBrush, nodeRect); if (drawBorder) { wa.DrawRectangle(Pens.Black, nodeRect); } } else { wa.FillEllipse(nodeBrush, nodeRect); if (drawBorder) { wa.DrawEllipse(Pens.Black, nodeRect); } } } return(true); }
private bool DrawItem(Graphics wa, Graph.ILaneRow row) { ThreadHelper.AssertOnUIThread(); if (row == null || row.NodeLane == -1) { return(false); } // Clip to the area we're drawing in, but draw 1 pixel past so // that the top/bottom of the line segment's anti-aliasing isn't // visible in the final rendering. int top = wa.RenderingOrigin.Y + (_rowHeight / 2); var laneRect = new Rectangle(0, top, Width, _rowHeight); Region oldClip = wa.Clip; var newClip = new Region(laneRect); newClip.Intersect(oldClip); wa.Clip = newClip; wa.Clear(Color.Transparent); // Getting RevisionGraphDrawStyle results in call to AppSettings. This is not very cheap, cache. _revisionGraphDrawStyleCache = RevisionGraphDrawStyle; ////for (int r = 0; r < 2; r++) for (int lane = 0; lane < row.Count; lane++) { int mid = wa.RenderingOrigin.X + (int)((lane + 0.5) * _laneWidth); for (int item = 0; item < row.LaneInfoCount(lane); item++) { Graph.LaneInfo laneInfo = row[lane, item]; bool highLight = (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && laneInfo.Junctions.Any(j => j.IsRelative)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && laneInfo.Junctions.Any(j => j.HighLight)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); UpdateJunctionColors(laneInfo.Junctions); // Create the brush for drawing the line Brush lineBrush = null; Pen linePen = null; try { bool drawBorder = highLight && AppSettings.BranchBorders; // hide border for "non-relatives" if (_junctionColors.Count == 1 || !AppSettings.StripedBranchChange) { if (_junctionColors[0] != _nonRelativeColor) { lineBrush = new SolidBrush(_junctionColors[0]); } else if (_junctionColors.Count > 1 && _junctionColors[1] != _nonRelativeColor) { lineBrush = new SolidBrush(_junctionColors[1]); } else { drawBorder = false; lineBrush = new SolidBrush(_nonRelativeColor); } } else { Color lastRealColor = _junctionColors.LastOrDefault(c => c != _nonRelativeColor); if (lastRealColor.IsEmpty) { lineBrush = new SolidBrush(_nonRelativeColor); drawBorder = false; } else { lineBrush = new HatchBrush(HatchStyle.DarkDownwardDiagonal, _junctionColors[0], lastRealColor); } } // Precalculate line endpoints bool sameLane = laneInfo.ConnectLane == lane; int x0 = mid; int y0 = top - 1; int x1 = sameLane ? x0 : mid + ((laneInfo.ConnectLane - lane) * _laneWidth); int y1 = top + _rowHeight; Point p0 = new Point(x0, y0); Point p1 = new Point(x1, y1); // Precalculate curve control points when needed Point c0, c1; if (sameLane) { // We are drawing between two points in the same // lane, so there will be no curve c0 = c1 = default; } else { // Left shifting int is fast equivalent of dividing by two, // thus computing the average of y0 and y1. var yMid = (y0 + y1) >> 1; c0 = new Point(x0, yMid); c1 = new Point(x1, yMid); } for (int i = drawBorder ? 0 : 2; i < 3; i++) { Pen pen; switch (i) { case 0: pen = _whiteBorderPen; break; case 1: pen = _blackBorderPen; break; default: if (linePen == null) { linePen = new Pen(lineBrush, _laneLineWidth); } pen = linePen; break; } if (sameLane) { wa.DrawLine(pen, p0, p1); } else { wa.DrawBezier(pen, p0, c0, c1, p1); } } } finally { linePen?.Dispose(); lineBrush?.Dispose(); } } } // Reset the clip region wa.Clip = oldClip; // Draw node var nodeRect = new Rectangle( wa.RenderingOrigin.X + ((_laneWidth - _nodeDimension) / 2) + (row.NodeLane * _laneWidth), wa.RenderingOrigin.Y + ((_rowHeight - _nodeDimension) / 2), _nodeDimension, _nodeDimension); Brush nodeBrush; UpdateJunctionColors(row.Node.Ancestors); bool highlight = (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && row.Node.Ancestors.Any(j => j.IsRelative)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && row.Node.Ancestors.Any(j => j.HighLight)) || (_revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); bool drawNodeBorder = AppSettings.BranchBorders && highlight; if (_junctionColors.Count == 1) { nodeBrush = new SolidBrush(highlight ? _junctionColors[0] : _nonRelativeColor); if (_junctionColors[0] == _nonRelativeColor) { drawNodeBorder = false; } } else { nodeBrush = new LinearGradientBrush( nodeRect, _junctionColors[0], _junctionColors[1], LinearGradientMode.Horizontal); if (_junctionColors.All(c => c == _nonRelativeColor)) { drawNodeBorder = false; } } if (row.Node.Data == null) { wa.FillEllipse(Brushes.White, nodeRect); using (var pen = new Pen(Color.Red, 2)) { wa.DrawEllipse(pen, nodeRect); } } else if (row.Node.IsActive) { wa.FillRectangle(nodeBrush, nodeRect); nodeRect.Inflate(1, 1); using (var pen = new Pen(Color.Black, 3)) { wa.DrawRectangle(pen, nodeRect); } } else if (row.Node.IsSpecial) { wa.FillRectangle(nodeBrush, nodeRect); if (drawNodeBorder) { wa.DrawRectangle(Pens.Black, nodeRect); } } else { wa.FillEllipse(nodeBrush, nodeRect); if (drawNodeBorder) { wa.DrawEllipse(Pens.Black, nodeRect); } } nodeBrush.Dispose(); return(true); void UpdateJunctionColors(IEnumerable <Junction> junction) { _junctionColors.Clear(); // Color of non-relative branches. _junctionColors.AddRange(junction.Select(GetJunctionColor)); if (_junctionColors.Count == 0) { _junctionColors.Add(Color.Black); } } }
private bool DrawItem(Graphics wa, Graph.ILaneRow row) { if (row == null || row.NodeLane == -1) { return(false); } // Clip to the area we're drawing in, but draw 1 pixel past so // that the top/bottom of the line segment's anti-aliasing isn't // visible in the final rendering. int top = wa.RenderingOrigin.Y + _rowHeight / 2; var laneRect = new Rectangle(0, top, Width, _rowHeight); Region oldClip = wa.Clip; var newClip = new Region(laneRect); newClip.Intersect(oldClip); wa.Clip = newClip; wa.Clear(Color.Transparent); //Getting RevisionGraphDrawStyle results in call to AppSettings. This is not very cheap, cache. revisionGraphDrawStyleCache = RevisionGraphDrawStyle; //for (int r = 0; r < 2; r++) for (int lane = 0; lane < row.Count; lane++) { int mid = wa.RenderingOrigin.X + (int)((lane + 0.5) * _laneWidth); for (int item = 0; item < row.LaneInfoCount(lane); item++) { Graph.LaneInfo laneInfo = row[lane, item]; bool highLight = (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && laneInfo.Junctions.Any(j => j.IsRelative)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && laneInfo.Junctions.Any(j => j.HighLight)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); List <Color> curColors = GetJunctionColors(laneInfo.Junctions); // Create the brush for drawing the line Brush brushLineColor = null; Pen brushLineColorPen = null; try { bool drawBorder = highLight && AppSettings.BranchBorders; //hide border for "non-relatives" if (curColors.Count == 1 || !AppSettings.StripedBranchChange) { if (curColors[0] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[0]); } else if (curColors.Count > 1 && curColors[1] != _nonRelativeColor) { brushLineColor = new SolidBrush(curColors[1]); } else { drawBorder = false; brushLineColor = new SolidBrush(_nonRelativeColor); } } else { Color lastRealColor = curColors.LastOrDefault(c => c != _nonRelativeColor); if (lastRealColor.IsEmpty) { brushLineColor = new SolidBrush(_nonRelativeColor); drawBorder = false; } else { brushLineColor = new HatchBrush(HatchStyle.DarkDownwardDiagonal, curColors[0], lastRealColor); } } for (int i = drawBorder ? 0 : 2; i < 3; i++) { Pen penLine = null; if (i == 0) { penLine = _whiteBorderPen; } else if (i == 1) { penLine = _blackBorderPen; } else { if (brushLineColorPen == null) { brushLineColorPen = new Pen(brushLineColor, _laneLineWidth); } penLine = brushLineColorPen; } if (laneInfo.ConnectLane == lane) { wa.DrawLine ( penLine, new Point(mid, top - 1), new Point(mid, top + _rowHeight + 2) ); } else { wa.DrawBezier ( penLine, new Point(mid, top - 1), new Point(mid, top + _rowHeight + 2), new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top - 1), new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top + _rowHeight + 2) ); } } } finally { if (brushLineColorPen != null) { ((IDisposable)brushLineColorPen).Dispose(); } if (brushLineColor != null) { ((IDisposable)brushLineColor).Dispose(); } } } } // Reset the clip region wa.Clip = oldClip; { // Draw node var nodeRect = new Rectangle ( wa.RenderingOrigin.X + (_laneWidth - _nodeDimension) / 2 + row.NodeLane * _laneWidth, wa.RenderingOrigin.Y + (_rowHeight - _nodeDimension) / 2, _nodeDimension, _nodeDimension ); Brush nodeBrush; List <Color> nodeColors = GetJunctionColors(row.Node.Ancestors); bool highlight = (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.DrawNonRelativesGray && row.Node.Ancestors.Any(j => j.IsRelative)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.HighlightSelected && row.Node.Ancestors.Any(j => j.HighLight)) || (revisionGraphDrawStyleCache == RevisionGraphDrawStyleEnum.Normal); bool drawBorder = AppSettings.BranchBorders && highlight; if (nodeColors.Count == 1) { nodeBrush = new SolidBrush(highlight ? nodeColors[0] : _nonRelativeColor); if (nodeColors[0] == _nonRelativeColor) { drawBorder = false; } } else { nodeBrush = new LinearGradientBrush(nodeRect, nodeColors[0], nodeColors[1], LinearGradientMode.Horizontal); if (nodeColors.All(c => c == _nonRelativeColor)) { drawBorder = false; } } if (_filterMode == FilterType.Highlight && row.Node.IsFiltered) { Rectangle highlightRect = nodeRect; highlightRect.Inflate(2, 3); wa.FillRectangle(Brushes.Yellow, highlightRect); wa.DrawRectangle(Pens.Black, highlightRect); } if (row.Node.Data == null) { wa.FillEllipse(Brushes.White, nodeRect); using (var pen = new Pen(Color.Red, 2)) { wa.DrawEllipse(pen, nodeRect); } } else if (row.Node.IsActive) { wa.FillRectangle(nodeBrush, nodeRect); nodeRect.Inflate(1, 1); using (var pen = new Pen(Color.Black, 3)) wa.DrawRectangle(pen, nodeRect); } else if (row.Node.IsSpecial) { wa.FillRectangle(nodeBrush, nodeRect); if (drawBorder) { wa.DrawRectangle(Pens.Black, nodeRect); } } else { wa.FillEllipse(nodeBrush, nodeRect); if (drawBorder) { wa.DrawEllipse(Pens.Black, nodeRect); } } } return(true); }
public void ForceRefreshRevisions() { try { RevisionGraphDrawStyle = RevisionGraphDrawStyleEnum.DrawNonRelativesGray; IsMessageMultilineDataGridViewColumn.Visible = AppSettings.ShowIndicatorForMultilineMessage; ApplyFilterFromRevisionFilterDialog(); _initialLoad = true; BuildServerWatcher.CancelBuildStatusFetchOperation(); DisposeRevisionGraphCommand(); var newCurrentCheckout = Module.GetCurrentCheckout(); Task<SuperProjectInfo> newSuperPrjectInfo = Task.Factory.StartNew(() => GetSuperprojectCheckout(ShowRemoteRef)); newSuperPrjectInfo.ContinueWith((task) => Refresh(), TaskScheduler.FromCurrentSynchronizationContext()); // If the current checkout changed, don't get the currently selected rows, select the // new current checkout instead. if (newCurrentCheckout == CurrentCheckout) { LastSelectedRows = Revisions.SelectedIds; } else { // This is a new checkout, so ensure the variable is cleared out. LastSelectedRows = null; } Revisions.ClearSelection(); CurrentCheckout = newCurrentCheckout; FiltredCurrentCheckout = CurrentCheckout; SuperprojectCurrentCheckout = newSuperPrjectInfo; Revisions.Clear(); Error.Visible = false; if (!Module.IsValidGitWorkingDir()) { Revisions.Visible = false; NoCommits.Visible = true; Loading.Visible = false; NoGit.Visible = true; string dir = Module.WorkingDir; if (String.IsNullOrEmpty(dir) || !Directory.Exists(dir) || Directory.GetDirectories(dir).Length == 0 && Directory.GetFiles(dir).Length == 0) CloneRepository.Show(); else CloneRepository.Hide(); NoGit.BringToFront(); return; } NoCommits.Visible = false; NoGit.Visible = false; Revisions.Visible = true; Revisions.BringToFront(); Revisions.Enabled = false; Loading.Visible = true; Loading.BringToFront(); _isLoading = true; base.Refresh(); IndexWatcher.Reset(); if (!AppSettings.ShowGitNotes && (_refsOptions & (RefsFiltringOptions.All | RefsFiltringOptions.Boundary)) == (RefsFiltringOptions.All | RefsFiltringOptions.Boundary)) _refsOptions |= RefsFiltringOptions.ShowGitNotes; if (AppSettings.ShowGitNotes) _refsOptions &= ~RefsFiltringOptions.ShowGitNotes; if (!AppSettings.ShowMergeCommits) _refsOptions |= RefsFiltringOptions.NoMerges; RevisionGridInMemFilter revisionFilterIMF = RevisionGridInMemFilter.CreateIfNeeded(_revisionFilter.GetInMemAuthorFilter(), _revisionFilter.GetInMemCommitterFilter(), _revisionFilter.GetInMemMessageFilter(), _revisionFilter.GetIgnoreCase()); RevisionGridInMemFilter filterBarIMF = RevisionGridInMemFilter.CreateIfNeeded(InMemAuthorFilter, InMemCommitterFilter, InMemMessageFilter, InMemFilterIgnoreCase); RevisionGraphInMemFilter revGraphIMF; if (revisionFilterIMF != null && filterBarIMF != null) revGraphIMF = new RevisionGraphInMemFilterOr(revisionFilterIMF, filterBarIMF); else if (revisionFilterIMF != null) revGraphIMF = revisionFilterIMF; else revGraphIMF = filterBarIMF; _revisionGraphCommand = new RevisionGraph(Module) { BranchFilter = BranchFilter, RefsOptions = _refsOptions, Filter = _revisionFilter.GetFilter() + Filter + FixedFilter }; _revisionGraphCommand.Updated += GitGetCommitsCommandUpdated; _revisionGraphCommand.Exited += GitGetCommitsCommandExited; _revisionGraphCommand.Error += _revisionGraphCommand_Error; _revisionGraphCommand.InMemFilter = revGraphIMF; _revisionGraphCommand.Execute(); LoadRevisions(); SetRevisionsLayout(); ResetNavigationHistory(); } catch (Exception) { Error.Visible = true; Error.BringToFront(); throw; } }