Skip to content

Commit

Permalink
Revert "add tool tip support for annotations"
Browse files Browse the repository at this point in the history
* this (partially) reverts commit 39b6141
* expect for the changes in OxyPlot.Maui.Skia/Manipulators/TouchTrackerManipulator.cs,
  which are kept
  • Loading branch information
janusw committed Nov 25, 2023
1 parent f0a6d8b commit efee33c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,11 @@ public static PlotModel EllipseAnnotation()
var model = new PlotModel { Title = "EllipseAnnotation" };
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
model.Annotations.Add(new EllipseAnnotation
{
X = 20,
Y = 60,
Width = 20,
Height = 15,
Text = "EllipseAnnotation",
ToolTip = "EllipseAnnotation",
TextRotation = 10,
Fill = OxyColor.FromAColor(99, OxyColors.Green),
Stroke = OxyColors.Black,
StrokeThickness = 2
});
model.Annotations.Add(new EllipseAnnotation { X = 20, Y = 60, Width = 20, Height = 15, Text = "EllipseAnnotation", TextRotation = 10, Fill = OxyColor.FromAColor(99, OxyColors.Green), Stroke = OxyColors.Black, StrokeThickness = 2 });

model.Annotations.Add(new EllipseAnnotation
{
X = 20,
Y = 20,
Width = 20,
Height = 20,
Fill = OxyColor.FromAColor(99, OxyColors.Green),
ToolTip = "Green",
Stroke = OxyColors.Black,
StrokeThickness = 2
});
model.Annotations.Add(new EllipseAnnotation
{
X = 30,
Y = 20,
Width = 20,
Height = 20,
Fill = OxyColor.FromAColor(99, OxyColors.Red),
ToolTip = "Red",
Stroke = OxyColors.Black,
StrokeThickness = 2
});
model.Annotations.Add(new EllipseAnnotation
{
X = 25,
Y = 30,
Width = 20,
Height = 20,
Fill = OxyColor.FromAColor(99, OxyColors.Blue),
ToolTip = "Blue",
Stroke = OxyColors.Black,
StrokeThickness = 2
});
model.Annotations.Add(new EllipseAnnotation { X = 20, Y = 20, Width = 20, Height = 20, Fill = OxyColor.FromAColor(99, OxyColors.Green), Stroke = OxyColors.Black, StrokeThickness = 2 });
model.Annotations.Add(new EllipseAnnotation { X = 30, Y = 20, Width = 20, Height = 20, Fill = OxyColor.FromAColor(99, OxyColors.Red), Stroke = OxyColors.Black, StrokeThickness = 2 });
model.Annotations.Add(new EllipseAnnotation { X = 25, Y = 30, Width = 20, Height = 20, Fill = OxyColor.FromAColor(99, OxyColors.Blue), Stroke = OxyColors.Black, StrokeThickness = 2 });
return model;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Examples/ExampleLibrary/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Example(PlotModel model, IPlotController controller = null)
/// <value>
/// The controller.
/// </value>
public IPlotController Controller { get; set; }
public IPlotController Controller { get; private set; }

/// <summary>
/// Gets the model.
Expand Down
2 changes: 1 addition & 1 deletion Source/Examples/ExampleLibrary/ExampleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ExampleInfo
/// <summary>
/// The un-modified example.
/// </summary>
public Example Example { get; private set; }
private Example Example;

/// <summary>
/// The examples for this example info.
Expand Down
35 changes: 0 additions & 35 deletions Source/OxyplotMauiSample/Pages/ExampleBrowser.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using ExampleLibrary;
using System.Collections.ObjectModel;
using System.Windows.Input;
using OxyPlot;
using OxyPlot.Maui.Skia;
using OxyPlot.Maui.Skia.Core;

namespace OxyplotMauiSample
{
Expand Down Expand Up @@ -32,46 +29,14 @@ private async void ListView_OnItemSelected(object sender, SelectedItemChangedEve
return;

var exampleInfo = e.SelectedItem as ExampleInfo;
if (exampleInfo == null)
return;

var page = new PlotViewPage
{
ExampleInfo = exampleInfo
};

// try add tracker support for annotations
if (exampleInfo.Tags.Contains("Annotations") && exampleInfo.PlotController == null)
{
exampleInfo.Example.Controller = CreateAnnotationTrackController();
}
await Navigation.PushAsync(page);

LvExamples.SelectedItem = null;
}

private IPlotController CreateAnnotationTrackController()
{
var controller = new OxyPlot.Maui.Skia.PlotController();
controller.UnbindTouchDown();

var snapTrackTouch = new DelegatePlotCommand<OxyTouchEventArgs>((view, c, args) =>
c.AddTouchManipulator(view, new OxyPlot.Maui.Skia.Manipulators.TouchTrackerManipulator(view)
{
Snap = true,
PointsOnly = true,
LockToInitialSeries = false,
IsTrackAnnotations = true
}, args));

var cmd = new CompositeDelegateViewCommand<OxyTouchEventArgs>(
snapTrackTouch,
OxyPlot.Maui.Skia.PlotCommands.PanZoomByTouch
);
controller.BindTouchDown(cmd);

return controller;
}
}

public class ExampleBrowserViewModel : ViewModelBase
Expand Down

0 comments on commit efee33c

Please sign in to comment.