Exemple #1
0
        public void Invalidate(FilesystemSelection filesystemSelection)
        {
            if (RootWidget.Parent == null)
            {
                return;
            }
            if (savedFilesystemSelection == filesystemSelection)
            {
                return;
            }
            savedFilesystemSelection = filesystemSelection.Clone();
            RootWidget.Content.Nodes.Clear();
            if (filesystemSelection.Empty)
            {
                return;
            }
            RootWidget.ScrollPosition = 0;
            List <Tuple <string, Image> > previews = new List <Tuple <string, Image> >();

            foreach (var filename in filesystemSelection)
            {
                var pv = GeneratePreview(filename);
                if (pv != null)
                {
                    pv.MinMaxSize = (Vector2)pv.Texture.ImageSize;
                    previews.Add(new Tuple <string, Image>(filename, pv));
                }
            }
            previews.Sort((a, b) => {
                var szA = a.Item2.Texture.SurfaceSize;
                var szB = b.Item2.Texture.SurfaceSize;
                return(Comparer <float> .Default.Compare((float)szB.Width / szB.Height, (float)szA.Width / szA.Height));
            });
            foreach (var t in previews)
            {
                RootWidget.Content.AddNode(new Widget {
                    Layout = new VBoxLayout(),
                    Nodes  =
                    {
                        t.Item2,
                        new ThemedSimpleText {
                            OverflowMode = TextOverflowMode.Ellipsis,
                            Text         = Path.GetFileName(t.Item1)
                        }
                    }
                });
            }
            CalcZoomAndMaxZoom();
            ApplyZoom();
        }
Exemple #2
0
        public void Invalidate(FilesystemSelection filesystemSelection)
        {
            savedFilesystemSelection = filesystemSelection;
            scrollView.Content.Nodes.Clear();
            if (RootWidget.Parent == null)
            {
                return;
            }
            if (filesystemSelection == null || filesystemSelection.Empty)
            {
                return;
            }
            var targetDir = Path.GetDirectoryName(filesystemSelection.First());

            if (Orange.The.Workspace.AssetsDirectory == null || !targetDir.StartsWith(Orange.The.Workspace.AssetsDirectory))
            {
                // We're somewhere outside the project directory
                return;
            }
            var t = Orange.CookingRulesBuilder.Build(
                new BundleForCookingRulesBuilder(AssetBundle.Current, Orange.The.Workspace.AssetsDirectory, targetDir),
                ActiveTarget,
                AssetBundle.Current.FromSystemPath(targetDir));

            foreach (var path in filesystemSelection)
            {
                CreateEditingInterfaceForPath(t, path);
            }
            scrollView.Content.Presenter = new SyncDelegatePresenter <Widget>((w) => {
                if (cachedZebraTexture == null)
                {
                    cachedZebraTexture = new Texture2D();
                    cachedZebraTexture.LoadImage(new[] { Theme.Colors.ZebraColor1, Theme.Colors.ZebraColor2 }, 1, 2);
                    cachedZebraTexture.TextureParams = new TextureParams {
                        WrapMode     = TextureWrapMode.Repeat,
                        MinMagFilter = TextureFilter.Nearest
                    };
                }
                w.PrepareRendererState();
                Renderer.DrawSprite(cachedZebraTexture, Color4.White, Vector2.Zero, w.Size, Vector2.Zero, w.Size / (Vector2)cachedZebraTexture.ImageSize / RowHeight);
            });
        }