Ejemplo n.º 1
0
 private void RestoreLayout(State state, string name, ISupportXtraSerializer serializer)
 {
     using (var stream = new MemoryStream())
     {
         var layout = (string)state[name];
         if (string.IsNullOrEmpty(layout))
         {
             return;
         }
         var writter = new StreamWriter(stream);
         writter.AutoFlush = true;
         writter.Write(layout);
         stream.Position = 0;
         serializer.RestoreLayoutFromStream(stream);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Загрузить внешний вид объекта из массива байтов
        /// </summary>
        /// <param name="sxs">Объект для применения настроек</param>
        /// <param name="layout">Массив байтов</param>
        internal static void RestoreLayoutSerializingFromStream(this ISupportXtraSerializer sxs, byte[] layout)
        {
            if (sxs == null || layout == null || layout.Count() == 0)
            {
                return;
            }
            var stream = new MemoryStream(layout);

            try
            {
                sxs.RestoreLayoutFromStream(stream);
            }
            catch (Exception ex)
            {
                throw new Exception("Wrong data format", ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Загрузить внешний вид объекта из массива байтов
        /// </summary>
        /// <param name="control">Объект для применения настроек</param>
        /// <param name="layout">Массив байтов</param>
        public static void RestoreLayoutFromStream(this Control control, byte[] layout)
        {
            ISupportXtraSerializer sxs = null;
            var gc = control as GridControl;

            if (gc != null)
            {
                sxs = gc.MainView;
            }
            else
            {
                var pv = control as PivotGridControl;
                if (pv != null)
                {
                    sxs = pv;
                }
                else
                {
                    var tl = control as TreeList;
                    if (tl != null)
                    {
                        sxs = tl;
                    }
                }
            }
            if (sxs == null)
            {
                return;
            }
            if (layout == null || layout.Count() == 0)
            {
                return;
            }
            var stream = new MemoryStream(layout);

            try
            {
                sxs.RestoreLayoutFromStream(stream);
            }
            catch (Exception ex)
            {
                throw new Exception("Wrong data format", ex);
            }
        }
Ejemplo n.º 4
0
 public void RestoreLayoutFromStream(System.IO.Stream stream)
 {
     _serializer.RestoreLayoutFromStream(stream);
 }