Beispiel #1
0
 public static void DeleteUILayout(UserUILayout layout)
 {
     if (!string.IsNullOrEmpty(layout.Path) && File.Exists(layout.Path))
     {
         File.Delete(layout.Path);
     }
 }
Beispiel #2
0
        public static UserUILayout SaveUILayout(WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel, string layoutName)
        {
            string layoutDir = Path.Combine(AppDataFolder, "layouts");

            if (!Directory.Exists(layoutDir))
            {
                Directory.CreateDirectory(layoutDir);
            }

            string filename = FileHelper.GetSafeFileName(layoutName) + ".xml";

            filename = Path.Combine(layoutDir, filename);
            dockPanel.SaveAsXml(filename, Encoding.UTF8);

            var layoutInfo = new UserUILayout()
            {
                Name       = layoutName,
                Path       = filename,
                AppVersion = $"{CurrentAppVersion.Major}.{CurrentAppVersion.Minor}.{CurrentAppVersion.Build}"
            };

            var doc = XDocument.Load(filename);

            doc.Root.Add(new XAttribute(nameof(UserUILayout.Name), layoutInfo.Name));
            doc.Root.Add(new XAttribute(nameof(UserUILayout.AppVersion), layoutInfo.AppVersion));
            doc.Save(filename);

            return(layoutInfo);
        }