示例#1
0
        private void LibraryContentChanged(object sender, ItemChangeEventArgs e)
        {
            if (e.ChangeType != ContentChangeType.CollectionAdd && e.ChangeType != ContentChangeType.CollectionRemove)
            {
                return;
            }

            var node    = (IAssetNode)e.Collection;
            var assetId = node.PropertyGraph.RootNode[nameof(Asset.Id)].Retrieve();

            if (assetId == null)
            {
                return;
            }

            var viewModel = Session.GetAssetById((AssetId)assetId) as UILibraryViewModel;

            if (viewModel == null)
            {
                return;
            }

            var index = (Guid)e.Index.Value;

            if (e.ChangeType == ContentChangeType.CollectionAdd)
            {
                factories.Add(new UIElementFromLibrary(ServiceProvider, viewModel, index));
            }
            else
            {
                factories.RemoveWhere(f => (f as UIElementFromLibrary)?.Id == index);
            }
        }
示例#2
0
 public void AddFile(UFile filePath)
 {
     // Reload settings in case concurrent Game Studio instances are running.
     LoadFromSettings();
     // Remove it if it was already in the list
     mostRecentlyUsedFiles.RemoveWhere(x => string.Equals(x.FilePath, filePath, StringComparison.OrdinalIgnoreCase));
     // Add it on top of the list
     mostRecentlyUsedFiles.Insert(0, new MostRecentlyUsedFile(filePath));
     // Save immediately
     SaveToSettings();
 }
 private bool RemoveFilePrivate(UFile filePath)
 {
     return(mruList.RemoveWhere(x => string.Equals(x.FilePath, filePath, StringComparison.OrdinalIgnoreCase)) > 0);
 }