Ejemplo n.º 1
0
        public bool Save()
        {
            try
            {
                var persistable = Persistable.ToArray();

                if (string.IsNullOrWhiteSpace(ToolboxApp.Project.State.ProjectFolder))
                {
                    OnRecreateMenuItems(new RecreateMenuItemsEventArgs(persistable));
                    return(false);
                }

                var proj   = new XenProjectFile(_fs);
                var loaded = proj.Load(ToolboxApp.Project.State.XenProjectFilePath);

                if (!loaded)
                {
                    ToolboxApp.Log.Info($"Creating new project file: {ToolboxApp.Project.State.XenProjectFilePath}.");
                    proj.Schema = XenFormsEnvironment.ProjectFileSchema;
                }

                proj.Views = persistable;
                proj.Save(ToolboxApp.Project.State.XenProjectFilePath);

                foreach (var pv in proj.Views)
                {
                    pv.Persisted = true;
                }

                OnRecreateMenuItems(new RecreateMenuItemsEventArgs(proj.Views));
                return(true);
            }
            catch (Exception ex)
            {
                ToolboxApp.Log.Error(ex, $"Error saving file: {ToolboxApp.Project.State.XenProjectFilePath}.");

                MessageBox.Show(Application.Instance.MainForm,
                                "There was an error saving the project file. Please check the log for more information.",
                                "XenForms",
                                MessageBoxButtons.OK,
                                MessageBoxType.Error);

                return(false);
            }
        }
Ejemplo n.º 2
0
        public void Save()
        {
            try
            {
                var proj = new XenProjectFile(_fs)
                {
                    Schema     = XenFormsEnvironment.ProjectFileSchema,
                    Assemblies = IncludedAssemblies?.ToArray() ?? new ProjectAssembly[] {}
                };

                proj.Save(ToolboxApp.Project.State.XenProjectFilePath);
            }
            catch (Exception ex)
            {
                ToolboxApp.Log.Error(ex, $"Error saving file: {ToolboxApp.Project.State.XenProjectFilePath}.");

                MessageBox.Show(Application.Instance.MainForm,
                                "There was an error saving the project file. Please check the log for more information.",
                                "XenForms",
                                MessageBoxButtons.OK,
                                MessageBoxType.Error);
            }
        }