Ejemplo n.º 1
0
        internal async Task<string> SyncNodeAsync(TmNode root)
        {
            if (root == null)
                return "No node provided for sync";

            root.SuspendUpdates();
            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)
            {
                progressLabel.Text = string.Format("Syncing {1} of {2} ({0})", node.Name, index + 1, count);
                progressBar.Value = (int)(100 * (float)index / count);
                try
                {
                    await node.SyncWithMetadataAsync(false);
                }
                catch (Exception ex)
                {
                    root.ResumeUpdates(); 
                    return ex.Message;
                }
                if (CancelRequested)
                {
                    root.ResumeUpdates();
                    return null;
                }
                index++;
            }
            root.ResumeUpdates();
            return null;
        }
Ejemplo n.º 2
0
        internal async Task<string> ReloadNodeAsync(TmNode root)
        {
            if (root == null)
                return "No node provided for reload";

            root.SuspendUpdates();
            List<TmNode> nodes = root.Recurse(x => x.Children)
                                        .Where(n => n.IsTheme)
                                        .ToList();
            int count = nodes.Count;
            int index = 0;
            foreach (var node in nodes)
            {
                progressLabel.Text = string.Format("Loading {1} of {2} ({0})", node.Name, index + 1, count);
                progressBar.Value = (int)(100 * (float)index / count);
                try
                {
                    await node.ReloadThemeAsync();
                }
                catch (Exception ex)
                {
                    root.ResumeUpdates();
                    return ex.Message;
                }
                if (CancelRequested)
                {
                    root.ResumeUpdates();
                    return null;
                }
                index++;
            }
            root.ResumeUpdates();
            return null;
        }