private void MC_SaveSimulationResults_Executed(object sender, ExecutedEventArgs e)
        {
            if (_output != null && _newResultsAvailable)
            {
                var input = _simulationInputVM.SimulationInput;
                var store = IsolatedStorageFile.GetUserStoreForApplication();

                if (store.FileExists(input.OutputName + ".zip"))
                {
                    try
                    {
                        using (var zipStream = StreamFinder.GetLocalFilestreamFromSaveFileDialog("zip"))
                        {
                            using (var readStream = StreamFinder.GetFileStream(input.OutputName + ".zip", FileMode.Open))
                            {
                                FileIO.CopyStream(readStream, zipStream);
                            }
                        }
                        logger.Info(() => "Finished copying results to user file.\r");
                    }
                    catch (SecurityException)
                    {
                        logger.Error(() => "Problem exporting results to user file...sorry user :(\r");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Writes tab-delimited
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Plot_ExportDataToText_Executed(object sender, ExecutedEventArgs e)
 {
     if (_Labels != null && _Labels.Count > 0 && _PlotSeriesCollection != null && _PlotSeriesCollection.Count > 0)
     {
         using (var stream = StreamFinder.GetLocalFilestreamFromSaveFileDialog("txt"))
         {
             if (stream != null)
             {
                 using (StreamWriter sw = new StreamWriter(stream))
                 {
                     sw.Write("%");
                     _Labels.ForEach(label => sw.Write(label + " (X)" + "\t" + label + " (Y)" + "\t"));
                     sw.WriteLine();
                     for (int i = 0; i < _PlotSeriesCollection[0].Length; i++)
                     {
                         sw.WriteLine();
                         for (int j = 0; j < _PlotSeriesCollection.Count; j++)
                         {
                             sw.Write(_PlotSeriesCollection[j][i].X + "\t" + _PlotSeriesCollection[j][i].Y + "\t");
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        public static void SaveUIElementToJpegImage(UIElement element)
        {
            // todo: pass myChart as a command parameter declaratively to be handled in PlotViewModel
            var b = new WriteableBitmap(element, null);

            using (var s = StreamFinder.GetLocalFilestreamFromSaveFileDialog("jpg"))
            {
                if (s != null)
                {
                    SaveBitmapToJpeg(b, s);
                }
            }
        }
        private void MC_DownloadDefaultSimulationInput_Executed(object sender, ExecutedEventArgs e)
        {
            using (var stream = StreamFinder.GetLocalFilestreamFromSaveFileDialog("zip"))
            {
                if (stream != null)
                {
                    var files = SimulationInputProvider.GenerateAllSimulationInputs().Select(input =>
                                                                                             new
                    {
                        Name  = "infile_" + input.OutputName + ".txt",
                        Input = input
                    });

                    foreach (var file in files)
                    {
                        file.Input.ToFile(file.Name);
                    }
                    var allFiles = files.Concat(files);
                    FileIO.ZipFiles(files.Select(file => file.Name), "", stream);
                    logger.Info(() => "Template simulation input files exported to a zip file.\r");
                }
            }
        }
 private void Maps_ExportDataToText_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
 {
     if (_mapData != null && _mapData.RawData != null && _mapData.XValues != null && _mapData.YValues != null)
     {
         using (var stream = StreamFinder.GetLocalFilestreamFromSaveFileDialog("txt"))
         {
             if (stream != null)
             {
                 using (StreamWriter sw = new StreamWriter(stream))
                 {
                     sw.Write("% X Values:\t");
                     _mapData.XValues.ForEach(x => sw.Write(x + "\t"));
                     sw.WriteLine();
                     sw.Write("% Y Values:\t");
                     _mapData.YValues.ForEach(y => sw.Write(y + "\t"));
                     sw.WriteLine();
                     sw.Write("% Map Values:\t");
                     _mapData.RawData.ForEach(val => sw.Write(val + "\t"));
                     sw.WriteLine();
                 }
             }
         }
     }
 }