本文整理汇总了C#中System.Windows.Forms.TreeView.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.Sort方法的具体用法?C# TreeView.Sort怎么用?C# TreeView.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeView
的用法示例。
在下文中一共展示了TreeView.Sort方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadExamplesInGui
/// <summary>
/// Carga los ejemplos dinámicamente en el TreeView de Ejemplo
/// </summary>
public void loadExamplesInGui(TreeView treeView, string[] exampleDirs)
{
//Cargar ejemplos dinamicamente
currentExamples = new List<TgcExample>();
foreach (string exampleDir in exampleDirs)
{
currentExamples.AddRange(loadExamples(exampleDir));
}
//Cargar el TreeView, agrupando ejemplos por categoria
treeExamplesDict.Clear();
foreach (TgcExample example in currentExamples)
{
TreeNode node = new TreeNode();
string exampleName = example.getName();
string exampleCategory = example.getCategory();
node.Text = exampleName;
node.Name = exampleName;
node.ToolTipText = example.getDescription();
//Crear nodo padre si no existe
TreeNode parent = treeNodeExists(treeView, exampleCategory);
if (parent == null)
{
parent = new TreeNode();
parent.Name = exampleCategory;
parent.Text = exampleCategory;
parent.ToolTipText = exampleCategory;
treeView.Nodes.Add(parent);
}
parent.Nodes.Add(node);
treeExamplesDict[node] = example;
}
//Ordenar en forma ascendente los nodos del arbol
treeView.Sort();
}
示例2: Sort
public static void Sort(TreeView treeview, IComparer nodeSorter)
{
MethodInvoker mi = delegate
{
treeview.TreeViewNodeSorter = nodeSorter;
treeview.Sort();
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
}
示例3: FillStationTreeView
/// <summary>
///
/// </summary>
/// <param name="hardWareManager"></param>
/// <param name="treeView"></param>
private void FillStationTreeView(HardwareManager hardWareManager, TreeView treeView)
{
foreach (Station station in hardWareManager.Stations)
{
TreeNode stationTreeNode = AddStationToTreeView(treeView, station);
foreach (Device device in station.Devices)
{
AddDeviceToStationTreeNode(stationTreeNode, device);
}
}
treeView.Sort();
}
示例4: showO2CirDataInTreeView
public void showO2CirDataInTreeView(CirData fcdCirData, TreeView tvTargetTreeView, List<String> lsFunctionsAdded)
{
clearViewers();
// make it not visible for performance reasons:
tvTargetTreeView.Visible = false;
// add list of files process to ListBox
lbCirAnalyzer_Files.Visible = false;
foreach (String sFile in fcdCirData.lFiles)
lbCirAnalyzer_Files.Items.Add(sFile);
lbCirAnalyzer_Files.Visible = true;
// add data to ClassesAndMethod Tree View
tvTargetTreeView.Sort();
if (fcdCirData.dClasses_bySignature != null)
foreach (CirClass ccCirClass in fcdCirData.dClasses_bySignature.Values)
{
if (ccCirClass.bClassHasMethodsWithControlFlowGraphs && ccCirClass.dFunctions.Count > 0)
//only Classes with methods with ControlFlowGraphs
{
bool bFunctionAdded = false;
TreeNode tnClass = O2Forms.newTreeNode(ccCirClass.Signature, "", 0, null);
// add SuperClasses
foreach (String sSuperClass in ccCirClass.dSuperClasses.Keys)
tnClass.Nodes.Add(O2Forms.newTreeNode(CirDataUtils.getSymbol(fcdCirData,sSuperClass), "", 5, null));
foreach (String sIsSuperClassedBy in ccCirClass.dIsSuperClassedBy.Keys)
tnClass.Nodes.Add(
O2Forms.newTreeNode("IsSuperClassedBy:" + CirDataUtils.getSymbol(fcdCirData,sIsSuperClassedBy), "", 5,
null));
// add fields
if (rbShowFieldsAndVariables.Checked)
{
foreach (FieldClass fsFieldClass in ccCirClass.dField_Class.Values)
tnClass.Nodes.Add(
O2Forms.newTreeNode(
String.Format("fc: {0} {1} - {2}", fsFieldClass.Signature, fsFieldClass.Name,
fsFieldClass.Signature), "", 4, null));
foreach (FieldMember fsFieldMember in ccCirClass.dField_Member.Values)
tnClass.Nodes.Add(
O2Forms.newTreeNode(
String.Format("fm: {0} {1}", fsFieldMember.PrintableType, fsFieldMember.Name),
"", 4, null));
}
// add methods in code, its variables, who it calls
foreach (CirFunction cfCirFunction in ccCirClass.dFunctions.Values)
{
if (processFunctionAndAddItToNode(tnClass.Nodes, cfCirFunction, lsFunctionsAdded))
bFunctionAdded = true;
}
if (bFunctionAdded && tnClass.Nodes.Count > 0)
tvTargetTreeView.Nodes.Add(tnClass);
}
/* // for C++ files (handles with the NonClassFunctions)
foreach (CirFunction cfCirFunction in fcdCirData.dFunctions.Values)
{
processFunctionAndAddItToNode(tvTargetTreeView.Nodes, cfCirFunction);
}*/
Application.DoEvents(); // refresh GUI
}
//tvAllClassesAndMethods.ExpandAll();
// if (tvAllClassesAndMethods.Nodes.Count > 0 )
// tvAllClassesAndMethods.Nodes[0].Expand();
// if (cbCirAnalyzer_TextFilter_MakesCallsTo.Checked || cbCirAnalyzer_TextFilter_Functions.Checked || cbCirAnalyzer_TextFilter_RemoveMakesCallsTo.Checked)
// tvTargetTreeView.ExpandAll();
tvTargetTreeView.Visible = true;
}
示例5: AddRoot
internal static void AddRoot(TreeView tv, Control mainControl)
{
var nrd = new NewRootDialog { StartPosition = FormStartPosition.CenterParent };
if (nrd.ShowDialog(mainControl) == DialogResult.OK)
{
var rootNode = new TreeNode(nrd.RootName) { ImageIndex = 0, SelectedImageIndex = 0 };
tv.Nodes.Add(rootNode);
tv.TreeViewNodeSorter = new NodeSorter();
tv.Sort();
}
}
示例6: AddFolder
internal static void AddFolder(TreeView tvWebResources, Control mainControl)
{
var selectedNode = tvWebResources.SelectedNode;
var nfd = new NewFolderDialog { StartPosition = FormStartPosition.CenterParent };
if (nfd.ShowDialog(mainControl) == DialogResult.OK)
{
var parts = nfd.FolderName.Split('/');
var currentNode = selectedNode;
foreach (var part in parts.Where(x => x.Length > 0))
{
var node = new TreeNode(part.Trim()) { ImageIndex = 1, SelectedImageIndex = 1 };
currentNode.Nodes.Add(node);
tvWebResources.SelectedNode = node;
currentNode = node;
}
}
tvWebResources.TreeViewNodeSorter = new NodeSorter();
tvWebResources.Sort();
}
示例7: AddExistingWebResource
internal static void AddExistingWebResource(TreeView tv, Control mainControl)
{
TreeNode selectedNode = tv.SelectedNode;
TreeNode tempNode = selectedNode;
string name = tempNode.Text;
while (tempNode.Parent != null)
{
name = string.Format("{0}/{1}", tempNode.Parent.Text, name);
tempNode = tempNode.Parent;
}
var ofd = new OpenFileDialog { Multiselect = true, Title = "Select file(s) for web resource(s)" };
if (ofd.ShowDialog(mainControl) == DialogResult.OK)
{
var errorList = new List<string>();
foreach (string fileName in ofd.FileNames)
{
var fi = new FileInfo(fileName);
//Test valid characters
if (WebResource.IsInvalidName(fi.Name))
{
errorList.Add(fileName);
}
else
{
var webResource = new Entity("webresource");
webResource["content"] = Convert.ToBase64String(File.ReadAllBytes(fileName));
webResource["webresourcetype"] =
new OptionSetValue(WebResource.GetTypeFromExtension(fi.Extension.Remove(0, 1)));
webResource["name"] = string.Format("{0}/{1}", name, fi.Name);
webResource["displayname"] = string.Format("{0}/{1}", name, fi.Name);
var wr = new WebResource(webResource, fileName);
var node = new TreeNode(fi.Name)
{
ImageIndex =
WebResource.GetImageIndexFromExtension(fi.Extension.Remove(0,
1))
};
node.SelectedImageIndex = node.ImageIndex;
node.Tag = wr;
selectedNode.Nodes.Add(node);
selectedNode.Expand();
}
if (errorList.Count > 0)
{
MessageBox.Show("Some file have not been added since their name does not match naming policy\r\n"
+ string.Join("\r\n", errorList));
}
}
}
tv.TreeViewNodeSorter = new NodeSorter();
tv.Sort();
}
示例8: SortedRecursive
public void SortedRecursive ()
{
TreeView tv = new TreeView ();
tv.TreeViewNodeSorter = new InverseNodeSorter ();
tv.BeginUpdate ();
TreeNode root_node = tv.Nodes.Add ("Root");
for (char c = 'a'; c <= 'f'; c++) {
TreeNode node = new TreeNode (c.ToString ());
for (int i = 0; i < 3; i++)
node.Nodes.Add (i.ToString ());
root_node.Nodes.Add (node);
}
tv.EndUpdate ();
// Make sure we are sorted
tv.Sort ();
Assert.AreEqual ("f", root_node.Nodes [0].Text, "#A1");
Assert.AreEqual ("e", root_node.Nodes [1].Text, "#A2");
Assert.AreEqual ("d", root_node.Nodes [2].Text, "#A3");
Assert.AreEqual ("c", root_node.Nodes [3].Text, "#A4");
Assert.AreEqual ("b", root_node.Nodes [4].Text, "#A5");
Assert.AreEqual ("a", root_node.Nodes [5].Text, "#A5");
foreach (TreeNode n in root_node.Nodes) {
Assert.AreEqual ("2", n.Nodes [0].Text, "#B1");
Assert.AreEqual ("1", n.Nodes [1].Text, "#B2");
Assert.AreEqual ("0", n.Nodes [2].Text, "#B3");
}
}
示例9: SortedBeforeNodeAdd
public void SortedBeforeNodeAdd ()
{
TreeView tv = new TreeView ();
tv.Sort ();
tv.Nodes.Add ("bbb");
tv.Nodes.Add ("aaa");
Assert.AreEqual ("aaa", tv.Nodes[0].Text, "A1");
}
示例10: SortChangesSorted
public void SortChangesSorted ()
{
TreeView tv = new TreeView ();
Assert.AreEqual (false, tv.Sorted, "A1");
tv.Sort ();
Assert.AreEqual (true, tv.Sorted, "A2");
}
示例11: PopulateActivities
//.........这里部分代码省略.........
activityTypes.Add(stockType);
}
//***************NON PREVIWABLE DESIGNER TYPES*************
IList<Type> nonpreviewableDesignerTypes = new List<Type>();
//These designer might be designers such as CADesigner which we eliminated
//We have just kept the code so that in future if this functionality is needed
//we can add it
//Populate the designer combobox
treeView.BeginUpdate();
treeView.Nodes.Clear();
//Work around: ***WE DISPLAY THE COMMON PROPERTIES FOR WORKFLOW AND APPLY THEM RECURSIVELY TO DESIGNERS
TreeNode workflowNode = new TreeNode(DR.GetString(DR.WorkflowDesc));
treeView.Nodes.Add(workflowNode);
//Now we go thru the toolbox items and get all the items which are not in our assembly
IToolboxService toolboxService = serviceProvider.GetService(typeof(IToolboxService)) as IToolboxService;
ITypeProviderCreator typeProviderCreator = serviceProvider.GetService(typeof(ITypeProviderCreator)) as ITypeProviderCreator;
if (toolboxService != null && typeProviderCreator != null)
{
ToolboxItemCollection toolboxItems = toolboxService.GetToolboxItems();
foreach (ToolboxItem toolboxItem in toolboxItems)
{
bool customWinOEActivityType = (toolboxItem is ActivityToolboxItem);
if (!customWinOEActivityType)
{
foreach (ToolboxItemFilterAttribute filter in toolboxItem.Filter)
{
if (filter.FilterString.StartsWith("Microsoft.Workflow.VSDesigner", StringComparison.OrdinalIgnoreCase) ||
filter.FilterString.StartsWith("System.Workflow.ComponentModel", StringComparison.OrdinalIgnoreCase))
{
customWinOEActivityType = true;
break;
}
}
}
if (customWinOEActivityType)
{
Type type = null;
Assembly assembly = typeProviderCreator.GetTransientAssembly(toolboxItem.AssemblyName);
if (assembly != null)
type = assembly.GetType(toolboxItem.TypeName);
if (type != null)
{
ConstructorInfo[] constructors = type.GetConstructors();
foreach (ConstructorInfo constructor in constructors)
{
if (constructor.IsPublic && constructor.GetParameters().GetLength(0) == 0)
activityTypes.Add(type);
}
}
}
}
}
foreach (Type type in activityTypes)
{
Type designerBaseType = (type.FullName.Equals(DesignerHelpers.SequentialWorkflowTypeRef, StringComparison.OrdinalIgnoreCase)) ? typeof(IRootDesigner) : typeof(IDesigner);
Type designerType = ActivityDesigner.GetDesignerType(serviceProvider, type, designerBaseType);
if (designerType != null && !nonpreviewableDesignerTypes.Contains(designerType))
{
object[] attribs = designerType.GetCustomAttributes(typeof(ActivityDesignerThemeAttribute), true);
ActivityDesignerThemeAttribute themeAttrib = (attribs != null && attribs.GetLength(0) > 0) ? attribs[0] as ActivityDesignerThemeAttribute : null;
if (themeAttrib != null)
{
Image image = ActivityToolboxItem.GetToolboxImage(type);
if (treeView.ImageList == null)
{
treeView.ImageList = new ImageList();
treeView.ImageList.ColorDepth = ColorDepth.Depth32Bit;
Image standardImage = DR.GetImage(DR.Activity) as Image;
treeView.ImageList.Images.Add(standardImage, AmbientTheme.TransparentColor);
}
TreeNode parentNode = ThemeConfigHelpers.GetCatagoryNodeForDesigner(designerType, ThemeConfigHelpers.GetAllTreeNodes(treeView));
if (parentNode != null)
{
int imageIndex = (image != null) ? treeView.ImageList.Images.Add(image, AmbientTheme.TransparentColor) : 0;
TreeNode nodeToInsert = (imageIndex >= 0) ? new TreeNode(ActivityToolboxItem.GetToolboxDisplayName(type), imageIndex, imageIndex) : new TreeNode(ActivityToolboxItem.GetToolboxDisplayName(type));
nodeToInsert.Tag = type;
//We always make sure that cata----es are at the end
int index = parentNode.Nodes.Count - 1;
while (index >= 0 && parentNode.Nodes[index].Tag is System.Type)
index = index - 1;
parentNode.Nodes.Insert(index, nodeToInsert);
}
}
}
}
treeView.TreeViewNodeSorter = new ThemeTreeNodeComparer();
treeView.Sort();
treeView.Nodes[0].ExpandAll();
treeView.EndUpdate();
}
示例12: FillTreeView
/// <summary>
/// Fills the list of trials from the given Data Table into
/// an sorted treeview that is specified in the first parameter.
/// </summary>
/// <param name="treeview">
/// A <see cref="TreeView"/> control
/// that should be filled.
/// </param>
/// <param name="table">
/// A <see cref="DataTable"/> with the trial Data
/// </param>
public static void FillTreeView(TreeView treeview, DataTable table)
{
treeview.BeginUpdate();
treeview.Nodes.Clear();
foreach (DataRow trialRow in table.Rows)
{
string category = trialRow["Category"].ToString();
string trialName = trialRow["TrialName"].ToString();
string trialID = trialRow["TrialID"].ToString();
if (category == string.Empty || category == " ")
{
category = "no category";
}
if (!treeview.Nodes.ContainsKey(category))
{
treeview.Nodes.Add(category, category, string.Empty, string.Empty);
treeview.Nodes[category].Checked = true;
}
if (!treeview.Nodes[category].Nodes.ContainsKey(trialID))
{
treeview.Nodes[category].Nodes.Add(trialID, trialName, string.Empty, string.Empty);
treeview.Nodes[category].Nodes[trialID].Checked = true;
}
}
treeview.Sort();
treeview.EndUpdate();
}
示例13: PopulateActivities
internal static void PopulateActivities(IServiceProvider serviceProvider, TreeView treeView)
{
List<System.Type> list = new List<System.Type>();
foreach (string str in new List<string> { "System.Workflow.Activities.SequentialWorkflowActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "System.Workflow.Activities.StateMachineWorkflowActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "System.Workflow.Activities.IfElseBranchActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", typeof(FaultHandlersActivity).AssemblyQualifiedName, "System.Workflow.Activities.EventHandlersActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", typeof(CompensationHandlerActivity).AssemblyQualifiedName, typeof(CancellationHandlerActivity).AssemblyQualifiedName })
{
System.Type type = System.Type.GetType(str, false);
if (type != null)
{
list.Add(type);
}
}
IList<System.Type> list3 = new List<System.Type>();
treeView.BeginUpdate();
treeView.Nodes.Clear();
TreeNode node = new TreeNode(DR.GetString("WorkflowDesc", new object[0]));
treeView.Nodes.Add(node);
IToolboxService service = serviceProvider.GetService(typeof(IToolboxService)) as IToolboxService;
ITypeProviderCreator creator = serviceProvider.GetService(typeof(ITypeProviderCreator)) as ITypeProviderCreator;
if ((service != null) && (creator != null))
{
foreach (ToolboxItem item in service.GetToolboxItems())
{
bool flag = item is ActivityToolboxItem;
if (!flag)
{
foreach (ToolboxItemFilterAttribute attribute in item.Filter)
{
if (attribute.FilterString.StartsWith("Microsoft.Workflow.VSDesigner", StringComparison.OrdinalIgnoreCase) || attribute.FilterString.StartsWith("System.Workflow.ComponentModel", StringComparison.OrdinalIgnoreCase))
{
flag = true;
break;
}
}
}
if (flag)
{
System.Type type2 = null;
Assembly transientAssembly = creator.GetTransientAssembly(item.AssemblyName);
if (transientAssembly != null)
{
type2 = transientAssembly.GetType(item.TypeName);
}
if (type2 != null)
{
foreach (ConstructorInfo info in type2.GetConstructors())
{
if (info.IsPublic && (info.GetParameters().GetLength(0) == 0))
{
list.Add(type2);
}
}
}
}
}
}
foreach (System.Type type3 in list)
{
System.Type designerBaseType = type3.FullName.Equals("System.Workflow.Activities.SequentialWorkflowActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", StringComparison.OrdinalIgnoreCase) ? typeof(IRootDesigner) : typeof(IDesigner);
System.Type type5 = ActivityDesigner.GetDesignerType(serviceProvider, type3, designerBaseType);
if ((type5 != null) && !list3.Contains(type5))
{
object[] customAttributes = type5.GetCustomAttributes(typeof(ActivityDesignerThemeAttribute), true);
if ((((customAttributes != null) && (customAttributes.GetLength(0) > 0)) ? (customAttributes[0] as ActivityDesignerThemeAttribute) : null) != null)
{
Image toolboxImage = ActivityToolboxItem.GetToolboxImage(type3);
if (treeView.ImageList == null)
{
treeView.ImageList = new ImageList();
treeView.ImageList.ColorDepth = ColorDepth.Depth32Bit;
Image image = DR.GetImage("Activity");
treeView.ImageList.Images.Add(image, AmbientTheme.TransparentColor);
}
TreeNode catagoryNodeForDesigner = GetCatagoryNodeForDesigner(type5, GetAllTreeNodes(treeView));
if (catagoryNodeForDesigner != null)
{
int imageIndex = (toolboxImage != null) ? treeView.ImageList.Images.Add(toolboxImage, AmbientTheme.TransparentColor) : 0;
TreeNode node3 = (imageIndex >= 0) ? new TreeNode(ActivityToolboxItem.GetToolboxDisplayName(type3), imageIndex, imageIndex) : new TreeNode(ActivityToolboxItem.GetToolboxDisplayName(type3));
node3.Tag = type3;
int index = catagoryNodeForDesigner.Nodes.Count - 1;
while ((index >= 0) && (catagoryNodeForDesigner.Nodes[index].Tag is System.Type))
{
index--;
}
catagoryNodeForDesigner.Nodes.Insert(index, node3);
}
}
}
}
treeView.TreeViewNodeSorter = new ThemeConfigurationDialog.ThemeTreeNodeComparer();
treeView.Sort();
treeView.Nodes[0].ExpandAll();
treeView.EndUpdate();
}
示例14: populateWithListOfFilteredFindings_TreeView
public static void populateWithListOfFilteredFindings_TreeView(TreeView tvTargetTreeView,
List<FindingViewItem> lviFindingViewItem,
Dictionary<String, List<FindingViewItem>>
dFilteredFindings)
{
tvTargetTreeView.Nodes.Clear();
//lbTargetListBox.Tag = lviFindingViewItem;
foreach (FindingViewItem lFindingViewItem in lviFindingViewItem)
{
int iImageIndex = 0;
if (lFindingViewItem.fFinding.Trace != null)
iImageIndex = 1;
//TreeNode tnTreeNode = tvTargetTreeView.Nodes.Add(lFindingViewItem.ToString());
tvTargetTreeView.Nodes.Add(O2Forms.newTreeNode(lFindingViewItem.ToString(),
lFindingViewItem.ToString(), iImageIndex,
lFindingViewItem));
//else
// tnTreeNode.ImageIndex = -1;
}
tvTargetTreeView.Sort();
}