예제 #1
0
        public void Update(List <string> pendingChanges, string solutionDir)
        {
            ViewModel.Root.Clear();

            if (!string.IsNullOrEmpty(solutionDir))
            {
                var root = new TSVNTreeViewFolderItem
                {
                    Label      = $"Changes ({pendingChanges.Count})",
                    Foreground = ToBrush(EnvironmentColors.ToolWindowTextColorKey),
                    IsExpanded = true
                };

                var solutionDirItem = CreateFolderTreeViewItem(solutionDir, "S");

                foreach (var change in pendingChanges)
                {
                    ProcessChange(solutionDirItem, solutionDir, change);
                }

                root.Items.Add(solutionDirItem);

                ViewModel.Root.Add(root);

                commitButton.IsEnabled = true;
                revertButton.IsEnabled = true;
            }
            else
            {
                commitButton.IsEnabled = false;
                revertButton.IsEnabled = false;
            }
        }
예제 #2
0
        private void ProcessChange(TSVNTreeViewFolderItem root, string solutionDir, string change)
        {
            if (change.Length <= 8)
            {
                return;
            }

            var path      = change.Substring(8);
            var pathParts = path.Split('\\');

            for (var i = 0; i < pathParts.Length; i++)
            {
                var item = FindItem(root, pathParts[i]);
                if (item == null)
                {
                    TSVNTreeViewItem newItem;
                    if (i == pathParts.Length - 1 && File.Exists(Path.Combine(solutionDir, path)))
                    {
                        newItem = CreateFileTreeViewItem(pathParts[i], solutionDir, path, change);
                    }
                    else
                    {
                        newItem = CreateFolderTreeViewItem(pathParts[i], change);
                    }

                    root.Items.Add(newItem);

                    root = newItem as TSVNTreeViewFolderItem;
                }
                else if (item is TSVNTreeViewFolderItem folderItem)
                {
                    root = folderItem;
                }
            }
        }
예제 #3
0
        private TSVNTreeViewItem FindItem(TSVNTreeViewFolderItem root, string text)
        {
            if (root?.Items == null)
            {
                return(null);
            }

            foreach (var item in root.Items)
            {
                if (item.Label.Equals(text))
                {
                    return(item);
                }
            }

            return(null);
        }