Пример #1
0
 public static void RestoreLayoutExFromXml(this LayoutControl layoutControl, string filePath)
 {
     try
     {
         ObjectInfoCollection objects = new ObjectInfoCollection();
         string filePathForControls   = filePath.Replace(".xml", "Controls.xml");
         serializer.DeserializeObject(objects, filePathForControls, appName);
         foreach (ObjectInfo info in objects.Collection)
         {
             Control ctrl = info.SerializableObject as Control;
             if (ctrl != null)
             {
                 Control[] controls = layoutControl.Controls.Find(ctrl.Name, false);
                 if (controls.Length > 0)
                 {
                     layoutControl.Controls.Remove(controls[0]);
                 }
                 layoutControl.Controls.Add(ctrl);
             }
         }
         layoutControl.RestoreLayoutFromXml(filePath);
     }
     catch (Exception exc)
     {
         XtraMessageBox.Show(exc.Message);
     }
 }
Пример #2
0
 public static void SaveLayoutExToXml(this LayoutControl layoutControl, string filePath)
 {
     try
     {
         ObjectInfoCollection objects = new ObjectInfoCollection();
         foreach (Control ctrl in layoutControl.Controls)
         {
             if (layoutControl.GetItemByControl(ctrl) != null)
             {
                 objects.Collection.Add(new ObjectInfo(ctrl));
             }
         }
         string filePathForControls = filePath.Replace(".xml", "Controls.xml");
         layoutControl.SaveLayoutToXml(filePath);
         serializer.SerializeObject(objects, filePathForControls, appName);
     }
     catch (Exception exc)
     {
         XtraMessageBox.Show(exc.Message);
     }
 }