// Generic way to hook a LineGraphInterop up with a DrawingSurface private LineGraphInterop initializeLineGraph(DrawingSurface canvas) { // Create the LineGraphInterop, the C++/CX component that will draw out to the canvas LineGraphInterop graph = new LineGraphInterop(); // Set window bounds graph.WindowBounds = new Windows.Foundation.Size( (float)canvas.ActualWidth, (float)canvas.ActualHeight ); // Set native/rendering resolution! graph.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(canvas.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(canvas.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); graph.RenderResolution = graph.NativeResolution; // Notify the canvas who we're hooking up to them canvas.SetContentProvider(graph.CreateContentProvider()); canvas.SetManipulationHandler(graph); // Give back the graph object! return graph; }
// Generic way to hook a LineGraphInterop up with a DrawingSurface private LineGraphInterop initializeLineGraph(DrawingSurface canvas) { // Create the LineGraphInterop, the C++/CX component that will draw out to the canvas LineGraphInterop graph = new LineGraphInterop(); // Set window bounds graph.WindowBounds = new Windows.Foundation.Size( (float)canvas.ActualWidth, (float)canvas.ActualHeight ); // Set native/rendering resolution! graph.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(canvas.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(canvas.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); graph.RenderResolution = graph.NativeResolution; // Notify the canvas who we're hooking up to them canvas.SetContentProvider(graph.CreateContentProvider()); canvas.SetManipulationHandler(graph); // Give back the graph object! return(graph); }
private void botCanvas_Loaded(object sender, RoutedEventArgs e) { logString("botCanvas_Loaded()"); // Initialize the lineGraph (this only happens ONCE per app lifecycle!) botGraph = initializeLineGraph(botCanvas); // Set configuration settings of botCanvas. This configuration will get lost! botGraph.setColor(0.0f, 0.0f, 1.0f); botGraph.setYLimits(-1.5f, 1.5f); }
private void topCanvas_Loaded(object sender, RoutedEventArgs e) { logString("topCanvas_Loaded()"); // Initialize the lineGraph (this only happens ONCE per app lifecycle!) topGraph = initializeLineGraph(topCanvas); topGraph.Initialized += setupTopCanvas; // Note that we do have to call it initially, as the Initialized event has already fired by this point. :P setupTopCanvas(); }
private void negCanvas_Loaded(object sender, RoutedEventArgs e) { negGraph = initializeLineGraph(negCanvas, negGraph_Initialized); }
private void posCanvas_Loaded(object sender, RoutedEventArgs e) { posGraph = initializeLineGraph(posCanvas, posGraph_Initialized); }
private void bCanvas_Loaded(object sender, RoutedEventArgs e) { bGraph = initializeLineGraph(bCanvas, bGraph_Initialized); }