Пример #1
0
    public static void Save(WorksheetController ctrl, System.IO.Stream myStream, bool saveAsTemplate)
    {
      Altaxo.Serialization.Xml.XmlStreamSerializationInfo info = new Altaxo.Serialization.Xml.XmlStreamSerializationInfo();
      if(saveAsTemplate)
      {
        info.SetProperty("Altaxo.Data.DataColumn.SaveAsTemplate","true");
      }
      info.BeginWriting(myStream);

      // TODO there is an issue with TableLayout that prevents a nice deserialization 
      // this is because TableLayout stores the name of its table during serialization
      // onto deserialization this works well if the entire document is restored, but
      // doesn't work if only a table and its layout is to be restored. In this case, the layout
      // references the already present table with the same name in the document instead of the table
      // deserialized. Also, the GUID isn't unique if the template is deserialized more than one time.

      Altaxo.Worksheet.TablePlusLayout tableAndLayout = 
        new Altaxo.Worksheet.TablePlusLayout(ctrl.DataTable, ctrl.WorksheetLayout);
      info.AddValue("TablePlusLayout",tableAndLayout);
      info.EndWriting();    
    }
Пример #2
0
        public static void Save(WorksheetController ctrl, System.IO.Stream myStream, bool saveAsTemplate)
        {
            Altaxo.Serialization.Xml.XmlStreamSerializationInfo info = new Altaxo.Serialization.Xml.XmlStreamSerializationInfo();
            if (saveAsTemplate)
            {
                info.SetProperty("Altaxo.Data.DataColumn.SaveAsTemplate", "true");
            }
            info.BeginWriting(myStream);

            // TODO there is an issue with TableLayout that prevents a nice deserialization
            // this is because TableLayout stores the name of its table during serialization
            // onto deserialization this works well if the entire document is restored, but
            // doesn't work if only a table and its layout is to be restored. In this case, the layout
            // references the already present table with the same name in the document instead of the table
            // deserialized. Also, the GUID isn't unique if the template is deserialized more than one time.

            Altaxo.Worksheet.TablePlusLayout tableAndLayout =
                new Altaxo.Worksheet.TablePlusLayout(ctrl.DataTable, ctrl.WorksheetLayout);
            info.AddValue("TablePlusLayout", tableAndLayout);
            info.EndWriting();
        }