本文整理汇总了C#中Sce.Atf.Controls.TreeControl类的典型用法代码示例。如果您正苦于以下问题:C# TreeControl类的具体用法?C# TreeControl怎么用?C# TreeControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeControl类属于Sce.Atf.Controls命名空间,在下文中一共展示了TreeControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawData
/// <summary>
/// Draws the data of a tree node at the specified location.</summary>
/// <param name="node">The tree control's node whose data is to be drawn</param>
/// <param name="g">The current GDI+ graphics object</param>
/// <param name="x">The x-coordinate of the upper-left corner of the node label</param>
/// <param name="y">The y-coordinate of the upper-left corner of the node label</param>
public override void DrawData(TreeControl.Node node, Graphics g, int x, int y)
{
var treeListControl = node.TreeControl as TreeListControl;
ItemInfo info = new WinFormsItemInfo();
m_itemView.GetInfo(node.Tag, info);
if (info.Properties.Length ==0)
return;
Region oldClip = g.Clip;
UpdateColumnWidths(node, info, g);
int xOffset = treeListControl.TreeWidth;
for (int i = 0; i < info.Properties.Length; ++i)
{
var dataEditor = info.Properties[i] as DataEditor;
if (dataEditor != null) // show object data details in columns
{
if (TrackingEditor != null && (TrackingEditor.Owner == node.Tag) &&
(TrackingEditor.Name == dataEditor.Name))
dataEditor = TrackingEditor;
var clip = new Rectangle(xOffset, y, treeListControl.Columns[i].ActualWidth, treeListControl.GetRowHeight(node));
if (i == info.Properties.Length-1) // extends last column
clip.Width = node.TreeControl.ActualClientSize.Width - xOffset;
g.SetClip(clip);
dataEditor.PaintValue(g, clip);
}
xOffset += treeListControl.Columns[i].ActualWidth;
}
g.Clip = oldClip;
}
示例2: Configure
/// <summary>
/// Configures the editor</summary>
/// <param name="treeControl">Control to display data</param>
/// <param name="treeControlAdapter">Adapter to drive control. Its ITreeView should
/// implement IInstancingContext and/or IHierarchicalInsertionContext.</param>
/// <remarks>Default is to create a TreeControl and TreeControlAdapter,
/// using the global image lists.</remarks>
protected override void Configure(
out TreeControl treeControl,
out TreeControlAdapter treeControlAdapter)
{
treeControl = new TreeControl();
treeControl.ImageList = ResourceUtil.GetImageList16();
treeControl.StateImageList = ResourceUtil.GetImageList16();
treeControlAdapter = new TreeControlAdapter(treeControl);
treeControl.PreviewKeyDown += treeControl_PreviewKeyDown;
treeControl.NodeExpandedChanging += treeControl_NodeExpandedChanging;
treeControl.NodeExpandedChanged += treeControl_NodeExpandedChanged;
m_searchInput = new StringSearchInputUI();
m_searchInput.Updated += UpdateFiltering;
m_control = new UserControl();
m_control.Dock = DockStyle.Fill;
m_control.SuspendLayout();
m_control.Name = "Tree View".Localize();
m_control.Text = "Tree View".Localize();
m_control.Controls.Add(m_searchInput);
m_control.Controls.Add(TreeControl);
m_control.Layout += controls_Layout;
m_control.ResumeLayout();
}
示例3: Configure
/// <summary>
/// Configures the editor</summary>
/// <param name="treeControl">Tree control to display data</param>
/// <param name="treeControlAdapter">Tree control adapter to drive control</param>
protected override void Configure(
out TreeControl treeControl,
out TreeControlAdapter treeControlAdapter)
{
treeControl = new TreeControl(TreeControl.Style.CategorizedPalette);
treeControl.ImageList = ResourceUtil.GetImageList16();
treeControl.AllowDrop = true;
treeControl.SelectionMode = SelectionMode.MultiExtended;
treeControlAdapter = new TreeControlAdapter(treeControl);
}
示例4: Configure
/// <summary>
/// Create and configure TreeControl</summary>
/// <param name="treeControl">New TreeControl</param>
/// <param name="treeControlAdapter">Adapter for TreeControl</param>
protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
{
base.Configure(out treeControl, out treeControlAdapter);
treeControl.ShowRoot = false; // UI node can't really be edited, so hide it
treeControl.Text = ("Add packages to the UI." + Environment.NewLine +
"Add forms, shaders, textures, and fonts to packages." + Environment.NewLine +
"Add sprites or text items to forms or sprites." + Environment.NewLine +
"Drag shaders, textures, and fonts onto the reference slots of sprites and text items.").Localize();
treeControl.AllowDrop = true;
treeControl.SelectionMode = SelectionMode.MultiExtended;
}
示例5: Configure
/// <summary>
/// Configures the editor</summary>
/// <param name="treeControl">Control to display data</param>
/// <param name="treeControlAdapter">Adapter to drive control. Its ITreeView should
/// implement IInstancingContext and/or IHierarchicalInsertionContext.</param>
/// <remarks>Default is to create a TreeControl and TreeControlAdapter,
/// using the global image lists.</remarks>
protected virtual void Configure(
out TreeControl treeControl,
out TreeControlAdapter treeControlAdapter)
{
treeControl =
new TreeControl
{
ImageList = ResourceUtil.GetImageList16(),
StateImageList = ResourceUtil.GetImageList16()
};
treeControlAdapter = new TreeControlAdapter(treeControl);
}
示例6: TreeControlAdapter
/// <summary>
/// Constructor that uses the given TreeControl and equality comparer</summary>
/// <param name="treeControl">Tree control to use. Use "new TreeControl()" for the default.</param>
/// <param name="comparer">The comparer used to compare nodes in the tree, or null to use the
/// default comparer for type T</param>
public TreeControlAdapter(TreeControl treeControl, IEqualityComparer<object> comparer)
{
m_treeControl = treeControl;
m_itemToNodeMap = new Multimap<object, TreeControl.Node>(comparer);
m_treeControl.MouseDown += treeControl_MouseDown;
m_treeControl.MouseUp += treeControl_MouseUp;
m_treeControl.DragOver += treeControl_DragOver;
m_treeControl.DragDrop += treeControl_DragDrop;
m_treeControl.NodeExpandedChanged += treeControl_NodeExpandedChanged;
m_treeControl.NodeSelectedChanged += treeControl_NodeSelectedChanged;
m_treeControl.SelectionChanging += treeControl_SelectionChanging;
m_treeControl.SelectionChanged += treeControl_SelectionChanged;
}
示例7: SettingsDialog
/// <summary>
/// Constructor</summary>
/// <param name="settingsService">Settings service</param>
/// <param name="dialogOwner">Dialog owner window HWND</param>
/// <param name="pathName">Path of settings to display initially, or null</param>
public SettingsDialog(SettingsService settingsService, IWin32Window dialogOwner, string pathName)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
SplitterRatio = 0.33f;
m_settingsService = settingsService;
m_dialogOwner = dialogOwner;
m_originalState = m_settingsService.UserState; // for cancel
m_treeControl = new TreeControl(TreeControl.Style.SimpleTree);
m_treeControl.Dock = DockStyle.Fill;
m_treeControl.SelectionMode = SelectionMode.One;
m_treeControl.ShowRoot = false;
m_treeControl.ImageList = ResourceUtil.GetImageList16();
m_treeControl.ExpandAll();
m_treeControl.NodeSelectedChanged += treeControl_NodeSelectedChanged;
m_treeControlAdapter = new TreeControlAdapter(m_treeControl);
m_treeControlAdapter.TreeView = settingsService.UserSettings;
treePanel.Controls.Add(m_treeControl);
m_propertyGrid = new Sce.Atf.Controls.PropertyEditing.PropertyGrid();
m_propertyGrid.Dock = DockStyle.Fill;
propertiesPanel.Controls.Add(m_propertyGrid);
// select an initial node so something is displayed in the PropertyGrid
TreeControl.Node firstNode = null;
if (pathName != null)
firstNode = m_treeControlAdapter.ExpandPath(m_settingsService.GetSettingsPath(pathName));
if (firstNode == null) // in case pathName is not null, but ExpandPath returns null
firstNode = m_treeControl.ExpandToFirstLeaf();
firstNode.Selected = true;
ShowProperties(m_settingsService.GetProperties((Tree<object>)firstNode.Tag)); //does auto-setting of column widths
defaultsButton.Click += DefaultsButton_Click;
}
示例8: Configure
/// <summary>
/// Create and configure TreeControl</summary>
/// <param name="treeControl">New TreeControl</param>
/// <param name="treeControlAdapter">Adapter for TreeControl</param>
protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
{
base.Configure(out treeControl, out treeControlAdapter);
m_searchInput = new StringSearchInputUI();
m_searchInput.Updated += UpdateFiltering;
m_control = new UserControl();
m_control.Dock = DockStyle.Fill;
m_control.SuspendLayout();
m_control.Name = "Tree View".Localize();
m_control.Text = "Tree View".Localize();
m_control.Controls.Add(m_searchInput);
m_control.Controls.Add(TreeControl);
m_control.Layout += controls_Layout;
m_control.ResumeLayout();
TreeControl.PreviewKeyDown += TreeControl_PreviewKeyDown;
TreeControl.NodeExpandedChanging += TreeControl_NodeExpandedChanging;
TreeControl.NodeExpandedChanged += TreeControl_NodeExpandedChanged;
TreeControl.ItemRendererChanged += (sender, e) => UpdateTreeItemRenderer();
}
示例9: UpdateColumnWidths
/// <summary>
/// Update column widths only under auto-resizing mode.</summary>
/// <param name="node">Tree node</param>
/// <param name="info">Mode info</param>
/// <param name="g">Graphics object used for drawing</param>
private void UpdateColumnWidths(TreeControl.Node node, ItemInfo info, Graphics g)
{
var treeListControl = node.TreeControl as TreeListControl;
if (treeListControl.AutoResizeColumns)
{
bool updateColumnWidths = treeListControl.Columns.Count == info.Properties.Length;
for (int i = 0; i < info.Properties.Length; ++i)
{
var dataEditor = info.Properties[i] as DataEditor;
if (dataEditor != null) // show object data details in columns
{
var size = dataEditor.Measure(g, SizeF.Empty);
if (updateColumnWidths)
{
treeListControl.Columns[i].ActualWidth = Math.Max(treeListControl.Columns[i].Width,
(int)size.Width);
}
}
}
}
}
示例10: DomExplorer
public DomExplorer(IControlHostService controlHostService)
{
m_controlHostService = controlHostService;
m_treeControl = new TreeControl();
m_treeControl.Dock = DockStyle.Fill;
m_treeControl.AllowDrop = true;
m_treeControl.SelectionMode = SelectionMode.MultiExtended;
m_treeControl.ImageList = ResourceUtil.GetImageList16();
m_treeControl.NodeSelectedChanged += treeControl_NodeSelectedChanged;
m_treeControlAdapter = new TreeControlAdapter(m_treeControl);
m_treeView = new TreeView();
m_propertyGrid = new Sce.Atf.Controls.PropertyEditing.PropertyGrid();
m_propertyGrid.Dock = DockStyle.Fill;
m_splitContainer = new SplitContainer();
m_splitContainer.Text = "Dom Explorer";
m_splitContainer.Panel1.Controls.Add(m_treeControl);
m_splitContainer.Panel2.Controls.Add(m_propertyGrid);
}
示例11: treeControl_NodeSelectedChanged
private void treeControl_NodeSelectedChanged(object sender, TreeControl.NodeEventArgs e)
{
if (e.Node.Selected)
{
ShowProperties(m_settingsService.GetProperties((Tree<object>)e.Node.Tag));
}
}
示例12: treeControl_NodeExpandedChanging
/// <summary>
/// Performs custom actions before changing a node's Expanded property</summary>
/// <param name="sender">Sender</param>
/// <param name="e">Event args</param>
void treeControl_NodeExpandedChanging(object sender, TreeControl.CancelNodeEventArgs e)
{
if ((!m_autoExpanding) && m_searching)
{
var filteredTreeView = TreeView as FilteredTreeView;
// 3 states to toggle:
if (filteredTreeView.IsNodeOpaque(e.Node) && filteredTreeView.IsNodeCurrentlyOpaque(e.Node))
{
// two cases here: a) if the node is expanding and all the child nodes are opaque, just expand all its children
// if some of the child nodes are visible, and the node is already expanded, then we need to expand all its children too
IEnumerable<object> itsChildren = filteredTreeView.GetChildren(e.Node.Tag); // get visible children
if (!itsChildren.Any())
{
if (!e.Node.Expanded) /* case a*/
{
foreach (object child in filteredTreeView.GetUnfilteredChildren(e.Node.Tag))
filteredTreeView.AddCurrentVisibleNode(child);
}
}
else if (e.Node.Expanded) // an opaque node is about to collapsing; but we actually want it fully expanded
{
// this is a manual click-expanding case, make all children of the node visible
bool added = false;
foreach (object child in filteredTreeView.GetUnfilteredChildren(e.Node.Tag))
{
if (filteredTreeView.AddCurrentVisibleNode(child))
added = true;
}
filteredTreeView.RemoveOpaqueNode(e.Node);
filteredTreeView.RememberExpansion(e.Node);
if (added) // if false, all children are already visible, just collapse the node
m_nodeToExpand = e.Node;
}
}
else if (filteredTreeView.IsNodeOpaque(e.Node) && (!filteredTreeView.IsNodeCurrentlyOpaque(e.Node)) && (e.Node.Expanded))
{
// the opaque node is fakely(fully) expanded, restore to hide non-matched ones
filteredTreeView.AddOpaqueNode(e.Node);
filteredTreeView.RememberExpansion(e.Node);
foreach (TreeControl.Node child in e.Node.Children)
{
if (!filteredTreeView.IsNodeMatched(child))
filteredTreeView.RemoveVisibleNode(child.Tag);
}
}
else if (e.Node.Expanded)
filteredTreeView.RememberExpansion(e.Node);
else if (!filteredTreeView.IsNodeOpaque(e.Node)) // check expanding a node with all childen invisible
{
foreach (object child in filteredTreeView.GetUnfilteredChildren(e.Node.Tag))
{
filteredTreeView.AddCurrentVisibleNode(child);
}
}
}
}
示例13: treeControl_NodeExpandedChanged
/// <summary>
/// Performs custom actions after changing a node's Expanded property</summary>
/// <param name="sender">Sender</param>
/// <param name="e">Event args</param>
void treeControl_NodeExpandedChanged(object sender, TreeControl.NodeEventArgs e)
{
if (!m_searching)
return;
var filteredTreeView = TreeView as FilteredTreeView;
if (m_nodeToExpand != null)
{
TreeControl.Node nodeToExpand = m_nodeToExpand;
m_autoExpanding = true;
TreeControlAdapter.Expand(m_nodeToExpand.Tag);
filteredTreeView.RestoreExpansion(TreeControlAdapter, nodeToExpand);
m_nodeToExpand = null;
m_autoExpanding = false;
}
else if (e.Node.Expanded && RestoreSubExpansion)
{
filteredTreeView.RestoreExpansion(TreeControlAdapter, e.Node);
}
}
示例14: Configure
protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
{
base.Configure(out treeControl, out treeControlAdapter);
treeControl.ShowRoot = false; // hide root node, because it's the project
treeControl.Text = Localizer.Localize("No Project Loaded");
treeControl.Dock = DockStyle.Fill;
treeControl.AllowDrop = true;
treeControl.SelectionMode = SelectionMode.One;
}
示例15: GetDataEditor
/// <summary>
/// Get the data editor hit by point p; also set edit mode if the editor supports multiple controls.</summary>
/// <param name="node">The node</param>
/// <param name="p">The point</param>
/// <returns>Data editor hit by point</returns>
internal DataEditor GetDataEditor(TreeControl.Node node, Point p)
{
var treeListControl = node.TreeControl as TreeListControl;
ItemInfo info = new WinFormsItemInfo();
treeListControl.TreeListItemRenderer.ItemView.GetInfo(node.Tag, info);
if (info.Properties.Length != treeListControl.Columns.Count)
return null;
int left = treeListControl.TreeWidth;
for (int i = 0; i < treeListControl.Columns.Count; ++i)
{
var column = treeListControl.Columns[i];
if (p.X >= left && p.X <= left + column.ActualWidth)
{
var dataEditor = info.Properties[i] as DataEditor;
if (dataEditor != null)
{
foreach (NodeLayoutInfo nodeLayout in NodeLayout)
{
if (nodeLayout.Node == node)
{
dataEditor.TextBox = m_editTextBox;
dataEditor.Bounds = GetEditArea(nodeLayout, dataEditor);
dataEditor.SetEditingMode(p);
break;
}
}
}
return dataEditor;
}
left += column.ActualWidth;
}
return null;
}