|
2 | 2 | // ReactiveUI Association Incorporated licenses this file to you under the MIT license. |
3 | 3 | // See the LICENSE file in the project root for full license information. |
4 | 4 |
|
| 5 | +using System.Diagnostics; |
5 | 6 | using System.Reactive; |
6 | 7 | using System.Reactive.Disposables; |
7 | 8 | using System.Reactive.Linq; |
@@ -73,7 +74,14 @@ public LiveChartViewModel(Grid grid) |
73 | 74 | CreateAxisWithTimeStamp(); |
74 | 75 | AutoScale = ReactiveCommand.Create(() => { }); |
75 | 76 | GraphLocked = ReactiveCommand.Create(() => { }); |
76 | | - EnableMarkerBtn = ReactiveCommand.Create(() => { }); |
| 77 | + EnableMarkerBtn = ReactiveCommand.Create(() => |
| 78 | + { |
| 79 | + foreach (var p in SignalCollectionUI) |
| 80 | + { |
| 81 | + p.ChartSettings.IsCrossHairVisible = !p.ChartSettings.IsCrossHairVisible; |
| 82 | + } |
| 83 | + }); |
| 84 | + |
77 | 85 | MakeLeftPanelVisible = ReactiveCommand.Create(() => { }); |
78 | 86 |
|
79 | 87 | AxesSetup(); // axes colors setup |
@@ -563,6 +571,9 @@ where i < 9 |
563 | 571 | } |
564 | 572 |
|
565 | 573 | newMyItem.DataLogger!.Axes.YAxis = YAxisList[a]; |
| 574 | + newMyItem.Marker!.Axes.YAxis = YAxisList[a]; |
| 575 | + newMyItem.MarkerText!.Axes.YAxis = YAxisList[a]; |
| 576 | + newMyItem.Crosshair!.Axes.YAxis = YAxisList[a]; |
566 | 577 | ////newMyItem.SignalXY!.Axes.YAxis = YAxisList[a]; |
567 | 578 | }) |
568 | 579 | .DisposeWith(Disposables); |
@@ -938,164 +949,14 @@ private void InitializeMouseObservable() |
938 | 949 | try |
939 | 950 | { |
940 | 951 | MouseCoordinatesObservable.OnNext(mouseLocation); |
| 952 | + |
| 953 | + Trace.WriteLine("Mouse Location: { X: " + position.X + " Y: " + position.Y + " }"); |
941 | 954 | } |
942 | 955 | catch (Exception ex) |
943 | 956 | { |
944 | | - Console.WriteLine(ex.ToString()); |
| 957 | + Console.WriteLine("mouse location error: " + ex.ToString()); |
945 | 958 | } |
946 | | - |
947 | | - ////foreach (var x in SignalCollectionUI) |
948 | | - ////{ |
949 | | - //// WpfPlot1vm!.Refresh(); |
950 | | - //// var closestCoordinate = x.MyItem.SignalXY!.Data.GetNearestX(rect, WpfPlot1vm!.Plot.LastRender).Coordinates; |
951 | | - //// ////.OrderBy(coordinate => Math.Abs(coordinate.X - rect!.Value.X)) |
952 | | - //// ////.FirstOrDefault(); |
953 | | - |
954 | | - //// // hide the crosshair, marker and text when no point is selected |
955 | | - //// var visible = x.MyItem.IsChecked && EnableMarker; |
956 | | - //// x.Item2.Crosshair!.IsVisible = visible; |
957 | | - //// x.Item2.Marker!.IsVisible = visible; |
958 | | - //// x.Item2.Text!.IsVisible = visible; |
959 | | - |
960 | | - //// if (closestCoordinate != Coordinates.NaN) |
961 | | - //// { |
962 | | - //// x.Item2.Crosshair!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
963 | | - //// x.Item2.Crosshair.Position = closestCoordinate; |
964 | | - //// x.Item2.Crosshair.LineColor = x.MyItem.SignalXY.Color; |
965 | | - |
966 | | - //// x.Item2.Marker!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
967 | | - //// x.Item2.Marker.Location = closestCoordinate; |
968 | | - //// x.Item2.Marker.MarkerStyle.LineColor = x.MyItem.SignalXY.Color; |
969 | | - |
970 | | - //// x.Item2.Text!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
971 | | - //// x.Item2.Text.Location = closestCoordinate; |
972 | | - //// try |
973 | | - //// { |
974 | | - //// x.Item2.Text.LabelText = $"{closestCoordinate.Y:0.##}\n{DateTime.FromOADate(closestCoordinate.X)}"; |
975 | | - //// } |
976 | | - //// catch |
977 | | - //// { |
978 | | - //// x.Item2.Text.LabelText = $"{closestCoordinate.Y:0.##}\n{closestCoordinate.X}"; |
979 | | - //// } |
980 | | - |
981 | | - //// x.Item2.Text.LabelFontColor = x.MyItem.SignalXY.Color; |
982 | | - //// } |
983 | | - |
984 | | - //// WpfPlot1vm?.Refresh(); |
985 | | - ////} |
986 | 959 | }; |
987 | | - ////WpfPlot1vm.Events().MouseMove.Select(e => e.GetPosition(e.Device.Target)) |
988 | | - //// .CombineLatest( |
989 | | - //// SignalCollectionUI.CurrentItems.Select(x => |
990 | | - //// { |
991 | | - //// var l = new List<(SignalUI MyItem, (Crosshair? Crosshair, Marker? Marker, Text? Text))>(); |
992 | | - //// foreach (var d in x) |
993 | | - //// { |
994 | | - //// l.Add((d, CreateCursorValues())); |
995 | | - //// } |
996 | | - |
997 | | - //// return l; |
998 | | - //// }), |
999 | | - //// (e, x) => (e, x)).Subscribe(d => |
1000 | | - //// { |
1001 | | - //// Point mousePosition = d.e; |
1002 | | - //// float xx = Convert.ToSingle(mousePosition.X); |
1003 | | - //// float yy = Convert.ToSingle(mousePosition.Y); |
1004 | | - //// var rect = WpfPlot1vm!.Plot.GetCoordinates(xx, yy); |
1005 | | - //// foreach (var x in d.x) |
1006 | | - //// { |
1007 | | - //// WpfPlot1vm!.Refresh(); |
1008 | | - //// var closestCoordinate = x.MyItem.SignalXY!.Data.GetNearestX(rect, WpfPlot1vm!.Plot.LastRender).Coordinates; |
1009 | | - //// ////.OrderBy(coordinate => Math.Abs(coordinate.X - rect!.Value.X)) |
1010 | | - //// ////.FirstOrDefault(); |
1011 | | - |
1012 | | - //// // hide the crosshair, marker and text when no point is selected |
1013 | | - //// var visible = x.MyItem.IsChecked && EnableMarker; |
1014 | | - //// x.Item2.Crosshair!.IsVisible = visible; |
1015 | | - //// x.Item2.Marker!.IsVisible = visible; |
1016 | | - //// x.Item2.Text!.IsVisible = visible; |
1017 | | - |
1018 | | - //// if (closestCoordinate != Coordinates.NaN) |
1019 | | - //// { |
1020 | | - //// x.Item2.Crosshair!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
1021 | | - //// x.Item2.Crosshair.Position = closestCoordinate; |
1022 | | - //// x.Item2.Crosshair.LineColor = x.MyItem.SignalXY.Color; |
1023 | | - |
1024 | | - //// x.Item2.Marker!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
1025 | | - //// x.Item2.Marker.Location = closestCoordinate; |
1026 | | - //// x.Item2.Marker.MarkerStyle.LineColor = x.MyItem.SignalXY.Color; |
1027 | | - |
1028 | | - //// x.Item2.Text!.Axes.YAxis = x.MyItem.SignalXY.Axes.YAxis; |
1029 | | - //// x.Item2.Text.Location = closestCoordinate; |
1030 | | - //// try |
1031 | | - //// { |
1032 | | - //// x.Item2.Text.LabelText = $"{closestCoordinate.Y:0.##}\n{DateTime.FromOADate(closestCoordinate.X)}"; |
1033 | | - //// } |
1034 | | - //// catch |
1035 | | - //// { |
1036 | | - //// x.Item2.Text.LabelText = $"{closestCoordinate.Y:0.##}\n{closestCoordinate.X}"; |
1037 | | - //// } |
1038 | | - |
1039 | | - //// x.Item2.Text.LabelFontColor = x.MyItem.SignalXY.Color; |
1040 | | - //// } |
1041 | | - |
1042 | | - //// WpfPlot1vm?.Refresh(); |
1043 | | - //// } |
1044 | | - //// }); |
1045 | | - |
1046 | | - ////// MOUSE EVENT |
1047 | | - ////WpfPlot1vm.Events().MouseMove.Select(e => e.GetPosition(e.Device.Target)) |
1048 | | - //// .CombineLatest( |
1049 | | - //// ScatterCollectionUI.CurrentItems.Select(x => |
1050 | | - //// { |
1051 | | - //// var l = new List<(ScatterUI MyItem, (Crosshair? Crosshair, Marker? Marker, Text? Text))>(); |
1052 | | - //// foreach (var d in x) |
1053 | | - //// { |
1054 | | - //// l.Add((d, CreateCursorValues())); |
1055 | | - //// } |
1056 | | - |
1057 | | - //// return l; |
1058 | | - //// }), |
1059 | | - //// (e, x) => (e, x)).Subscribe(d => |
1060 | | - //// { |
1061 | | - //// Point mousePosition = d.e; |
1062 | | - //// float xx = Convert.ToSingle(mousePosition.X); |
1063 | | - //// float yy = Convert.ToSingle(mousePosition.Y); |
1064 | | - //// var rect = WpfPlot1vm!.Plot.GetCoordinates(xx, yy); |
1065 | | - //// foreach (var x in d.x) |
1066 | | - //// { |
1067 | | - //// WpfPlot1vm!.Refresh(); |
1068 | | - //// var closestCoordinate = x.MyItem.Scatter!.Data.GetNearestX(rect, WpfPlot1vm!.Plot.LastRender).Coordinates; |
1069 | | - //// ////.OrderBy(coordinate => Math.Abs(coordinate.X - rect!.Value.X)) |
1070 | | - //// ////.FirstOrDefault(); |
1071 | | - |
1072 | | - //// // hide the crosshair, marker and text when no point is selected |
1073 | | - //// var visible = x.MyItem.IsChecked && EnableMarker; |
1074 | | - //// x.Item2.Crosshair!.IsVisible = visible; |
1075 | | - //// x.Item2.Marker!.IsVisible = visible; |
1076 | | - //// x.Item2.Text!.IsVisible = visible; |
1077 | | - |
1078 | | - //// if (closestCoordinate != Coordinates.NaN) |
1079 | | - //// { |
1080 | | - //// x.Item2.Crosshair!.Axes.YAxis = x.MyItem.Scatter.Axes.YAxis; |
1081 | | - //// x.Item2.Crosshair.Position = closestCoordinate; |
1082 | | - //// x.Item2.Crosshair.LineColor = x.MyItem.Scatter.Color; |
1083 | | - |
1084 | | - //// x.Item2.Marker!.Axes.YAxis = x.MyItem.Scatter.Axes.YAxis; |
1085 | | - //// x.Item2.Marker.Location = closestCoordinate; |
1086 | | - //// x.Item2.Marker.MarkerStyle.LineColor = x.MyItem.Scatter.Color; |
1087 | | - |
1088 | | - //// x.Item2.Text!.Axes.YAxis = x.MyItem.Scatter.Axes.YAxis; |
1089 | | - //// x.Item2.Text.Location = closestCoordinate; |
1090 | | - |
1091 | | - //// x.Item2.Text.LabelText = $"{closestCoordinate.Y:0.##}\n{closestCoordinate.X}"; |
1092 | | - |
1093 | | - //// x.Item2.Text.LabelFontColor = x.MyItem.Scatter.Color; |
1094 | | - //// } |
1095 | | - |
1096 | | - //// WpfPlot1vm?.Refresh(); |
1097 | | - //// } |
1098 | | - //// }); |
1099 | 960 | } |
1100 | 961 |
|
1101 | 962 | /// <summary> |
|
0 commit comments