PKStudio.Helpers.EditorsFormsController.SaveEditorsFormsState C# (CSharp) Method

SaveEditorsFormsState() public method

Ru: Сохраняет список открытых для редактирования форм En: Saves edit forms list to file
public SaveEditorsFormsState ( ) : void
return void
        public void SaveEditorsFormsState()
        {
            PKStudio.Helpers.OpenedDocumentsList modlist = new Helpers.OpenedDocumentsList();

            foreach (DockContent item in DockPanel.Contents)
            {
                if (item.GetType() == typeof(PKStudio.Forms.Editors.SourceFileEditor))
                {
                    PKStudio.Forms.Editors.SourceFileEditor file = (PKStudio.Forms.Editors.SourceFileEditor)item;
                    modlist.Files.Add(file.EditingFilePath);
                }
                else if (item.GetType() == typeof(PKStudio.Forms.Editors.LibraryCategoryEditor))
                {
                    PKStudio.Forms.Editors.LibraryCategoryEditor editor = (PKStudio.Forms.Editors.LibraryCategoryEditor)item;
                    modlist.Components.Add(ComponentWrapper.GetComponentWrapper(editor.LibraryCategory));
                }
                else if (item.GetType() == typeof(PKStudio.Forms.Editors.LibraryEditor))
                {
                    PKStudio.Forms.Editors.LibraryEditor editor = (PKStudio.Forms.Editors.LibraryEditor)item;
                    modlist.Components.Add(ComponentWrapper.GetComponentWrapper(editor.Library));
                }
                else if (item.GetType() == typeof(PKStudio.Forms.Editors.FeatureEditor))
                {
                    PKStudio.Forms.Editors.FeatureEditor editor = (PKStudio.Forms.Editors.FeatureEditor)item;
                    modlist.Components.Add(ComponentWrapper.GetComponentWrapper(editor.Feature));
                }
            }

            string Path = Application.StartupPath + "\\edlist.dat";

            if (File.Exists(Path))
            {
                FileInfo FI = new FileInfo(Path);

                if ((FI.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    FI.Attributes -= FileAttributes.ReadOnly;

                    modlist.Serialize(modlist, Path);
                }
                else
                {
                    modlist.Serialize(modlist, Path);
                }
            }
            else
            {
                modlist.Serialize(modlist, Path);
            }

            
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// En: Save forms configuration
        /// Ru: Сохраняет текущее формы
        /// </summary>
        private void SaveState()
        {
            string docksPath = Application.StartupPath + "\\Docks.xml";

            if (File.Exists(docksPath))
            {
                FileInfo FI = new FileInfo(docksPath);

                if ((FI.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    FI.Attributes -= FileAttributes.ReadOnly;

                    dockPanel1.SaveAsXml(docksPath);
                }
                else
                {
                    dockPanel1.SaveAsXml(docksPath);
                }
            }
            else
            {
                dockPanel1.SaveAsXml(docksPath);
            }

            mEditorsController.SaveEditorsFormsState();
        }