private void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            data = BuildSampleData(imageSize);

            NaiveColorMap map = new NaiveColorMap {
                Data = data, Palette = UniformLinearPalettes.BlackAndWhitePalette
            };
            var bmp = map.BuildImage();

            image.Source = bmp;
        }
        private void MakePlots()
        {
            if (!PlotsMade) //Only do this once
            {
                Model  mShe         = new Model(SheFileName);
                DFS3   dfs          = new DFS3(Dfs3FileName);
                Item   dfsI         = dfs.Items[ItemNumber - 1];
                string BaseFileName = System.IO.Path.ChangeExtension(Dfs3FileName, "");

                int[] TimeSteps = Dfs3plotdfs0.MainWindow.ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1);
                int[] Layers    = Dfs3plotdfs0.MainWindow.ParseString(LayersAsString, 0, dfs.NumberOfLayers - 1);

                //Set graph headers
                Header.Content = dfsI.Name;
                Unit.Content   = dfsI.EumQuantity.UnitAbbreviation;

                //Give plot the same scale as the dfs grid
                plotter.Width = plotter.Height * ((double)dfs.NumberOfColumns) / (double)dfs.NumberOfRows;

                //Plot the extraction wells
                EnumerableDataSource <MikeSheWell> ds = new EnumerableDataSource <MikeSheWell>(mShe.ExtractionWells);
                ds.SetXMapping(var => var.X);
                ds.SetYMapping(var => var.Y);
                var point = new Microsoft.Research.DynamicDataDisplay.PointMarkers.CirclePointMarker();
                point.Size = 10;
                point.Pen  = new Pen(Brushes.Black, 3);
                plotter.AddLineGraph(ds, null, point, null);

                //Now loop, first on time steps then on layers
                foreach (int T in TimeSteps)
                {
                    foreach (int L in Layers)
                    {
                        Header2.Content = "Time: " + dfs.TimeSteps[T].ToShortDateString() + ", Layer: " + L;
                        var           M  = dfs.GetData(T, ItemNumber)[L];
                        NaiveColorMap nc = new NaiveColorMap();
                        M.Transpose(); //Need to transpose
                        nc.Data = M.ToArray();
                        M.Transpose(); //Transpose back as this is a reference to data held in the buffer
                        nc.Palette = Microsoft.Research.DynamicDataDisplay.Common.Palettes.UniformLinearPalettes.RedGreenBluePalette;
                        var bmp = nc.BuildImage();
                        image.Source = bmp;

                        //Set the color scale
                        paletteControl.Palette = nc.Palette;
                        paletteControl.Range   = nc.Data.GetMinMax();

                        //Set the size
                        var visible = new Microsoft.Research.DynamicDataDisplay.DataRect(dfs.XOrigin, dfs.YOrigin, dfs.GridSize * dfs.NumberOfColumns, dfs.GridSize * dfs.NumberOfRows);
                        ViewportPanel.SetViewportBounds(image, visible);
                        plotter.Visible = visible;

                        //Write the bitmap
                        this.UpdateLayout();
                        string fname = BaseFileName + "TimeStep_" + T + "_Layer_" + L;
                        Dfs3plotdfs0.MainWindow.SaveScreen(this, fname + ".jpg", (int)ActualWidth, (int)ActualHeight);

                        //Now write the ascii grid
                        using (StreamWriter sw = new StreamWriter(fname + ".asc"))
                        {
                            sw.Write(dfs.GetASCIIGrid(T, ItemNumber, L));
                        }
                    }
                }
            }
        }