Esempio n. 1
0
        /////////////////////////////////////////

        public DocumentInstance(string realFileName, Resource.Instance loadedResource, string specialMode)
        {
            this.realFileName   = realFileName;
            this.loadedResource = loadedResource;
            this.specialMode    = specialMode;

            //!!!!max level
            undoSystem = new UndoSystem(32);
            undoSystem.ListOfActionsChanged += UndoSystem_ListOfActionsChanged;
        }
Esempio n. 2
0
 public static DocumentInstance GetDocumentByResource(Resource.Instance ins)
 {
     foreach (var document in Documents)
     {
         if (document.LoadedResource == ins)
         {
             return(document);
         }
     }
     return(null);
 }
Esempio n. 3
0
        static internal DocumentInstance CreateDocument(string realFileName, string specialMode = "")
        {
            if (specialMode == "TextEditor")
            {
                var document = new DocumentInstance(realFileName, null, specialMode);
                Documents.Add(document);
                return(document);
            }

            string virtualFileName = VirtualPathUtility.GetVirtualPathByReal(realFileName);

            if (!string.IsNullOrEmpty(virtualFileName) && IsDocumentFileSupport(virtualFileName))
            {
                Resource.Instance resourceIns = null;

                var ext = Path.GetExtension(virtualFileName).ToLower();
                if (ext != "" && ext[0] == '.')
                {
                    ext = ext.Substring(1);
                }
                if (ResourceManager.GetTypeByFileExtension(ext) != null)
                {
                    //unload resource if it file was deleted
                    {
                        var res = ResourceManager.GetByName(virtualFileName);
                        if (res != null && res.FileWasDeleted)
                        {
                            res.Dispose();
                        }
                    }

                    //!!!!!good?
                    //!!!!wait

                    resourceIns = ResourceManager.LoadSeparateInstance(virtualFileName, true, true, null);
                    //resourceIns = ResourceManager.LoadResource( virtualFileName, true );

                    if (resourceIns == null)
                    {
                        return(null);
                    }
                }

                var document = new DocumentInstance(realFileName, resourceIns, specialMode);
                Documents.Add(document);

                return(document);
            }

            return(null);
        }
Esempio n. 4
0
        public void Destroy()
        {
            if (destroyed)
            {
                return;
            }
            destroyed = true;

            if (undoSystem != null)
            {
                undoSystem.Dispose();
            }

            EditorForm.instance?.Documents.Remove(this);

            loadedResource?.Dispose();
            loadedResource = null;
        }