Exemple #1
0
        private TSVNTreeViewItem CreateFileTreeViewItem(string text, string solutionDir, string path, string change)
        {
            var item = new TSVNTreeViewItem
            {
                IsExpanded = false,
                FontWeight = FontWeights.Normal,
                Path       = Path.Combine(solutionDir, path),
                Padding    = new Thickness(-3)
            };

            item.MouseDoubleClick += Item_MouseDoubleClick;

            // create Tooltip
            item.ToolTip = $"Name: {text}\nFolder: {Path.GetDirectoryName(item.Path)}\nType: {GetTypeOfChange(change[0])}";

            // create stack panel
            var stack = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            // create Image
            var image = new Image
            {
                Source =
                    File.Exists(item.Path)
                        ? ToImageSource(Icon.ExtractAssociatedIcon(item.Path))
                        : new BitmapImage(new Uri("Resources\\Document_16x.png", UriKind.Relative)),
                Width  = 16,
                Height = 16
            };

            // Label
            var lbl = new Label {
                Content = text
            };

            // Add into stack
            stack.Children.Add(image);
            stack.Children.Add(lbl);

            var typeOfChangeShort = GetTypeOfChangeShort(change[0]);

            if (!string.IsNullOrEmpty(typeOfChangeShort))
            {
                var lblChange = new Label
                {
                    Content    = typeOfChangeShort,
                    Foreground = new SolidColorBrush(Colors.Gray)
                };
                stack.Children.Add(lblChange);
            }

            // assign stack to header
            item.Header = stack;

            item.ContextMenu = _contextMenu;

            return(item);
        }
        private TSVNTreeViewItem CreateFileTreeViewItem(string text, string solutionDir, string path, string change)
        {
            var item = new TSVNTreeViewItem();
            item.IsExpanded = false;
            item.FontWeight = FontWeights.Normal;
            item.Path = Path.Combine(solutionDir, path);
            item.MouseDoubleClick += Item_MouseDoubleClick;
            item.Padding = new Thickness(-3);

            // create Tooltip
            item.ToolTip = $"Name: {text}\nFolder: {Path.GetDirectoryName(item.Path)}\nType: {GetTypeOfChange(change[0])}";

            // create stack panel
            StackPanel stack = new StackPanel();
            stack.Orientation = Orientation.Horizontal;

            // create Image
            var image = new Image
            {
                Source =
                    File.Exists(item.Path)
                        ? ToImageSource(Icon.ExtractAssociatedIcon(item.Path))
                        : new BitmapImage(new Uri("Resources\\Document_16x.png", UriKind.Relative)),
                Width = 16,
                Height = 16
            };

            // Label
            Label lbl = new Label();
            lbl.Content = text;

            // Add into stack
            stack.Children.Add(image);
            stack.Children.Add(lbl);

            var typeOfChangeShort = GetTypeOfChangeShort(change[0]);
            if (!string.IsNullOrEmpty(typeOfChangeShort))
            {
                Label lblChange = new Label();
                lblChange.Content = typeOfChangeShort;
                lblChange.Foreground = new SolidColorBrush(Colors.Gray);
                stack.Children.Add(lblChange);
            }

            // assign stack to header
            item.Header = stack;

            item.ContextMenu = _contextMenu;

            return item;
        }