Beispiel #1
0
        /// <summary>
        /// Saves the state of the main window into a zipped file.
        /// </summary>
        /// <param name="zippedStream">The file stream of the zip file.</param>
        /// <param name="info">The serialization info used to serialize the state of the main window.</param>
        public void SaveWindowStateToZippedFile(ICompressedFileContainerStream zippedStream, Altaxo.Serialization.Xml.XmlStreamSerializationInfo info)
        {
            System.Text.StringBuilder errorText = new System.Text.StringBuilder();

            {
                // first, we save our own state
                zippedStream.StartFile("Workbench/MainWindow.xml", 0);
                try
                {
                    info.BeginWriting(zippedStream.Stream);
                    info.AddValue("MainWindow", Current.Workbench);
                    info.EndWriting();
                }
                catch (Exception exc)
                {
                    errorText.Append(exc.ToString());
                }
            }

            // second, we save all workbench windows into the Workbench/Views
            int i = 0;

            foreach (IViewContent ctrl in Current.Workbench.ViewContentCollection)
            {
                if (info.IsSerializable(ctrl))
                {
                    i++;
                    zippedStream.StartFile("Workbench/Views/View" + i.ToString() + ".xml", 0);
                    try
                    {
                        info.BeginWriting(zippedStream.Stream);
                        info.AddValue("WorkbenchViewContent", ctrl);
                        info.EndWriting();
                    }
                    catch (Exception exc)
                    {
                        errorText.Append(exc.ToString());
                    }
                }
            }

            if (errorText.Length != 0)
            {
                throw new ApplicationException(errorText.ToString());
            }
        }
Beispiel #2
0
        public void SaveToZippedFile(ICompressedFileContainerStream zippedStream, Altaxo.Serialization.Xml.XmlStreamSerializationInfo info)
        {
            System.Text.StringBuilder errorText = new System.Text.StringBuilder();

            // first, we save all tables into the tables subdirectory
            foreach (Altaxo.Data.DataTable table in this.m_DataSet)
            {
                try
                {
                    zippedStream.StartFile("Tables/" + table.Name + ".xml", 0);
                    //ZipEntry ZipEntry = new ZipEntry("Tables/"+table.Name+".xml");
                    //zippedStream.PutNextEntry(ZipEntry);
                    //zippedStream.SetLevel(0);
                    info.BeginWriting(zippedStream.Stream);
                    info.AddValue("Table", table);
                    info.EndWriting();
                }
                catch (Exception exc)
                {
                    errorText.Append(exc.ToString());
                }
            }

            // second, we save all graphs into the Graphs subdirectory
            foreach (GraphDocument graph in this.m_GraphSet)
            {
                try
                {
                    zippedStream.StartFile("Graphs/" + graph.Name + ".xml", 0);
                    //ZipEntry ZipEntry = new ZipEntry("Graphs/"+graph.Name+".xml");
                    //zippedStream.PutNextEntry(ZipEntry);
                    //zippedStream.SetLevel(0);
                    info.BeginWriting(zippedStream.Stream);
                    info.AddValue("Graph", graph);
                    info.EndWriting();
                }
                catch (Exception exc)
                {
                    errorText.Append(exc.ToString());
                }
            }

            // third, we save all TableLayouts into the TableLayouts subdirectory
            foreach (Altaxo.Worksheet.WorksheetLayout layout in this.m_TableLayoutList)
            {
                try
                {
                    zippedStream.StartFile("TableLayouts/" + layout.Name + ".xml", 0);
                    //ZipEntry ZipEntry = new ZipEntry("TableLayouts/"+layout.Name+".xml");
                    //zippedStream.PutNextEntry(ZipEntry);
                    //zippedStream.SetLevel(0);
                    info.BeginWriting(zippedStream.Stream);
                    info.AddValue("WorksheetLayout", layout);
                    info.EndWriting();
                }
                catch (Exception exc)
                {
                    errorText.Append(exc.ToString());
                }
            }

            // 4th, we save all FitFunctions into the FitFunctions subdirectory
            foreach (Altaxo.Scripting.FitFunctionScript fit in this._FitFunctionScripts)
            {
                try
                {
                    zippedStream.StartFile("FitFunctionScripts/" + fit.CreationTime.ToString() + ".xml", 0);
                    //ZipEntry ZipEntry = new ZipEntry("TableLayouts/"+layout.Name+".xml");
                    //zippedStream.PutNextEntry(ZipEntry);
                    //zippedStream.SetLevel(0);
                    info.BeginWriting(zippedStream.Stream);
                    info.AddValue("FitFunctionScript", fit);
                    info.EndWriting();
                }
                catch (Exception exc)
                {
                    errorText.Append(exc.ToString());
                }
            }


            if (errorText.Length != 0)
            {
                throw new ApplicationException(errorText.ToString());
            }
        }
    /// <summary>
    /// Saves the state of the main window into a zipped file.
    /// </summary>
    /// <param name="zippedStream">The file stream of the zip file.</param>
    /// <param name="info">The serialization info used to serialize the state of the main window.</param>
    public void SaveWindowStateToZippedFile(ICompressedFileContainerStream zippedStream, Altaxo.Serialization.Xml.XmlStreamSerializationInfo info)
    {
      System.Text.StringBuilder errorText = new System.Text.StringBuilder();

      {
        // first, we save our own state 
        zippedStream.StartFile("Workbench/MainWindow.xml", 0);
        try
        {
          info.BeginWriting(zippedStream.Stream);
          info.AddValue("MainWindow", Current.Workbench);
          info.EndWriting();
        }
        catch (Exception exc)
        {
          errorText.Append(exc.ToString());
        }
      }

      // second, we save all workbench windows into the Workbench/Views 
      int i = 0;
      foreach (IViewContent ctrl in Current.Workbench.ViewContentCollection)
      {
        if (info.IsSerializable(ctrl))
        {
          i++;
          zippedStream.StartFile("Workbench/Views/View" + i.ToString() + ".xml", 0);
          try
          {
            info.BeginWriting(zippedStream.Stream);
            info.AddValue("WorkbenchViewContent", ctrl);
            info.EndWriting();
          }
          catch (Exception exc)
          {
            errorText.Append(exc.ToString());
          }
        }
      }

      if (errorText.Length != 0)
        throw new ApplicationException(errorText.ToString());
    }