Ejemplo n.º 1
0
 /// <summary>
 /// Function used by the saveAll function.
 /// </summary>
 /// <param name="location"></param>
 public static void saveWorkshop(MainWindow w, string location)
 {
     if (w.Results.Items.Count > 0)
     {
         using (TextWriter TW = new StreamWriter(location))
             foreach (string itemText in w.Results.Items)
             {
                 TW.WriteLine(itemText);
             }
     }
     else
     {
         EmptyWorkshopException except = new EmptyWorkshopException("Numerical workshop is empty");
         ErrorMsg err = new ErrorMsg(except.Message, except.ErrorCode);
         err.ShowDialog();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to save the workshop onto an external text file.
        /// </summary>
        /// <param name="w"></param>
        public static void saveWorkshop(MainWindow w)
        {
            if (w.Results.Items.Count > 0)
            {
                SaveFileDialog saveAs = new SaveFileDialog();
                saveAs.Filter           = "Text file(*.txt)|*.txt";
                saveAs.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                if (saveAs.ShowDialog() == true)
                {
                    using (TextWriter TW = new StreamWriter(saveAs.FileName))
                        foreach (string itemText in w.Results.Items)
                        {
                            TW.WriteLine(itemText);
                        }
                }
            }
            else
            {
                EmptyWorkshopException except = new EmptyWorkshopException("Numerical workshop is empty");
                ErrorMsg err = new ErrorMsg(except.Message, except.ErrorCode);
                err.ShowDialog();
            }
        }