Exemplo n.º 1
0
        internal AssetManagerUI()
        {
            if (string.IsNullOrEmpty(Properties.Settings.Default.ImportedAssetsPath))
            {
                var setupProperties = new SetupProperties();
                var result          = setupProperties.ShowDialog();

                Func <string, string> ensureTrailingSlash = (s) => { if (s.EndsWith("\\"))
                                                                     {
                                                                         return(s);
                                                                     }
                                                                     else
                                                                     {
                                                                         return(s + "\\");
                                                                     } };

                if (result == true)
                {
                    Properties.Settings.Default.ImportedAssetsPath = ensureTrailingSlash(setupProperties.ImportedAssetsPath);
                    Properties.Settings.Default.MetadataPath       = ensureTrailingSlash(setupProperties.MetadataPath);
                    Properties.Settings.Default.RawAssetsPath      = ensureTrailingSlash(setupProperties.RawAssetsPath);
                    Properties.Settings.Default.Save();
                }
                else
                {
                    MessageBox.Show("Properties were not setup, please run again and fill all the textboxes");
                    Application.Current.Shutdown();
                    return;
                }
            }

            InitializeComponent();
            viewmodel = new AssetViewmodel();

            this.DataContext = viewmodel;

            Action <Action> invoke = f => this.Dispatcher.Invoke(() => f());

            metadataHandler = new MetadataHandler(invoke, viewmodel);
            setup();

            this.Closed += (a, b) =>
            {
                metadataHandler.stopWatchingAssets();
            };
        }
        internal RawAssetWatcher(AssetViewmodel model,
                                 Action <string> displayError, Action <string> displaySuccess,
                                 Action <object> updateDependents)
        {
            viewmodel             = model;
            this.displayError     = displayError;
            this.displaySuccess   = displaySuccess;
            this.updateDependents = updateDependents;

            watcher                       = new FileSystemWatcher();
            watcher.Path                  = Path.GetFullPath(Properties.Settings.Default.RawAssetsPath);
            watcher.NotifyFilter          = NotifyFilters.LastWrite | NotifyFilters.FileName;
            watcher.Filter                = "*.*";
            watcher.IncludeSubdirectories = true;
            watcher.Changed              += watcher_Changed;
            watcher.Renamed              += watcher_Renamed;
            watcher.EnableRaisingEvents   = true;
        }
Exemplo n.º 3
0
        internal MetadataHandler(Action <Action> invoke, AssetViewmodel viewmodel)
        {
            this.viewmodel = viewmodel;

            displayError = error => invoke(() => viewmodel.LogEvent(error));

            assetWatcher = new RawAssetWatcher(viewmodel,
                                               error =>
            {
                invoke(() =>
                {
                    viewmodel.LogEvent(error);
                });
            },
                                               success =>
            {
                invoke(() => viewmodel.LogEvent(success));
            },
                                               asset =>
            {
                invoke(() => updateDependents(asset));
            }
                                               );
        }