private static void CreateRenderers()
        {
            ScrollBarRenderer scrollBarRenderer;
            ListViewRenderer  listViewRenderer;
            HeaderRenderer    headerRenderer;
            TreeViewRenderer  treeViewRenderer;

            _renderers = new ThemeRenderer[]
            {
                scrollBarRenderer = new ScrollBarRenderer(),
                listViewRenderer  = new ListViewRenderer(),
                headerRenderer    = new HeaderRenderer(),
                treeViewRenderer  = new TreeViewRenderer(),
                new EditRenderer(),
                new SpinRenderer(),
                new ComboBoxRenderer(),
                new ButtonRenderer(),
                new TooltipRenderer(),
            };

            var editorHandle   = new ICSharpCode.TextEditor.TextEditorControl().Handle;
            var listViewHandle = new NativeListView().Handle;
            var treeViewHandle = new NativeTreeView().Handle;

            scrollBarRenderer.AddThemeData(editorHandle);
            scrollBarRenderer.AddThemeData(listViewHandle);
            headerRenderer.AddThemeData(listViewHandle);
            listViewRenderer.AddThemeData(listViewHandle);
            treeViewRenderer.AddThemeData(treeViewHandle);
        }
Example #2
0
        private void PopulateTreeView(NativeTreeView treeView, string filePathToAdd)
        {
            var parts    = filePathToAdd.Split(Path.DirectorySeparatorChar);
            var folders  = parts.Take(parts.Length - 1);
            var fileName = parts[parts.Length - 1];
            var nodes    = treeView.Nodes;

            foreach (var folder in folders)
            {
                if (nodes.ContainsKey(folder))
                {
                    nodes = nodes[folder].Nodes;
                }
                else
                {
                    var node = nodes.Add(folder);
                    var item = new GitItem(666, GitObjectType.Tree, ObjectId.WorkTreeId, folder);
                    node.Name = folder;
                    node.Tag  = item;
                    nodes     = node.Nodes;
                }
            }

            var fileNode = nodes.Add(fileName);
            var fileItem = new GitItem(666, GitObjectType.Blob, ObjectId.WorkTreeId, fileName);

            fileNode.Tag = fileItem;
        }
Example #3
0
        public static void LoadThemeData()
        {
            Validates.NotNull(_renderers);
            Validates.NotNull(_scrollBarRenderer);
            Validates.NotNull(_headerRenderer);
            Validates.NotNull(_listViewRenderer);
            Validates.NotNull(_treeViewRenderer);
            Validates.NotNull(_tabRenderer);

            foreach (ThemeRenderer renderer in _renderers)
            {
                renderer.AddThemeData(IntPtr.Zero);
            }

            var editorHandle   = new ICSharpCode.TextEditor.TextEditorControl().Handle;
            var listViewHandle = new NativeListView().Handle;
            var treeViewHandle = new NativeTreeView().Handle;

            _scrollBarRenderer.AddThemeData(editorHandle);
            _scrollBarRenderer.AddThemeData(listViewHandle);
            _headerRenderer.AddThemeData(listViewHandle);
            _listViewRenderer.AddThemeData(listViewHandle);
            _treeViewRenderer.AddThemeData(treeViewHandle);
            _tabRenderer.AddThemeData(new TabControl().Handle);
        }
Example #4
0
        public void SelectFileOrFolder_should_not_select_an_inexisting_folder()
        {
            var nativeTreeView = new NativeTreeView();
            PopulateTreeView(nativeTreeView, @"folder1\file1");
            var isNodeFound = _controller.SelectFileOrFolder(nativeTreeView, "inexisting_folder");

            Assert.IsFalse(isNodeFound);
            Assert.IsNull(nativeTreeView.SelectedNode);
        }
Example #5
0
        public void SelectFileOrFolder_should_select_a_file()
        {
            var nativeTreeView = new NativeTreeView();
            PopulateTreeView(nativeTreeView, @"folder1\file1");
            PopulateTreeView(nativeTreeView, @"folder1\file2");
            var isNodeFound = _controller.SelectFileOrFolder(nativeTreeView, @"folder1\file1");

            Assert.IsTrue(isNodeFound);
            Assert.AreEqual(@"folder1\file1", nativeTreeView.SelectedNode.FullPath);
        }
        public bool SelectFileOrFolder(NativeTreeView tree, string fileSubPath)
        {
            var pathParts = new Queue <string>(fileSubPath.Split(Path.DirectorySeparatorChar));
            var foundNode = FindSubNode(tree.Nodes, pathParts);

            if (foundNode is null)
            {
                return(false);
            }

            tree.SelectedNode = foundNode;
            return(true);
        }