private void InvalidateFSWatcher(string path) { fsWatcher?.Dispose(); fsWatcher = new Lime.FileSystemWatcher(path, includeSubdirectories: false); // TODO: throttle Action <string> OnFsWatcherChanged = p => { InvalidateView(model.CurrentPath); preview.ClearTextureCache(p); }; fsWatcher.Deleted += p => { selection.Deselect(p); OnFsWatcherChanged(p); }; fsWatcher.Created += OnFsWatcherChanged; fsWatcher.Renamed += OnFsWatcherChanged; fsWatcher.Changed += OnFsWatcherChanged; }
void InitializeWidgets() { RootWidget.AddChangeWatcher(() => selection.Version, Selection_Changed); scrollView.Content.Layout = new FlowLayout { Spacing = 1.0f }; scrollView.Content.Padding = new Thickness(5.0f); scrollView.Content.CompoundPostPresenter.Insert(0, new DelegatePresenter <Widget>(RenderFilesWidgetRectSelection)); scrollView.Updated += ScrollViewUpdated; scrollView.Content.Presenter = new DelegatePresenter <Widget>((w) => { w.PrepareRendererState(); var wp = w.ParentWidget; var p = wp.Padding; Renderer.DrawRect(-w.Position + Vector2.Zero - new Vector2(p.Left, p.Top), -w.Position + wp.Size + new Vector2(p.Right, p.Bottom), Theme.Colors.WhiteBackground); }); RootWidget.AddChangeWatcher(() => dragState, (ds) => Window.Current.Invalidate()); RootWidget.AddChangeWatcher(() => dragEndPosition, WhenSelectionRectChanged); RootWidget.AddChangeWatcher(() => WidgetContext.Current.NodeUnderMouse, (value) => { if (value != null && scrollView.Content == value.Parent) { Window.Current.Invalidate(); } }); RootWidget.AddChangeWatcher(() => model.CurrentPath, (p) => { var up = RootWidget.Components.Get <ViewNodeComponent>().ViewNode as FSViewNode; up.Path = p; AddToNavHystory(p); selection.Clear(); InvalidateView(p); InvalidateFSWatcher(p); preview.ClearTextureCache(); lastKeyboardSelectedFilesystemItem = scrollView.Content.FirstChild as FilesystemItem; }); RootWidget.Layout = new VBoxLayout(); RootWidget.AddNode((cookingRulesSplitter = new ThemedHSplitter { Nodes = { (new Widget { Layout = new VBoxLayout(), Nodes = { toolbar, (selectionPreviewSplitter = new ThemedVSplitter{ Nodes = { scrollView, preview.RootWidget, } }) } }), crEditor.RootWidget, } })); }