コード例 #1
0
        // TODO: Add the following to your testing code to test the visualizer:
        //
        //    MatrixVisualizer.TestShowVisualizer(new SomeType());
        //
        /// <summary>
        /// Tests the visualizer by hosting it outside of the debugger.
        /// </summary>
        /// <param name="objectToVisualize">The object to display in the visualizer.</param>
        public static void TestShowVisualizer(object objectToVisualize)
        {
            //VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(objectToVisualize, typeof(MatrixVisualizer));
            //visualizerHost.ShowVisualizer();
            //MessageBox.Show(objectToVisualize.ToString());

            var ctrl = new MatrixVisualizerControl();

            var rows = (int)objectToVisualize.GetType().GetProperty("RowCount", BindingFlags.Public | BindingFlags.Instance).GetValue(objectToVisualize);


            var cols = (int)objectToVisualize.GetType().GetProperty("ColumnCount", BindingFlags.Public | BindingFlags.Instance).GetValue(objectToVisualize);

            var arr = (double[])objectToVisualize.GetType().GetField("Values", BindingFlags.Public | BindingFlags.Instance).GetValue(objectToVisualize);
            // TODO: why not directly cast to DenseMatrix?

            var mtx = new DenseMatrix(rows, cols, arr);

            ctrl.VisualizeMatrix(mtx);
            new Window()
            {
                Content = ctrl, Title = "epsi1on Matrix Visualizer!", Width = cols * 150, Height = rows * 50
            }
            .ShowDialog();
        }
コード例 #2
0
        // TODO: Add the following to your testing code to test the visualizer:
        //
        //    MatrixVisualizer.TestShowVisualizer(new SomeType());
        //
        /// <summary>
        /// Tests the visualizer by hosting it outside of the debugger.
        /// </summary>
        /// <param name="objectToVisualize">The object to display in the visualizer.</param>
        public static void TestShowVisualizer(object objectToVisualize)
        {
            //VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(objectToVisualize, typeof(MatrixVisualizer));
            //visualizerHost.ShowVisualizer();

            var ctrl = new MatrixVisualizerControl();

            var rows = (int)objectToVisualize.GetType().GetField("rowCount", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(objectToVisualize);
            var cols = (int)objectToVisualize.GetType().GetField("columnCount", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(objectToVisualize);
            var arr  = (double[])objectToVisualize.GetType().GetProperty("CoreArray", BindingFlags.Public | BindingFlags.Instance).GetValue(objectToVisualize, null);


            var mtx = new Matrix((int)rows, (int)cols);

            Array.Copy(arr as double[], mtx.CoreArray, mtx.CoreArray.Length);

            ctrl.VisualizeMatrix(mtx);
            new Window()
            {
                Content = ctrl, Title = "epsi1on Matrix Visualizer!", Width = cols * 150, Height = rows * 50
            }
            .ShowDialog();
        }