Esempio n. 1
0
        private void OnMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var    mousePos = e.MouseDevice.GetPosition(TimetableGraph);
            double mouseX   = TimetableGraph.plt.CoordinateFromPixelX(mousePos.X);
            double mouseY   = TimetableGraph.plt.CoordinateFromPixelY(mousePos.Y);

            scatterHighLight.HighlightClear();
            var(x, y, index) = scatterHighLight.HighlightPointNearest(mouseX, mouseY);
            TimeGraphUIModel graph = highlightedTimeGraphUiModels[index];

            if (graph != null)
            {
                double[] xs = { x };
                double[] ys = { y };
                if (marker != null)
                {
                    marker.markerShape = MarkerShape.none;
                }

                marker = TimetableGraph.plt.PlotScatter(xs, ys, Color.Red,
                                                        markerShape: MarkerShape.openCircle, markerSize: 15);
                if (GraphModel.SelectedTimeGraph != null && GraphModel.SelectedTimeGraph.Plot != null)
                {
                    GraphModel.SelectedTimeGraph.Plot.lineWidth = 1;
                }
                graph.Plot.lineWidth         = 3;
                GraphModel.SelectedTimeGraph = graph;
                TimetableGraph.Render();
            }
            TimetableGraph.Render();
        }
Esempio n. 2
0
        public void PlotGraph(ScottPlotGraph graphModel)
        {
            var locationCount = GraphModel.LocationList.Count;
            var serviceCount  = GraphModel.TimeGraphUI.Count;
            var pointCount    = locationCount * serviceCount;

            scatterDataX = new double[pointCount + 1];
            scatterDataY = new double[pointCount + 1];
            highlightedTimeGraphUiModels = new TimeGraphUIModel[pointCount + 1];
            scatterIndex = 0;
            int i = 0;

            foreach (var graph in GraphModel.TimeGraphUI)
            {
                graph.Plot = PlotService(graphModel, graph, GraphModel.TimeGraphUI[i].ServiceAbbreviation);
                i++;
            }

            PlotTimeAxis(graphModel.Zoom, graphModel.Pan);
            PlotLocationAxis(graphModel);

            if (marker != null)
            {
                //redraw marker
                marker = TimetableGraph.plt.PlotScatter(marker.xs, marker.ys, Color.Red,
                                                        markerShape: MarkerShape.openCircle, markerSize: 15);
            }

            if (GraphModel.SelectedTimeGraph != null)
            {
                GraphModel.SelectedTimeGraph.Plot.lineWidth = 3;
            }

            TimetableGraph.plt.Style(figBg: GetResourceColor("WindowBackground"));
            TimetableGraph.plt.Style(dataBg: GetResourceColor("ControlBackground"));
            TimetableGraph.plt.Grid(enable: true, color: GetResourceColor("GridLine"));
            scatterHighLight = TimetableGraph.plt.PlotScatterHighlight(scatterDataX, scatterDataY, lineWidth: 0, markerSize: 0.5);
            TimetableGraph.Configure(enablePanning: false, enableScrollWheelZoom: false, enableRightClickZoom: false);
            TimetableGraph.Render();
        }