Ejemplo n.º 1
0
        internal string ReloadNode(BackgroundWorker bw, TmNode root, string path)
        {
            if (root == null)
                return "No node provided for reload";

            root.BeginUpdate();
            List<TmNode> nodes = root.Recurse(x => x.Children)
                                        .Where(n => n is ThemeNode)
                                        .ToList();
            int count = nodes.Count;
            int index = 0;
            foreach (var node in nodes)
            {
                Message = string.Format("Loading {1} of {2} ({0})", node.Name, index + 1, count);
                bw.ReportProgress((int)(100 * (float)index / count));
                try
                {
                    // node.ReloadTheme() may need to load to query ArcObjects
                    // which could throw any number of exceptions.
                    node.Reload();
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                if (bw.CancellationPending)
                    return null;
                index++;
            }
            root.EndUpdate();
            return null;
        }
Ejemplo n.º 2
0
        internal string SyncNode(BackgroundWorker bw, TmNode root, string path)
        {
            if (root == null)
                return "No node provided for sync";

            root.BeginUpdate();
            List<TmNode> nodes = root.Recurse(x => x.Children)
                                        .Where(n => !string.IsNullOrEmpty(n.Metadata.Path))
                                        .ToList();
            int count = nodes.Count;
            int index = 0;
            foreach (var node in nodes)
            {
                Message = string.Format("Syncing {1} of {2} ({0})", node.Name, index + 1, count);
                bw.ReportProgress((int)(100 * (float)index / count));
                try
                {
                    // node.SyncWithMetadata() will load/verify metadata
                    // which could throw any number of exceptions.
                    node.SyncWithMetadata();
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                if (bw.CancellationPending)
                    return null;
                index++;
            }
            root.EndUpdate();
            return null;
        }