Esempio n. 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);
     }
 }
Esempio n. 2
0
        private static void RestoreConditions(TreeList treeList, string fileName)
        {
            if (!File.Exists(fileName))
            {
                return;
            }
            XmlXtraSerializer serializer = new XmlXtraSerializer();

            using (FileStream stream = new FileStream(fileName, FileMode.Open))
            {
                try
                {
                    TreeListFormatConditions collection = new TreeListFormatConditions();
                    serializer.DeserializeObject(collection, stream, "FormatConditions");
                    collection.Conditions.CopyToStyleFormats(treeList.FormatConditions);
                    treeList.Refresh();
                }
                finally { stream.Close(); }
            }
        }
        public static void LoadLayoutFromStream(MyRibbonControl control, MemoryStream stream)
        {
            RibbonCustomizationModel model = null;

            try
            {
                model = new RibbonCustomizationModel(control);
                XmlXtraSerializer serializer = new XmlXtraSerializer();
                serializer.DeserializeObject(model, stream, GetApplicationName(model));
            }
            catch (Exception e)
            {
            }

            if (model == null || !model.IsModelValid(control))
            {
                return;
            }
            typeof(RibbonControl).GetMethod("ApplyCustomizationSettings", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(control, new object[] { model });
        }
Esempio n. 4
0
 public void DeserializeFromXMLFile(string fileName)
 {
     XmlXtraSerializer serializer = new XmlXtraSerializer();
     serializer.DeserializeObject(this, fileName, this.GetType().Name);
 }