Пример #1
0
 /// <summary>
 /// Restore layout control.
 /// </summary>
 /// <param name="ctl"></param>
 /// <param name="layout"></param>
 private static void RestoreLayout(object ctl, ControlLayout layout)
 {
     if (layout.Layout != null)
     {
         using (MemoryStream stream = new MemoryStream(layout.Layout))
         {
             try
             {
                 MethodInfo mi = GetLayoutMethod(ctl.GetType(), "RestoreLayoutFromStream");
                 mi.Invoke(ctl, new object[] { stream });
             }
             finally { stream.Close(); }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Save layout control return object ControlLayout.
        /// </summary>
        /// <param name="ctl"></param>
        /// <returns></returns>
        private static ControlLayout SaveLayout(object ctl)
        {
            ControlLayout c = new ControlLayout(ctl.GetType().Name);

            using (MemoryStream stream = new MemoryStream())
            {
                try
                {
                    MethodInfo mi = GetLayoutMethod(ctl.GetType(), "SaveLayoutToStream");
                    if (mi != null)
                    {
                        mi.Invoke(ctl, new object[] { stream });
                        c.Layout = stream.ToArray();
                    }
                    return(c);
                }
                finally { stream.Close(); }
            }
        }