private void AddButton(MarkerButton[] buttons, DiffEditorButtonType type, IDiffMarker editMarker) { int top = editMarker.Line * _viewPort.LineHeight; int height = editMarker.Length * _viewPort.LineHeight; int left; switch (type) { case DiffEditorButtonType.CopyLeft: left = 0; break; case DiffEditorButtonType.DeleteLeft: left = ButtonWidth + 1; break; case DiffEditorButtonType.DeleteRight: left = Width - (ButtonWidth * 2 + 1); break; case DiffEditorButtonType.CopyRight: left = Width - ButtonWidth; break; default: throw new InvalidOperationException(); } buttons[(int)type] = new MarkerButton(type, new Rectangle(left, top, ButtonWidth, height)); }
private void SetupMarkerButton(MarkerButton markerButton, Context context) { if (markerButton == null) { return; } Action onClick = () => OpenSearch(context); Action onClear = () => ClearMarker(context); markerButton.AddListener(onClick, onClear); markerButton.Set(null); }
protected override void OnMouseDown(MouseEventArgs e) { if (_viewPort == null) { return; } Capture = true; var location = e.Location; location.Offset(0, _viewPort.Offset); var button = FindButton(location); _downButton = button == null ? null : button.Item2; }
public void SetMarkers(List <IDiffMarker> markers, int visibleLines) { if (markers == null) { _markers = null; Width = DisabledWidth; Invalidate(); return; } Width = (ButtonWidth * 2 + 2) * 2 + SeparatorWidth; // Rebuild the marker list to have it indexed by line. _markers = new Marker[visibleLines]; foreach (var editMarker in markers) { var buttons = new MarkerButton[4]; AddButton(buttons, DiffEditorButtonType.CopyLeft, editMarker); AddButton(buttons, DiffEditorButtonType.CopyRight, editMarker); if (editMarker.Type == DiffMarkerType.Removed) { AddButton(buttons, DiffEditorButtonType.DeleteLeft, editMarker); } if (editMarker.Type == DiffMarkerType.Added) { AddButton(buttons, DiffEditorButtonType.DeleteRight, editMarker); } var marker = new Marker(editMarker, buttons); for (int i = 0; i < editMarker.Length; i++) { Debug.Assert(_markers[editMarker.Line + i] == null); _markers[editMarker.Line + i] = marker; } } Invalidate(); Update(); }
public void SetMarkers(List<IDiffMarker> markers, int visibleLines) { if (markers == null) { _markers = null; Width = DisabledWidth; Invalidate(); return; } Width = (ButtonWidth * 2 + 2) * 2 + SeparatorWidth; // Rebuild the marker list to have it indexed by line. _markers = new Marker[visibleLines]; foreach (var editMarker in markers) { var buttons = new MarkerButton[4]; AddButton(buttons, DiffEditorButtonType.CopyLeft, editMarker); AddButton(buttons, DiffEditorButtonType.CopyRight, editMarker); if (editMarker.Type == DiffMarkerType.Removed) AddButton(buttons, DiffEditorButtonType.DeleteLeft, editMarker); if (editMarker.Type == DiffMarkerType.Added) AddButton(buttons, DiffEditorButtonType.DeleteRight, editMarker); var marker = new Marker(editMarker, buttons); for (int i = 0; i < editMarker.Length; i++) { Debug.Assert(_markers[editMarker.Line + i] == null); _markers[editMarker.Line + i] = marker; } } Invalidate(); Update(); }
void ReleaseDesignerOutlets() { if (CaloriesLabel != null) { CaloriesLabel.Dispose(); CaloriesLabel = null; } if (DistanceLabel != null) { DistanceLabel.Dispose(); DistanceLabel = null; } if (DurationLabel != null) { DurationLabel.Dispose(); DurationLabel = null; } if (MarkerButton != null) { MarkerButton.Dispose(); MarkerButton = null; } if (MarkerLabel != null) { MarkerLabel.Dispose(); MarkerLabel = null; } if (PauseResumeButton != null) { PauseResumeButton.Dispose(); PauseResumeButton = null; } }
protected override void OnMouseUp(MouseEventArgs e) { if (!Capture) { return; } if (_downButton != null) { var location = e.Location; location.Offset(0, _viewPort.Offset); var button = FindButton(location); if (button != null && button.Item2 == _downButton) { OnButtonClick(new DiffEditorButtonEventArgs(button.Item1.EditMarker, button.Item2.Type)); } _downButton = null; } Capture = false; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { _00.Focus(); MarkerButton.Focus(); }
public Marker(IDiffMarker editMarker, MarkerButton[] buttons) { EditMarker = editMarker; Buttons = buttons; switch (editMarker.Type) { case DiffMarkerType.Added: Color = DiffColor.Added; break; case DiffMarkerType.Removed: Color = DiffColor.Removed; break; case DiffMarkerType.Changed: Color = DiffColor.Changed; break; } }
private void AddButton(MarkerButton[] buttons, DiffEditorButtonType type, IDiffMarker editMarker) { int top = editMarker.Line * _viewPort.LineHeight; int height = editMarker.Length * _viewPort.LineHeight; int left; switch (type) { case DiffEditorButtonType.CopyLeft: left = 0; break; case DiffEditorButtonType.DeleteLeft: left = ButtonWidth + 1; break; case DiffEditorButtonType.DeleteRight: left = Width - (ButtonWidth * 2 + 1); break; case DiffEditorButtonType.CopyRight: left = Width - ButtonWidth; break; default: throw new InvalidOperationException(); } buttons[(int)type] = new MarkerButton(type, new Rectangle(left, top, ButtonWidth, height)); }
protected override void OnMouseUp(MouseEventArgs e) { if (!Capture) return; if (_downButton != null) { var location = e.Location; location.Offset(0, _viewPort.Offset); var button = FindButton(location); if (button != null && button.Item2 == _downButton) OnButtonClick(new DiffEditorButtonEventArgs(button.Item1.EditMarker, button.Item2.Type)); _downButton = null; } Capture = false; }
protected override void OnMouseDown(MouseEventArgs e) { if (_viewPort == null) return; Capture = true; var location = e.Location; location.Offset(0, _viewPort.Offset); var button = FindButton(location); _downButton = button == null ? null : button.Item2; }