Exemplo n.º 1
0
 public bool Close()
 {
     if (Current != this)
     {
         throw new InvalidOperationException();
     }
     if (Current == Null)
     {
         return(true);
     }
     fsWatcher?.Dispose();
     fsWatcher = null;
     UserPreferences.Documents.Clear();
     foreach (var doc in documents.ToList())
     {
         UserPreferences.Documents.Add(doc.Path);
         if (!CloseDocument(doc))
         {
             return(false);
         }
     }
     try {
         TangerineYuzu.Instance.Value.WriteObjectToFile(UserprefsPath, UserPreferences, Serialization.Format.JSON);
     } catch (System.Exception) { }
     AssetBundle.Current = null;
     Current             = Null;
     return(true);
 }
Exemplo n.º 2
0
        public bool Close()
        {
            if (Current != this)
            {
                throw new InvalidOperationException();
            }
            if (Current == Null)
            {
                return(true);
            }
            fsWatcher?.Dispose();
            fsWatcher = null;
            var userprefs = new Userprefs();

            if (Document.Current != null)
            {
                userprefs.CurrentDocument = Document.Current.Path;
            }
            foreach (var doc in documents.ToList())
            {
                if (!CloseDocument(doc))
                {
                    return(false);
                }
                userprefs.Documents.Add(doc.Path);
            }
            try {
                Serialization.WriteObjectToFile(UserprefsPath, userprefs, Serialization.Format.JSON);
            } catch (System.Exception) { }
            AssetBundle.Current = null;
            Current             = Null;
            return(true);
        }
Exemplo n.º 3
0
        public bool Close()
        {
            if (Current != this)
            {
                throw new InvalidOperationException();
            }
            if (Current == Null)
            {
                return(true);
            }
            if (PluginLoader.CurrentPlugin != null)
            {
                foreach (var action in PluginLoader.CurrentPlugin.TangerineProjectClosing)
                {
                    action?.Invoke();
                }
            }
            var modifiedDocuments = documents.Where(d => d.IsModified).ToList();

            foreach (var d in modifiedDocuments)
            {
                // Call Document.Close() instead of CloseDocument, since latter invokes Document.SetCurrent() and forces document loading.
                // All this stuff for the sake of performance.
                if (!d.Close())
                {
                    return(false);
                }
            }
            UserPreferences.Documents.Clear();
            foreach (var d in documents)
            {
                UserPreferences.Documents.Add(d.Path);
            }
            foreach (var d in modifiedDocuments)
            {
                CloseDocument(d, true);
            }
            var closingDocuments = documents.ToList();

            Document.SetCurrent(null);
            documents.Clear();
            foreach (var doc in closingDocuments)
            {
                if (!CloseDocument(doc))
                {
                    return(false);
                }
            }
            try {
                TangerinePersistence.Instance.WriteObjectToFile(UserprefsPath, UserPreferences, Persistence.Format.Json);
            } catch (System.Exception) { }
            AssetBundle.Current = null;
            FileSystemWatcher?.Dispose();
            FileSystemWatcher = null;
            Current           = Null;
            return(true);
        }
Exemplo n.º 4
0
        private void InvalidateFSWatcher(string path)
        {
            fsWatcher?.Dispose();
            fsWatcher = new Lime.FileSystemWatcher(path, includeSubdirectories: false);
            // TODO: throttle
            Action OnFsWatcherChanged = () => {
                InvalidateView(model.CurrentPath);
            };

            fsWatcher.Deleted += (p) => {
                selection.Deselect(p);
                OnFsWatcherChanged();
            };
            fsWatcher.Created += (p) => OnFsWatcherChanged();
            fsWatcher.Renamed += (p) => OnFsWatcherChanged();
        }