コード例 #1
0
		private void LoadField()
		{
			List<string> strings = new List<string>();
			using (FileStream fs = new FileStream(@"SampleData.txt", FileMode.Open, FileAccess.Read))
			{
				using (StreamReader reader = new StreamReader(fs))
				{
					while (!reader.EndOfStream)
					{
						string str = reader.ReadLine();
						if (str == "Data:")
						{
							// do nothing
						}
						else if (str == "Grid:")
						{
							// do nothing too
						}
						else
						{
							strings.Add(str);
						}
					}
				}
			}

			// data
			string[] nums = ParseDataString(strings[0]);
			int width = nums.Length;
			int height = strings.Count / 2;

			CultureInfo culture = new CultureInfo("ru-RU");

			double[,] data = new double[width, height];
			for (int row = 0; row < height; row++)
			{
				nums = ParseDataString(strings[row]);
				for (int column = 0; column < width; column++)
				{
					double d = Double.Parse(nums[column], culture);
					data[column, row] = d;
				}
			}

			Point[,] gridData = new Point[width, height];
			for (int row = 0; row < height; row++)
			{
				string str = strings[row + height];
				nums = ParseGridString(str);
				for (int column = 0; column < width; column++)
				{
					string[] vecStrs = nums[column].Split(new string[] { "; " }, StringSplitOptions.None);
					gridData[column, row] = new Point(
						Double.Parse(vecStrs[0], culture),
						Double.Parse(vecStrs[1], culture));
				}
			}

			WarpedDataSource2D<double> dataSource = new WarpedDataSource2D<double>(data, gridData);
			isolineGraph.DataSource = dataSource;
			trackingGraph.DataSource = dataSource;

			Rect visible = dataSource.GetGridBounds();
			plotter.Viewport.Visible = visible;
		}
コード例 #2
0
        private void LoadField()
        {
            var assembly = Assembly.GetExecutingAssembly();

            List<string> strings = new List<string>();
            using (Stream stream = assembly.GetManifestResourceStream("Microsoft.Research.DynamicDataDisplay.Xbap.Samples.Demos.v03.Isolines.SampleData.txt"))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string str = reader.ReadLine();
                        if (str == "Data:")
                        {
                            // do nothing
                        }
                        else if (str == "Grid:")
                        {
                            // do nothing too
                        }
                        else
                        {
                            strings.Add(str);
                        }
                    }
                }
            }

            // data
            string[] nums = ParseDataString(strings[0]);
            int width = nums.Length;
            int height = strings.Count / 2;

            CultureInfo culture = new CultureInfo("ru-RU");

            double[,] data = new double[width, height];
            for (int row = 0; row < height; row++)
            {
                nums = ParseDataString(strings[row]);
                for (int column = 0; column < width; column++)
                {
                    double d = Double.Parse(nums[column], culture);
                    data[column, row] = d;
                }
            }

            Point[,] gridData = new Point[width, height];
            for (int row = 0; row < height; row++)
            {
                string str = strings[row + height];
                nums = ParseGridString(str);
                for (int column = 0; column < width; column++)
                {
                    string[] vecStrs = nums[column].Split(new string[] { "; " }, StringSplitOptions.None);
                    gridData[column, row] = new Point(
                        Double.Parse(vecStrs[0], culture),
                        Double.Parse(vecStrs[1], culture));
                }
            }

            WarpedDataSource2D<double> dataSource = new WarpedDataSource2D<double>(data, gridData);
            isolineGraph.DataSource = dataSource;
            trackingGraph.DataSource = dataSource;

            Rect visible = dataSource.GetGridBounds();
            plotter.Viewport.Visible = visible;
        }
コード例 #3
0
        private void LoadField()
        {
            var assembly = Assembly.GetExecutingAssembly();

            List <string> strings = new List <string>();

            using (Stream stream = assembly.GetManifestResourceStream("DynamicDataDisplay.Samples.Demos.v03.Isolines.SampleData.txt"))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string str = reader.ReadLine();
                        if (str == "Data:")
                        {
                            // do nothing
                        }
                        else if (str == "Grid:")
                        {
                            // do nothing too
                        }
                        else
                        {
                            strings.Add(str);
                        }
                    }
                }
            }

            // data
            string[] nums   = ParseDataString(strings[0]);
            int      width  = nums.Length;
            int      height = strings.Count / 2;

            CultureInfo culture = new CultureInfo("ru-RU");

            double[,] data = new double[width, height];
            for (int row = 0; row < height; row++)
            {
                nums = ParseDataString(strings[row]);
                for (int column = 0; column < width; column++)
                {
                    double d = double.Parse(nums[column], culture);
                    data[column, row] = d;
                }
            }

            Point[,] gridData = new Point[width, height];
            for (int row = 0; row < height; row++)
            {
                string str = strings[row + height];
                nums = ParseGridString(str);
                for (int column = 0; column < width; column++)
                {
                    string[] vecStrs = nums[column].Split(new string[] { "; " }, StringSplitOptions.None);
                    gridData[column, row] = new Point(
                        double.Parse(vecStrs[0], culture),
                        double.Parse(vecStrs[1], culture));
                }
            }

            WarpedDataSource2D <double> dataSource = new WarpedDataSource2D <double>(data, gridData);

            isolineGraph.DataSource  = dataSource;
            trackingGraph.DataSource = dataSource;

            Rect visible = dataSource.GetGridBounds();

            plotter.Viewport.Visible = visible;
        }
        private void LoadField()
        {
            List <string> strings = new List <string>();

            using (FileStream fs = new FileStream(@"SampleData.txt", FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(fs))
                {
                    while (!reader.EndOfStream)
                    {
                        string str = reader.ReadLine();
                        if (str == "Data:")
                        {
                            // do nothing
                        }
                        else if (str == "Grid:")
                        {
                            // do nothing too
                        }
                        else
                        {
                            strings.Add(str);
                        }
                    }
                }
            }

            // data
            string[] nums   = ParseDataString(strings[0]);
            int      width  = nums.Length;
            int      height = strings.Count / 2;

            CultureInfo culture = new CultureInfo("ru-RU");

            double[,] data = new double[width, height];
            for (int row = 0; row < height; row++)
            {
                nums = ParseDataString(strings[row]);
                for (int column = 0; column < width; column++)
                {
                    double d = Double.Parse(nums[column], culture);
                    data[column, row] = d;
                }
            }

            Point[,] gridData = new Point[width, height];
            for (int row = 0; row < height; row++)
            {
                string str = strings[row + height];
                nums = ParseGridString(str);
                for (int column = 0; column < width; column++)
                {
                    string[] vecStrs = nums[column].Split(new string[] { "; " }, StringSplitOptions.None);
                    gridData[column, row] = new Point(
                        Double.Parse(vecStrs[0], culture),
                        Double.Parse(vecStrs[1], culture));
                }
            }

            WarpedDataSource2D <double> dataSource = new WarpedDataSource2D <double>(data, gridData);

            isolineGraph.DataSource  = dataSource;
            trackingGraph.DataSource = dataSource;

            Rect visible = dataSource.GetGridBounds();

            plotter.Viewport.Visible = visible;
        }